/* ============================================================
   TAKO — Design System
   Paleta: Preto & Branco (Monocromático)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

/* ── Tokens ── */
:root {
  --accent: #FFFFFF;
  --accent-light: #F0F0F0;
  --accent-dark: #CCCCCC;
  --coal: #0D0D0D;
  --coal-2: #161616;
  --coal-3: #1F1F1F;
  --coal-4: #2A2A2A;
  --coal-5: #3A3A3A;
  --ivory: #F5F5F5;
  --ivory-2: #E0E0E0;
  --text-primary: #FFFFFF;
  --text-secondary: #A0A0A0;
  --text-muted: #666666;
  --surface: #161616;
  --surface-2: #1F1F1F;
  --surface-3: #2A2A2A;
  --border: rgba(255, 255, 255, 0.15);
  --border-hover: rgba(255, 255, 255, 0.4);
  --shadow: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-accent: 0 4px 24px rgba(255, 255, 255, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --radius-full: 999px;
  --transition: 0.25s cubic-bezier(0.4,0,0.2,1);
  --font: 'Outfit', sans-serif;

  /* Nav */
  --nav-h: 64px;
  --header-h: 60px;
}

[data-theme="light"] {
  --accent: #000000;
  --accent-light: #333333;
  --accent-dark: #000000;
  --coal: #FFFFFF;
  --coal-2: #F5F5F5;
  --coal-3: #EBEBEB;
  --coal-4: #E0E0E0;
  --coal-5: #CCCCCC;
  --ivory: #0D0D0D;
  --ivory-2: #1A1A1A;
  --text-primary: #000000;
  --text-secondary: #555555;
  --text-muted: #888888;
  --surface: #F5F5F5;
  --surface-2: #EBEBEB;
  --surface-3: #E0E0E0;
  --border: rgba(0, 0, 0, 0.12);
  --border-hover: rgba(0, 0, 0, 0.3);
  --shadow: 0 8px 32px rgba(0,0,0,0.08);
  --shadow-accent: 0 4px 24px rgba(0, 0, 0, 0.15);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--coal);
  color: var(--text-primary);
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background var(--transition), color var(--transition);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: var(--font); }
input, textarea, select { font-family: var(--font); }
a { text-decoration: none; color: inherit; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--coal-5); border-radius: 2px; }

/* ── Layout ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

.page {
  display: none;
  flex: 1;
  flex-direction: column;
  padding-bottom: calc(var(--nav-h) + 16px);
  animation: fadeUp 0.3s ease;
}
.page.active { display: flex; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--coal);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-logo .logo-mark {
  width: 34px;
  height: 34px;
  background: var(--text-primary);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  font-weight: 900;
  color: var(--coal);
  letter-spacing: -0.5px;
}
.header-logo .logo-text {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 2px;
}
.header-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  color: var(--text-secondary);
  transition: all var(--transition);
  font-size: 17px;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text-primary); border-color: var(--border-hover); }

/* ── Bottom Nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: var(--coal-2);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 200;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
  cursor: pointer;
}
.nav-item.active { color: var(--text-primary); }
.nav-item .nav-icon { font-size: 20px; line-height: 1; opacity: 0.5; transition: opacity var(--transition); }
.nav-item.active .nav-icon { opacity: 1; }
.nav-item .nav-label { font-size: 10px; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; }
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  width: 24px; height: 3px;
  background: var(--text-primary);
  border-radius: 2px 2px 0 0;
}
.nav-fab {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: var(--text-primary);
  box-shadow: var(--shadow-accent);
  display: grid;
  place-items: center;
  color: var(--coal);
  font-size: 24px;
  font-weight: 700;
  transition: all var(--transition);
  cursor: pointer;
  border: none;
  flex-shrink: 0;
}
.nav-fab:active { transform: scale(0.93); }

/* ── Section ── */
.section { padding: 20px; }
.section + .section { padding-top: 0; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.card:hover { border-color: var(--border-hover); box-shadow: var(--shadow-accent); }

.card-glass {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.08);
}
[data-theme="light"] .card-glass {
  background: rgba(255,255,255,0.6);
  border: 1px solid rgba(0,0,0,0.08);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: 0.3px;
}
.btn-primary {
  background: var(--text-primary);
  color: var(--coal);
  box-shadow: var(--shadow-accent);
}
.btn-primary:hover { transform: translateY(-1px); opacity: 0.9; }
.btn-primary:active { transform: scale(0.97); }
.btn-secondary {
  background: var(--surface-2);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--surface-3); }
.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
}
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger {
  background: rgba(220, 50, 50, 0.1);
  color: #FF6B6B;
  border: 1px solid rgba(220, 50, 50, 0.2);
}
.btn-danger:hover { background: rgba(220, 50, 50, 0.2); }
.btn-full { width: 100%; }
.btn-sm { padding: 10px 18px; font-size: 13px; }
.btn-lg { padding: 16px 28px; font-size: 16px; }

