/* ================= Amitid HQ — design system =================
   Brand: cream / lavender / ink (matches studio-site)
   Mobile-first, RTL native. */

:root {
  --cream:    #F2EAE0;
  --cream-2:  #FBF6EE;
  --lav:      #BDA6CE;
  --lav-soft: #E4DAEC;
  --lav-deep: #8A6BA6;
  --ink:      #292233;
  --ink-2:    #352C43;
  --muted:    #6A5A78;
  --line:     rgba(41, 34, 51, .14);
  --wa:       #1FAF54;

  /* chart series — validated (dataviz) */
  --ser-income:  #7B4FA6;
  --ser-expense: #B5762F;

  /* status colors — reserved, never decorative */
  --good:   #2E7D46;
  --warn:   #A36A00;
  --danger: #C0392B;
  --good-bg:   #DDEEE2;
  --warn-bg:   #F5E7CC;
  --danger-bg: #F6DAD5;

  --font-display: "Secular One", "Arial Hebrew", sans-serif;
  --font-body: "Assistant", "Arial Hebrew", sans-serif;
  --radius: 14px;
  --nav-h: 62px;
  --shadow: 0 1px 2px rgba(41,34,51,.06), 0 6px 20px -8px rgba(41,34,51,.14);
  --ease: cubic-bezier(.22,.9,.3,1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--cream); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.55;
  min-height: 100dvh;
}
h1,h2,h3 { font-family: var(--font-display); font-weight: 400; line-height: 1.2; margin: 0; }
a { color: var(--lav-deep); text-decoration: none; }
button { font: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--lav-deep); outline-offset: 2px;
}
[hidden] { display: none !important; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--cream) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.topbar__logo, .login__logo {
  font-family: var(--font-display); font-size: 22px; color: var(--ink); letter-spacing: .5px;
}
.topbar__logo span, .login__logo span { color: var(--lav-deep); margin-inline-start: 2px; }
.bell { position: relative; display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--ink); }
.bell:hover { background: var(--lav-soft); }
.bell__badge, .nav__badge {
  position: absolute; top: 4px; inset-inline-start: 22px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; line-height: 1;
}

.view { padding: 16px 16px calc(var(--nav-h) + 24px + env(safe-area-inset-bottom)); max-width: 1120px; margin-inline: auto; }
.view:focus { outline: none; }

.nav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--ink); border-top: 1px solid var(--line);
}
.nav a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: #C9BFD6; font-size: 11.5px; font-weight: 600;
}
.nav a svg { width: 21px; height: 21px; }
.nav a.active { color: #fff; }
.nav a.active::before {
  content: ""; position: absolute; top: 0; width: 34px; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--lav);
}
.nav .nav__badge { top: 6px; inset-inline-start: calc(50% + 6px); background: var(--lav-deep); }
.nav .nav__badge--danger { background: var(--danger); }

@media (min-width: 900px) {
  body { font-size: 16.5px; }
  .nav {
    top: 0; bottom: auto; inset-inline-start: 0; inset-inline-end: auto;
    width: 92px; height: 100dvh; grid-template-columns: 1fr; grid-auto-rows: 76px;
    align-content: start; padding-top: 78px; border-top: 0;
  }
  .topbar { padding-inline-start: 108px; }
  .view { padding: 24px 32px 48px; padding-inline-start: calc(92px + 32px); max-width: calc(1120px + 92px); }
}

/* ---------- login ---------- */
.login {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 70% -10%, var(--lav-soft), var(--cream));
  padding: 24px;
}
.login__card {
  width: min(360px, 100%); background: var(--cream-2); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: var(--shadow); padding: 32px 28px;
  display: grid; gap: 14px; text-align: center;
}
.login__logo { font-size: 34px; }
.login__sub { margin: -6px 0 6px; color: var(--muted); }
.login__err { color: var(--danger); font-weight: 600; margin: 0; }

