/* =========================================================
   Samira Infinity — Clinic Manager (demo)
   Simple, calm design. Arial. Black & gold. Light + dark.
   ========================================================= */
:root {
  --font-ui: Arial, Helvetica, sans-serif;
  --radius: 12px;
}

:root,
[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f5f3;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f6f3;
  --surface-3: #e9e9e4;
  --border: #e3e3dd;
  --border-strong: #cfcfc7;
  --text: #1a1a1a;
  --text-2: #444440;
  --muted: #6c6c66;
  --gold: #d4a91c;
  --gold-text: #8a6800;
  --gold-soft: #fbf3d6;
  --gold-line: #e6cf7a;
  --bar-exp: #c9c9c0;
  --ok: #1f7a46;
  --ok-soft: #e1f3e8;
  --warn: #9a5f00;
  --warn-soft: #fdeccb;
  --bad: #b42d20;
  --bad-soft: #fbe4e1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .05);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101010;
  --bg-elev: #1b1b1b;
  --surface: #1a1a1a;
  --surface-2: #222222;
  --surface-3: #2e2e2e;
  --border: #2d2d2d;
  --border-strong: #404040;
  --text: #f3f3f0;
  --text-2: #d0d0ca;
  --muted: #9a9a93;
  --gold: #e3b72b;
  --gold-text: #efc94c;
  --gold-soft: #2c2610;
  --gold-line: #6b5a1c;
  --bar-exp: #55554e;
  --ok: #54c48a;
  --ok-soft: #153324;
  --warn: #ecaa48;
  --warn-soft: #382a10;
  --bad: #f2776a;
  --bad-soft: #3b1b17;
  --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.modal-open { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold-text); }