/* ── Form Controls ── */
.form-group { display: flex; flex-direction: column; gap: 8px; }
.form-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-secondary);
}
.form-control {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  color: var(--text-primary);
  font-size: 15px;
  font-family: var(--font);
  outline: none;
  transition: all var(--transition);
  width: 100%;
}
.form-control:focus { border-color: var(--text-primary); }
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
}

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.badge-gold, .badge-neutral { background: var(--surface-3); color: var(--text-primary); border: 1px solid var(--border); }
.badge-green { background: rgba(50,200,100,0.12); color: #50C878; border: 1px solid rgba(50,200,100,0.25); }
.badge-red { background: rgba(220,50,50,0.12); color: #FF6B6B; border: 1px solid rgba(220,50,50,0.25); }

/* ── Amount Display ── */
.amount {
  font-weight: 800;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.amount-lg { font-size: 36px; }
.amount-md { font-size: 22px; }
.amount-sm { font-size: 16px; }
.amount-gold, .amount-accent { color: var(--text-primary); }
.amount-green { color: #50C878; }
.amount-red { color: #FF6B6B; }

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: calc(100% - 40px);
  max-width: 360px;
}
.toast {
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
}
.toast.success { border-color: rgba(80,200,120,0.4); }
.toast.error { border-color: rgba(220,50,50,0.4); }
.toast-icon { font-size: 18px; flex-shrink: 0; }
@keyframes toastIn { from { opacity:0; transform:translateY(-12px) scale(0.95); } to { opacity:1; transform:none; } }
@keyframes toastOut { to { opacity:0; transform:translateY(-8px) scale(0.97); } }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-sheet {
  width: 100%;
  background: var(--coal-2);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-top: 1px solid var(--border);
  padding: 12px 20px 36px;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-overlay.open .modal-sheet { transform: translateY(0); }
.modal-handle {
  width: 40px; height: 4px;
  background: var(--coal-5);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
.empty-icon { font-size: 48px; opacity: 0.6; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); }
.empty-desc { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── Stat card ── */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--text-primary);
}
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--text-muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text-primary); letter-spacing: -0.5px; }
.stat-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.stat-icon { position: absolute; top: 16px; right: 16px; font-size: 22px; opacity: 0.6; }

/* ── Transaction item ── */
.tx-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.tx-item:last-child { border-bottom: none; }
.tx-icon {
  width: 40px; height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.tx-icon.sale { background: rgba(255,255,255,0.08); }
[data-theme="light"] .tx-icon.sale { background: rgba(0,0,0,0.05); }
.tx-icon.expense { background: rgba(255,255,255,0.08); }
[data-theme="light"] .tx-icon.expense { background: rgba(0,0,0,0.05); }

.tx-info { flex: 1; min-width: 0; }
.tx-name { font-size: 14px; font-weight: 600; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-date { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.tx-amount { font-size: 15px; font-weight: 700; flex-shrink: 0; }

/* ── Upload zone ── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  background: var(--surface);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--text-primary);
  background: var(--surface-2);
}
.upload-zone .upload-icon { font-size: 36px; opacity: 0.8; }
.upload-zone .upload-text { font-size: 14px; font-weight: 500; color: var(--text-secondary); }
.upload-zone .upload-sub { font-size: 12px; color: var(--text-muted); }
.upload-preview {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 16/9;
  background: var(--surface-3);
}
.upload-preview img { width: 100%; height: 100%; object-fit: cover; }
.upload-preview-remove {
  position: absolute;
  top: 8px; right: 8px;
  width: 28px; height: 28px;
  background: rgba(0,0,0,0.6);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 14px;
  cursor: pointer;
  color: #fff;
  backdrop-filter: blur(4px);
}

/* ── Switch ── */
.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.switch-row:last-child { border-bottom: none; }
.switch-info .switch-label { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.switch-info .switch-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.switch {
  position: relative;
  width: 44px; height: 26px;
  flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-track {
  position: absolute;
  inset: 0;
  background: var(--coal-5);
  border-radius: 13px;
  cursor: pointer;
  transition: background 0.25s;
}
.switch-track::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  background: var(--coal);
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.switch input:checked + .switch-track { background: var(--text-primary); }
.switch input:checked + .switch-track::after { transform: translateX(18px); }

/* ── Loader ── */
.loader {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ── */
.text-gold, .text-accent { color: var(--text-primary); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.font-bold { font-weight: 700; }
.font-black { font-weight: 900; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Responsive ── */
@media (max-width: 400px) {
  .amount-lg { font-size: 28px; }
  .stat-value { font-size: 22px; }
}

/* Desktop Blocker */
.desktop-blocker {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-primary);
  z-index: 999999;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.desktop-blocker-content {
  background: var(--surface-1);
  padding: 40px 20px;
  border-radius: 20px;
  max-width: 400px;
  border: 1px solid var(--border-color);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}
@media (min-width: 768px) {
  .desktop-blocker {
    display: flex;
  }
  #app, #splash, #toast-container, .fab-overlay, .fab-menu, .modal-overlay, .modal {
    display: none !important;
  }
  body {
    overflow: hidden !important;
  }
}
