:root {
  --teal: #0f766e; --teal-2: #14b8a6; --teal-bg: #e6f6f4;
  --ink: #12202b; --muted: #64748b; --line: #e5ebef; --bg: #f3f6f8; --card: #fff;
  --red: #dc2626; --red-bg: #fdecec; --blue: #2563eb; --blue-bg: #e8effd;
  --amber: #b45309; --amber-bg: #fdf3e2; --green: #15803d; --green-bg: #e7f6ec;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.55 "Segoe UI", Tahoma, "Noto Sans Arabic", "Geeza Pro", system-ui, sans-serif;
}
a { color: var(--teal); text-decoration: none; }
h1 { font-size: 1.4rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; display: flex; justify-content: space-between; align-items: center; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.num { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.big { font-size: 1.2rem; font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }

/* layout: bottom tab bar on phones, sidebar on wide screens */
main { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top .clinic { font-weight: 600; color: var(--teal); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top a { color: var(--muted); font-size: .9rem; flex: none; }
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav .brand { display: none; }
.nav a { flex: 1; position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 2px 6px; min-height: 58px; color: var(--muted); font-size: .72rem; }
.nav a.on { color: var(--teal); font-weight: 600; }
.nav svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }
.count { position: absolute; top: 4px; left: calc(50% - 22px); background: var(--red); color: #fff;
  font-size: .7rem; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px; text-align: center; padding: 0 4px; }

@media (min-width: 900px) {
  .nav { top: 0; bottom: 0; left: auto; width: 230px; flex-direction: column; border-top: 0;
    border-left: 1px solid var(--line); padding: 16px 12px; gap: 4px; }
  .nav .brand { display: block; font-weight: 700; color: var(--teal); padding: 6px 10px 18px; line-height: 1.4; }
  .nav a { flex: none; flex-direction: row; gap: 12px; min-height: 46px; padding: 10px 12px;
    font-size: .95rem; border-radius: 10px; }
  .nav a.on { background: var(--teal-bg); }
  .count { position: static; margin-inline-start: auto; }
  .top, main { margin-right: 230px; }
  .top .clinic { visibility: hidden; }
  main { padding: 24px 32px 40px; }
}

/* cards & rows */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card.list { padding: 0 14px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-link, .appt { display: block; padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--ink); }
.list > :last-child { border-bottom: 0; }
.sum { margin: 4px 0; color: #334155; font-size: .93rem; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.appt.cancelled, .appt.no_show { opacity: .65; }
.time { font-variant-numeric: tabular-nums; }
.flash { background: var(--teal-bg); color: var(--teal); border-radius: 10px; padding: 10px 14px; margin-bottom: 12px; }
.backlink { display: inline-block; margin-bottom: 10px; padding: 6px 0; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.more { font-size: .9rem; font-weight: 400; }

@media (min-width: 900px) {
  .reqs { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .reqs .card { margin: 0; }
  .two { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
}

/* KPI cards */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
@media (min-width: 700px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: flex; flex-direction: column; color: var(--ink); min-width: 0; }
.kpi i { width: 30px; height: 30px; border-radius: 9px; margin-bottom: 8px; }
.kpi span { color: var(--muted); font-size: .82rem; }
.kpi b { font-size: 1.7rem; line-height: 1.2; }
.kpi small { color: var(--muted); font-size: .78rem; }
.c1 { background: radial-gradient(circle, var(--teal-2) 34%, var(--teal-bg) 36%); }
.c2 { background: radial-gradient(circle, #f59e0b 34%, var(--amber-bg) 36%); }
.c3 { background: radial-gradient(circle, #60a5fa 34%, var(--blue-bg) 36%); }
.c4 { background: radial-gradient(circle, #8b5cf6 34%, #f1ebfd 36%); }

/* badges */
.badge, .tag { display: inline-block; border-radius: 999px; padding: 1px 10px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.tag { padding: 0 8px; background: #f1ebfd; color: #6d28d9; font-weight: 500; }
.tag.ai { background: var(--teal-bg); color: var(--teal); }
.booking, .st-attended, .rq-confirmed { background: var(--green-bg); color: var(--green); }
.inquiry, .st-scheduled, .rq-new { background: var(--blue-bg); color: var(--blue); }
.missed, .st-no_show, .rq-rejected { background: var(--red-bg); color: var(--red); }
.st-cancelled { background: #eef1f4; color: var(--muted); }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 16px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.ok { color: var(--green); }
.btn.danger { color: var(--red); }
.btn.wide { width: 100%; }
.actions { display: flex; gap: 8px; margin-top: 10px; }
.actions > *, .actions form .btn { flex: 1; }
.actions form { display: flex; flex: 1; }
input, textarea, select { width: 100%; font: inherit; padding: 10px 12px; min-height: 44px; border: 1px solid #cfd8de;
  border-radius: 10px; background: #fff; color: var(--ink); }
input:focus, textarea:focus { outline: 2px solid var(--teal-2); border-color: transparent; }
label { display: block; font-size: .9rem; color: var(--muted); }
label input { margin-top: 4px; color: var(--ink); }
details summary { cursor: pointer; color: var(--teal); font-weight: 600; padding: 10px 0; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details.add summary { padding: 4px 0; }
.edit .slot { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.edit .slot .btn { grid-column: 1 / -1; }
.grid-form { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 10px; }
@media (min-width: 600px) { .grid-form { grid-template-columns: 1fr 1fr; } .grid-form .full { grid-column: 1 / -1; } }
.search { display: flex; gap: 8px; margin: 12px 0; }
.search .btn { flex: none; }
.note-form .btn { margin-top: 8px; width: 100%; }
.note p { white-space: pre-wrap; }
.login { max-width: 380px; margin: 12vh auto 0; display: grid; gap: 14px; }
.summary { background: var(--teal-bg); border-radius: 10px; padding: 10px 12px; }

/* tabs & segmented control */
.tabs, .seg { display: flex; background: #e7edf0; border-radius: 12px; padding: 4px; gap: 4px; }
.tabs { margin: 4px 0 14px; }
.tabs a, .seg a { flex: 1; text-align: center; padding: 9px 14px; border-radius: 9px; color: var(--muted); font-weight: 600; }
.tabs a.on, .seg a.on { background: #fff; color: var(--teal); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* calendar */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 6px 0 12px; }
.pager b { text-align: center; }
.cal-month .dayview, .cal-day .monthview { display: none; }
@media (max-width: 899px) { .cal-auto .monthview { display: none; } .seg a.auto-day { background: #fff; color: var(--teal); } }
@media (min-width: 900px) { .cal-auto .dayview { display: none; } .seg a.auto-month { background: #fff; color: var(--teal); } }
.month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding: 8px; }
.wd { text-align: center; font-size: .7rem; color: var(--muted); padding: 4px 0; overflow: hidden; white-space: nowrap; }
.cell { min-height: 54px; border-radius: 8px; padding: 4px; background: #f8fafb; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.cell.blank { background: transparent; }
.cell.today { outline: 2px solid var(--teal-2); }
.dn { font-weight: 600; font-size: .9rem; }
.dot { background: var(--teal); color: #fff; border-radius: 999px; font-size: .7rem; min-width: 20px; text-align: center; }
.ev { display: none; }
@media (min-width: 900px) {
  .cell { min-height: 104px; align-items: stretch; }
  .dot { display: none; }
  .ev { display: block; font-size: .72rem; border-radius: 5px; padding: 1px 5px; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; }
  .ev.more { background: none; color: var(--muted); }
  .wd { font-size: .8rem; }
}

/* transcript */
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 85%; padding: 8px 12px; border-radius: 14px; line-height: 1.6; }
.bubble small { display: block; font-size: .72rem; color: var(--muted); }
.bubble.agent { align-self: flex-start; background: var(--teal-bg); border-start-start-radius: 4px; }
.bubble.user { align-self: flex-end; background: var(--card); border: 1px solid var(--line); border-start-end-radius: 4px; }

/* stats bars */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 190px; }
.bar { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.bar .col { width: 100%; max-width: 32px; background: var(--teal-2); border-radius: 5px 5px 0 0; display: flex;
  flex-direction: column; justify-content: flex-end; overflow: hidden; min-height: 2px; }
.bar .ah, .sw.ah { background: #8b5cf6; }
.bar .v { font-size: .7rem; color: var(--muted); }
.bar .d { font-size: .7rem; color: var(--muted); margin-top: 4px; }
.legend { color: var(--muted); margin-top: 10px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--teal-2); margin: 0 6px 0 2px; }
