/* ============================================================================
 * accounts-view.css, BudgetThink "Accounts" screen (self-contained)
 *
 * Quicken-dense desktop layout + AlterRich up/down sparklines.
 * Every class is prefixed .bt-acct- so this file only styles its own module.
 * Visual language matches the app: 13px system font, hairline separators,
 * periwinkle #808fbc selection, green #0f8a53 for positive money, red for debt.
 * Green is used ONLY for money (net worth, gains); never decoratively.
 * ==========================================================================*/

.bt-acct-root {
  /* local tokens (fall back to app vars where present) */
  --bta-line: var(--line, #e6e9e3);
  --bta-line-soft: #eef1ed;
  --bta-card: var(--card, #ffffff);
  --bta-bg: var(--bg, #f3f5f2);
  --bta-ink: var(--text, #16231d);
  --bta-muted: var(--muted, #6b7670);
  --bta-faint: #9aa39c;
  --bta-green: var(--pos, #0f8a53);
  --bta-red: var(--neg, #c0493b);
  --bta-peri: #808fbc;
  --bta-peri-soft: #eef0f7;
  --bta-hover: #f5f7f4;

  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.35;
  color: var(--bta-ink);
  background: var(--bta-bg);
  -webkit-font-smoothing: antialiased;
  padding: 0 0 40px;
}

.bt-acct-root *,
.bt-acct-root *::before,
.bt-acct-root *::after { box-sizing: border-box; }

.bt-acct-empty {
  padding: 40px; text-align: center; color: var(--bta-muted); font-size: 13px;
}

/* ---------- Header ---------- */
.bt-acct-header {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 18px 22px 14px;
  background: var(--bta-card);
  border-bottom: 1px solid var(--bta-line);
}
.bt-acct-head-left { display: flex; align-items: baseline; gap: 18px; min-width: 0; }
.bt-acct-title {
  font-size: 19px; font-weight: 700; letter-spacing: -.2px; color: var(--bta-ink);
}
.bt-acct-networth { display: flex; align-items: baseline; gap: 8px; }
.bt-acct-nw-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px;
  color: var(--bta-faint);
}
.bt-acct-nw-value {
  font-size: 22px; font-weight: 700; letter-spacing: -.4px;
  color: var(--bta-green); font-variant-numeric: tabular-nums;
}
.bt-acct-nw-value.neg { color: var(--bta-red); }

.bt-acct-head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* ---------- Sync (↻) control ---------- */
.bt-acct-sync {
  display: inline-flex; align-items: center; gap: 7px;
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--bta-peri);
  background: var(--bta-card); border: 1px solid var(--bta-line);
  border-radius: 8px; padding: 7px 12px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(22,35,29,.04);
}
.bt-acct-sync:hover { border-color: var(--bta-peri); background: var(--bta-peri-soft); }
.bt-acct-sync:disabled { cursor: default; opacity: .9; }
.bt-acct-sync.block { padding: 11px 18px; font-size: 14px; }
.bt-acct-sync-ic { display: block; color: currentColor; transform-origin: 50% 50%; }
.bt-acct-sync.spinning .bt-acct-sync-ic { animation: bt-acct-spin .8s linear infinite; }
.bt-acct-sync-lbl { white-space: nowrap; }
@keyframes bt-acct-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .bt-acct-sync.spinning .bt-acct-sync-ic { animation-duration: 1.6s; }
}

/* ---------- Blue dot (newly-downloaded / unreviewed) ---------- */
.bt-acct-bluedot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #2b7fff; box-shadow: 0 0 0 2px var(--bta-card);
  flex: none; display: inline-block;
}
.bt-acct-bluedot.sm { width: 7px; height: 7px; margin-right: 6px; box-shadow: none; vertical-align: middle; }

/* ---------- Entity chip (cosmetic segmented control) ---------- */
.bt-acct-entity {
  display: inline-flex; padding: 2px; gap: 1px;
  background: var(--bta-bg); border: 1px solid var(--bta-line); border-radius: 8px;
}
.bt-acct-entity-btn {
  font: inherit; font-size: 11.5px; font-weight: 600; line-height: 1;
  color: var(--bta-muted); background: transparent; border: none; cursor: pointer;
  padding: 6px 10px; border-radius: 6px; white-space: nowrap;
}
.bt-acct-entity-btn:hover { color: var(--bta-ink); }
.bt-acct-entity-btn.active {
  background: var(--bta-card); color: var(--bta-peri);
  box-shadow: 0 1px 2px rgba(22,35,29,.08); font-weight: 700;
}

/* ---------- Period dropdown ---------- */
.bt-acct-dd { position: relative; }
.bt-acct-dd-btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 12.5px; font-weight: 600; color: var(--bta-ink);
  background: var(--bta-card); border: 1px solid var(--bta-line);
  border-radius: 8px; padding: 7px 11px; cursor: pointer; min-width: 132px;
  justify-content: space-between;
  box-shadow: 0 1px 2px rgba(22,35,29,.04);
}
.bt-acct-dd-btn:hover { border-color: #cfd6ce; }
.bt-acct-dd.open .bt-acct-dd-btn {
  border-color: var(--bta-peri);
  box-shadow: 0 0 0 3px rgba(128,143,188,.16);
}
.bt-acct-dd-cur { white-space: nowrap; }
.bt-acct-dd-chev { color: var(--bta-faint); transition: transform .15s ease; flex: none; }
.bt-acct-dd.open .bt-acct-dd-chev { transform: rotate(180deg); color: var(--bta-peri); }

.bt-acct-dd-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 100%; padding: 5px;
  background: var(--bta-card); border: 1px solid var(--bta-line);
  border-radius: 10px; box-shadow: 0 10px 30px rgba(22,35,29,.14);
  display: none; flex-direction: column; gap: 1px;
}
.bt-acct-dd.open .bt-acct-dd-menu { display: flex; }
.bt-acct-dd-opt {
  font: inherit; font-size: 12.5px; text-align: left; white-space: nowrap;
  color: var(--bta-ink); background: transparent; border: none; cursor: pointer;
  padding: 7px 12px; border-radius: 6px;
}
.bt-acct-dd-opt:hover { background: var(--bta-hover); }
.bt-acct-dd-opt.sel {
  background: var(--bta-peri-soft); color: var(--bta-peri); font-weight: 700;
}

/* ---------- Body / groups ---------- */
.bt-acct-body { padding: 10px 22px 0; }

.bt-acct-group { margin-top: 16px; }
.bt-acct-group-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 6px 2px 5px; border-bottom: 1.5px solid var(--bta-ink);
  margin-bottom: 2px;
}
.bt-acct-group-name {
  font-size: 11.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .8px;
  color: var(--bta-ink);
}
.bt-acct-group-total {
  font-size: 13px; font-weight: 700; color: var(--bta-ink);
  font-variant-numeric: tabular-nums;
}
.bt-acct-group-total.neg { color: var(--bta-red); }

.bt-acct-sub-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 9px 2px 3px;
}
.bt-acct-sub-name {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--bta-faint);
}
.bt-acct-sub-total {
  font-size: 11.5px; font-weight: 600; color: var(--bta-muted);
  font-variant-numeric: tabular-nums;
}
.bt-acct-sub-total.neg { color: var(--bta-red); }

