/* Soorya — single stylesheet
   Light theme. Blue + gold. 3D curvy buttons. Responsive. */

/* =====================================================================
   1) Design tokens
   ===================================================================== */
:root {
  --c-bg:        #FAFBFC;
  --c-surface:   #FFFFFF;
  --c-surface-2: #F3F5F9;
  --c-text:      #0F1B3D;
  --c-text-mute: #5B6478;
  --c-primary:   #1E3A8A;
  --c-primary-2: #3B82F6;
  --c-primary-d: #142A66;
  --c-gold:      #D4AF37;
  --c-gold-2:    #F4C430;
  --c-gold-d:    #B58E1A;
  --c-success:   #1F9D55;
  --c-danger:    #D64545;
  --c-warning:   #E0A21A;
  --c-border:    #E4E7EE;
  --c-focus:     #93C5FD;

  --shadow-1: 0 1px 2px rgba(15,27,61,.06), 0 2px 6px rgba(15,27,61,.06);
  --shadow-2: 0 4px 12px rgba(15,27,61,.08), 0 8px 24px rgba(15,27,61,.06);
  --shadow-3d-blue:
      0 1px 0 rgba(255,255,255,.4) inset,
      0 -2px 0 rgba(0,0,0,.10) inset,
      0 4px 10px rgba(30,58,138,.22),
      0 10px 20px -8px rgba(30,58,138,.28);
  --shadow-3d-gold:
      0 1px 0 rgba(255,255,255,.55) inset,
      0 -2px 0 rgba(120,80,0,.18) inset,
      0 4px 10px rgba(180,140,30,.28),
      0 10px 20px -8px rgba(180,140,30,.30);

  --radius-sm: 8px;
  --radius:    14px;
  --radius-lg: 20px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --font-sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-num:  'Inter', ui-monospace, 'SF Mono', Menlo, monospace;

  --nav-w: 240px;
  --nav-w-collapsed: 72px;
  --topbar-h: 64px;
  --bottom-nav-h: 64px;
}

/* =====================================================================
   2) Base
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1,h2,h3,h4 { margin: 0 0 var(--space-3); font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p  { margin: 0 0 var(--space-3); color: var(--c-text-mute); }
a  { color: var(--c-primary-2); text-decoration: none; }
a:hover { text-decoration: underline; }

::selection { background: var(--c-gold-2); color: var(--c-text); }
:focus-visible {
  outline: 3px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* =====================================================================
   3) Buttons — simple, neat, curvy, 3D
   ===================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 0;
  border-radius: var(--radius);
  padding: .85rem 1.4rem;
  font: inherit;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  background: linear-gradient(180deg, var(--c-primary-2) 0%, var(--c-primary) 100%);
  color: #fff;
  box-shadow: var(--shadow-3d-blue);
  transition: transform .08s ease, box-shadow .15s ease, filter .15s ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover  { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); box-shadow: var(--shadow-1); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.btn--gold {
  background: linear-gradient(180deg, var(--c-gold-2), var(--c-gold));
  color: #2A1E00;
  box-shadow: var(--shadow-3d-gold);
}
.btn--ghost {
  background: var(--c-surface);
  color: var(--c-primary);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-1);
}
.btn--ghost:hover { background: var(--c-surface-2); filter: none; }
.btn--danger {
  background: linear-gradient(180deg, #EF6B6B, var(--c-danger));
}
.btn--sm { padding: .55rem .9rem; font-size: .9rem; border-radius: var(--radius-sm); }
.btn--lg { padding: 1.05rem 1.8rem; font-size: 1.05rem; }
.btn--block { width: 100%; }
.btn--icon { padding: .55rem; aspect-ratio: 1; border-radius: 50%; }

/* =====================================================================
   4) Layout — sidebar + topbar + main
   ===================================================================== */
.app {
  display: grid;
  grid-template-columns: var(--nav-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  min-height: 100vh;
}
.sidebar {
  grid-area: sidebar;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  padding: var(--space-5) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--c-border);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--c-primary);
}
.sidebar__brand img { width: 28px; height: 28px; }
.sidebar__nav { display: flex; flex-direction: column; gap: 2px; margin-top: var(--space-3); }
.sidebar__link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  color: var(--c-text-mute);
  font-weight: 600;
  transition: background .15s, color .15s;
  text-decoration: none;
}
.sidebar__link:hover { background: var(--c-surface-2); color: var(--c-text); text-decoration: none; }
.sidebar__link--active {
  background: linear-gradient(180deg, rgba(59,130,246,.10), rgba(30,58,138,.10));
  color: var(--c-primary);
  box-shadow: inset 0 0 0 1px rgba(59,130,246,.15);
}
.sidebar__icon { width: 20px; height: 20px; flex-shrink: 0; }

