:root{
  --brand:#0e7490; --brand-dark:#155e75; --brand-soft:#e0f2f7;
  --ink:#0f172a; --muted:#64748b; --line:#e2e8f0; --bg:#f5f8f9; --card:#ffffff;
  --ok:#0f766e; --warn:#b45309; --warn-bg:#fef3c7; --bad:#b91c1c; --bad-bg:#fee2e2;
  --ok-bg:#ccfbf1; --radius:16px; --shadow:0 1px 2px rgba(15,23,42,.06),0 8px 24px -12px rgba(15,23,42,.18);
  --max:520px;
}
*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  font-family:"Tajawal","Segoe UI",system-ui,-apple-system,"Noto Kufi Arabic",sans-serif;
  background:var(--bg); color:var(--ink); line-height:1.6; font-size:16px;
  -webkit-text-size-adjust:100%;
}
a{color:var(--brand); text-decoration:none}
img{max-width:100%}
.wrap{max-width:var(--max); margin:0 auto; padding:0 16px 96px}
.wide{max-width:900px}
h1,h2,h3{margin:0; line-height:1.35; font-weight:700}
h1{font-size:1.35rem}
h2{font-size:1.1rem}
h3{font-size:1rem}
p{margin:.4rem 0}
.muted{color:var(--muted)}
.small{font-size:.85rem}
.tiny{font-size:.78rem}
.center{text-align:center}
.hidden{display:none !important}
.row{display:flex; gap:10px; align-items:center}
.row.between{justify-content:space-between}
.row.wrap{flex-wrap:wrap}
.grow{flex:1}
.stack{display:flex; flex-direction:column; gap:12px}