/* ---------- Account cards (clean, big, bold, one design per account) ---------- */
.bt-acct-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 2px 0 4px;
}
.bt-acct-row {
  position: relative; display: flex; flex-direction: column; align-items: stretch;
  min-height: 118px;
  background: var(--bta-card); border: 1px solid var(--bta-line);
  border-radius: 14px; padding: 14px;
  cursor: pointer; outline: none; overflow: hidden;
  box-shadow: 0 1px 2px rgba(22,35,29,.04);
  transition: box-shadow .15s ease, border-color .15s ease, transform .1s ease;
}
.bt-acct-row:hover { box-shadow: 0 8px 24px rgba(22,35,29,.10); border-color: #cdd5cf; }
.bt-acct-row:active { transform: translateY(1px); }
.bt-acct-row:focus-visible { box-shadow: 0 0 0 2px rgba(128,143,188,.55); border-color: var(--bta-peri); }

.bt-acct-rowtop { display: flex; align-items: center; gap: 8px; }
.bt-acct-ico { font-size: 18px; line-height: 1; filter: saturate(.9); }
/* blue dot sits just after the icon, like Quicken's sidebar dot */

.bt-acct-name-wrap { min-width: 0; display: flex; flex-direction: column; margin-top: 8px; }
.bt-acct-name {
  font-size: 14px; font-weight: 700; color: var(--bta-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bt-acct-sub {
  font-size: 11.5px; color: var(--bta-muted); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; margin-top: 1px;
}

/* ---------- Sparkline (only drawn from real history) ---------- */
.bt-acct-spark-wrap { flex: 1; display: flex; align-items: center; min-height: 0; margin: 8px 0 2px; }
.bt-acct-spark-wrap svg { width: 100%; height: 38px; }
.bt-acct-spark { display: block; overflow: visible; }
.bt-acct-spark-line { stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.bt-acct-spark.up   .bt-acct-spark-line { stroke: var(--bta-green); }
.bt-acct-spark.down .bt-acct-spark-line { stroke: var(--bta-red); }
.bt-acct-spark.flat .bt-acct-spark-line { stroke: var(--bta-faint); }
.bt-acct-spark-area { stroke: none; }
.bt-acct-spark.up   .bt-acct-spark-area { fill: rgba(15,138,83,.10); }
.bt-acct-spark.down .bt-acct-spark-area { fill: rgba(192,73,59,.09); }
.bt-acct-spark.flat .bt-acct-spark-area { fill: rgba(154,163,156,.07); }

/* ---------- Delta (only drawn from real history) ---------- */
.bt-acct-delta-wrap { position: absolute; top: 14px; right: 14px; text-align: right; }
.bt-acct-delta {
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bt-acct-delta.up   { color: var(--bta-green); }
.bt-acct-delta.down { color: var(--bta-red); }
.bt-acct-delta.flat { color: var(--bta-faint); }

/* ---------- Balance ---------- */
.bt-acct-bal {
  margin-top: auto; font-size: 21px; font-weight: 800; color: var(--bta-ink);
  font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -.4px;
}
.bt-acct-bal.neg { color: var(--bta-red); }

/* ---------- Empty states (no grey backgrounds) ---------- */
.bt-acct-empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 8px;
  padding: 56px 24px; margin: 22px;
  background: var(--bta-card); border: 1px solid var(--bta-line); border-radius: 16px;
}
.bt-acct-empty-ic { font-size: 40px; line-height: 1; }
.bt-acct-empty-title { font-size: 18px; font-weight: 800; color: var(--bta-ink); }
.bt-acct-empty-sub { font-size: 13px; color: var(--bta-muted); max-width: 360px; }
.bt-acct-empty-state .bt-acct-sync { margin-top: 10px; }

/* ---------- Account detail / register view ---------- */
.bt-acct-back {
  display: inline-flex; align-items: center; gap: 5px;
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--bta-peri);
  background: transparent; border: none; cursor: pointer; padding: 4px 6px 4px 0;
}
.bt-acct-back:hover { text-decoration: underline; }
.bt-acct-head-left .bt-acct-detail-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.bt-acct-detail-title .bt-acct-ico { font-size: 22px; }
.bt-acct-detail-name { font-size: 20px; font-weight: 800; color: var(--bta-ink); letter-spacing: -.3px; }
.bt-acct-detail-sub { font-size: 12px; color: var(--bta-muted); }
.bt-acct-detail-bal { display: flex; flex-direction: column; align-items: flex-end; margin-right: 4px; }
.bt-acct-detail-bal-lbl { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .7px; color: var(--bta-faint); }
.bt-acct-detail-bal-val { font-size: 22px; font-weight: 800; color: var(--bta-green); font-variant-numeric: tabular-nums; letter-spacing: -.4px; }
.bt-acct-detail-bal.neg .bt-acct-detail-bal-val { color: var(--bta-red); }

.bt-acct-detail-body { padding: 14px 22px 0; }
.bt-acct-reg {
  background: var(--bta-card); border: 1px solid var(--bta-line); border-radius: 14px; overflow: hidden;
}
.bt-acct-reg-head, .bt-acct-reg-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1.4fr) minmax(0, 1fr) 120px;
  gap: 12px; align-items: center; padding: 10px 16px;
}
.bt-acct-reg-head {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--bta-faint); border-bottom: 1.5px solid var(--bta-ink);
}
.bt-acct-reg-row { border-bottom: 1px solid var(--bta-line-soft); font-size: 13px; }
.bt-acct-reg-row:last-child { border-bottom: none; }
.bt-acct-reg-row:hover { background: var(--bta-hover); }
.bt-acct-reg-c-payee { font-weight: 600; color: var(--bta-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-acct-reg-c-cat { color: var(--bta-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-acct-reg-c-date { color: var(--bta-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt-acct-reg-c-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bt-acct-reg-c-amt.pos { color: var(--bta-green); }
.bt-acct-reg-c-amt.neg { color: var(--bta-ink); }

/* ---------- Narrow (<720px): stack gracefully ---------- */
@media (max-width: 720px) {
  .bt-acct-header { padding: 14px 14px 12px; }
  .bt-acct-body { padding: 6px 12px 0; }
  .bt-acct-head-right { width: 100%; justify-content: space-between; }
  .bt-acct-entity { overflow-x: auto; max-width: 62%; }
  .bt-acct-list { grid-template-columns: repeat(2, 1fr); }
  .bt-acct-detail-body { padding: 10px 12px 0; }
  .bt-acct-reg-head, .bt-acct-reg-row {
    grid-template-columns: 78px minmax(0, 1fr) 96px;
  }
  .bt-acct-reg-c-cat { display: none; }
}
@media (max-width: 420px) {
  .bt-acct-list { grid-template-columns: 1fr; }
}

/* ---------- Dark mode ---------- */
@media (prefers-color-scheme: dark) {
  .bt-acct-root:not([data-theme='light']) {
    --bta-line: #2a322d;
    --bta-line-soft: #232a26;
    --bta-card: #1a211d;
    --bta-bg: #141a17;
    --bta-ink: #e7ece8;
    --bta-muted: #9aa49d;
    --bta-faint: #727d76;
    --bta-green: #39b47f;
    --bta-red: #e0776a;
    --bta-peri: #9aa8d6;
    --bta-peri-soft: #232838;
    --bta-hover: #20272300;
  }
  .bt-acct-root:not([data-theme='light']) .bt-acct-row:hover { background: #20272322; }
  .bt-acct-root:not([data-theme='light']) .bt-acct-group-head { border-bottom-color: #4a554e; }
  .bt-acct-root:not([data-theme='light']) .bt-acct-entity-btn.active,
  .bt-acct-root:not([data-theme='light']) .bt-acct-dd-btn { box-shadow: none; }
  .bt-acct-root:not([data-theme='light']) .bt-acct-spark.up   .bt-acct-spark-area { fill: rgba(57,180,127,.14); }
  .bt-acct-root:not([data-theme='light']) .bt-acct-spark.down .bt-acct-spark-area { fill: rgba(224,119,106,.12); }
}
