/* ============================================================
   FlipDebt Design System
   Palette pulled from the TheFlipDesk logo: navy + blue gradient,
   teal + amber accents from the "D" swoosh.
   Money figures use a monospace ledger typeface with tabular
   numerals — the signature detail of this design.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600;700&display=swap');

* { box-sizing: border-box; }

:root {
  --ink: #0B1220;
  --ink-soft: #4B5573;
  --ink-faint: #8A93B0;
  --paper: #F3F5FB;
  --surface: #FFFFFF;
  --line: #E6E9F5;
  --line-strong: #D6DBEE;

  --brand-1: #155EEF;
  --brand-2: #2F6FED;
  --navy: #101B3D;
  --navy-2: #0B1330;
  --teal: #0FA99C;
  --amber: #F1A226;
  --coral: #E0405C;
  --green: #16A34A;

  --font-display: 'Sora', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11,18,32,0.04), 0 6px 20px rgba(11,18,32,0.06);
  --sidebar-w: 232px;
}

html.dark, body.dark {
  --ink: #E7EAF7;
  --ink-soft: #A6AECB;
  --ink-faint: #6B7394;
  --paper: #080C18;
  --surface: #111830;
  --line: #212B4A;
  --line-strong: #2C3861;
  --navy: #0A0F22;
  --navy-2: #060911;
}

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; }
.money, .card .value, td.money, .amount { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------------- App Shell (sidebar + content) ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 9px; font-family: var(--font-display); font-weight: 700; font-size: 17px; padding: 0 8px 20px; }
.sidebar .brand .emoji { font-size: 20px; }

.runway { margin: 0 8px 22px; }
.runway .rlabel { font-size: 10.5px; color: #97A2C9; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.runway .rtrack { height: 7px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.runway .rfill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--brand-2)); border-radius: 999px; }
.runway .rpct { font-family: var(--font-mono); font-size: 12px; color: #C7CEEB; margin-top: 6px; }

.navlinks { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.navlinks a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px;
  color: #B9C1E6; text-decoration: none; font-size: 14px; font-weight: 500;
}
.navlinks a svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.navlinks a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.navlinks a.active { background: rgba(255,255,255,0.12); color: #fff; }
.navlinks a.active svg { opacity: 1; }

.sidebar .userbox { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 14px; margin-top: 8px; }
.sidebar .userbox .uname { font-size: 13px; color: #E5E9FA; font-weight: 600; margin-bottom: 8px; padding: 0 12px; }
.sidebar .userbox a { font-size: 13px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mobile-topbar { display: none; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 28px 28px 100px; width: 100%; }

/* Bottom app-bar for mobile */
.bottom-nav { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: linear-gradient(135deg, var(--navy), var(--navy-2));
    color: #fff; padding: 14px 16px; position: sticky; top: 0; z-index: 20;
  }
  .mobile-topbar .brand { display: flex; align-items: center; gap: 8px; font-family: var(--font-display); font-weight: 700; font-size: 16px; }
  .mobile-topbar .mt-actions { display: flex; align-items: center; gap: 14px; font-size: 13px; color: #C7CEEB; }
  .wrap { padding: 18px 16px 90px; }

  .bottom-nav {
    display: flex; justify-content: space-around; align-items: center;
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 18px rgba(11,18,32,0.06);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--ink-faint); text-decoration: none; font-size: 10.5px; font-weight: 600; padding: 4px 10px; }
  .bottom-nav a svg { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--brand-2); }
}

