/* ============================================================================
   CASH — private-banking "ink" theme. Deep near-black canvas, emerald for money,
   coral for debt, warm gold highlights. Editorial Fraunces numerals over Hanken
   Grotesk UI. Built to be glanced at on a phone or a desktop, daily.
   ========================================================================== */

:root {
  --ink:        #090c0b;
  --ink-2:      #0c100f;
  --panel:      #111917;
  --panel-2:    #16201d;
  --panel-hi:   #1b2622;
  --line:       rgba(233, 239, 233, 0.07);
  --line-2:     rgba(233, 239, 233, 0.12);

  --text:       #e9efe9;
  --muted:      #8ba398;
  --faint:      #5e726a;

  --emerald:    #3ddc97;
  --emerald-2:  #2bb67d;
  --emerald-soft: rgba(61, 220, 151, 0.13);
  --gold:       #d9b56b;
  --coral:      #f08769;
  --coral-soft: rgba(240, 135, 105, 0.13);
  --amber:      #e6b54a;

  --r-sm: 10px;
  --r:    16px;
  --r-lg: 22px;
  --shadow: 0 18px 40px -24px rgba(0, 0, 0, 0.8);
  --shadow-hi: 0 26px 60px -28px rgba(0, 0, 0, 0.9);

  --display: "Fraunces", Georgia, serif;
  --ui: "Hanken Grotesk", ui-sans-serif, system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--ui);
  background: var(--ink);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

/* Atmosphere: a soft emerald horizon glow + a fine grain overlay for depth. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(1100px 620px at 78% -8%, rgba(61, 220, 151, 0.10), transparent 60%),
    radial-gradient(900px 600px at 8% 110%, rgba(217, 181, 107, 0.06), transparent 55%),
    var(--ink);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.035'/%3E%3C/svg%3E");
}

.num {
  font-family: var(--display);
  font-variant-numeric: tabular-nums lining-nums;
  font-weight: 460;
  letter-spacing: -0.012em;
}

.pos { color: var(--emerald); }
.neg { color: var(--coral); }

/* ---- shell ---- */
.wrap { max-width: 1180px; margin: 0 auto; padding: clamp(16px, 3vw, 34px); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: clamp(20px, 4vw, 40px);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(26px, 3.4vw, 38px);
  letter-spacing: 0.01em;
  line-height: 1;
}
.brand .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 0 4px var(--emerald-soft), 0 0 14px 2px rgba(61, 220, 151, 0.5);
  align-self: center;
}
.brand small {
  color: var(--faint);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.updated { color: var(--muted); font-size: 12.5px; text-align: right; line-height: 1.3; }
.updated b { color: var(--text); font-weight: 600; }

.btn {
  font-family: var(--ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s, transform 0.1s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: var(--panel-hi); border-color: rgba(61,220,151,0.4); }
.btn:active { transform: translateY(1px); }
.btn .spin { width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--faint); border-top-color: var(--emerald); display: none; }
.btn.loading .spin { display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.ghost:hover { color: var(--text); }

/* range pills */
.pills { display: inline-flex; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 3px; gap: 2px; }
.pills button {
  font-family: var(--ui); font-size: 12.5px; font-weight: 600;
  color: var(--muted); background: transparent; border: none; cursor: pointer;
  padding: 6px 13px; border-radius: 999px; transition: color 0.15s, background 0.15s;
}
.pills button:hover { color: var(--text); }
.pills button.active { color: var(--ink); background: var(--emerald); }

/* stale banner */
.stale {
  display: none;
  align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(230,181,74,0.16), rgba(230,181,74,0.05));
  border: 1px solid rgba(230,181,74,0.35);
  color: #f0d9a3;
  border-radius: var(--r-sm);
  padding: 10px 14px; font-size: 13px; margin-bottom: 20px;
}
.stale.show { display: flex; }

/* ---- hero / NET ---- */
.hero {
  position: relative;
  background:
    linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: clamp(22px, 4vw, 38px);
  box-shadow: var(--shadow-hi);
  overflow: hidden;
  margin-bottom: 22px;
}
.hero::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(600px 240px at 88% -40%, var(--emerald-soft), transparent 70%);
  pointer-events: none;
}
.hero .eyebrow { color: var(--muted); font-size: 12px; letter-spacing: 0.2em;
  text-transform: uppercase; margin-bottom: 8px; }