/* ---------- primitives ---------- */
.card {
  background: var(--cream-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px;
  background: #fff; color: var(--ink); font-weight: 700; transition: transform .12s var(--ease), background .12s;
}
.btn:active { transform: scale(.97); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primary:hover { background: var(--ink-2); }
.btn--accent { background: var(--lav-deep); border-color: var(--lav-deep); color: #fff; }
.btn--wa { background: var(--wa); border-color: var(--wa); color: #fff; }
.btn--danger-ghost { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); background: transparent; }
.btn--ghost { background: transparent; }
.btn--full { width: 100%; }
.btn--sm { padding: 7px 12px; border-radius: 10px; font-size: 14px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  background: var(--lav-soft); color: var(--ink);
}
.pill--good   { background: var(--good-bg);   color: var(--good); }
.pill--warn   { background: var(--warn-bg);   color: var(--warn); }
.pill--danger { background: var(--danger-bg); color: var(--danger); }
.pill--ink    { background: var(--ink); color: #fff; }

.page-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 16px; }
.page-title h1 { font-size: 26px; }
.section-title { font-size: 15px; font-weight: 800; color: var(--muted); letter-spacing: .3px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.mono-num { font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { padding: 14px; display: grid; gap: 2px; align-content: start; }
.kpi__num { font-family: var(--font-display); font-size: 30px; line-height: 1.1; }
.kpi__num small { font-size: 16px; color: var(--muted); font-family: var(--font-body); font-weight: 700; }
.kpi__label { color: var(--muted); font-size: 13px; font-weight: 600; }
.kpi--danger .kpi__num { color: var(--danger); }
.kpi--good .kpi__num { color: var(--good); }
.kpi--accent .kpi__num { color: var(--lav-deep); }
a.kpi { color: inherit; }
a.kpi:hover { border-color: var(--lav-deep); }

/* ---------- lists / rows ---------- */
.rows { display: grid; gap: 10px; }
.row-card { display: grid; gap: 8px; }
.row-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row-card__title { font-weight: 800; font-size: 16.5px; }
.row-card__meta { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; color: var(--muted); font-size: 13.5px; }
a.row-card { color: inherit; }
a.row-card:hover { border-color: var(--lav-deep); }

.countdown { font-variant-numeric: tabular-nums; font-weight: 800; }
.countdown--risk { color: var(--danger); }

/* ---------- client card ---------- */
.client-head { display: grid; gap: 8px; margin-bottom: 14px; }
.client-head h1 { font-size: 24px; }
.client-head__row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.quick-actions .btn { font-size: 13.5px; padding: 9px 6px; }

.subtabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin: 14px 0 12px; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
.subtab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.subtab .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-inline-start: 5px; vertical-align: 2px; }

.build-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin-bottom: 12px; }
.build-tab {
  border: 1px solid var(--line); background: var(--cream-2); border-radius: 10px;
  padding: 8px 2px; text-align: center; font-size: 12px; font-weight: 700; color: var(--muted);
  display: grid; gap: 1px; justify-items: center;
}
.build-tab b { font-family: var(--font-display); font-weight: 400; font-size: 17px; color: inherit; }
.build-tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.build-tab.done { border-color: var(--good); color: var(--good); }
.build-tab:disabled { opacity: .5; cursor: default; }

.compare { display: grid; gap: 12px; }
@media (min-width: 860px) { .compare { grid-template-columns: 1fr 1fr; align-items: start; } }
.kv { display: grid; gap: 8px; }
.kv > div { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.kv dt { font-size: 12.5px; font-weight: 800; color: var(--lav-deep); margin: 0; }
.kv dd { margin: 1px 0 0; white-space: pre-wrap; }

.qa-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.qa-list li { display: flex; gap: 8px; align-items: baseline; font-size: 14px; }
.qa-list li::before { content: "✓"; color: var(--good); font-weight: 900; }
.qa-list li b { color: var(--muted); font-weight: 700; }

.timeline { display: grid; gap: 0; margin-top: 6px; }
.timeline__item { position: relative; padding: 0 22px 16px 0; }
.timeline__item::before { content: ""; position: absolute; top: 6px; inset-inline-start: 0; width: 9px; height: 9px; border-radius: 50%; background: var(--lav); }
.timeline__item::after { content: ""; position: absolute; top: 17px; bottom: -2px; inset-inline-start: 4px; width: 1.5px; background: var(--line); }
.timeline__item:last-child::after { display: none; }
.timeline__meta { font-size: 12.5px; color: var(--muted); }

/* health */
.health { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13.5px; }
.health--gold { color: #8a6d00; }
.health--regular { color: var(--muted); }
.health--headache { color: var(--danger); }

/* ---------- forms / modal ---------- */
.modal-back { position: fixed; inset: 0; z-index: 60; background: rgba(41,34,51,.45); display: grid; place-items: end center; }
@media (min-width: 700px) { .modal-back { place-items: center; } }
.modal {
  width: min(560px, 100%); max-height: 88dvh; overflow-y: auto;
  background: var(--cream-2); border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: grid; gap: 12px;
}
@media (min-width: 700px) { .modal { border-radius: 20px; } }
.modal h2 { font-size: 20px; }
.modal label { display: grid; gap: 4px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.modal .modal__row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal__actions { display: flex; gap: 8px; justify-content: flex-start; margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); inset-inline: 16px; z-index: 80;
  margin-inline: auto; width: fit-content; max-width: calc(100% - 32px);
  background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 12px;
  font-weight: 700; box-shadow: var(--shadow); animation: toast-in .25s var(--ease);
}
@media (min-width: 900px) { .toast { bottom: 24px; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- chart ---------- */
.chart-wrap { overflow-x: auto; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; font-weight: 700; color: var(--muted); margin-top: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-inline-start: 6px; vertical-align: -1px; }

/* ---------- tables (finance per-client) ---------- */
.tbl { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.tbl th { text-align: start; color: var(--muted); font-size: 12.5px; font-weight: 800; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 9px 6px; border-bottom: 1px dashed var(--line); }
.tbl tr:last-child td { border-bottom: 0; }

/* photo gallery (intake photos) */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.photo-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); display: block;
}
.photo-grid a:hover img { border-color: var(--lav-deep); }

/* misc */
.grid-2 { display: grid; gap: 12px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; } }
.stack { display: grid; gap: 10px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.checkline { display: flex; align-items: center; gap: 10px; }
.checkline input { width: auto; }
details.fold { border: 1px solid var(--line); border-radius: var(--radius); background: var(--cream-2); padding: 0 14px; }
details.fold summary { padding: 12px 0; font-weight: 800; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; }
details.fold summary::after { content: "+"; font-size: 20px; color: var(--muted); }
details.fold[open] summary::after { content: "−"; }
details.fold > .fold__body { padding: 0 0 14px; }
