/* =====================================================================
   SAMBHAL — visual identity v2
   Modern fintech-app look: navy + white, soft rounded cards, flat
   colorful category accents, bottom tab bar. Replaces the earlier
   "digital khata" ledger theme with a cleaner native-app feel.
   ===================================================================== */

:root {
  --bg:          #F5F7FA;
  --bg-card:     #FFFFFF;
  --bg-card-alt: #F0F3F8;
  --ink:         #1A2332;
  --ink-soft:    #6B7686;
  --navy:        #1B3A5C;
  --navy-dark:   #12283F;
  --blue:        #2F6FED;
  --leaf:        #22C55E;
  --leaf-bg:     #E7F8EE;
  --vermilion:   #EF4444;
  --vermilion-bg:#FDEAEA;
  --turmeric:    #F59E0B;
  --turmeric-bg: #FEF3DE;
  --purple:      #8B5CF6;
  --teal:        #14B8A6;
  --pink:        #EC4899;
  --border:      #E7EBF1;
  --shadow:      0 2px 14px rgba(20, 30, 50, 0.06), 0 1px 3px rgba(20,30,50,.04);

  --font-display: 'Poppins', sans-serif;
  --font-body:    'Inter', sans-serif;
  --font-mono:    'Inter', sans-serif;

  --radius-card: 18px;
  --radius-btn:  14px;
  --radius-pill: 999px;

  --cat-1: var(--navy); --cat-2: var(--turmeric); --cat-3: var(--vermilion);
  --cat-4: var(--leaf); --cat-5: var(--blue); --cat-6: var(--purple);
  --cat-7: var(--teal); --cat-8: var(--pink);

  /* backward-compatible aliases (old theme variable names still used inline in a few pages) */
  --indigo: var(--navy);
  --indigo-dark: var(--navy-dark);
  --paper-line: var(--border);
  --rule: var(--border);
  --turmeric-dk: #B45309;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  font-size: 16px;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0 0 .4em; color: var(--ink); }
h1 { font-size: 1.7rem; font-weight: 700; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .8em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.stitchline { display: none; }

/* ---------------------------------------------------------------- topbar */
.topbar { background: var(--navy); border-bottom: none; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 1180px; margin: 0 auto; display: flex; align-items: center; gap: 1.5rem; padding: .8rem 1.25rem; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: #FFFFFF; display: flex; align-items: center; gap: .5rem; margin-right: auto; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 10px; background: var(--blue); color: #fff; font-family: var(--font-display); font-weight: 700; }
.topnav { display: flex; gap: 1.3rem; flex-wrap: wrap; }
.topnav a { color: rgba(255,255,255,.72); font-weight: 500; font-size: .92rem; padding: .3rem 0; border-bottom: 2px solid transparent; }
.topnav a:hover, .topnav a.active { color: #fff; border-bottom-color: var(--blue); text-decoration: none; }
.topbar-user { display: flex; align-items: center; gap: .8rem; color: rgba(255,255,255,.8); font-size: .9rem; }
.btn-ghost-sm { border: 1px solid rgba(255,255,255,.35); padding: .35rem .8rem; border-radius: var(--radius-pill); color: #fff !important; font-size: .82rem; }
.lang-switch { display: flex; gap: .2rem; background: rgba(255,255,255,.12); border-radius: var(--radius-pill); padding: .15rem; }
.lang-pill { color: rgba(255,255,255,.65) !important; font-size: .74rem; padding: .25rem .6rem; border-radius: var(--radius-pill); font-weight: 600; }
.lang-pill:hover { color: #fff !important; text-decoration: none; }
.lang-pill.active { background: var(--blue); color: #fff !important; }
.card .lang-switch { background: var(--bg-card-alt); }
.card .lang-pill { color: var(--ink-soft) !important; }
.card .lang-pill.active { background: var(--navy); color: #fff !important; }
@media (max-width: 900px) { .topnav, .topbar-user { display: none; } }

/* ---------------------------------------------------------------- bottom app bar (mobile) */
.bottom-nav { display: none; }
@media (max-width: 900px) {
  body { padding-bottom: 68px; }
  .bottom-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--border); padding: .4rem 0 calc(.4rem + env(safe-area-inset-bottom)); box-shadow: 0 -2px 16px rgba(20,30,50,.07); }
  .bottom-nav a, .bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem; background: none; border: none; color: #9AA4B2; font-family: var(--font-body); padding: .3rem 0; cursor: pointer; }
  .bottom-nav a:hover, .bottom-nav button:hover { text-decoration: none; }
  .bn-icon { font-size: 1.3rem; line-height: 1; }
  .bn-label { font-size: .66rem; font-weight: 600; }
  .bottom-nav a.active, .bottom-nav button.active { color: var(--navy); }
}

.sheet-backdrop { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 40; }
.sheet-backdrop.open { display: block; }
.more-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--bg-card); border-radius: 22px 22px 0 0; padding: .6rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); transform: translateY(110%); transition: transform .25s ease; box-shadow: 0 -4px 24px rgba(20,30,50,.18); max-height: 70vh; overflow-y: auto; }
.more-sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--border); border-radius: 4px; margin: .3rem auto 1rem; }
.sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.sheet-grid a { display: flex; align-items: center; gap: .5rem; padding: .9rem .8rem; border-radius: var(--radius-btn); background: var(--bg-card-alt); color: var(--ink); font-weight: 600; font-size: .9rem; }
.sheet-grid a:hover { text-decoration: none; background: #E7ECF3; }
@media (min-width: 901px) { .sheet-backdrop, .more-sheet { display: none !important; } }

/* ---------------------------------------------------------------- layout */
.page { max-width: 1180px; margin: 0 auto; padding: 1.6rem 1.25rem 3rem; position: relative; z-index: 1; }
.page-narrow { max-width: 480px; margin: 0 auto; padding: 3rem 1.25rem; position: relative; z-index: 1; }
.eyebrow { font-family: var(--font-body); text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; color: var(--blue); font-weight: 700; margin-bottom: .35rem; display: block; }
.page-head { margin-bottom: 1.6rem; }
.page-head p { color: var(--ink-soft); max-width: 60ch; }

.grid { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 800px) { .grid-3, .grid-2 { grid-template-columns: 1fr; } }

/* ---------------------------------------------------------------- card */
.card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-card); box-shadow: var(--shadow); padding: 1.3rem 1.4rem; position: relative; }
.card::before { content: none; }
.card-plain { background-image: none; }
.card h3 { margin-bottom: .6rem; }
.card-tight { padding: .9rem 1.1rem; }
.card-tight::before { content: none; }

