/* ============================================================
   Compatibility Layer — Maps original compact class names
   used by page modules to proper styling.
   This bridges the gap until page modules are fully refactored.
   ============================================================ */

/* ─── Variable aliases (pages use old var names) ──────────── */
:root {
  --td: var(--text-dim);
  --tm: var(--text-muted);
  --tf: var(--text-faint);
  --tx: var(--text);
  --sf: var(--surface);
  --sf2: var(--surface-2);
  --sfh: var(--surface-hover);
  --sfe: var(--surface-elevated);
  --bd: var(--border);
  --exp: var(--expense);
  --exp-g: var(--expense-glow);
  --r: var(--radius);
  --rs: var(--radius-sm);
  --rl: var(--radius-lg);
}

/* ─── Grid ────────────────────────────────────────────────── */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: 1fr 1fr; }
.g3 { grid-template-columns: 1fr 1fr 1fr; }
.gsb { grid-template-columns: 2fr 1fr; }

@media(max-width:768px) {
  .g2, .g3 { grid-template-columns: 1fr 1fr; }
  .gsb { grid-template-columns: 1fr; }
}
@media(max-width:400px) { .g3 { grid-template-columns: 1fr; } }

/* ─── Card ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.card:hover { border-color: hsla(var(--brand-hue), 30%, 50%, 0.25); }
.cp { padding: 16px; }
.ct { font-size: 13px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; color: var(--text); letter-spacing: -0.01em; }
.cta { font-size: 11px; color: var(--brand); cursor: pointer; font-weight: 600; }

/* ─── Currency Tabs ───────────────────────────────────────── */
.cur-t { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; margin-bottom: 12px; }
.cur-t::-webkit-scrollbar { display: none; }
.ctb { padding: 5px 12px; border-radius: 16px; white-space: nowrap; border: 1px solid var(--border); background: transparent; color: var(--text-dim); font-size: 10px; font-weight: 600; cursor: pointer; flex-shrink: 0; transition: all .2s; }
.ctb.act { border-color: var(--brand); background: var(--brand-glow); color: var(--brand); }

/* ─── Account Cards ───────────────────────────────────────── */
.acs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.acs::-webkit-scrollbar { display: none; }
.acs-wrap { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; }
.acs-wrap .acc-c { min-width: unset; flex-shrink: unset; scroll-snap-align: unset; }
.acc-c { min-width: 170px; flex-shrink: 0; scroll-snap-align: start; background: linear-gradient(145deg, var(--surface-2), var(--surface)); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; }
.acc-c.hl { border-color: hsla(var(--brand-hue), 72%, 40%, .3); }
.atp { display: flex; justify-content: space-between; align-items: center; margin-bottom: 5px; }
.abg { font-size: 7px; padding: 2px 5px; border-radius: 4px; font-weight: 700; letter-spacing: .5px; background: var(--brand-glow); color: var(--brand); }
.anm { font-size: 10px; color: var(--text-muted); margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.abl { font-size: 16px; font-weight: 800; direction: ltr; text-align: end; }
.acr { font-size: 8px; color: var(--text-dim); }

/* ─── Stats ───────────────────────────────────────────────── */
.stats { display: grid; gap: 12px; margin-bottom: 16px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.stat:hover { border-color: hsla(var(--brand-hue), 40%, 50%, 0.35); transform: translateY(-1px); }
.stl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stv { font-size: 20px; font-weight: 800; line-height: 1.2; letter-spacing: -0.02em; }
.sv-c { font-size: 11px; color: var(--text-muted); font-weight: 600; margin-inline-start: 2px; }
.sv-l { display: block; font-size: 15px; font-weight: 700; line-height: 1.5; direction: ltr; text-align: start; letter-spacing: -0.01em; }
@media(max-width:768px) { .stats { grid-template-columns: 1fr 1fr; } }
@media(max-width:380px) { .stats { grid-template-columns: 1fr; } }

/* ─── Skeleton / Shimmer Loading ──────────────────────────── */
.skel { position: relative; overflow: hidden; background: var(--surface-2); border-radius: var(--radius-sm); }
.skel::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--surface-hover) 50%, transparent 100%);
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
@keyframes skel-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}
.skel-stat .skel-label { height: 8px; width: 50%; margin-bottom: 8px; }
.skel-stat .skel-value { height: 18px; width: 70%; }
.skel-chart { height: 180px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); position: relative; overflow: hidden; }
.skel-chart .skel-title { height: 10px; width: 40%; margin-bottom: 14px; background: var(--surface-2); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.skel-chart .skel-title::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--surface-hover) 50%, transparent 100%);
  animation: skel-shimmer 1.4s ease-in-out infinite;
}
.skel-chart .skel-area { height: 120px; background: var(--surface-2); border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.skel-chart .skel-area::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, var(--surface-hover) 50%, transparent 100%);
  animation: skel-shimmer 1.4s ease-in-out infinite;
}

