/* ==========================================================================
   OFICIO — Finanzas para Freelancers e Independientes (Powered by AQ-INVEST)
   Identidad Visual Propia: Grafito (#1E242B) · Papel Crema (#FAF8F4) · Ámbar (#D97706)
   Web Desktop + Mobile PWA Responsive
   ========================================================================== */

:root {
  --bg: #FAF8F4;
  --bg-soft: #F1EDE4;
  --surface: #FFFFFF;
  --slate: #1E242B;
  --slate-deep: #12161B;
  --amber: #D97706;
  --amber-bright: #F59E0B;
  --amber-soft: rgba(217, 119, 6, 0.13);
  --teal: #0D9488;
  --teal-soft: rgba(13, 148, 136, 0.12);
  --tax: #4F46E5;
  --tax-soft: rgba(79, 70, 229, 0.11);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.11);
  --ink: #181D23;
  --muted: #5C6570;
  --dim: #88929E;
  --border: rgba(30, 36, 43, 0.11);
  --border-strong: rgba(30, 36, 43, 0.22);
  --shadow: 0 8px 24px rgba(18, 22, 27, 0.055);
  --radius: 16px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #101419;
  --bg-soft: #181E26;
  --surface: #1B212A;
  --slate: #141920;
  --slate-deep: #0B0E12;
  --amber: #F59E0B;
  --amber-bright: #FBBF24;
  --amber-soft: rgba(245, 158, 11, 0.16);
  --teal: #2DD4BF;
  --teal-soft: rgba(45, 212, 191, 0.15);
  --tax: #818CF8;
  --tax-soft: rgba(129, 140, 248, 0.16);
  --danger: #F87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --ink: #F3F0EA;
  --muted: #9BA5B2;
  --dim: #6B7685;
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.20);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); -webkit-font-smoothing: antialiased; }
button, input, select { font-family: inherit; }
.num { font-variant-numeric: tabular-nums; }

/* Onboarding */
.onb-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.14), transparent 48%), var(--bg);
}
.onb-card {
  width: 100%;
  max-width: 510px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 30px 26px;
  box-shadow: var(--shadow);
}
.onb-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.onb-brand img { width: 46px; height: 46px; border-radius: 13px; }
.onb-title { font-family: var(--font-display); font-size: 30px; font-weight: 700; margin: 0 0 8px; line-height: 1.12; letter-spacing: -0.03em; }
.onb-sub { font-size: 14px; color: var(--muted); margin: 0 0 20px; line-height: 1.55; }

