﻿:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #14181d;
  --muted: #667085;
  --line: #e3e7ec;
  --field: #f8fafc;
  --brand: #0f766e;
  --brand-ink: #ffffff;
  --brand-soft: #e6f4f2;
  --ok: #15803d;   --ok-soft: #e7f6ec;
  --warn: #b45309; --warn-soft: #fdf3e3;
  --bad: #c62828;  --bad-soft: #fdecec;
  --ad: #6d28d9;   --ad-soft: #efe9fd;
  --clinic: #0f766e; --clinic-soft: #e2f3f0;
  --ref: #b45309;  --ref-soft: #fcf0de;
  --booked: #475467; --booked-soft: #eef1f5;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --on-color: #ffffff;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --card: #181c22; --text: #e8ecf1; --muted: #98a2b3; --line: #2a3039; --field: #11151a;
    --brand: #2dd4bf; --brand-ink: #062a26; --brand-soft: #123532;
    --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #33270c; --bad: #f87171; --bad-soft: #3a1717;
    --ad: #b79cff; --ad-soft: #2a2145; --clinic: #5eead4; --clinic-soft: #123532; --ref: #fbbf24; --ref-soft: #33270c;
    --booked: #c3cad5; --booked-soft: #262c35; --shadow: none; --on-color: #14181d;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --card: #181c22; --text: #e8ecf1; --muted: #98a2b3; --line: #2a3039; --field: #11151a;
  --brand: #2dd4bf; --brand-ink: #062a26; --brand-soft: #123532;
  --ok: #4ade80; --ok-soft: #12301d; --warn: #fbbf24; --warn-soft: #33270c; --bad: #f87171; --bad-soft: #3a1717;
  --ad: #b79cff; --ad-soft: #2a2145; --clinic: #5eead4; --clinic-soft: #123532; --ref: #fbbf24; --ref-soft: #33270c;
  --booked: #c3cad5; --booked-soft: #262c35; --shadow: none; --on-color: #14181d;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
a { color: inherit; }
.muted { color: var(--muted); font-weight: 400; }
.small { font-size: .875rem; margin: 2px 0 8px; }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px 96px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}

/* ---------- top bar ---------- */
.demo-bar { background: var(--warn-soft); color: var(--warn); text-align: center; font-size: .85rem; padding: 6px 16px; }
.top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.logo {
  display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 28px; line-height: 1;
}
.logo.sm { width: 28px; height: 28px; border-radius: 8px; font-size: 18px; flex: none; }
.tag { font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); }
.tag-admin { background: var(--ad-soft); color: var(--ad); }
.top-right { display: flex; align-items: center; gap: 12px; flex: none; }
.sync { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.sync.busy { color: var(--warn); }
.sync.bad { color: var(--bad); }
.link { background: none; border: 0; padding: 4px 0; color: var(--brand); font-weight: 600; font-size: .9rem; }

.tabs { max-width: 760px; margin: 12px auto 0; padding: 0 16px; display: flex; gap: 6px; }
.tabs button {
  flex: 1; padding: 10px; border: 1px solid var(--line); background: var(--card); border-radius: 10px;
  font-weight: 600; color: var(--muted);
}
.tabs button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- date bar ---------- */
.datebar { display: flex; align-items: center; gap: 8px; margin: 4px 0 8px; }
.icon-btn {
  flex: none; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); font-size: 26px; line-height: 1; color: var(--text);
}
.icon-btn.sm { width: 40px; height: 40px; font-size: 18px; color: var(--muted); }
.icon-btn:hover { border-color: var(--muted); }
.date-pick {
  position: relative; flex: 1; height: 48px; display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-weight: 700; font-size: 1.1rem; cursor: pointer;
}
.date-rel { font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 99px; background: var(--brand); color: var(--brand-ink); }
.date-pick input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.quick { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.chip {
  padding: 6px 14px; border-radius: 99px; border: 1px solid var(--line); background: var(--card);
  font-size: .9rem; font-weight: 600; color: var(--muted);
}
.chip.active { background: var(--brand-soft); color: var(--brand); border-color: transparent; }

/* ---------- capacity ---------- */
.cap { --c: var(--ok); --cs: var(--ok-soft); border-left: 6px solid var(--c); }
.cap.low { --c: var(--warn); --cs: var(--warn-soft); }
.cap.full { --c: var(--bad); --cs: var(--bad-soft); }
.cap.loading { --c: var(--line); }
.cap-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; }
.cap-main { display: flex; align-items: baseline; gap: 10px; }
.cap-num { font-size: 3.4rem; font-weight: 800; line-height: 1; color: var(--c); font-variant-numeric: tabular-nums; }
.cap.loading .cap-num { color: var(--muted); }
.cap-txt { font-size: 1.15rem; font-weight: 700; }
.over { font-size: .8rem; background: var(--bad); color: var(--on-color); padding: 2px 8px; border-radius: 99px; margin-left: 4px; vertical-align: middle; }
.cap-side { text-align: right; }
.cap-booked { color: var(--muted); white-space: nowrap; }
.cap-booked b { color: var(--text); font-size: 1.1rem; }
.bar { height: 10px; border-radius: 99px; background: var(--cs); margin: 14px 0 10px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--c); border-radius: inherit; transition: width .3s; }
.cap-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .9rem; color: var(--muted); }
.cap-stats b { color: var(--text); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-ad { background: var(--ad); } .dot-came { background: var(--ok); } .dot-noshow { background: var(--bad); } .dot-all { background: var(--line); }
.limit-edit { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: grid; gap: 8px; }
.limit-edit label { font-weight: 600; font-size: .9rem; }
.limit-edit input { width: 120px; }
.limit-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- form ---------- */
.add.is-editing { outline: 2px solid var(--brand); outline-offset: -1px; }
.form-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.fields { display: grid; gap: 10px; }
@media (min-width: 640px) { .fields { grid-template-columns: 1.2fr 1fr 1.2fr; } }
input[type="text"], input:not([type]), input[type="tel"], input[type="number"], input[type="password"], input[type="date"] {
  width: 100%; height: 50px; padding: 0 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--field); font-size: 16px; outline: none;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--card); }
