/* ---------- Tokens ---------- */
/* Palette matches archmkd.com: deep teal + rose/magenta, on a clean warm-white canvas. */
:root {
  --bg: #f6f4ef;
  --bg-warm: #f3e3e7;
  --bg-sage: #dcebe9;
  --ink: #16242a;
  --ink-2: #5a6a6d;
  --muted: #6f7c7e;
  --card: rgba(255, 255, 255, 0.68);
  --card-solid: #fcfbf8;
  --line: rgba(17, 61, 69, 0.1);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 14px 34px -20px rgba(17, 61, 69, 0.35);

  --brand: #113d45;
  --brand-ink: #ffffff;
  --accent: #96425a;
  --accent-bg: #f3e1e6;

  --green: #1f4a42;
  --red: #b54525;
  --yellow: #e9c25a;
  --dark: #16242a;

  --g-bg: #dcebe6;
  --g-ink: #1f4a42;
  --y-bg: #f3e2a6;
  --y-ink: #5b4700;
  --r-bg: #f2d9cc;
  --r-ink: #8a2e12;

  --radius: 22px;
  --font: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0e1517;
  --bg-warm: #231a1e;
  --bg-sage: #122220;
  --ink: #eef2f1;
  --ink-2: #b3bfc0;
  --muted: #80898b;
  --card: rgba(24, 34, 36, 0.7);
  --card-solid: #152023;
  --line: rgba(255, 255, 255, 0.08);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 14px 34px -20px rgba(0, 0, 0, 0.6);

  --brand: #4fa3ad;
  --brand-ink: #0e1517;
  --accent: #d98ca2;
  --accent-bg: #2c1b21;

  --green: #3f7e6f;
  --red: #c85a35;
  --yellow: #e0b64c;
  --dark: #2a2e2c;

  --g-bg: #1a2e29;
  --g-ink: #a9d8cb;
  --y-bg: #3a3320;
  --y-ink: #f3e2a6;
  --r-bg: #3a2620;
  --r-ink: #f2b59a;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.bg {
  position: fixed; inset: 0; z-index: -1;
  background:
    radial-gradient(900px 520px at 92% 0%, var(--bg-sage), transparent 60%),
    radial-gradient(820px 540px at 0% 100%, var(--bg-warm), transparent 60%),
    var(--bg);
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.r { text-align: right; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px;
  backdrop-filter: blur(10px);
  background: linear-gradient(var(--bg) 60%, transparent);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.logo {
  width: 28px; height: 28px;
  display: grid; place-items: center;
}
.logo svg { width: 28px; height: 21px; }
.tabs {
  display: flex; gap: 2px; flex: 1; min-width: 0;
  overflow-x: auto; overflow-y: visible; scrollbar-width: none;
  background: var(--card); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px; box-shadow: var(--shadow);
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
  color: var(--ink-2); font-size: 13px; font-weight: 500;
  transition: background .2s ease, color .2s ease, transform .12s ease-out;
}
/* Magnify-on-hover scaling (graduated by distance from the hovered tab) is applied inline by
   magnifyGroup() in app.js — see there. This just handles the hover text color. */
.tab:hover { color: var(--brand); }
.tab.active { background: var(--brand); color: var(--brand-ink); }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; font-size: 12px; font-weight: 600;
  display: grid; place-items: center;
}
.ib {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card-solid);
  display: inline-grid; place-items: center; position: relative; padding: 0; color: var(--ink);
}
.ib.sm { width: 26px; height: 26px; border: 0; background: transparent; }
.ib.has-dot::after {
  content: ""; position: absolute; top: 6px; right: 7px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--red);
  border: 1.5px solid var(--card-solid);
}

/* ---------- Floating dock ---------- */
.dock {
  position: fixed; left: 12px; top: 50%; transform: translateY(-50%); z-index: 20;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 14px 8px; border-radius: 999px;
  background: var(--card); backdrop-filter: blur(14px);
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.dock-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent;
  display: grid; place-items: center; color: var(--ink); position: relative;
  transition: background .2s ease, transform .12s ease-out;
}
/* Magnify-on-hover scaling (graduated by distance from the hovered icon) is applied inline by
   magnifyGroup() in app.js — see there. This just handles the hover background tint. */