.topbar {
  grid-area: topbar;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 0 var(--space-5);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  position: sticky; top: 0; z-index: 20;
}
.topbar__title { font-weight: 700; font-size: 1.05rem; }
.topbar__right { display: flex; align-items: center; gap: var(--space-3); }
.topbar__date { color: var(--c-text-mute); font-size: .9rem; }
.topbar__profile {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--c-primary-2), var(--c-primary));
  color: #fff; display: grid; place-items: center;
  font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow-1);
}

.main {
  grid-area: main;
  padding: var(--space-5);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Bottom nav (mobile) — hidden on desktop */
.bottom-nav { display: none; }

@media (max-width: 768px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr var(--bottom-nav-h);
    grid-template-areas:
      "topbar"
      "main"
      "bottomnav";
  }
  .sidebar { display: none; }
  .bottom-nav {
    grid-area: bottomnav;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    display: flex; justify-content: space-around; align-items: stretch;
    position: sticky; bottom: 0; z-index: 30;
  }
  .bottom-nav__link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px;
    color: var(--c-text-mute); text-decoration: none;
    font-size: .72rem; font-weight: 600;
    padding: .35rem;
  }
  .bottom-nav__link svg { width: 22px; height: 22px; }
  .bottom-nav__link--active { color: var(--c-primary); }
  .main { padding: var(--space-4); }
  .topbar { padding: 0 var(--space-4); }
  .topbar__date { display: none; }
}

/* =====================================================================
   5) Cards
   ===================================================================== */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: var(--space-5);
  box-shadow: var(--shadow-1);
}
.card + .card { margin-top: var(--space-4); }
.card__title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 0 0 var(--space-4);
  font-size: 1.05rem; font-weight: 700;
}
.card__subtitle { color: var(--c-text-mute); font-size: .9rem; margin-top: -8px; }