.card-hero { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); color: #fff; border: none; border-radius: var(--radius-card); padding: 1.5rem; box-shadow: var(--shadow); }
.card-hero .stat-label { color: rgba(255,255,255,.65); }
.card-hero .stat-value { color: #fff; }
.card-hero .stat-sub { color: rgba(255,255,255,.7); }
.card-hero a { color: #fff; }

/* ---------------------------------------------------------------- stat blocks */
.stat-label { font-family: var(--font-body); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--ink); }
.stat-value.leaf { color: var(--leaf); }
.stat-value.vermilion { color: var(--vermilion); }
.stat-sub { font-size: .83rem; color: var(--ink-soft); margin-top: .2rem; }

.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .8rem .4rem; border-radius: var(--radius-btn); background: var(--bg-card); border: 1px solid var(--border); color: var(--ink); font-size: .74rem; font-weight: 600; text-align: center; }
.quick-action:hover { text-decoration: none; background: var(--bg-card-alt); }
.quick-action .qa-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; background: var(--bg-card-alt); }
@media (max-width: 500px) { .quick-actions { grid-template-columns: repeat(4, 1fr); gap: .4rem; } .quick-action { font-size: .68rem; } }

.cat-row { display: flex; align-items: center; justify-content: space-between; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.cat-row:last-child { border-bottom: none; }
.cat-left { display: flex; align-items: center; gap: .6rem; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.cat-pct { font-size: .78rem; color: var(--ink-soft); margin-left: .4rem; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-family: var(--font-body); font-weight: 600; font-size: .95rem; padding: .75rem 1.4rem; border-radius: var(--radius-btn); border: 2px solid var(--navy); background: var(--navy); color: #fff; cursor: pointer; }
.btn:hover { background: var(--navy-dark); border-color: var(--navy-dark); text-decoration: none; }
.btn-turmeric { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-turmeric:hover { background: #2558C4; border-color: #2558C4; }
.btn-outline { background: transparent; color: var(--navy); }
.btn-outline:hover { background: var(--navy); color: #fff; }
.btn-sm { padding: .45rem .9rem; font-size: .82rem; border-radius: var(--radius-pill); }
.btn-block { width: 100%; }

/* ---------------------------------------------------------------- forms */
label { display: block; font-weight: 600; font-size: .87rem; margin-bottom: .35rem; color: var(--ink); }
input, select, textarea { width: 100%; font-family: var(--font-body); font-size: 1rem; padding: .65rem .8rem; border: 1.5px solid var(--border); border-radius: 12px; background: #fff; color: var(--ink); margin-bottom: 1rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,237,.14); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .field-row { grid-template-columns: 1fr; } }
fieldset { border: none; padding: 0; margin: 0; }

/* ---------------------------------------------------------------- tables */
.ledger { width: 100%; border-collapse: collapse; }
.ledger th { text-align: left; font-family: var(--font-body); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: .5rem .6rem; border-bottom: 2px solid var(--border); }
.ledger td { padding: .65rem .6rem; border-bottom: 1px solid var(--border); font-size: .92rem; }
.ledger tr:hover td { background: var(--bg-card-alt); }
.amt { font-family: var(--font-body); font-weight: 700; }
.amt.income { color: var(--leaf); }
.amt.expense { color: var(--vermilion); }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-block; font-family: var(--font-body); font-size: .72rem; font-weight: 700; padding: .22rem .65rem; border-radius: var(--radius-pill); }
.badge-safe { background: var(--leaf-bg); color: #16A34A; }
.badge-risky { background: var(--turmeric-bg); color: #B45309; }
.badge-postpone { background: var(--vermilion-bg); color: #DC2626; }
.badge-soon { background: var(--vermilion-bg); color: #DC2626; }
.badge-ok { background: var(--leaf-bg); color: #16A34A; }

/* ---------------------------------------------------------------- verdict panel */
.verdict-panel { border-radius: var(--radius-card); padding: 1.5rem; margin: 1.3rem 0; border: none; }
.verdict-safe { background: var(--leaf-bg); }
.verdict-risky { background: var(--turmeric-bg); }
.verdict-postpone { background: var(--vermilion-bg); }
.verdict-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; margin-bottom: .3rem; }
.verdict-safe .verdict-title { color: #16A34A; }
.verdict-risky .verdict-title { color: #B45309; }
.verdict-postpone .verdict-title { color: #DC2626; }

.bar-track { height: 8px; background: var(--bg-card-alt); border-radius: var(--radius-pill); overflow: hidden; margin: .3rem 0 .1rem; }
.bar-fill { height: 100%; background: var(--navy); border-radius: var(--radius-pill); }
.bar-fill.over { background: var(--vermilion); }

/* ---------------------------------------------------------------- provider / list cards */
.provider-card { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.provider-name { font-family: var(--font-display); font-weight: 600; font-size: 1rem; color: var(--ink); }
.provider-meta { font-size: .84rem; color: var(--ink-soft); margin-top: .15rem; }
.verified-tag { font-size: .72rem; font-weight: 700; color: var(--leaf); }
.avatar-circle { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-card-alt); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.service-icon-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; margin-bottom: 1.2rem; }
.service-icon { display: flex; flex-direction: column; align-items: center; gap: .4rem; padding: .7rem .3rem; border-radius: var(--radius-btn); background: var(--bg-card); border: 1px solid var(--border); font-size: .72rem; font-weight: 600; color: var(--ink); text-align: center; }
.service-icon:hover { text-decoration: none; background: var(--bg-card-alt); }
.service-icon .si-icon { width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; background: var(--bg-card-alt); }
@media (max-width: 500px) { .service-icon-grid { grid-template-columns: repeat(4, 1fr); } }

/* ---------------------------------------------------------------- misc */
.muted { color: var(--ink-soft); font-size: .9rem; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.3rem 0; }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--ink-soft); }
.tag-pill { display: inline-block; background: var(--bg-card-alt); border-radius: var(--radius-pill); padding: .35rem .9rem; font-size: .82rem; font-weight: 600; margin: 0 .3rem .3rem 0; color: var(--ink); border: 1px solid transparent; cursor: pointer; }
.tag-pill.active { background: var(--navy); color: #fff; }
.alert-box { border-left: 4px solid var(--vermilion); background: var(--vermilion-bg); padding: .8rem 1rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; }
.success-box { border-left: 4px solid var(--leaf); background: var(--leaf-bg); padding: .8rem 1rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; }

.sitefooter { text-align: center; padding: 2rem 1rem; color: var(--ink-soft); font-size: .85rem; border-top: 1px solid var(--border); }

/* ---------------------------------------------------------------- auth pages */
.auth-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); padding: 2.2rem; }
.auth-mark { width: 48px; height: 48px; border-radius: 14px; background: var(--blue); color: #fff; font-family: var(--font-display); font-weight: 700; font-size: 1.4rem; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }

/* ---------------------------------------------------------------- Profile hub */
.profile-header { background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 100%); border-radius: var(--radius-card); padding: 1.4rem; color: #fff; display: flex; align-items: center; gap: 1rem; margin-bottom: 1.2rem; }
.profile-avatar { width: 56px; height: 56px; border-radius: 50%; background: rgba(255,255,255,.18); display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 700; flex-shrink: 0; }
.profile-list a { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.2rem; background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-btn); margin-bottom: .6rem; color: var(--ink); font-weight: 600; }
.profile-list a:hover { text-decoration: none; background: var(--bg-card-alt); }
.profile-list .pl-left { display: flex; align-items: center; gap: .8rem; }
.profile-list .pl-chevron { color: var(--ink-soft); }

/* ---------------------------------------------------------------- print */
@media print {
  .topbar, .bottom-nav, .sheet-backdrop, .more-sheet, .sitefooter, .no-print, .stitchline, form { display: none !important; }
  body { background: #fff; }
  .page { padding: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