/* header */
.top{background:linear-gradient(135deg,#0e7490,#0f766e); color:#fff; padding:22px 16px 26px; border-radius:0 0 26px 26px}
.top .inner{max-width:var(--max); margin:0 auto}
.top h1{font-size:1.5rem}
.top .sub{opacity:.9; font-size:.92rem; margin-top:4px}
.top a{color:#fff}
.chip-line{display:flex; gap:14px; flex-wrap:wrap; margin-top:12px; font-size:.85rem; opacity:.95}
.chip-line span{display:inline-flex; align-items:center; gap:5px}

/* cards */
.card{background:var(--card); border:1px solid var(--line); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow)}
.card + .card{margin-top:12px}
.card h2{margin-bottom:10px}
.section-title{display:flex; align-items:center; justify-content:space-between; margin:20px 0 10px}
.section-title h2{font-size:1.05rem}

/* buttons */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:1px solid transparent; border-radius:12px; padding:12px 16px;
  font-family:inherit; font-size:1rem; font-weight:700; cursor:pointer;
  background:var(--brand); color:#fff; min-height:48px; text-align:center;
  transition:filter .15s, transform .05s;
}
.btn:active{transform:translateY(1px)}
.btn:hover{filter:brightness(1.05)}
.btn[disabled]{opacity:.55; cursor:not-allowed}
.btn.block{width:100%}
.btn.ghost{background:#fff; color:var(--brand); border-color:var(--brand)}
.btn.soft{background:var(--brand-soft); color:var(--brand-dark); border-color:transparent}
.btn.small{padding:8px 12px; min-height:38px; font-size:.88rem; border-radius:10px}
.btn.wa{background:#25d366; color:#08331a}
.btn.danger{background:#fff; color:var(--bad); border-color:#fecaca}
.btn.ok{background:var(--ok)}
.btn svg{width:18px; height:18px}

/* form */
label{display:block; font-size:.9rem; font-weight:700; margin:0 0 6px}
input,select,textarea{
  width:100%; font-family:inherit; font-size:1rem; color:var(--ink);
  background:#fff; border:1px solid var(--line); border-radius:12px; padding:12px 14px; min-height:48px;
}
textarea{min-height:110px; resize:vertical; line-height:1.6}
input:focus,select:focus,textarea:focus{outline:2px solid var(--brand-soft); border-color:var(--brand)}
.field{margin-bottom:14px}
.hint{font-size:.8rem; color:var(--muted); margin-top:5px}
.err{background:var(--bad-bg); color:var(--bad); border-radius:10px; padding:10px 12px; font-size:.9rem; margin-bottom:12px}

/* dates strip */
.days{display:flex; gap:8px; overflow-x:auto; padding:4px 0 8px; scrollbar-width:none; -webkit-overflow-scrolling:touch}
.days::-webkit-scrollbar{display:none}
.day{
  flex:0 0 auto; min-width:74px; border:1px solid var(--line); background:#fff; border-radius:14px;
  padding:8px 6px; text-align:center; cursor:pointer; font-family:inherit; color:var(--ink);
}
.day .dow{font-size:.75rem; color:var(--muted)}
.day .num{font-size:1.15rem; font-weight:700; line-height:1.2}
.day .mon{font-size:.7rem; color:var(--muted)}
.day[aria-pressed="true"]{background:var(--brand); border-color:var(--brand); color:#fff}
.day[aria-pressed="true"] .dow,.day[aria-pressed="true"] .mon{color:#d8f3f8}
.day[disabled]{opacity:.38; cursor:not-allowed; background:#f8fafc}
.day.today .dow{color:var(--brand); font-weight:700}

/* slots */
.slot-group{margin-top:6px}
.slot-group .glabel{font-size:.82rem; color:var(--muted); margin:8px 0 6px; display:flex; align-items:center; gap:6px}
.slots{display:grid; grid-template-columns:repeat(auto-fill,minmax(84px,1fr)); gap:8px}
.slot{
  border:1px solid var(--line); background:#fff; border-radius:11px; padding:10px 4px;
  font-family:inherit; font-size:.95rem; font-weight:700; color:var(--brand-dark); cursor:pointer; direction:ltr;
}
.slot[aria-pressed="true"]{background:var(--brand); color:#fff; border-color:var(--brand)}
.slot[disabled]{opacity:.35; cursor:not-allowed; text-decoration:line-through}

/* steps */
.steps{display:flex; gap:6px; margin:0 0 14px}
.step{flex:1; height:4px; border-radius:4px; background:var(--line)}
.step.on{background:var(--brand)}

/* pills */
.pill{display:inline-flex; align-items:center; gap:4px; font-size:.75rem; font-weight:700; padding:3px 9px; border-radius:999px; background:#eef2f5; color:#475569; white-space:nowrap}
.pill.pending{background:var(--warn-bg); color:var(--warn)}
.pill.confirmed{background:var(--ok-bg); color:var(--ok)}
.pill.done{background:#e2e8f0; color:#334155}
.pill.canceled{background:var(--bad-bg); color:var(--bad)}

/* appointment list */
.appt{display:flex; gap:12px; align-items:flex-start; padding:14px 0; border-bottom:1px solid var(--line)}
.appt:last-child{border-bottom:0; padding-bottom:0}
.appt .time{
  flex:0 0 62px; text-align:center; background:var(--brand-soft); color:var(--brand-dark);
  border-radius:12px; padding:8px 4px; font-weight:700; direction:ltr;
}
.appt .time small{display:block; font-weight:400; font-size:.68rem; color:var(--muted)}
.appt .body{flex:1; min-width:0}
.appt .name{font-weight:700; display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.appt .meta{font-size:.85rem; color:var(--muted); direction:ltr; text-align:right; unicode-bidi:plaintext}
.appt .acts{display:flex; gap:6px; margin-top:8px; flex-wrap:wrap}
.appt.is-canceled{opacity:.6}

/* confirmation */
.big-check{
  width:74px; height:74px; border-radius:50%; background:var(--ok-bg); color:var(--ok);
  display:flex; align-items:center; justify-content:center; margin:0 auto 12px;
}
.big-check svg{width:38px; height:38px}
.ticket{border:1px dashed var(--brand); border-radius:14px; padding:14px; background:#f0fbfd; margin:14px 0}
.ticket .code{font-family:ui-monospace,monospace; font-size:1.5rem; font-weight:700; letter-spacing:2px; color:var(--brand-dark); direction:ltr}
.kv{display:flex; justify-content:space-between; gap:10px; padding:7px 0; border-bottom:1px dashed var(--line); font-size:.95rem}
.kv:last-child{border-bottom:0}
.kv .k{color:var(--muted)}
.kv .v{font-weight:700; text-align:left}

/* dashboard */
.dash-top{background:#fff; border-bottom:1px solid var(--line); padding:14px 16px; position:sticky; top:0; z-index:20}
.dash-top .inner{max-width:900px; margin:0 auto; display:flex; align-items:center; gap:12px; justify-content:space-between}
.avatar{width:38px; height:38px; border-radius:50%; background:var(--brand-soft); color:var(--brand-dark); display:flex; align-items:center; justify-content:center; font-weight:700}
.daynav{display:flex; align-items:center; gap:8px; justify-content:space-between; margin:14px 0}
.daynav .date{font-weight:700; text-align:center}
.daynav .date small{display:block; font-weight:400; color:var(--muted); font-size:.78rem}
.iconbtn{width:42px; height:42px; border-radius:12px; border:1px solid var(--line); background:#fff; font-size:1.1rem; cursor:pointer; font-family:inherit; color:var(--brand-dark)}
.stats{display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin-bottom:6px}
.stat{background:#fff; border:1px solid var(--line); border-radius:12px; padding:10px 6px; text-align:center}
.stat .n{font-size:1.25rem; font-weight:700; line-height:1.2}
.stat .l{font-size:.7rem; color:var(--muted)}
.tabs{display:flex; gap:6px; margin:14px 0 4px; background:#eef2f5; padding:4px; border-radius:12px}
.tabs button{flex:1; border:0; background:transparent; padding:9px 6px; border-radius:9px; font-family:inherit; font-size:.9rem; font-weight:700; color:var(--muted); cursor:pointer}
.tabs button[aria-selected="true"]{background:#fff; color:var(--brand-dark); box-shadow:0 1px 3px rgba(15,23,42,.12)}
.searchbar{display:flex; gap:8px; margin:12px 0}
.searchbar input{flex:1}
.empty{text-align:center; color:var(--muted); padding:28px 10px; font-size:.92rem}
.empty svg{width:42px; height:42px; opacity:.4; margin-bottom:8px}

/* sheet (patient panel) */
.sheet-bg{position:fixed; inset:0; background:rgba(15,23,42,.45); display:none; z-index:50}
.sheet-bg.open{display:block}
.sheet{
  position:fixed; inset-inline:0; bottom:0; z-index:60; background:var(--bg);
  border-radius:22px 22px 0 0; max-height:92vh; overflow-y:auto; transform:translateY(102%);
  transition:transform .22s ease; padding-bottom:24px;
}
.sheet.open{transform:none}
.sheet .handle{width:44px; height:5px; border-radius:5px; background:#cbd5e1; margin:10px auto 4px}
.sheet-head{position:sticky; top:0; background:var(--bg); padding:6px 16px 10px; display:flex; justify-content:space-between; align-items:center; border-bottom:1px solid var(--line)}
.visit{border:1px solid var(--line); border-radius:12px; padding:12px; background:#fff; margin-bottom:10px}
.visit .vhead{display:flex; justify-content:space-between; gap:8px; font-size:.85rem; color:var(--muted); margin-bottom:6px}
.visit .vbody{font-size:.92rem; white-space:pre-wrap}
.rx{font-family:"Tajawal",sans-serif}

/* login */
.auth{max-width:420px; margin:0 auto; padding:32px 16px}
.auth .logo{width:64px; height:64px; border-radius:18px; background:var(--brand); color:#fff; display:flex; align-items:center; justify-content:center; margin:0 auto 14px; font-size:1.7rem; font-weight:700}
.demo-box{background:#f0fbfd; border:1px dashed var(--brand); border-radius:12px; padding:10px 12px; font-size:.85rem; margin-top:14px}
.demo-box code{background:#fff; padding:1px 5px; border-radius:5px; direction:ltr; display:inline-block; font-size:.82rem}

/* landing */
.hero{padding:36px 16px 26px; text-align:center; background:linear-gradient(160deg,#0e7490,#0f766e); color:#fff}
.hero h1{font-size:1.6rem; margin-bottom:8px}
.hero p{opacity:.92; font-size:.95rem; max-width:420px; margin:0 auto}
.feature{display:flex; gap:12px; align-items:flex-start; padding:12px 0}
.feature .ico{flex:0 0 40px; height:40px; border-radius:12px; background:var(--brand-soft); color:var(--brand-dark); display:flex; align-items:center; justify-content:center}
.feature .ico svg{width:20px; height:20px}

/* print */
@media print{
  body{background:#fff}
  .no-print{display:none !important}
  .print-page{box-shadow:none; border:0; padding:0}
}

@media (max-width:380px){
  .stats{grid-template-columns:repeat(2,1fr)}
  .appt .time{flex-basis:56px}
}

/* clinical records */
.tooth-row{display:grid; grid-template-columns:repeat(16,1fr); gap:3px; margin-bottom:5px; direction:ltr}
.tooth{border:1px solid var(--line); background:#fff; border-radius:6px; padding:0; height:42px; display:flex; align-items:center; justify-content:center; cursor:pointer; font-family:inherit; font-size:.6rem; color:#334155; direction:ltr}
.tooth.sel{outline:2px solid var(--brand); outline-offset:1px}
.tooth.st-caries{background:#fee2e2; border-color:#fca5a5; color:#991b1b}
.tooth.st-filled{background:#dbeafe; border-color:#93c5fd; color:#1e3a8a}
.tooth.st-rct{background:#ede9fe; border-color:#c4b5fd; color:#5b21b6}
.tooth.st-extracted{background:#e2e8f0; border-color:#cbd5e1; color:#94a3b8; text-decoration:line-through}
.tooth.st-crown{background:#ccfbf1; border-color:#5eead4; color:#115e59}
.tooth.st-bridge{background:#fef3c7; border-color:#fcd34d; color:#92400e}
.tooth-palette{display:flex; flex-wrap:wrap; gap:6px; margin:10px 0 12px}
.chip{border:1px solid var(--line); background:#fff; border-radius:999px; padding:6px 12px; font-family:inherit; font-size:.82rem; cursor:pointer; color:#334155}
.chip.on{background:var(--brand); color:#fff; border-color:var(--brand)}
.legend{display:flex; flex-wrap:wrap; gap:10px; font-size:.72rem; color:var(--muted); margin-top:6px}
.legend i{display:inline-block; width:10px; height:10px; border-radius:3px; margin-inline-end:4px; vertical-align:-1px}
.rec{border:1px solid var(--line); border-radius:12px; padding:12px; background:#fff; margin-bottom:10px}
.rec .rhead{display:flex; justify-content:space-between; font-size:.82rem; color:var(--muted); margin-bottom:6px}
.rec .rbody{font-size:.9rem; white-space:pre-wrap}