/* KPI cards */
.kpi-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: var(--space-5);
}
.kpi {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: var(--space-5);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-1);
  position: relative; overflow: hidden;
}
.kpi__label { color: var(--c-text-mute); font-size: .85rem; font-weight: 600; }
.kpi__value {
  font-size: 1.75rem; font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: var(--space-2);
  color: var(--c-text);
}
.kpi__delta { font-size: .85rem; margin-top: var(--space-2); font-weight: 600; }
.kpi__delta--up   { color: var(--c-success); }
.kpi__delta--down { color: var(--c-danger); }
.kpi__delta--flat { color: var(--c-text-mute); }
.kpi--income::before, .kpi--expense::before, .kpi--balance::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--c-primary-2), var(--c-primary));
}
.kpi--expense::before { background: linear-gradient(90deg, var(--c-danger), #B83333); }
.kpi--balance::before { background: linear-gradient(90deg, var(--c-gold-2), var(--c-gold)); }

/* =====================================================================
   6) Forms
   ===================================================================== */
.form { display: grid; gap: var(--space-4); max-width: 720px; }
.form--grid-2 { grid-template-columns: 1fr 1fr; }
.form--grid-2 .form__full { grid-column: 1 / -1; }
@media (max-width: 600px) { .form--grid-2 { grid-template-columns: 1fr; } }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field__label {
  font-size: .85rem; font-weight: 600; color: var(--c-text);
}
.field__label .req { color: var(--c-danger); }
.field__hint  { font-size: .8rem; color: var(--c-text-mute); }
.field__error { font-size: .82rem; color: var(--c-danger); }

.input, .select, .textarea {
  width: 100%;
  padding: .75rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
  background: var(--c-surface);
  font: inherit;
  color: var(--c-text);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--c-primary-2);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}
.input--error, .select--error, .textarea--error {
  border-color: var(--c-danger);
}
.textarea { min-height: 96px; resize: vertical; }
.input[type="number"] { font-variant-numeric: tabular-nums; }

.form__actions {
  grid-column: 1 / -1;
  display: flex; gap: var(--space-3); justify-content: flex-end;
  margin-top: var(--space-3);
}
@media (max-width: 600px) {
  .form__actions { flex-direction: column; }
  .form__actions .btn { width: 100%; }
}

/* =====================================================================
   7) Tables
   ===================================================================== */
.table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: .85rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}
.table th {
  background: var(--c-surface-2);
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--c-text-mute);
  position: sticky; top: 0;
}
.table tbody tr:hover { background: rgba(59,130,246,.04); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.table .pill { display: inline-block; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.pill--income  { background: rgba(31,157,85,.12); color: var(--c-success); }
.pill--expense { background: rgba(214,69,69,.12); color: var(--c-danger); }
.row-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* Mobile: card list */
@media (max-width: 640px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr {
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius);
    margin-bottom: var(--space-3);
    padding: var(--space-3);
  }
  .table td {
    border: 0;
    padding: .25rem 0;
    display: flex; justify-content: space-between;
    align-items: center;
  }
  .table td::before {
    content: attr(data-label);
    font-size: .75rem; color: var(--c-text-mute); font-weight: 600; text-transform: uppercase;
  }
  .table td.num { text-align: right; }
  .row-actions { width: 100%; justify-content: flex-end; margin-top: var(--space-2); }
}

/* =====================================================================
   8) Toast, modal, empty state
   ===================================================================== */
.toast-stack {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: var(--space-2);
  z-index: 9999;
}
.toast {
  background: var(--c-surface);
  border-left: 4px solid var(--c-primary-2);
  border-radius: var(--radius-sm);
  padding: .85rem 1.1rem;
  box-shadow: var(--shadow-2);
  font-size: .9rem;
  animation: slidein .25s ease;
  min-width: 220px;
}
.toast--success { border-left-color: var(--c-success); }
.toast--error   { border-left-color: var(--c-danger); }
@keyframes slidein { from { transform: translateY(20px); opacity: 0 } to { transform: translateY(0); opacity: 1 } }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,27,61,.4); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 9990; padding: var(--space-4);
}
.modal {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 480px; width: 100%;
  box-shadow: var(--shadow-2);
  animation: pop .2s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.modal__title { font-size: 1.2rem; font-weight: 700; margin-bottom: var(--space-3); }
.modal__actions { display: flex; gap: var(--space-3); justify-content: flex-end; margin-top: var(--space-5); }

.empty {
  text-align: center; padding: var(--space-7) var(--space-4);
  color: var(--c-text-mute);
}
.empty__icon { font-size: 2.5rem; margin-bottom: var(--space-3); }

/* =====================================================================
   9) Auth pages (signup + login)
   ===================================================================== */
.auth-wrap {
  min-height: 100vh;
  display: grid; place-items: center;
  padding: var(--space-5);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(212,175,55,.10), transparent),
    radial-gradient(1000px 500px at -10% 110%, rgba(30,58,138,.12), transparent),
    var(--c-bg);
}
.auth-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 440px; width: 100%;
  box-shadow: var(--shadow-2);
  border: 1px solid var(--c-border);
}
.auth-card__logo {
  display: flex; align-items: center; gap: var(--space-3);
  margin-bottom: var(--space-5);
  font-size: 1.35rem; font-weight: 800;
  color: var(--c-primary);
}
.auth-card__logo img { width: 36px; height: 36px; }
.auth-card__sub { color: var(--c-text-mute); margin-top: -8px; margin-bottom: var(--space-5); }
.auth-card__footer { margin-top: var(--space-5); text-align: center; color: var(--c-text-mute); font-size: .9rem; }
.auth-card__footer a { font-weight: 600; }

/* =====================================================================
   10) Filter bar + chips
   ===================================================================== */
.filter-bar {
  display: grid;
  gap: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin-bottom: var(--space-4);
}
.filter-bar .field { gap: 4px; }
.filter-bar .field__label { font-size: .75rem; }

/* Chart canvas wrapper */
.chart-wrap { position: relative; height: 280px; }
@media (max-width: 640px) { .chart-wrap { height: 220px; } }

/* =====================================================================
   11) Settings tabs
   ===================================================================== */
.tabs {
  display: flex; gap: var(--space-2);
  border-bottom: 1px solid var(--c-border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab {
  border: 0; background: transparent;
  padding: .75rem 1.1rem;
  font: inherit; font-weight: 600;
  color: var(--c-text-mute);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  white-space: nowrap;
}
.tab:hover { color: var(--c-text); }
.tab--active { color: var(--c-primary); border-bottom-color: var(--c-gold); }

/* =====================================================================
   12) Utilities
   ===================================================================== */
.row    { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.row--end     { justify-content: flex-end; }
.muted  { color: var(--c-text-mute); }
.small  { font-size: .85rem; }
.mono   { font-variant-numeric: tabular-nums; font-family: var(--font-num); }
.spacer { flex: 1; }
.hide   { display: none !important; }
.text-right { text-align: right; }
.skeleton {
  background: linear-gradient(90deg, var(--c-surface-2) 25%, #EAEEF5 50%, var(--c-surface-2) 75%);
  background-size: 200% 100%;
  animation: skel 1.2s infinite;
  border-radius: var(--radius-sm);
  height: 1em;
}
@keyframes skel { 0%{background-position:200% 0} 100%{background-position:-200% 0} }

.amount-positive { color: var(--c-success); }
.amount-negative { color: var(--c-danger); }