/* ─── Sparkline ───────────────────────────────────────────── */
.spk { display: flex; align-items: flex-end; gap: 2px; height: 20px; margin-top: 4px; }
.spk b { width: 3px; border-radius: 1.5px; min-height: 2px; transition: height .4s; }

/* ─── Chart Wrapper ───────────────────────────────────────── */
.cht-tabs { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.cht-tabs::-webkit-scrollbar { display: none; }
.cht-tb { padding: 6px 14px; font-size: 12px; font-weight: 600; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); cursor: pointer; white-space: nowrap; transition: all 0.2s ease; }
.cht-tb:hover { color: var(--text); border-color: var(--text-dim); }
.cht-tb.act { border-color: var(--brand); background: var(--brand-glow); color: var(--brand); }
.chw { position: relative; direction: ltr; padding: 4px 0 2px; }
.chw canvas { width: 100%; display: block; }

/* Donut + legend sit side-by-side on every screen (was wrapping below
   on phones). Centered both axes; legend takes the rest of the row.   */
.donut-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  direction: ltr;
  padding: 8px 0;
}
.donut-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 130px;
  height: 130px;
  align-self: center;
  justify-self: center;
}
.donut-wrap canvas { display: block; margin: 0 auto; }
@media (min-width: 480px) { .donut-wrap { width: 160px; height: 160px; } }
@media (min-width: 640px) { .donut-wrap { width: 200px; height: 200px; } }
@media (min-width: 1024px) { .donut-wrap { width: 220px; height: 220px; } }
.dctr { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.dcv { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.dcl { font-size: 10px; color: var(--text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }

/* Empty-state chart card — only the title + filter tabs + a one-line
   "no data" hint. Saves ~150px per empty chart on first paint. */
.card.chart-empty .ct { margin-bottom: 6px; }
.chart-empty-body {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 8px;
  color: var(--text-muted);
  font-size: 12px;
  opacity: 0.85;
}
.chart-empty-icon { font-size: 16px; opacity: 0.6; }
.chart-empty-text { font-weight: 600; }

/* ─── Legend ───────────────────────────────────────────────── */
.lgd { margin-top: 6px; }
.lr { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; padding: 6px 8px; border-radius: 8px; transition: background-color 0.15s ease; }
.lr:hover { background: var(--surface-2); }
.ld { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.ln { font-size: 12px; color: var(--text); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.lp { font-size: 11px; color: var(--text-muted); font-weight: 600; min-width: 36px; text-align: end; }
.lv { font-size: 12px; font-weight: 700; min-width: 60px; text-align: end; }

/* ─── List Items ──────────────────────────────────────────── */
.li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); transition: background-color 0.15s ease; cursor: pointer; }
.li:last-child { border-bottom: none; }
.li:hover { background: var(--surface-hover); }
.lic { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 16px; flex-shrink: 0; line-height: 1; }
.lic.inc { background: var(--brand-glow); }
.lic.exp { background: var(--expense-glow); }
.lic.inv { background: var(--gold-glow); }
.lic.ct { background: var(--info-glow); }
.lib { flex: 1; min-width: 0; }
.lit { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
.lis { font-size: 11px; color: var(--text-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lir { text-align: end; flex-shrink: 0; }
.lia { font-size: 14px; font-weight: 700; direction: ltr; text-align: end; letter-spacing: -0.01em; }
.lia.inc { color: var(--brand); }
.lia.exp { color: var(--expense); }
.lid { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ─── List Actions ────────────────────────────────────────── */
.las { display: flex; gap: 3px; flex-shrink: 0; }
.la { width: 26px; height: 26px; border-radius: 6px; border: none; display: flex; align-items: center; justify-content: center; font-size: 11px; cursor: pointer; }
.la.ed { background: var(--info-glow); color: var(--info); }
.la.dl { background: var(--expense-glow); color: var(--expense); }

.la.ex { background: var(--brand-glow); color: var(--brand); }

.la:hover { opacity: .8; }
/* ─── Badges ──────────────────────────────────────────────── */
.bdg { font-size: 8px; padding: 2px 7px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.bi { background: var(--brand-glow); color: var(--brand); }
.be { background: var(--expense-glow); color: var(--expense); }
.bd { background: var(--gold-glow); color: var(--gold); }
.bp { background: var(--brand-glow); color: var(--brand); }
.bo { background: var(--expense-glow); color: var(--expense); }
.bs { background: var(--info-glow); color: var(--info); }

/* ─── Filters ─────────────────────────────────────────────── */
.flt { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; flex-wrap: wrap; }
.flt::-webkit-scrollbar { display: none; }
.fb { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
.fb:hover { color: var(--text); border-color: var(--text-dim); }
.fb.act { border-color: var(--brand); background: var(--brand-glow); color: var(--brand); }

/* ─── Invoice Stats ───────────────────────────────────────── */
.ivs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.ivs-c { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; text-align: center; }
.ivs-v { font-size: 16px; font-weight: 800; margin-top: 2px; }
.ivs-l { font-size: 8px; color: var(--text-dim); }

/* ─── Empty State ─────────────────────────────────────────── */
.ety { padding: 56px 24px; text-align: center; }
.eti { font-size: 44px; opacity: .35; margin-bottom: 12px; }
.ett { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── Settings ────────────────────────────────────────────── */
.sg { margin-bottom: 18px; }
.sgt { font-size: 9px; color: var(--text-faint); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 7px; padding-top: 6px; font-weight: 600; }

/* Collapsible CRUD section (categories, bank accounts, currencies, …) */
.sg-collapsible {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.sg-collapsible.is-open {
  border-color: hsla(var(--brand-hue), 72%, 40%, 0.35);
  box-shadow: 0 4px 14px hsla(var(--brand-hue), 72%, 40%, 0.06);
}
.sgt-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  margin: 0;
  background: transparent;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: start;
  font-size: 13px;
  font-weight: 700;
  text-transform: none;
  letter-spacing: 0;
  transition: background-color 0.15s ease;
}
.sgt-toggle:hover { background: var(--surface-hover); }
.sgt-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
[dir="rtl"] .sgt-chevron { transform: rotate(180deg); }
.sg-collapsible.is-open .sgt-chevron { transform: rotate(90deg); color: var(--brand); }
[dir="rtl"] .sg-collapsible.is-open .sgt-chevron { transform: rotate(90deg); }
.sgt-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sgt-count {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 9px;
  border-radius: 999px;
  min-width: 24px;
  text-align: center;
}
.sg-collapsible.is-open .sgt-count {
  background: var(--brand-glow);
  border-color: hsla(var(--brand-hue), 72%, 40%, 0.4);
  color: var(--brand);
}
.sg-body {
  border-top: 1px solid var(--border);
  padding: 6px 0 8px;
  animation: sg-slide 0.22s ease;
}
.sg-body[hidden] { display: none !important; }
.sg-body > .adr { margin: 6px 12px 4px; }
@keyframes sg-slide {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}
.si { display: flex; align-items: center; gap: 9px; padding: 9px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: 11px; margin-bottom: 4px; transition: background .1s; }
.si:hover { background: var(--surface-hover); }
.si-i { flex: 1; min-width: 0; }
.si-t { font-size: 11px; font-weight: 600; }
.si-s { font-size: 9px; color: var(--text-dim); margin-top: 1px; }
.si-r { font-size: 11px; font-weight: 700; flex-shrink: 0; }
.adr { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 9px; border: 1px dashed var(--border); border-radius: 11px; color: var(--brand); font-size: 10px; font-weight: 600; cursor: pointer; margin-bottom: 4px; transition: all .2s; }
.adr:hover { border-color: var(--brand); background: var(--brand-glow); }

/* ─── Planning: Collapsible Month Groups ──────────────────── */
.plan-month-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  margin: 4px 2px 10px;
  font-size: 11px;
}
.plan-month-actions .month-link {
  background: transparent;
  color: var(--text-muted);
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s ease, background-color 0.2s ease;
}
.plan-month-actions .month-link:hover {
  color: var(--brand);
  background: var(--brand-glow);
}
.plan-month-actions .month-link-sep {
  color: var(--text-faint);
  font-size: 11px;
}

.month-group {
  margin-bottom: 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.month-group.is-current {
  border-color: hsla(var(--brand-hue), 72%, 40%, 0.45);
  box-shadow: 0 0 0 1px hsla(var(--brand-hue), 72%, 40%, 0.15),
              0 6px 18px hsla(var(--brand-hue), 72%, 40%, 0.08);
}
.month-head {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  text-align: start;
  transition: background-color 0.15s ease;
}
.month-head:hover {
  background: var(--surface-hover);
}
.month-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}
[dir="rtl"] .month-chevron { transform: rotate(180deg); }
.month-group.is-open .month-chevron { transform: rotate(90deg); color: var(--brand); }
[dir="rtl"] .month-group.is-open .month-chevron { transform: rotate(90deg); }
.month-title {
  flex: 1;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.month-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--brand-glow);
  color: var(--brand);
}
.month-summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  font-size: 11px;
  direction: ltr;
}
.month-count {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  min-width: 22px;
  text-align: center;
}
.month-amt { font-weight: 700; font-size: 11px; }
.month-amt.inc { color: var(--brand); }
.month-amt.exp { color: var(--expense); }
.month-amt.net { font-size: 12px; }

.month-body {
  border-top: 1px solid var(--border);
  border-radius: 0;
  background: var(--surface);
  animation: month-slide 0.22s ease;
}
.month-body[hidden] { display: none !important; }

@keyframes month-slide {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .month-summary { gap: 6px; }
  .month-summary .month-amt.exp,
  .month-summary .month-count { display: none; }
  .month-title { font-size: 12px; }
}

/* ─── Contact Sheet: Multi-tag input ─────────────────────── */
.ct-tags-input { gap: 6px; }
.ct-tags-input .tag-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ct-tags-input .tag-btn[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand-glow);
  color: var(--brand);
}
.ct-tag-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  margin-inline-start: 2px;
  padding: 0;
}
.ct-tag-remove:hover { background: var(--expense); }

.ct-tag-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}
.ct-tag-add-input {
  flex: 1;
  min-width: 0;
  padding: 8px 12px;
  font-size: 12px;
}
.ct-tag-add-btn {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--brand);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.ct-tag-add-btn:hover {
  background: var(--brand-glow);
  border-color: var(--brand);
}

/* ─── Contacts: Toolbar (search + filter chips) ──────────── */
.ct-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg);
  padding-top: 2px;
  padding-bottom: 6px;
}
.ct-search {
  position: relative;
  display: flex;
  align-items: center;
}
.ct-search-icon {
  position: absolute;
  inset-inline-start: 14px;
  font-size: 15px;
  color: var(--text-muted);
  pointer-events: none;
}
.ct-search-input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
[dir="rtl"] .ct-search-input { padding: 12px 42px 12px 14px; }
.ct-search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px var(--brand-glow);
}
.ct-chip-row,
.ct-tag-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.ct-tag-row {
  padding-top: 2px;
  border-top: 1px dashed var(--border);
  padding-top: 8px;
}

.ct-bool-chip,
.ct-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s ease;
}
.ct-bool-chip:hover,
.ct-tag-chip:hover {
  color: var(--text);
  border-color: var(--text-dim);
}
.ct-bool-chip.is-yes {
  background: var(--brand-glow);
  border-color: var(--brand);
  color: var(--brand);
}
.ct-bool-chip.is-no {
  background: var(--expense-glow);
  border-color: var(--expense);
  color: var(--expense);
}
.ct-tag-chip {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-muted);
}
.ct-tag-chip.is-on {
  background: hsla(var(--brand-hue), 72%, 40%, .14);
  border-color: var(--brand);
  color: var(--brand);
}
.ct-bool-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: currentColor;
  color: var(--surface);
  font-size: 10px;
  font-weight: 800;
}