.hero .net { font-size: clamp(46px, 9vw, 86px); line-height: 0.98; font-weight: 500; }
.hero .net.neg { color: var(--coral); }
.netsub { color: var(--faint); font-size: 13.5px; margin-top: 6px; }

.spark { position: relative; height: 74px; margin-top: 18px; opacity: 0.92; }
.spark canvas { display: block; width: 100%; height: 100%; }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 26px; position: relative; z-index: 1; }
.chip {
  background: rgba(9, 12, 11, 0.5);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 14px 16px;
}
.chip .k { display: flex; align-items: center; gap: 7px; color: var(--muted);
  font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; }
.chip .k i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.chip .v { font-size: clamp(20px, 3.4vw, 28px); margin-top: 6px; }

/* ---- section scaffold ---- */
.section { margin-top: 34px; }
.section > h2 {
  font-family: var(--ui);
  font-size: 12.5px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px;
  display: flex; align-items: center; gap: 14px;
}
.section > h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
}

/* ---- cashflow ---- */
.flow { padding: clamp(16px, 2.6vw, 22px); }
.flow .flowhead { display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
.flow .legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.flow .legend span { display: inline-flex; align-items: center; gap: 7px; }
.flow .legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.toggle { display: inline-flex; align-items: center; gap: 8px; color: var(--muted);
  font-size: 12.5px; cursor: pointer; user-select: none; }
.toggle input { accent-color: var(--gold); width: 15px; height: 15px; }
.chartbox { position: relative; height: clamp(220px, 34vw, 300px); }

/* ---- locations grid ---- */
.grid { display: grid; gap: 13px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.loc { padding: 17px 18px; position: relative; transition: transform 0.16s, border-color 0.16s; }
.loc:hover { transform: translateY(-3px); border-color: var(--line-2); }
.loc .top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.loc .name { font-family: var(--display); font-size: 18px; font-weight: 500; line-height: 1.15; }
.badge { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--faint);
  border: 1px solid var(--line-2); border-radius: 999px; padding: 3px 8px; white-space: nowrap; }
.badge.personal { color: var(--gold); border-color: rgba(217,181,107,0.4); }
.badge.internal { color: var(--muted); }
.loc .bal { font-size: 27px; margin-top: 14px; }
.loc .flowrow { display: flex; justify-content: space-between; margin-top: 12px;
  padding-top: 12px; border-top: 1px solid var(--line); font-size: 13px; }
.loc .flowrow .lab { color: var(--faint); font-size: 11px; letter-spacing: 0.06em;
  text-transform: uppercase; display: block; margin-bottom: 2px; }
.loc .io { display: flex; flex-direction: column; }
.loc .io.out { text-align: right; }

/* ---- cards & loans ---- */
.two { display: grid; gap: 13px; grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .two { grid-template-columns: 1fr; } }
.list { padding: 6px 4px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 6px 14px;
  padding: 15px 16px; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: none; }
.row .nm { font-weight: 600; font-size: 14.5px; }
.row .meta { color: var(--faint); font-size: 12px; }
.row .amt { text-align: right; font-size: 17px; }
.util { grid-column: 1 / -1; margin-top: 9px; display: flex; align-items: center; gap: 10px; }
.util .track { flex: 1; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.util .fill { height: 100%; border-radius: 999px; transition: width 0.6s cubic-bezier(.2,.8,.2,1); }
.util .pct { font-size: 12px; color: var(--muted); min-width: 42px; text-align: right; }

/* ---- recent activity ---- */
.feed { padding: 4px 4px; max-height: 420px; overflow-y: auto; }
.tx { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); }
.tx:last-child { border-bottom: none; }
.tx .t1 { font-size: 14px; font-weight: 550; }
.tx .t2 { color: var(--faint); font-size: 12px; }
.tx .amt { text-align: right; font-size: 15px; }
.tx .d { color: var(--faint); font-size: 11.5px; text-align: right; }

.muted { color: var(--muted); }
.empty { color: var(--faint); padding: 26px; text-align: center; font-size: 13.5px; }

/* ---- entrance animation ---- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.reveal { opacity: 0; animation: rise 0.6s cubic-bezier(.2,.7,.2,1) forwards; }
@media (prefers-reduced-motion: reduce) { .reveal { animation: none; opacity: 1; } }

.foot { color: var(--faint); font-size: 11.5px; text-align: center; margin: 38px 0 8px;
  letter-spacing: 0.04em; }

@media (max-width: 540px) {
  .chips { grid-template-columns: 1fr; }
  .updated { text-align: left; }
  .controls { width: 100%; }
}

/* ---- slide-over panel (location drill-down + tagging) ---- */
.loc.clickable { cursor: pointer; }
.loc.clickable::after { content: "›"; position: absolute; top: 14px; right: 16px; color: var(--faint);
  font-size: 20px; line-height: 1; transition: transform 0.16s, color 0.16s; }
.loc.clickable:hover::after { color: var(--emerald); transform: translateX(3px); }

.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.55); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s; z-index: 40; }
.backdrop.open { opacity: 1; pointer-events: auto; }
.panel { position: fixed; top: 0; right: 0; height: 100dvh; width: min(560px, 94vw);
  background: linear-gradient(180deg, var(--panel-2), var(--ink-2));
  border-left: 1px solid var(--line-2); box-shadow: -30px 0 60px -30px rgba(0,0,0,0.9);
  transform: translateX(101%); transition: transform 0.32s cubic-bezier(.2,.8,.2,1);
  z-index: 50; display: flex; flex-direction: column; }