.edit-date { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.edit-date label { color: var(--muted); font-size: .9rem; }
.edit-date input { max-width: 220px; }
.src-row { display: flex; align-items: center; gap: 12px; margin: 12px 0; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; }
.seg-btn { border: 0; background: none; padding: 8px 16px; border-radius: 8px; font-weight: 600; color: var(--muted); font-size: .95rem; }
.seg-btn.active.src-ad { background: var(--ad); color: var(--on-color); }
.seg-btn.active.src-clinic { background: var(--clinic); color: var(--brand-ink); }
.seg-btn.active.src-referral { background: var(--ref); color: var(--on-color); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font-weight: 700; font-size: .95rem;
}
.btn.big { height: 52px; font-size: 1.05rem; flex: 1; min-width: 180px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.primary:disabled { opacity: .6; }
.btn.primary.warn { background: var(--warn); color: var(--on-color); }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--text); }
.btn.danger { background: var(--card); border-color: var(--bad-soft); color: var(--bad); }

/* ---------- list ---------- */
.list-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.rows .row:first-child { border-top: 0; }
.row.pending { opacity: .55; }
.row.editing { background: var(--brand-soft); margin: 0 -16px; padding: 12px 16px; }
.num { flex: none; width: 24px; text-align: right; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.who { flex: 1; min-width: 0; }
.name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.meta { color: var(--muted); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta a { text-decoration: none; color: var(--text); font-variant-numeric: tabular-nums; }
.meta a:hover { text-decoration: underline; }
.badge { font-size: .7rem; font-weight: 700; padding: 1px 7px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; }
.src-ad.badge { background: var(--ad-soft); color: var(--ad); }
.src-clinic.badge { background: var(--clinic-soft); color: var(--clinic); }
.src-referral.badge { background: var(--ref-soft); color: var(--ref); }
.status {
  flex: none; min-width: 84px; height: 36px; padding: 0 12px; border-radius: 99px; border: 1px solid transparent;
  font-weight: 700; font-size: .85rem; user-select: none; display: inline-grid; place-items: center;
}
.status.static { height: 28px; min-width: 0; font-size: .78rem; }
.st-booked { background: var(--booked-soft); color: var(--booked); }
.st-came { background: var(--ok-soft); color: var(--ok); }
.st-noshow { background: var(--bad-soft); color: var(--bad); }
button.status:hover { border-color: currentColor; }
.icon-spacer { flex: none; width: 40px; }
.empty { color: var(--muted); text-align: center; margin: 12px 0; }
.rows.compact .row { padding: 10px 0; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 12px; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { margin: 0; }
.kpi-v { font-size: 2rem; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-l { font-weight: 600; font-size: .9rem; }
.kpi-s { color: var(--muted); font-size: .78rem; }
.kpis .kpi:first-child .kpi-v { color: var(--ad); }
.tbl { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.tbl th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px 4px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.days { display: grid; gap: 8px; margin-top: 10px; }
.day-row { display: grid; grid-template-columns: 96px 1fr auto; align-items: center; gap: 10px; font-size: .9rem; }
.day-date { color: var(--muted); white-space: nowrap; }
.day-bar { height: 14px; }
.seg-all { display: block; height: 100%; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 4px; }
.seg-ad { display: block; height: 100%; background: var(--ad); }
.day-num { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-num b { color: var(--ad); }
.legend { font-size: .8rem; color: var(--muted); margin: 10px 0 0; }
.legend .dot { margin-left: 10px; }
.legend .dot:first-child { margin-left: 0; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; text-align: center; display: grid; gap: 12px; padding: 28px 22px; }
.login-card .logo { margin: 0 auto 4px; }
.login-card p { margin: 0; }
.form-err { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.demo-note { font-size: .8rem; color: var(--muted); background: var(--warn-soft); padding: 8px; border-radius: 8px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 600;
  max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0, 0, 0, .18); transition: all .2s; z-index: 20;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); color: var(--on-color); }

@media (max-width: 420px) {
  .cap-num { font-size: 2.8rem; }
  .status { min-width: 74px; padding: 0 8px; }
  .sync { display: none; }
}