h1, h2, h3, h4 { font-family: var(--font-ui); }
.muted { color: var(--muted); }
.sm { font-size: 13px; }
.ic { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.gold-t { color: var(--gold-text); }
.hide { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh;
  background: #141414; color: #d9d9d4;
  display: flex; flex-direction: column; padding: 24px 14px 18px;
}
.brand { padding: 4px 10px 26px; }
.brand-name { font-size: 22px; font-weight: 700; color: #fff; white-space: nowrap; line-height: 1.1; }
.brand-name span { color: #e3b72b; }
.brand-sub { font-size: 12px; color: #9a9a93; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 12px; color: #77776f; padding: 6px 12px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; white-space: nowrap;
  color: #d9d9d4; text-decoration: none; font-weight: 700; font-size: 15px; cursor: pointer;
}
.nav a:hover { background: #222; color: #fff; }
.nav a.on { background: #e3b72b; color: #141414; }
.nav a .count { margin-left: auto; font-size: 12px; background: rgba(255,255,255,.14); color: #fff; padding: 1px 9px; border-radius: 99px; }
.nav a.on .count { background: rgba(0,0,0,.15); color: #141414; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px; }
.demo-tag { font-size: 12px; color: #a3a39c; background: #1f1f1f; border-radius: 10px; padding: 10px 12px; line-height: 1.45; }
.demo-tag b { color: #e3b72b; display: block; margin-bottom: 2px; }
.link-btn { background: none; border: 0; color: #a3a39c; padding: 6px 4px; display: flex; gap: 8px; align-items: center; font-size: 14px; }
.link-btn:hover { color: #e3b72b; }

.main { min-width: 0; padding: 28px 32px 56px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.topbar h1 { font-size: 28px; font-weight: 700; margin: 0; line-height: 1.15; }
.topbar .sub { color: var(--muted); margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mobile-brand { display: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border-strong); background: var(--surface);
  padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: #141414; }
.btn-gold:hover { background: var(--gold); filter: brightness(.94); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 7px 12px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; display: inline-grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 8px; }
.user-chip {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--border-strong); background: var(--surface);
  border-radius: 10px; padding: 4px 12px 4px 4px; text-align: left;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip b { display: block; font-size: 14px; line-height: 1.2; }
.user-chip small { color: var(--muted); font-size: 12px; }
.avatar { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; flex: none; background: #141414; color: #e3b72b; font-weight: 700; font-size: 12px; }

/* ---------- Cards / KPIs ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h3 { margin: 0; font-size: 17px; display: flex; align-items: center; gap: 8px; font-weight: 700; }
.card-h h3 .ic { color: var(--gold-text); }
.card-p { margin: -6px 0 14px; color: var(--muted); font-size: 14px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi-l { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 700; }
.kpi-l .ic { width: 17px; height: 17px; color: var(--gold-text); }
.kpi-v { font-size: 34px; font-weight: 700; line-height: 1.15; margin-top: 8px; }
.kpi-v small { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.kpi-s { color: var(--text-2); font-size: 14px; margin-top: 6px; }
.kpi-s b { color: var(--text); }
.kpi.feature { background: var(--gold-soft); border-color: var(--gold-line); }
.kpi.feature .kpi-l .ic { color: var(--gold-text); }
.delta { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-right: 4px; white-space: nowrap; }
.delta.up { background: var(--ok-soft); color: var(--ok); }
.delta.down { background: var(--bad-soft); color: var(--bad); }
.delta.up.inv { background: var(--bad-soft); color: var(--bad); }
.delta.down.inv { background: var(--ok-soft); color: var(--ok); }

.split { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.mt { margin-top: 18px; }

/* ---------- Segmented control ---------- */
.seg { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 8px; font-weight: 700; color: var(--text-2); font-size: 14px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
[data-theme="dark"] .seg button.on { background: var(--gold); color: #141414; }

/* ---------- Pills ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; text-transform: capitalize; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-confirmed { background: var(--gold-soft); color: var(--gold-text); }
.p-completed, .p-paid { background: var(--ok-soft); color: var(--ok); }
.p-no-show, .p-overdue { background: var(--bad-soft); color: var(--bad); }
.p-cancelled { background: var(--surface-3); color: var(--muted); }
.p-unpaid { background: var(--warn-soft); color: var(--warn); }
.lv { display: inline-block; font-style: normal; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.lv-quiet { background: var(--ok-soft); color: var(--ok); }
.lv-mod { background: var(--gold-soft); color: var(--gold-text); }
.lv-busy { background: var(--warn-soft); color: var(--warn); }
.lv-vbusy { background: var(--bad-soft); color: var(--bad); }
.lv-closed { background: var(--surface-3); color: var(--muted); }

/* ---------- Calendar head ---------- */
.cal-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.cal-title { font-size: 19px; font-weight: 700; flex: 1; text-align: center; min-width: 170px; }
.cal-nav { display: flex; gap: 6px; align-items: center; }
.cal-tip { margin-top: 12px; font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.cal-tip .ic { width: 15px; height: 15px; color: var(--gold-text); }
.tr-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; font-size: 13px; color: var(--text-2); }
.tr-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tr-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* ---------- Week view ---------- */
.wk-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.wk { min-width: 700px; display: grid; grid-template-columns: 54px repeat(var(--cols), minmax(0, 1fr)); }
.wk-corner { border-bottom: 1px solid var(--border); background: var(--surface-2); }
.wk-h { padding: 8px 4px 9px; text-align: center; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); background: var(--surface-2); cursor: pointer; border-top: 0; border-right: 0; }
.wk-h:hover { background: var(--surface-3); }
.wk-h span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.wk-h b { font-size: 19px; display: block; line-height: 1.25; }
.wk-h.today { background: var(--gold-soft); box-shadow: inset 0 -3px 0 var(--gold); }
.wk-hours div { height: var(--H); font-size: 12px; color: var(--muted); text-align: right; padding-right: 8px; }
.wk-hours div span { position: relative; top: -8px; }
.wk-col {
  position: relative; border-left: 1px solid var(--border); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--H) - 1px), var(--border) calc(var(--H) - 1px), var(--border) var(--H));
}
.wk-col.today { background-color: var(--gold-soft); }
.wk-col.past { background-color: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.wk-appt {
  position: absolute; left: 3px; right: 3px; border: 0; border-left: 4px solid var(--c);
  background: color-mix(in srgb, var(--c) 20%, var(--surface)); border-radius: 6px; padding: 3px 7px;
  text-align: left; overflow: hidden; font-size: 12px; line-height: 1.3; cursor: pointer; color: var(--text);
}
.wk-appt b { display: block; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-appt span { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.wk-appt:hover { outline: 2px solid var(--gold); z-index: 2; }
.wk-appt.st-completed { opacity: .65; }
.wk-appt.st-no-show { opacity: .5; }
.wk-appt.st-no-show b { text-decoration: line-through; }
.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 3; pointer-events: none; }
.now-line::before { content: ''; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }

/* ---------- Day view ---------- */
.day-sum { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; padding: 12px 14px; background: var(--surface-2); border-radius: 10px; }
.day-sum .big { font-size: 26px; font-weight: 700; line-height: 1; }
.day-sum .meter { flex: 1; min-width: 120px; height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.day-sum .meter i { display: block; height: 100%; background: var(--gold); border-radius: 99px; }
.tl { display: flex; flex-direction: column; gap: 8px; }
.tl-row {
  display: grid; grid-template-columns: 60px 5px minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer;
}
.tl-row:hover { border-color: var(--gold); background: var(--surface-2); }
.tl-time { font-weight: 700; font-size: 15px; }
.tl-time small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.tl-bar { align-self: stretch; border-radius: 4px; background: var(--c); min-height: 34px; }
.tl-main { min-width: 0; }
.tl-main b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-main span { color: var(--muted); font-size: 14px; }
.tl-meta { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.phone-link { color: var(--text-2); text-decoration: none; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; }
.phone-link .ic { width: 15px; height: 15px; color: var(--gold-text); }
.phone-link:hover { color: var(--gold-text); text-decoration: underline; }
.tl-row.gap { background: transparent; border-style: dashed; cursor: default; }
.tl-row.gap:hover { background: transparent; border-color: var(--border); }
.tl-row.gap .tl-bar { background: transparent; }
.tl-row.gap .tl-main { color: var(--muted); }
.tl-row.st-cancelled { opacity: .5; }
.tl-row.st-cancelled b { text-decoration: line-through; }
.tl-sep { font-size: 13px; color: var(--muted); font-weight: 700; margin: 12px 2px 2px; }

.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .ic { width: 36px; height: 36px; color: var(--gold-text); margin-bottom: 8px; }
.empty h4 { margin: 0 0 4px; font-size: 17px; color: var(--text); }

/* ---------- Month view ---------- */
.mo { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)) 84px; gap: 6px; }
.mo-wd { font-size: 13px; color: var(--muted); font-weight: 700; text-align: center; padding: 2px 0 4px; }
.mc {
  min-height: 74px; border: 1px solid var(--border); border-radius: 10px;
  background: color-mix(in srgb, var(--gold) calc(var(--l, 0) * 55%), var(--surface));
  padding: 7px 9px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; color: var(--text);
}
.mc:hover { border-color: var(--text); }
.mc-d { font-size: 13px; font-weight: 700; color: var(--text-2); }
.mc-n { font-size: 24px; font-weight: 700; line-height: 1; }
.mc small { font-size: 11px; color: var(--text-2); }
.mc.out { opacity: .35; }
.mc.closed { background: var(--surface-2); cursor: default; }
.mc.closed:hover { border-color: var(--border); }
.mc.closed small { color: var(--muted); }
.mc.today { outline: 2px solid var(--text); outline-offset: -1px; }
.mo-wk { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; border-radius: 10px; background: var(--surface-2); font-size: 12px; padding: 4px; text-align: center; }
.mo-wk b { font-size: 20px; line-height: 1; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 14px; flex-wrap: wrap; }
.legend i { width: 22px; height: 12px; border-radius: 4px; display: inline-block; border: 1px solid var(--border); }

/* ---------- Slots / suggestions ---------- */
.slots { display: grid; gap: 8px; }
.slots.cols { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.slot {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "d t" "l t"; column-gap: 8px; align-items: center;
  text-align: left; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 10px 12px;
}
.slot:hover, .slot.sel { border-color: var(--gold); background: var(--gold-soft); }
.slot.best { border-color: var(--gold); border-width: 2px; padding: 9px 11px; }
.slot-d { grid-area: d; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot-t { grid-area: t; font-size: 20px; font-weight: 700; }
.slot-l { grid-area: l; justify-self: start; margin-top: 3px; }
.select-inline { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 10px; width: 100%; margin-bottom: 12px; }

.wkbars { display: flex; flex-direction: column; gap: 6px; }
.wb-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.wb-top b { font-weight: 700; }
.wb-top span { color: var(--muted); }
.wb-track { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.wb-fill { height: 100%; border-radius: 99px; background: var(--gold); }
.wb-fill.busy { background: #e09a1f; }
.wb-fill.vbusy { background: #d8503f; }
.wb-row { cursor: pointer; border-radius: 8px; padding: 8px; }
.wb-row:hover { background: var(--surface-2); }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .5); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 16px; width: 100%; max-width: 560px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal.md { max-width: 660px; }
.modal.lg { max-width: 1100px; }
.modal-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 22px 24px 0; }
.modal-h h2 { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.2; }
.modal-h p { margin: 4px 0 0; }
.modal-b { padding: 18px 24px; }
.modal-f { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-f > div { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }

.call-hint { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; background: var(--gold-soft); color: var(--text-2); font-size: 14px; }
.call-hint .ic { color: var(--gold-text); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; color: var(--text); }
.form label .muted { font-weight: 400; }
.form input, .form select, .form textarea, .input {
  border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 10px 12px;
  font-size: 15px; font-weight: 400; outline: none; width: 100%; min-width: 0;
}
.form textarea { resize: vertical; }
.form input:focus, .form select:focus, .form textarea:focus, .input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.form-err { color: var(--bad); font-weight: 700; font-size: 14px; }
.form-err:empty { display: none; }
.client-hint { font-size: 14px; color: var(--ok); font-weight: 700; margin-top: -6px; }
.client-hint:empty { display: none; }
.suggest-box { border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; padding: 12px; }
.sb-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 14px; flex-wrap: wrap; }
.sb-h .ic { color: var(--gold-text); }
.day-note { font-size: 14px; margin-top: -6px; }
.day-note:empty { display: none; }

.dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 18px; margin: 0; }
.dl div dt { font-size: 13px; color: var(--muted); }
.dl div dd { margin: 3px 0 0; font-weight: 700; }
.dl .full { grid-column: 1 / -1; }
.status-row { margin-top: 18px; }
.status-row h4 { margin: 0 0 8px; font-size: 14px; }

/* ---------- Search / table ---------- */
.search { position: relative; }
.search .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.search input { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 10px; padding: 9px 12px 9px 34px; width: 230px; outline: none; }
.search input:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.tbl-tools { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tbl-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 680px; }
.tbl th { text-align: left; font-size: 13px; color: var(--muted); padding: 10px 12px; border-bottom: 2px solid var(--border); font-weight: 700; white-space: nowrap; }
.tbl td { padding: 13px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl tr.click { cursor: pointer; }
.tbl tr.click:hover td { background: var(--surface-2); }
.tbl .num { text-align: right; }
.tbl .mono { font-weight: 700; }
.tbl-foot { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; font-size: 14px; color: var(--muted); gap: 10px; flex-wrap: wrap; }

/* ---------- Charts ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .gl { stroke: var(--border); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 12px; font-family: var(--font-ui); }
.chart .ax.cur { fill: var(--text); font-weight: 700; }
.bar-rev { fill: var(--gold); }
.bar-exp { fill: var(--bar-exp); }
.pline { fill: none; stroke: var(--ok); stroke-width: 2.5; }
.pdot { fill: var(--surface); stroke: var(--ok); stroke-width: 2.5; }
.hz { fill: transparent; cursor: default; }
.hz:hover { fill: var(--surface-2); opacity: .7; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.hb { display: flex; flex-direction: column; gap: 14px; }
.hb-top { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; margin-bottom: 6px; }
.hb-top span:first-child { font-weight: 700; display: flex; align-items: center; gap: 8px; }
.hb-top span:last-child { color: var(--text-2); }
.hb-top em { font-style: normal; color: var(--muted); font-size: 13px; margin-left: 8px; }
.hb-track { height: 10px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.hb-fill { height: 100%; background: var(--gold); border-radius: 99px; }
.hb-fill.alt { background: #8d8d84; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.exp-list { display: flex; flex-direction: column; }
.exp-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.exp-row:last-child { border-bottom: 0; }
.exp-ic { width: 38px; height: 38px; border-radius: 10px; background: var(--surface-2); display: grid; place-items: center; color: var(--gold-text); }
.exp-ic .ic { width: 18px; height: 18px; }
.exp-row b { display: block; font-size: 14px; }
.exp-row span { font-size: 13px; color: var(--muted); }
.exp-row .amt { font-weight: 700; }

/* ---------- Invoice builder ---------- */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
.items-h { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 700; }
.items { display: flex; flex-direction: column; gap: 8px; }
.item-row { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 58px 92px 34px; gap: 6px; align-items: center; }
.item-row input, .item-row select { padding: 8px 9px !important; font-size: 14px !important; }
.item-labels { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.3fr) 58px 92px 34px; gap: 6px; font-size: 12px; color: var(--muted); }
.preview { position: sticky; top: 0; }
.preview-label { font-size: 14px; color: var(--muted); font-weight: 700; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; }
.paper-wrap { background: var(--surface-3); border-radius: 10px; padding: 16px; max-height: 72vh; overflow: auto; }

/* ---------- Invoice document (always white, print ready) ---------- */
.inv-doc {
  background: #fff; color: #1a1a1a; font-family: Arial, Helvetica, sans-serif; padding: 34px 36px; border-radius: 4px;
  font-size: 13px; line-height: 1.5; box-shadow: 0 1px 8px rgba(0,0,0,.12);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.inv-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; padding-bottom: 20px; border-bottom: 3px solid #d4a91c; }
.inv-name { font-size: 26px; font-weight: 700; line-height: 1.1; }
.inv-name span { color: #b08a00; }
.inv-tag { font-size: 12px; color: #6c6c66; margin-top: 4px; }
.inv-title { text-align: right; }
.inv-title h1 { margin: 0; letter-spacing: 3px; font-size: 26px; color: #1a1a1a; line-height: 1; }
.inv-title div { font-weight: 700; margin-top: 6px; }
.inv-status { display: inline-block; margin-top: 6px; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 10px; border-radius: 99px; border: 1.5px solid; }
.s-paid { color: #1f7a46; } .s-unpaid { color: #9a5f00; } .s-overdue { color: #b42d20; }
.inv-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 20px 0; }
.inv-meta h4 { margin: 0 0 3px; font-size: 11px; text-transform: uppercase; color: #77776f; }
.inv-meta h4 + * { margin-bottom: 10px; }
.inv-items { width: 100%; border-collapse: collapse; }
.inv-items th { text-align: left; font-size: 11px; text-transform: uppercase; color: #55554f; background: #f3f1e8; padding: 9px 10px; }
.inv-items td { padding: 11px 10px; border-bottom: 1px solid #e8e8e2; }
.inv-items .r { text-align: right; }
.inv-totals { margin-left: auto; width: 270px; max-width: 100%; margin-top: 14px; }
.inv-totals div { display: flex; justify-content: space-between; padding: 4px 10px; }
.inv-totals .grand { border-top: 2px solid #1a1a1a; margin-top: 6px; padding-top: 10px; font-weight: 700; font-size: 17px; }
.inv-notes { margin-top: 22px; padding: 12px 14px; background: #faf8ee; border-left: 3px solid #d4a91c; border-radius: 4px; }
.inv-notes h4 { margin: 0 0 3px; font-size: 11px; text-transform: uppercase; color: #77776f; }
.inv-foot { margin-top: 30px; padding-top: 14px; border-top: 1px solid #e3e3dd; font-size: 12px; color: #77776f; text-align: center; }

/* ---------- Tooltip / toast ---------- */
.tooltip {
  position: fixed; pointer-events: none; z-index: 80; background: #1a1a1a; color: #fff;
  padding: 8px 11px; border-radius: 8px; font-size: 13px; line-height: 1.5;
  opacity: 0; max-width: 240px; box-shadow: 0 6px 20px rgba(0,0,0,.3);
}
.tooltip.on { opacity: 1; }
.tooltip b { color: #efc94c; }
#toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px); }
.toast { background: #1a1a1a; color: #fff; padding: 12px 16px; border-radius: 10px; display: flex; gap: 10px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.3); font-weight: 700; font-size: 14px; }
.toast .ic { color: #efc94c; }
.toast.out { opacity: 0; transition: opacity .3s; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 560px; text-align: center; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 40px 32px; }
.login h1 { font-size: 38px; font-weight: 700; margin: 0; line-height: 1.1; }
.login h1 span { color: var(--gold-text); }
.login .tag { color: var(--muted); margin-top: 8px; }
.login p { color: var(--text-2); font-size: 17px; font-weight: 700; margin: 28px 0 0; }
.who { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
.who button { background: var(--surface); border: 2px solid var(--border-strong); border-radius: 12px; padding: 22px 18px; color: var(--text); text-align: center; }
.who button:hover { border-color: var(--gold); background: var(--gold-soft); }
.who .avatar { width: 48px; height: 48px; font-size: 16px; margin: 0 auto 12px; border-radius: 50%; }
.who b { display: block; font-size: 18px; }
.who small { color: var(--muted); font-size: 14px; }
.who .go { display: none; }
.login-note { margin-top: 22px; font-size: 13px; color: var(--muted); display: flex; gap: 8px; justify-content: center; align-items: center; }
.login-note .ic { width: 15px; height: 15px; color: var(--gold-text); }

.bottom-nav { display: none; }

/* ---------- Print ---------- */
#print-root { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff !important; }
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; }
  #print-root .inv-doc { box-shadow: none; padding: 0; border-radius: 0; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .split { grid-template-columns: minmax(0, 1fr); }
  .split > .stack { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .preview { position: static; }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .main { padding: 16px 16px 96px; }
  .mobile-brand { display: block; margin-bottom: 14px; font-size: 19px; font-weight: 700; }
  .mobile-brand span { color: var(--gold-text); }
  .topbar h1 { font-size: 24px; }
  .user-chip .uc-text { display: none; }
  .user-chip { padding: 4px; }
  .grid2, .split > .stack { grid-template-columns: minmax(0, 1fr); }
  .row2, .row3 { grid-template-columns: 1fr; }
  #toast-root { bottom: 86px; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: #141414; z-index: 40;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; color: #b5b5ae; font-size: 12px; font-weight: 700; padding: 6px; text-decoration: none; cursor: pointer; border-radius: 10px; }
  .bottom-nav a.on { color: #141414; background: #e3b72b; }
  .mo { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
  .mo-wk, .mo-wkh { display: none !important; }
  .mc { min-height: 50px; padding: 4px 5px; border-radius: 8px; }
  .mc-n { font-size: 18px; }
  .mc small { display: none; }
  .cal-title { order: -1; flex-basis: 100%; text-align: left; }
  .dl { grid-template-columns: 1fr; }
  .search input { width: 100%; }
  .search { flex: 1; min-width: 160px; }
  .item-labels { display: none; }
  .item-row { grid-template-columns: minmax(0, 1fr) 58px 86px 34px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
  .item-row .it-tr { grid-column: 1 / -1; }
  .inv-doc { padding: 22px 18px; }
  .inv-meta { grid-template-columns: 1fr 1fr; }
  .modal-bg { padding: 12px 8px; }
  .modal-h, .modal-b, .modal-f { padding-left: 16px; padding-right: 16px; }
  .tl-row { grid-template-columns: 50px 5px minmax(0, 1fr); }
  .tl-meta { grid-column: 3; justify-content: flex-start; }
  .tl-row.gap .btn { grid-column: 3; justify-self: start; }
}
@media (max-width: 480px) {
  .kpis { gap: 10px; }
  .kpi { padding: 14px; }
  .kpi-v { font-size: 28px; }
  .who { grid-template-columns: 1fr; }
  .login-card { padding: 28px 18px; }
  .login h1 { font-size: 32px; }
  .top-actions .btn .lbl-long { display: none; }
  .inv-top { flex-direction: column; }
  .inv-title { text-align: left; }
}

/* ---------- Finance charts row ---------- */
.charts-row { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 18px; }
.chart svg { max-width: 100%; height: auto; }
.chart .ax { font-size: 13px; }
.donut { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.donut svg { width: 100%; max-width: 190px; max-height: none; }
.donut-n { font-size: 30px; font-weight: 700; fill: var(--text); font-family: var(--font-ui); }
.donut-l { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.donut-l > div { display: flex; gap: 10px; align-items: flex-start; }
.donut-l .dot { margin-top: 5px; }
.donut-l b { display: block; font-size: 14px; }
.donut-l small { color: var(--muted); font-size: 13px; }
@media (max-width: 860px) { .charts-row { grid-template-columns: minmax(0, 1fr); } }