.dock-btn:hover { background: var(--line); }
.dock-btn svg { width: 16px; height: 16px; }
.dock-btn::after {
  content: attr(data-tip); position: absolute; left: 44px; top: 50%; transform: translateY(-50%);
  background: var(--ink); color: var(--bg); font-size: 11px; padding: 4px 8px; border-radius: 8px;
  white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.dock-btn:hover::after { opacity: 1; }
.dock-sep { width: 16px; height: 1px; background: var(--line); }

/* ---------- Page ---------- */
.page {
  max-width: 1120px; margin: 0 auto;
  padding: 6px 20px 120px 64px;
}
.fade { animation: page-in .45s cubic-bezier(.22,1,.36,1); }
.h-title {
  font-size: 34px; line-height: 1.05; font-weight: 600; letter-spacing: -0.025em;
  margin: 14px 0 18px;
}
.page-head { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.toolbar .grow { flex: 1; }
.stack { display: grid; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* ---------- Cards & controls ---------- */
.card {
  background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.card-title { color: var(--ink-2); font-size: 14px; font-weight: 500; }
.head-tools { display: flex; align-items: center; gap: 6px; }
.big { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin-top: 4px; }
.big-sm { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.card.dark-card { background: var(--green); color: #f2f2ed; border-color: transparent; }
.card.dark-card .card-title, .card.dark-card .sub { color: rgba(242, 242, 237, 0.65); }
.card.dark-card .ib { background: rgba(255, 255, 255, 0.12); color: #f2f2ed; border-color: transparent; }

.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.kpi {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; box-shadow: var(--shadow);
  transition: transform .3s cubic-bezier(.22,1,.36,1), box-shadow .3s ease;
}
.kpi:hover { transform: translateY(-5px); box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 44px -20px rgba(17,61,69,.45); }
.kpi-ic {
  width: 34px; height: 34px; border-radius: 50%; background: var(--line);
  display: grid; place-items: center; flex: none;
}
.kpi b { display: block; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.kpi small { color: var(--muted); font-size: 13px; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
  font-size: 11px; font-weight: 600; background: var(--line); color: var(--ink-2);
}
.pill.green { background: var(--g-bg); color: var(--g-ink); }
.pill.yellow { background: var(--y-bg); color: var(--y-ink); }
.pill.red { background: var(--r-bg); color: var(--r-ink); }
.pill.ghost { background: transparent; border: 1px dashed var(--muted); }

.seg {
  display: inline-flex; padding: 3px; border-radius: 999px; background: var(--line);
}
.seg button {
  border: 0; background: transparent; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; color: var(--ink-2);
}
.seg button.on { background: var(--card-solid); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08); }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--card-solid); color: var(--ink-2);
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
}
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.chip.off { opacity: .45; }

.btn {
  height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card-solid); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: transparent; }
.btn.primary:hover { opacity: .9; }
.btn.accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn.accent:hover { opacity: .9; }

.search {
  display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card-solid);
  min-width: 200px; color: var(--muted);
}
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.search:focus-within { border-color: var(--muted); }

.avs { display: inline-flex; align-items: center; }
.av {
  width: 24px; height: 24px; border-radius: 50%; margin-left: -6px;
  background: hsl(var(--hue, 30) 28% 52%); color: #fff;
  border: 2px solid var(--card-solid);
  font-style: normal; font-size: 9px; font-weight: 600;
  display: inline-grid; place-items: center;
}
.avs .av:first-child { margin-left: 0; }
.av.lg { width: 52px; height: 52px; font-size: 16px; border: 0; margin: 0; }
.av.xl { width: 72px; height: 72px; font-size: 22px; border: 0; margin: 0; }

/* ---------- Tones (stage colours) ---------- */
.tone-yellow { background: var(--yellow); color: #161818; }
.tone-green { background: var(--green); color: #f2f2ed; }
.tone-red { background: var(--red); color: #fff; }
.tone-dark { background: var(--dark); color: #f2f2ed; }
.tone-light { background: var(--card-solid); color: var(--ink); border: 1px solid var(--line); }
.tone-muted { background: var(--line); color: var(--ink-2); }
.sw { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Deal tiles (overview + customer history) ---------- */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile {
  border-radius: 18px; padding: 12px 13px 13px; min-height: 150px;
  display: flex; flex-direction: column; gap: 4px; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}
.tile:hover { transform: translateY(-2px); box-shadow: 0 12px 24px -14px rgba(0, 0, 0, .45); }
.tile-top { display: flex; align-items: center; justify-content: space-between; font-size: 11px; opacity: .85; }
.tile h4 { font-size: 14px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.tile .who { font-size: 11px; opacity: .7; }
.tile-val { font-size: 19px; font-weight: 600; margin-top: auto; letter-spacing: -0.01em; }
.tile-foot { display: flex; align-items: center; justify-content: space-between; font-size: 11px; opacity: .9; }
.tile .ib { border: 0; background: transparent; color: inherit; width: 22px; height: 22px; }

/* ---------- Mix bar & lists ---------- */
.mixbar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; gap: 3px; margin: 14px 0 10px; }
.mixbar span { display: block; border-radius: 6px; }
.mixlist { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.mixlist li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.mixlist b { margin-left: auto; font-weight: 600; }
.mixlist small { width: 40px; text-align: right; color: var(--muted); }

.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin: 8px 0 2px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw.dash { width: 14px; height: 0; border-radius: 0; border-top: 2px dashed var(--ink-2); }

.progress { height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; margin: 10px 0 6px; }
.progress span { display: block; height: 100%; background: var(--ink); border-radius: 6px; }

/* ---------- Donut ---------- */
.donut { position: relative; margin: 6px auto 0; }
.donut svg { width: 100%; height: 100%; transform: none; }
.donut circle { transition: stroke-dasharray .4s ease; }
.donut-c {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
}
.donut-c b { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.donut-c small { font-size: 11px; opacity: .7; }

/* ---------- Kanban ---------- */
.board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr);
  gap: 10px; overflow-x: auto; padding-bottom: 6px;
}
.col {
  background: var(--card); border: 1px solid var(--line); border-radius: 20px;
  padding: 10px; min-height: 320px; transition: outline-color .15s;
  outline: 2px dashed transparent; outline-offset: -2px;
}
.col.drop-over { outline-color: var(--muted); }
.col-h { display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; font-size: 13px; }
.col-h .count { color: var(--muted); font-size: 12px; }
.col-h em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 12px; }
.kcard {
  border-radius: 16px; padding: 12px; margin-bottom: 8px; cursor: grab;
  display: flex; flex-direction: column; gap: 4px;
}
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .5; }
.kc-top { display: flex; justify-content: space-between; font-size: 11px; opacity: .85; }
.kcard h4 { font-size: 13px; font-weight: 600; line-height: 1.25; }
.kcard p { font-size: 11px; opacity: .75; }
.kc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: 14px; }
.kc-foot b { font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 520px; }
.tbl th {
  text-align: left; color: var(--muted); font-weight: 500; font-size: 12px;
  padding: 8px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl small { display: block; color: var(--muted); font-size: 11px; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: rgba(127, 127, 127, 0.07); }
.tbl .r { text-align: right; }

/* ---------- Customers ---------- */
.cust-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.cust { cursor: pointer; transition: transform .15s ease; }
.cust:hover { transform: translateY(-2px); }
.cust-top { display: flex; align-items: center; justify-content: space-between; }
.cust h3 { font-size: 16px; font-weight: 600; margin-top: 14px; }
.cust-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cust-metrics small, .metric small { display: block; color: var(--muted); font-size: 11px; }
.cust-metrics b, .metric b { font-size: 13px; font-weight: 600; }
.metric { display: flex; flex-direction: column; gap: 2px; }
.kpis.two { grid-template-columns: repeat(3, 1fr); }
.profile { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.profile h3 { font-size: 18px; font-weight: 600; }
.facts-list { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 0; font-size: 13px; }
.facts-list dt { color: var(--muted); }
.facts-list dd { margin: 0; text-align: right; }

/* ---------- Tasks ---------- */
.task {
  display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.task:last-child { border-bottom: 0; }
.task input { width: 16px; height: 16px; accent-color: var(--ink); margin: 0; }
.task span { display: flex; flex-direction: column; }
.task b { font-weight: 500; }
.task small { color: var(--muted); font-size: 12px; }
.task.done b { text-decoration: line-through; color: var(--muted); }

/* ---------- Charts ---------- */
.chart { position: relative; margin-top: 6px; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 10px; fill: var(--muted); font-family: var(--font); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .target { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 4 4; }
.chart .series { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series.dashed { stroke-dasharray: 5 5; stroke-width: 1.8; }
.chart .hover { stroke: var(--ink-2); stroke-width: 1; stroke-dasharray: 3 3; display: none; }
.chart .hdot { display: none; stroke: var(--card-solid); stroke-width: 2; }
.chart .tip {
  position: absolute; top: 0; display: none; transform: translate(-50%, -8px);
  background: var(--ink); color: var(--bg); font-size: 12px; line-height: 1.5;
  padding: 7px 10px; border-radius: 10px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 8px 20px -10px rgba(0, 0, 0, .5); z-index: 2;
}
.chart .tip b { font-weight: 600; display: block; font-size: 11px; opacity: .7; }
.chart .tip i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; }
.chart.active .tip, .chart.active .hover, .chart.active .hdot { display: block; }
.chart.active .hdot { display: inline; }

/* Aging bars */
.aging { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; align-items: end; height: 110px; margin-top: 12px; }
.aging-col { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 6px; }
.aging-col span { display: block; border-radius: 10px; background: var(--ink); opacity: .85; min-height: 4px; }
.aging-col span.bad { background: var(--red); }
.aging-col span.zero { background: var(--line); }
.aging-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 6px; font-size: 13px; }
.aging-list li { display: flex; justify-content: space-between; }
.aging-list small { font-size: 11px; color: var(--muted); }

/* ---------- Modal ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20, 20, 18, 0.35); backdrop-filter: blur(4px);
  display: grid; place-items: center; padding: 16px;
  animation: fade .2s ease;
}
.sheet {
  width: min(460px, 100%); max-height: 90vh; overflow: auto;
  background: var(--card-solid); border: 1px solid var(--line);
  border-radius: 26px; padding: 20px; box-shadow: 0 30px 60px -20px rgba(0, 0, 0, .4);
  animation: rise .25s ease;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sheet h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin-top: 4px; }
.sheet-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.sheet-actions .btn { flex: 1; justify-content: center; }
.money-lg { font-size: 30px; font-weight: 600; letter-spacing: -0.02em; margin-top: 6px; }

.stages { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-top: 16px; }
.stg { border: 0; background: transparent; padding: 0; display: flex; flex-direction: column; gap: 6px; text-align: left; }
.stg span { height: 5px; border-radius: 5px; background: var(--line); display: block; }
.stg.on span { background: var(--ink); }
.stg small { font-size: 10px; color: var(--muted); }
.stg.on small { color: var(--ink); font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.facts div { background: var(--line); border-radius: 14px; padding: 10px; }
.facts span { display: block; font-size: 11px; color: var(--muted); }
.facts b { font-size: 13px; font-weight: 600; }
.note { margin-top: 14px; padding: 12px; border-radius: 14px; border: 1px solid var(--line); font-size: 13px; color: var(--ink-2); display: flex; gap: 8px; }

/* Invoice document */
.doc {
  position: relative; margin-top: 12px; padding: 18px; border-radius: 18px;
  background: var(--card); border: 1px solid var(--line);
}
.doc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.doc-top .brand { font-size: 14px; }
.doc-no { text-align: right; }
.doc-no small, .doc-cols small { display: block; font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.doc-no b { font-size: 15px; font-weight: 600; }
.doc-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; font-size: 12px; }
.doc-cols b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.doc-cols p { color: var(--ink-2); line-height: 1.5; }
.doc-meta { display: flex; gap: 14px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.doc-meta b { display: block; color: var(--ink); font-size: 12px; font-weight: 500; }
.doc table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 12px; }
.doc th { text-align: left; font-weight: 500; color: var(--muted); padding: 6px 0; border-bottom: 1px solid var(--line); }
.doc td { padding: 9px 0; border-bottom: 1px solid var(--line); }
.doc td small { display: block; color: var(--muted); }
.doc .r { text-align: right; }
.totals { margin-top: 10px; margin-left: auto; width: 60%; font-size: 12px; }
.totals div { display: flex; justify-content: space-between; padding: 3px 0; color: var(--ink-2); }
.totals .grand { font-size: 14px; font-weight: 600; color: var(--ink); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 8px; }
.stamp {
  position: absolute; left: 22px; bottom: 26px; transform: rotate(-10deg);
  border: 3px solid var(--green); color: var(--green); border-radius: 10px;
  padding: 4px 12px; font-size: 22px; font-weight: 800; letter-spacing: .12em; opacity: .85;
  animation: stamp .35s ease;
}
:root[data-theme="dark"] .stamp { color: #7fbf94; border-color: #7fbf94; }

/* ---------- Toast ---------- */
.toast-root {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100% - 32px);
}
.toast {
  display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: var(--bg); border-radius: 999px;
  padding: 8px 8px 8px 16px; font-size: 13px; box-shadow: 0 14px 30px -12px rgba(0, 0, 0, .5);
  animation: rise .25s ease;
}
.toast button {
  border: 0; background: var(--accent); color: #fff; border-radius: 999px;
  padding: 6px 12px; font-weight: 600; font-size: 12px;
}

/* ---------- Animations ---------- */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes stamp { from { transform: rotate(-10deg) scale(1.4); opacity: 0; } to { transform: rotate(-10deg) scale(1); opacity: .85; } }
@keyframes page-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* Stat/KPI cards and project tiles rise into place one after another on every page load,
   the way dashboard cards do in a polished product demo — pure CSS, no animation library. */
.kpis .kpi, .proj-grid .proj-tile, .cust-grid .p-card {
  animation: page-in .5s cubic-bezier(.22,1,.36,1) both;
}
.kpis .kpi:nth-child(1), .proj-grid .proj-tile:nth-child(1), .cust-grid .p-card:nth-child(1) { animation-delay: .04s; }
.kpis .kpi:nth-child(2), .proj-grid .proj-tile:nth-child(2), .cust-grid .p-card:nth-child(2) { animation-delay: .09s; }
.kpis .kpi:nth-child(3), .proj-grid .proj-tile:nth-child(3), .cust-grid .p-card:nth-child(3) { animation-delay: .14s; }
.kpis .kpi:nth-child(4), .proj-grid .proj-tile:nth-child(4), .cust-grid .p-card:nth-child(4) { animation-delay: .19s; }
.proj-grid .proj-tile:nth-child(5), .cust-grid .p-card:nth-child(5) { animation-delay: .24s; }
.proj-grid .proj-tile:nth-child(6), .cust-grid .p-card:nth-child(6) { animation-delay: .29s; }
.proj-grid .proj-tile:nth-child(n+7), .cust-grid .p-card:nth-child(n+7) { animation-delay: .34s; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; gap: 10px; }
  .brand span:last-child { display: none; }
  .page { padding: 4px 16px 130px 60px; }
  .dock { left: 6px; padding: 10px 6px; gap: 9px; }
  .dock-btn { width: 28px; height: 28px; }
  .h-title { font-size: 28px; }
  .kpis, .kpis.two { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .search { min-width: 0; flex: 1; }
  .facts { grid-template-columns: 1fr 1fr; }
  .aging { height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* A company name on a person after that company was deleted from the company list */
.co-gone { opacity: .45; text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }


/* ---- side dock: one Add menu ---- */
.dock-add { position: relative; }
.dock-pop[hidden] { display: none; }
.dock-pop { position: absolute; left: 44px; top: -6px; min-width: 180px; padding: 6px; border-radius: 14px; background: var(--card-solid); border: 1px solid var(--line); box-shadow: 0 18px 40px -16px rgba(0,0,0,.35); z-index: 40; display: grid; gap: 2px; }
.dock-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13px; border-radius: 10px; cursor: pointer; text-align: left; }
.dock-pop button:hover { background: var(--line); }
.dock-pop svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }
/* ---- list pages: the View panel ---- */
.view-panel { margin: 10px 0; }
.btn.on { border-color: var(--accent, #19717F); color: var(--accent, #19717F); }
/* ---- windows opened on top of another: the back arrow ---- */
.sheet { position: relative; }
.modal-back { position: absolute; top: 16px; left: 16px; }
.sheet.has-back .sheet-head { padding-left: 40px; }
/* ---- top bar: next prayer ---- */
.prayer-pill { width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
@media (max-width: 640px) {
  .prayer-pill { display: none; }
  .view-panel .filters { display: none; }   /* the filter builder is a desktop tool */
  .toolbar .qf-select { max-width: 46%; }
}

/* ---- Select mode: tick any kind of card, act on all of them from the bar ---- */
.ms-on .ms-card { position: relative; cursor: pointer; }
.ms-on .ms-card > .ms-box { position: absolute; top: 10px; left: 10px; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--ink-2); background: var(--card-solid); z-index: 5; pointer-events: none; }
.ms-on .ms-card.ms-selected { outline: 2px solid var(--accent, #19717F); outline-offset: 2px; }
.ms-on .ms-card.ms-selected > .ms-box { background: var(--accent, #19717F); border-color: var(--accent, #19717F); }
.ms-on .ms-card.ms-selected > .ms-box::after { content: ""; position: absolute; left: 6px; top: 2px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.ms-bar { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 32px); padding: 10px 14px; border-radius: 16px; background: var(--card-solid); border: 1px solid var(--line); box-shadow: 0 24px 50px -18px rgba(0,0,0,.45); z-index: 60; }
.ms-bar b { font-size: 13px; margin-right: 4px; }
.ms-sep { width: 1px; height: 22px; background: var(--line); }
@media (max-width: 640px) { .ms-bar { bottom: 8px; padding: 8px 10px; } }
