:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #687786;
  --primary: #087fc4;
  --primary-2: #13b8bf;
  --accent: #d7a63c;
  --border: #dfe7ee;
  --success: #18794e;
  --warning: #a66000;
  --danger: #b42318;
  --shadow: 0 12px 34px rgba(23, 50, 77, .08);
  --radius: 20px;
}

[data-theme="dark"] {
  --bg: #0e1720;
  --surface: #17232e;
  --text: #f2f6fa;
  --muted: #aab8c5;
  --primary: #83b8dc;
  --primary-2: #add4ed;
  --accent: #e5bd62;
  --border: #2a3a48;
  --shadow: 0 16px 40px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }
html { font-family: Arial, "Noto Sans Arabic", sans-serif; background: var(--bg); color: var(--text); }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top right, rgba(40,95,134,.10), transparent 32%), var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary-2); }

#app { width: min(1180px, calc(100% - 28px)); margin: auto; }
.topbar { display:flex; justify-content:space-between; align-items:center; padding:26px 0 18px; gap:16px; }
h1,h2,h3,p { margin-top:0; }
h1 { margin-bottom:0; font-size:clamp(1.7rem,3vw,2.45rem); }
.eyebrow { color:var(--muted); margin-bottom:5px; font-size:.88rem; }
.top-actions { display:flex; align-items:center; gap:8px; }
select,input,textarea { width:100%; border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:12px; padding:12px 13px; outline:none; }
select:focus,input:focus,textarea:focus { border-color:var(--primary-2); box-shadow:0 0 0 3px rgba(40,95,134,.13); }
.top-actions select { width:auto; min-width:120px; }
.icon-btn { border:1px solid var(--border); background:var(--surface); color:var(--text); width:44px; height:44px; border-radius:13px; }