.panel.open { transform: none; }
.phead { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 22px 24px 16px; border-bottom: 1px solid var(--line); }
.ptitle { font-family: var(--display); font-size: 25px; font-weight: 500; line-height: 1.1; }
.psub { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.pclose { background: var(--panel); border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 999px; width: 34px; height: 34px; font-size: 17px; cursor: pointer; flex: none; }
.pclose:hover { color: var(--text); border-color: var(--line-2); }
.pbody { padding: 18px 24px 30px; overflow-y: auto; flex: 1; }

.statline { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
.statline .s { background: rgba(9,12,11,0.45); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 13px; }
.statline .s .lab { color: var(--faint); font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; }
.statline .s .val { font-size: 20px; margin-top: 4px; }

.psec { font-size: 11px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--muted); margin: 24px 0 10px; }
.catrow { display: grid; grid-template-columns: 1fr auto; gap: 5px 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.catname { font-size: 13px; } .catamt { font-size: 13px; text-align: right; }
.cbar { grid-column: 1/-1; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.06); overflow: hidden; }
.cbar i { display: block; height: 100%; background: var(--coral); border-radius: 999px; }

.tagrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--line); }
.tagrow .v1 { font-weight: 600; font-size: 14px; }
.tagrow .v2 { color: var(--faint); font-size: 12px; }
.tagrow .amt { text-align: right; font-size: 14px; }
select.loc { grid-column: 1/-1; margin-top: 4px; font-family: var(--ui); font-size: 13px;
  color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; width: 100%; cursor: pointer; }
select.loc:focus { border-color: var(--emerald); outline: none; }
.tagged { color: var(--emerald); }
.rulerow { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.rulerow .del { background: transparent; border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 8px; padding: 5px 11px; font-size: 12px; cursor: pointer; }
.rulerow .del:hover { color: var(--coral); border-color: var(--coral); }
.hint2 { color: var(--faint); font-size: 12.5px; margin-bottom: 10px; }
.catcols { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
@media (max-width: 620px) { .catcols { grid-template-columns: 1fr; gap: 10px; } }
.tagrow select.cat { grid-column: 1 / -1; }
.tagrow .selrow { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 4px; }
@media (max-width: 480px) { .tagrow .selrow { grid-template-columns: 1fr; } }
.tagrow .selrow select.loc { grid-column: auto; margin-top: 0; }