/* ---------------- Banners ---------------- */
.banner-warn { background: #FEF3E0; color: #935B10; border: 1px solid #F3D28D; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 18px; }
html.dark .banner-warn, body.dark .banner-warn { background: #2B230F; color: #F1C579; border-color: #4A3B18; }
.banner-warn a { color: inherit; text-decoration: underline; font-weight: 600; }

/* ---------------- Page header ---------------- */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0 0 3px; }
.page-head p { color: var(--ink-soft); font-size: 13.5px; margin: 0; }

/* ---------------- Cards (summary) ---------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin: 0 0 24px; }
.card {
  background: var(--surface); border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  position: relative; overflow: hidden;
}
.card::before { content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent, var(--brand-2)); }
.card.debt { --accent: var(--coral); }
.card.paid { --accent: var(--green); }
.card.monthly { --accent: var(--amber); }
.card.interest { --accent: var(--teal); }
.card.target { --accent: linear-gradient(90deg, var(--brand-1), var(--teal)); }
.card .label { font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; font-weight: 600; }
.card .value { font-size: 23px; font-weight: 600; }
.card .sub { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }

/* ---------------- Section header ---------------- */
.section-header { display: flex; justify-content: space-between; align-items: center; margin: 30px 0 12px; flex-wrap: wrap; gap: 10px; }
.section-header h2 { font-size: 15.5px; margin: 0; font-weight: 700; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 9px; border: none;
  background: linear-gradient(135deg, var(--brand-1), var(--brand-2));
  color: #fff; text-decoration: none; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: var(--font-body);
  box-shadow: 0 1px 2px rgba(21,94,239,0.15);
}
.btn:hover { filter: brightness(1.06); }
.btn.secondary { background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: none; }
.btn.secondary:hover { background: var(--paper); }
.btn.danger { background: var(--coral); }
.btn.small { padding: 6px 12px; font-size: 12.5px; }

/* ---------------- Tables → mobile cards ---------------- */
.table-wrap { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 13px 16px; font-size: 13px; border-bottom: 1px solid var(--line); }
th { background: var(--paper); color: var(--ink-faint); font-weight: 700; text-transform: uppercase; font-size: 10.5px; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 10.5px; font-weight: 700; letter-spacing: 0.01em; }
.tag.bank { background: #DCE8FF; color: #1D4ED8; }
.tag.nbfc { background: #E6E1FF; color: #5B3FD1; }
.tag.cc { background: #FBDEE3; color: #C3244A; }
.tag.person { background: #DAF3E4; color: #147A46; }
.tag.other { background: #EDEFF6; color: #4B5573; }
html.dark .tag.bank, body.dark .tag.bank { background: #142A57; color: #8FB4FF; }
html.dark .tag.nbfc, body.dark .tag.nbfc { background: #251C57; color: #C6B8FF; }
html.dark .tag.cc, body.dark .tag.cc { background: #4A1522; color: #FF9DB2; }
html.dark .tag.person, body.dark .tag.person { background: #103821; color: #7EE0A6; }
html.dark .tag.other, body.dark .tag.other { background: #232B45; color: #B9C1E6; }
.due-soon { color: var(--coral); font-weight: 700; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions a { font-size: 11.5px; text-decoration: none; padding: 5px 9px; border-radius: 7px; background: var(--paper); color: var(--brand-2); font-weight: 600; }
.actions a.del { color: var(--coral); }
.empty { padding: 46px 20px; text-align: center; color: var(--ink-faint); font-size: 14px; }

@media (max-width: 760px) {
  .table-wrap { background: transparent; box-shadow: none; border: none; overflow: visible; }
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  table tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    margin-bottom: 12px; padding: 6px 4px; box-shadow: var(--shadow);
  }
  table td { border-bottom: none; padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13px; }
  table td::before { content: attr(data-label); font-size: 10.5px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0; }
  table td.actions { justify-content: flex-start; }
  table td.actions::before { display: none; }
  .progress-bar { width: 90px; }
}

/* ---------------- Forms ---------------- */
.form-card { background: var(--surface); border-radius: var(--radius); padding: 26px; max-width: 580px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.form-row { margin-bottom: 17px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--ink-soft); }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], select, textarea {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line-strong); border-radius: 9px; font-size: 14px;
  background: var(--surface); color: var(--ink); font-family: var(--font-body);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(47,111,237,0.14); }
.form-actions { display: flex; gap: 10px; margin-top: 22px; }
.hint { font-size: 11.5px; color: var(--ink-faint); margin-top: 5px; }

/* ---------------- Auth pages ---------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: stretch; background: var(--paper); }
.auth-side {
  flex: 1; background: linear-gradient(160deg, var(--navy) 0%, var(--brand-1) 130%);
  display: flex; flex-direction: column; justify-content: center; padding: 60px;
  color: #fff; position: relative; overflow: hidden;
}
.auth-side .brand { font-family: var(--font-display); font-size: 24px; font-weight: 700; display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.auth-side p { color: #C7D2F5; font-size: 15px; max-width: 380px; line-height: 1.6; }
.auth-side .stat { font-family: var(--font-mono); font-size: 34px; font-weight: 600; margin-top: 30px; }
.auth-side .stat + span { color: #A9B6E6; font-size: 12.5px; }
@media (max-width: 860px) { .auth-side { display: none; } }

.login-box-wrap { flex: 1; display: flex; align-items: center; justify-content: center; padding: 24px; min-width: 0; }
.login-box { background: var(--surface); padding: 36px; border-radius: 18px; width: 100%; max-width: 380px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.login-box h1 { font-size: 21px; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.login-box p.sub { color: var(--ink-soft); font-size: 13.5px; margin: 0 0 22px; }
.error-msg { background: #FDE7EA; color: #B0233F; padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; }
.success-msg { background: #DFF6E7; color: #147A46; padding: 11px 14px; border-radius: 9px; font-size: 13px; margin-bottom: 16px; }
html.dark .error-msg, body.dark .error-msg { background: #401520; color: #FF9DB2; }
html.dark .success-msg, body.dark .success-msg { background: #103821; color: #7EE0A6; }

/* ---------------- Progress ---------------- */
.progress-bar { width: 100%; background: var(--line); border-radius: 999px; height: 6px; overflow: hidden; margin-top: 4px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--teal), var(--brand-2)); }

/* ---------------- Priority list ---------------- */
.priority-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.priority-list li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--paper); border-radius: 10px; }
.priority-list .rank { width: 26px; height: 26px; border-radius: 50%; background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; font-family: var(--font-mono); }
.priority-list .pname { font-weight: 600; font-size: 13.5px; flex: 1; min-width: 0; }
.priority-list .pmeta { font-size: 12px; color: var(--ink-faint); }
.priority-list .pamt { font-family: var(--font-mono); font-weight: 600; font-size: 13.5px; }

/* ---------------- Toggle pills (strategy switch) ---------------- */
.pill-toggle { display: inline-flex; background: var(--paper); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.pill-toggle a { padding: 7px 14px; border-radius: 999px; font-size: 12.5px; font-weight: 600; text-decoration: none; color: var(--ink-soft); }
.pill-toggle a.active { background: var(--surface); color: var(--brand-2); box-shadow: var(--shadow); }

footer.note { text-align: center; color: var(--ink-faint); font-size: 12px; margin: 34px 0 10px; }
footer.note a { color: var(--brand-2); text-decoration: none; font-weight: 600; }

.back-link { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--brand-2); text-decoration: none; margin-bottom: 16px; }
.back-link svg { width: 15px; height: 15px; }

@media print { .no-print { display: none !important; } }