/* ─── Contacts: Row layout ───────────────────────────────── */
.ct-list-card { padding: 0; }

.ct-row {
  align-items: flex-start;
  padding: 14px;
  gap: 12px;
}
.ct-row .lic {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  align-self: flex-start;
}
.ct-row .lit {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
}
.ct-row .lis { font-size: 11px; }
.ct-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ct-company-badge {
  font-size: 12px;
  background: var(--info-glow);
  color: var(--info);
  border-radius: 6px;
  padding: 2px 6px;
}
.ct-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.ct-row-tag {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 999px;
}

/* ─── Contacts: Detail sheet ─────────────────────────────── */
.sheet.ct-detail { max-width: 640px; }

.ct-detail-loading {
  padding: 36px 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.ct-detail-empty {
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.ct-detail-head {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--border);
}
.ct-detail-avatar {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--info-glow);
  color: var(--info);
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.ct-detail-id { flex: 1; min-width: 0; }
.ct-detail-name {
  font-size: 16px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-detail-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.ct-detail-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.ct-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}
.ct-action-btn.danger { background: var(--expense-glow); color: var(--expense); border-color: hsla(0,72%,60%,.3); }

.ct-section {
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
}
.ct-section:last-child { border-bottom: none; }
.ct-section-title {
  margin: 0 0 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.ct-count {
  font-size: 10px;
  font-weight: 700;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 1px 8px;
}

.ct-info {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.ct-info-row {
  display: grid;
  grid-template-columns: 24px 110px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-2);
  border-radius: 10px;
  border: 1px solid var(--border);
}
.ct-info-icon { font-size: 14px; }
.ct-info-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}
.ct-info-value {
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.ct-info-value a { color: inherit; text-decoration: underline; text-decoration-color: var(--brand); }

@media (max-width: 480px) {
  .ct-info-row { grid-template-columns: 24px 1fr; }
  .ct-info-row .ct-info-label { font-size: 10px; }
  .ct-info-row .ct-info-value { grid-column: 1 / -1; padding-inline-start: 34px; margin-top: -4px; }
}

.ct-list { display: flex; flex-direction: column; gap: 6px; }
.ct-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.ct-item-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  flex-shrink: 0;
}
.ct-item-main { flex: 1; min-width: 0; }
.ct-item-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ct-item-sub {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ct-item-amt {
  font-size: 13px; font-weight: 800; flex-shrink: 0; letter-spacing: -0.01em;
}

/* ─── Contact: Legacy inline balance panel (kept for swipe + back-compat) */
.ct-row-wrap { border-bottom: 1px solid var(--border); }
.ct-row-wrap:last-child { border-bottom: none; }
.ct-row-wrap > .li { border-bottom: none; }

.ct-balance {
  padding: 8px 14px 12px;
  background: var(--surface-2);
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: ct-balance-in 0.22s ease;
}
.ct-balance-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 6px 0;
}

.ct-balance-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.ct-balance-icon { font-size: 16px; flex-shrink: 0; line-height: 1; }
.ct-balance-label {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ct-balance-amts {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
  direction: ltr;
}
.ct-amt {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.ct-amt-val { font-size: 12px; letter-spacing: -0.01em; }
.ct-amt-cur { font-size: 10px; opacity: 0.75; font-weight: 600; }

.ct-amt-exp  { background: var(--expense-glow); color: var(--expense); }
.ct-amt-inc  { background: var(--brand-glow);   color: var(--brand); }
.ct-amt-gold { background: var(--gold-glow);    color: var(--gold); }
.ct-amt-info { background: var(--info-glow);    color: var(--info); }

.ct-balance-row.ct-balance-exp  { border-color: hsla(0,  72%, 60%, .25); }
.ct-balance-row.ct-balance-inc  { border-color: hsla(var(--brand-hue), 72%, 40%, .25); }
.ct-balance-row.ct-balance-gold { border-color: hsla(38, 92%, 50%, .25); }
.ct-balance-row.ct-balance-info { border-color: hsla(220,90%, 55%, .25); }

@keyframes ct-balance-in {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .ct-balance-row { flex-wrap: wrap; }
  .ct-balance-amts { width: 100%; justify-content: flex-end; }
}

/* ─── Swipe-to-Delete Hint ───────────────────────────────── */
.swipe-delete-hint {
  position: absolute;
  top: 0;
  bottom: 0;
  inset-inline-end: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 22px;
  background: linear-gradient(
    to var(--swipe-grad-dir, left),
    var(--expense) 0%,
    var(--expense) 60%,
    transparent 100%
  );
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.15s ease;
}
[dir="rtl"] .swipe-delete-hint {
  justify-content: flex-start;
  --swipe-grad-dir: right;
}
.swipe-delete-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.swipe-delete-hint.is-armed .swipe-delete-icon {
  transform: scale(1.15);
  background: rgba(255, 255, 255, 0.28);
}

/* The row becomes a positioning + stacking context so the absolutely-
   positioned hint can sit behind the row's flex children while still
   being painted within the row's box. */
.li {
  position: relative;
  background-clip: padding-box;
  isolation: isolate;
  touch-action: pan-y;
}
.li > :not(.swipe-delete-hint) {
  position: relative;
  z-index: 1;
}