/* Shell */
.frame { display: flex; min-height: 100vh; }
.sidenav {
  width: 262px;
  background: linear-gradient(180deg, var(--slate) 0%, var(--slate-deep) 100%);
  color: #F3F0EA;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.sidenav-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 24px; cursor: pointer; }
.sidenav-brand img { width: 38px; height: 38px; border-radius: 11px; }
.sidenav-brand h1 { font-family: var(--font-display); font-size: 22px; margin: 0; line-height: 1; font-weight: 700; letter-spacing: -0.02em; }
.powered { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.72; display: block; margin-top: 3px; }
.powered strong { color: var(--amber-bright); font-weight: 700; }

.nav-list { display: flex; flex-direction: column; gap: 6px; }
.nav-btn {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px 13px;
  border-radius: 11px;
  border: none;
  background: transparent;
  color: rgba(243, 240, 234, 0.76);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav-btn.on { background: rgba(245, 158, 11, 0.18); color: #fff; box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.32); }
.nav-btn .ico { font-size: 17px; width: 22px; text-align: center; }

.sidenav-cta { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.sidenav-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.11); display: flex; flex-direction: column; gap: 6px; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(250, 248, 244, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 13px 26px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
[data-theme="dark"] .topbar { background: rgba(16, 20, 25, 0.92); }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.mobile-logo { display: none; width: 32px; height: 32px; border-radius: 9px; }
.page-title { font-family: var(--font-display); font-size: 21px; font-weight: 700; margin: 0; line-height: 1.1; letter-spacing: -0.02em; }
.page-sub { font-size: 12px; color: var(--muted); }
.topbar-right { display: flex; align-items: center; gap: 8px; }

.content {
  width: 100%;
  max-width: 1060px;
  margin: 0 auto;
  padding: 20px 26px 84px;
}

/* Month Switch */
.month-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.month-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 10px;
  font-weight: 700;
  font-size: 13.5px;
  text-transform: capitalize;
}
.month-pill button {
  border: none;
  background: var(--bg-soft);
  color: var(--ink);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

/* Hero Studio Split Card */
.hero-studio {
  background: radial-gradient(circle at top right, rgba(245, 158, 11, 0.24), transparent 52%), linear-gradient(135deg, var(--slate) 0%, var(--slate-deep) 100%);
  color: #FAF8F4;
  border-radius: 20px;
  padding: 24px 26px;
  margin-bottom: 16px;
  box-shadow: 0 16px 36px rgba(18, 22, 27, 0.22);
}
.hero-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.hero-kicker { font-size: 11px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--amber-bright); }
.hero-val { font-family: var(--font-display); font-size: clamp(32px, 5vw, 48px); font-weight: 700; line-height: 1.05; margin: 6px 0 4px; letter-spacing: -0.03em; }
.hero-sub { font-size: 13px; color: rgba(250, 248, 244, 0.72); margin-bottom: 18px; }

.buckets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.13);
}
.bucket {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 13px;
  padding: 12px;
}
.bucket small { display: block; font-size: 11px; color: rgba(250, 248, 244, 0.7); margin-bottom: 3px; }
.bucket strong { font-family: var(--font-display); font-size: 17px; font-weight: 700; display: block; }
.bucket.tax { border-color: rgba(129, 140, 248, 0.42); background: rgba(79, 70, 229, 0.2); }
.bucket.tax strong { color: #C7D2FE; }
.bucket.res strong { color: #FDE68A; }
.bucket.pend strong { color: #5EEAD4; }

/* Quick Capture Strip */
.quick-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.q-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 12px 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .12s, border-color .15s;
}
.q-btn:hover { transform: translateY(-1px); border-color: var(--amber); }

/* Cards & Grid */
.grid-2 { display: grid; grid-template-columns: 1.15fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-equal { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.grid-2 .card, .grid-equal .card { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { font-family: var(--font-display); font-size: 18px; font-weight: 700; margin: 0; letter-spacing: -0.02em; }
.hint { font-size: 12.5px; color: var(--muted); }

/* Buttons & Pills */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: 11px;
  border: none;
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s, opacity .15s;
}
.btn:hover { opacity: 0.93; transform: translateY(-1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-slate { background: var(--slate); color: #FAF8F4; }
.btn-amber { background: linear-gradient(135deg, #F59E0B, #D97706); color: #12161B; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-soft { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 7px 11px; font-size: 12px; border-radius: 9px; }
.btn-wide { width: 100%; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 800;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--muted);
}
.pill.paid { background: var(--teal-soft); color: var(--teal); }
.pill.pending { background: var(--amber-soft); color: var(--amber); }
.pill.overdue { background: var(--danger-soft); color: var(--danger); }
.pill.tax { background: var(--tax-soft); color: var(--tax); }
.pill.pro { background: var(--slate); color: var(--amber-bright); cursor: pointer; border: none; padding: 5px 11px; }

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* Segmented & Rows */
.seg {
  display: inline-flex;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 2px 6px rgba(0,0,0,0.06); }

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.item-row:last-child { border-bottom: none; }
.item-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.item-ico { width: 40px; height: 40px; border-radius: 11px; background: var(--bg-soft); display: grid; place-items: center; font-size: 18px; flex-shrink: 0; }
.item-name { font-size: 14px; font-weight: 700; color: var(--ink); }
.item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.item-right { text-align: right; flex-shrink: 0; }
.item-val { font-family: var(--font-display); font-size: 15.5px; font-weight: 700; }
.item-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }
.text-btn { background: none; border: none; color: var(--amber); font-size: 12px; font-weight: 700; cursor: pointer; padding: 2px 3px; }
.text-btn.teal { color: var(--teal); }
.text-btn.del { color: var(--danger); }

/* Rate Calculator & Progress */
.track { height: 9px; border-radius: 999px; background: var(--bg-soft); overflow: hidden; }
.track > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--amber), var(--teal)); }
.rate-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.kpi-box { background: var(--bg-soft); border: 1px solid var(--border); border-radius: 13px; padding: 14px; }
.kpi-box small { display: block; font-size: 11px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.kpi-box strong { display: block; font-family: var(--font-display); font-size: 22px; margin-top: 4px; }

/* Demo Bar & Scanner */
.demo-bar {
  background: var(--amber-soft);
  border: 1px solid rgba(217, 119, 6, 0.28);
  border-radius: 12px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  flex-wrap: wrap;
}
.scan-bar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.scan-btn { border: 1px solid var(--border-strong); background: var(--bg-soft); color: var(--ink); border-radius: 10px; padding: 9px 6px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.scan-preview { display: flex; align-items: center; gap: 10px; background: var(--amber-soft); border: 1px solid rgba(217,119,6,.3); border-radius: 12px; padding: 10px; margin-bottom: 12px; }
.scan-thumb { width: 46px; height: 46px; border-radius: 8px; object-fit: cover; }

/* Forms & Modals */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 5px; }
.input, .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
}
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.modal-bg {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(12, 15, 19, 0.58);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 16px;
}
.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-head h2 { font-family: var(--font-display); font-size: 21px; margin: 0; }
.close-btn { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--border); background: var(--bg-soft); color: var(--ink); cursor: pointer; font-weight: 700; }

.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.plan-opt { position: relative; border: 2px solid var(--border); background: var(--bg); border-radius: 13px; padding: 14px 12px; text-align: left; cursor: pointer; color: var(--ink); }
.plan-opt.on { border-color: var(--amber); background: var(--amber-soft); }
.plan-ribbon { position: absolute; top: -10px; right: 10px; background: var(--slate); color: var(--amber-bright); font-size: 10px; font-weight: 800; padding: 3px 8px; border-radius: 999px; }

/* Mobile Bottom Nav & Toast */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  grid-template-columns: repeat(4, 1fr);
}
.bnav-btn { border: none; background: transparent; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: 11px; font-weight: 700; cursor: pointer; }
.bnav-btn .ico { font-size: 18px; }
.bnav-btn.on { color: var(--amber); }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  background: var(--slate-deep);
  color: #FAF8F4;
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  max-width: 92vw;
  text-align: center;
}

@media (max-width: 960px) {
  .sidenav { display: none; }
  .mobile-logo { display: block; }
  .bottom-nav { display: grid; }
  .topbar { padding: 12px 16px; }
  .content { padding: 14px 14px 96px; }
  .hero-studio { padding: 20px 18px; }
  .buckets, .quick-strip { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-equal, .rate-kpis { grid-template-columns: 1fr; }
  .toast { bottom: 78px; }
}