.hero-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:14px; }
.card { background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); box-shadow:var(--shadow); }
.hero-grid .card { padding:20px; min-height:132px; display:flex; flex-direction:column; justify-content:space-between; }
.card.highlight { color:white; border:none; background:linear-gradient(135deg,#087fc4,#13b8bf); }
.card span { color:var(--muted); }
.card.highlight span,.card.highlight small { color:rgba(255,255,255,.8); }
.card strong { font-size:2.25rem; }
.card strong.compact { font-size:1.15rem; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.card small { color:var(--muted); }

.toolbar { margin:16px 0 26px; padding:10px; display:flex; justify-content:space-between; align-items:center; gap:12px; }
.view-tabs { display:flex; gap:4px; flex-wrap:wrap; }
.tab { border:0; background:transparent; color:var(--muted); padding:11px 16px; border-radius:12px; }
.tab.active { color:var(--text); background:var(--bg); font-weight:bold; }
.primary,.secondary,.danger { border:0; border-radius:12px; padding:12px 17px; font-weight:bold; }
.primary { color:#ffffff; background:#0a66a8; font-weight:800; letter-spacing:.3px; box-shadow:0 6px 16px rgba(8,127,196,.3); text-shadow:0 1px 2px rgba(0,0,0,.22); }
.primary span { color:#ffffff; }
.secondary { color:var(--text); background:var(--bg); border:1px solid var(--border); }
.danger { color:#fff; background:var(--danger); }

.section-title { display:flex; justify-content:space-between; align-items:end; gap:15px; margin-bottom:14px; }
.section-title h2 { margin-bottom:4px; }
.section-title p { color:var(--muted); margin-bottom:0; }
.section-title input { width:min(360px,100%); }
.appointment-list { display:grid; gap:10px; }
.appointment-item { display:grid; grid-template-columns:110px 1fr auto; align-items:center; gap:16px; background:var(--surface); border:1px solid var(--border); border-radius:17px; padding:15px; box-shadow:0 7px 20px rgba(23,50,77,.05); }
.time-block { text-align:center; border-inline-end:1px solid var(--border); padding-inline-end:15px; }
.time-block strong { display:block; font-size:1.2rem; }
.time-block small { color:var(--muted); }
.appointment-main h3 { margin-bottom:5px; }
.meta { color:var(--muted); display:flex; gap:10px; flex-wrap:wrap; font-size:.9rem; }
.status { display:inline-block; padding:6px 10px; border-radius:999px; font-size:.78rem; font-weight:bold; background:var(--bg); }
.status.completed { color:var(--success); }
.status.cancelled,.status.no-show { color:var(--danger); }
.status.confirmed { color:var(--primary-2); }
.item-actions { display:flex; gap:7px; }
.item-actions button { border:1px solid var(--border); background:var(--surface); color:var(--text); border-radius:10px; padding:8px 10px; }
.empty-state { text-align:center; padding:50px 20px; color:var(--muted); }
.empty-icon { font-size:3rem; }
.hidden { display:none !important; }

.clients-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.client-card { padding:18px; }
.client-card h3 { margin-bottom:6px; }
.client-card p { color:var(--muted); margin-bottom:6px; }
.settings-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:14px; }
.form-card { padding:20px; }
.form-card label { display:grid; gap:7px; margin-top:16px; }
.switch-row { grid-template-columns:1fr auto !important; align-items:center; }
.switch-row input { width:22px; height:22px; }
.button-stack { display:grid; gap:9px; margin-top:15px; }
.file-label { text-align:center; cursor:pointer; }
.legal-card a { display:block; margin-top:10px; }

footer { padding:35px 0 24px; text-align:center; color:var(--muted); font-size:.86rem; }

dialog { width:min(760px,calc(100% - 24px)); border:0; border-radius:24px; background:var(--surface); color:var(--text); padding:0; box-shadow:0 30px 80px rgba(0,0,0,.28); }
dialog::backdrop { background:rgba(8,18,28,.55); backdrop-filter:blur(3px); }
dialog form { padding:22px; }
.dialog-head { display:flex; justify-content:space-between; align-items:start; margin-bottom:20px; }
.form-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:14px; }
.form-grid label { display:grid; gap:7px; }
.full-width { grid-column:1/-1; }
.warning { color:var(--warning); border:1px solid rgba(166,96,0,.35); background:rgba(166,96,0,.08); padding:11px; border-radius:11px; margin-top:14px; }
.dialog-actions { display:flex; align-items:center; gap:9px; margin-top:20px; }
.spacer { flex:1; }
.toast { position:fixed; bottom:22px; left:50%; transform:translate(-50%,20px); background:#17212b; color:white; padding:12px 18px; border-radius:12px; opacity:0; pointer-events:none; transition:.25s; z-index:99; }
.toast.show { opacity:1; transform:translate(-50%,0); }

@media (max-width:850px) {
  .hero-grid { grid-template-columns:repeat(2,1fr); }
  .settings-grid,.clients-grid { grid-template-columns:1fr; }
  .appointment-item { grid-template-columns:85px 1fr; }
  .item-actions { grid-column:1/-1; justify-content:end; }
}
@media (max-width:600px) {
  #app { width:min(100% - 18px,1180px); }
  .topbar { align-items:flex-start; }
  .eyebrow { display:none; }
  .top-actions select { min-width:98px; }
  .hero-grid { gap:9px; }
  .hero-grid .card { min-height:114px; padding:15px; }
  .card strong { font-size:1.75rem; }
  .toolbar { align-items:stretch; flex-direction:column-reverse; }
  .view-tabs { justify-content:space-between; }
  .tab { flex:1; padding:10px 7px; }
  .section-title { align-items:stretch; flex-direction:column; }
  .section-title input { width:100%; }
  .form-grid { grid-template-columns:1fr; }
  .full-width { grid-column:auto; }
  .appointment-item { grid-template-columns:72px 1fr; gap:10px; padding:12px; }
  .meta { font-size:.8rem; }
}

.brand-wrap { display:flex; align-items:center; gap:12px; }
.brand-icon { width:58px; height:58px; border-radius:16px; object-fit:cover; box-shadow:0 8px 22px rgba(8,127,196,.24); }
.appointment-item { cursor:pointer; transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.appointment-item:hover { transform:translateY(-2px); box-shadow:0 12px 28px rgba(23,50,77,.11); border-color:rgba(8,127,196,.35); }
.appointment-item:focus-visible { outline:3px solid rgba(8,127,196,.25); outline-offset:2px; }
.appointment-item.ended { background:rgba(180,35,24,.065); border-color:rgba(180,35,24,.32); }
.appointment-item.ended .time-block strong,.appointment-item.ended .appointment-main h3 { color:var(--danger); }
.status.ended { color:#fff; background:var(--danger); }
.details-shell { padding:22px; }
.details-status { display:inline-flex; padding:7px 13px; border-radius:999px; font-weight:700; margin-bottom:18px; background:var(--bg); }
.details-status.ended,.details-status.cancelled,.details-status.no-show { color:#fff; background:var(--danger); }
.details-status.completed { color:#fff; background:var(--success); }
.details-status.confirmed { color:#fff; background:var(--primary-2); }
.details-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:12px; }
.details-grid>div { padding:15px; border:1px solid var(--border); border-radius:14px; background:var(--bg); display:grid; gap:6px; }
.details-grid span { color:var(--muted); font-size:.86rem; }
.details-grid strong,.details-grid p { margin:0; overflow-wrap:anywhere; }
.details-actions { flex-wrap:wrap; }
@media (max-width:600px){ .brand-icon{width:48px;height:48px;border-radius:13px}.details-grid{grid-template-columns:1fr}.details-grid .full-width{grid-column:auto}.details-actions .spacer{display:none}.details-actions button{flex:1} }

/* post-launch polish */
.card.clickable{cursor:pointer;transition:transform .15s ease, box-shadow .15s ease}
.card.clickable:active{transform:scale(.99)}
.card.clickable:hover{box-shadow:0 14px 32px rgba(23,50,77,.12)}
.primary:active{transform:translateY(1px)}
.appointment-item:active{transform:scale(.992);border-color:rgba(8,127,196,.45)}
.item-actions button:active{transform:scale(.96)}
@media (max-width:600px){
  .primary{width:100%;padding:15px;font-size:1.12rem}
  .topbar{padding:16px 0 12px}
  h1{font-size:1.6rem}
  .hero-grid{gap:8px}
  .hero-grid .card{min-height:92px;padding:13px}
  .card strong{font-size:1.5rem}
  .card span{font-size:.9rem}
  .toolbar{padding:8px;gap:10px}
  .appointment-item{padding:14px}
  .item-actions{gap:8px}
  .item-actions button{padding:10px 13px;font-size:.9rem}
  dialog form{padding:18px}
  .details-shell{padding:18px}
  .time-block{padding-inline-end:10px}
  .time-block strong{font-size:1.12rem}
  select,input,textarea{padding:13px 14px;font-size:1rem}
  .section-title h2{font-size:1.3rem}
  footer{padding:24px 0 18px}
}
