/* Clinic System — control panel */
:root { --blue: #0a5dc2; --navy: #0b2a5b; --bg: #f3f6fa; --ink: #1b2533; --muted: #64748b; --line: #e1e7ef; --ok: #1f8a5b; --warn: #b7791f; --err: #c0392b; --r: 10px; --font: "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", Tahoma, Arial, sans-serif; }
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; line-height: 1.6; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; color: var(--navy); }
.ic { width: 1.15em; height: 1.15em; flex: none; vertical-align: -.2em; }
.ic-xl { width: 40px; height: 40px; color: #9fb3c8; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.inline { display: inline; }
.empty { color: var(--muted); text-align: center; padding: 26px 10px !important; }
[hidden] { display: none !important; }

/* Shell */
.shell { display: flex; min-height: 100vh; }
.side { width: 258px; background: var(--navy); color: #fff; flex: none; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30; }
.side-brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.1); text-decoration: none !important; }
.side-brand img { width: 40px; height: 40px; border-radius: 50%; background: #fff; }
.side-brand strong { display: block; font-size: 14px; line-height: 1.3; }
.side-brand small { color: rgba(255,255,255,.6); font-size: 12px; }
.side nav { padding: 10px 10px 30px; }
.side-group { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,.45); padding: 16px 10px 6px; }
[dir="rtl"] .side-group { letter-spacing: 0; }
.side nav a { display: flex; align-items: center; gap: 10px; color: rgba(255,255,255,.82); padding: 8px 10px; border-radius: 8px; font-size: 14px; text-decoration: none !important; }
.side nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.side nav a.on { background: var(--blue); color: #fff; }
.side nav a span { flex: 1; }
.count { background: #f59e0b; color: #1b2533; border-radius: 999px; font-size: 11.5px; padding: 0 7px; line-height: 19px; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; gap: 14px; padding: 12px 26px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.top-title { font-size: 19px; margin: 0; flex: 1; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.top-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 8px; color: var(--ink); font-size: 13.5px; }
.top-link:hover { background: var(--bg); text-decoration: none; }
.usermenu { position: relative; }
.usermenu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 5px 8px; border-radius: 8px; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu summary:hover { background: var(--bg); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 700; }
.usermenu-pop { position: absolute; inset-inline-end: 0; top: 110%; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.1); min-width: 190px; padding: 6px; }
.usermenu-pop a, .usermenu-pop button { display: flex; gap: 8px; align-items: center; width: 100%; padding: 9px 10px; border: 0; background: none; font: inherit; color: var(--ink); border-radius: 6px; cursor: pointer; text-align: start; }
.usermenu-pop a:hover, .usermenu-pop button:hover { background: var(--bg); text-decoration: none; }
.content { padding: 24px 26px 60px; max-width: 1400px; width: 100%; }
.side-toggle { display: none; }
.icon-btn { background: none; border: 0; width: 40px; height: 40px; border-radius: 8px; display: inline-grid; place-items: center; cursor: pointer; color: var(--navy); }
.icon-btn:hover { background: var(--bg); }
.side-backdrop { display: none; }

/* Panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 20px 22px; margin-bottom: 20px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.panel-head h2, .panel-title { font-size: 16.5px; margin: 0; display: flex; gap: 8px; align-items: center; }
.panel-title { margin-bottom: 14px; }
.sub-h { font-size: 14.5px; margin: 16px 0 6px; display: flex; gap: 8px; align-items: center; }
.center-panel { text-align: center; padding: 50px 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; font-size: 13.5px; cursor: pointer; line-height: 1.35; white-space: nowrap; text-decoration: none !important; }
.btn:hover { border-color: #c4d0de; background: #f8fafc; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--navy); border-color: var(--navy); }
.btn-ok { background: #e8f6ef; border-color: #b9e3cd; color: #146c45; }
.btn-danger { color: var(--err); border-color: #f2c9c4; }
.btn-danger:hover { background: #fdecea; }
.btn-wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-wa:hover { background: #18834a; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-xs { padding: 4px 7px; font-size: 12.5px; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
td.actions { text-align: end; white-space: nowrap; }
td.actions > * { vertical-align: middle; margin-inline-start: 3px; }
.btn-row.actions { justify-content: flex-end; }

/* Alerts */
.alert { display: flex; gap: 10px; align-items: center; padding: 11px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 14px; }
.alert > span { flex: 1; }
.alert-ok { background: #e8f6ef; color: #135c3b; }
.alert-err { background: #fdecea; color: #7d1d12; }
.alert-warn { background: #fff5db; color: #6b4b00; }
.alert-info { background: #eaf3fe; color: #123a6b; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 20px; }
.kpi { display: flex; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; color: var(--ink); text-decoration: none !important; transition: box-shadow .15s; }
.kpi:hover { box-shadow: 0 6px 20px rgba(11,42,91,.08); }
.kpi-ic { width: 44px; height: 44px; border-radius: 11px; background: #eaf3fe; color: var(--blue); display: grid; place-items: center; }
.kpi-ic .ic { width: 22px; height: 22px; }
.kpi b { display: block; font-size: 26px; line-height: 1.1; color: var(--navy); }
.kpi span { font-size: 13px; color: var(--muted); }
.kpi-warn .kpi-ic { background: #fff5db; color: var(--warn); }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar span { width: 100%; background: linear-gradient(180deg, var(--blue), color-mix(in srgb, var(--blue) 60%, #fff)); border-radius: 5px 5px 2px 2px; color: #fff; font-size: 11px; text-align: center; min-height: 2px; }
.bar em { font-style: normal; font-size: 11px; color: var(--muted); margin-top: 4px; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.quick-actions a { display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px dashed #c8d4e3; border-radius: 10px; color: var(--navy); font-weight: 600; }
.quick-actions a:hover { background: #f5f9ff; border-color: var(--blue); text-decoration: none; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { font-size: 12.5px; color: var(--muted); font-weight: 600; background: #f8fafc; white-space: nowrap; }
.tbl tbody tr:hover { background: #fafcff; }
.tbl-compact th, .tbl-compact td { padding: 7px 8px; }
.tbl .w1 { width: 1%; }
.row-muted td { opacity: .55; }
.row-unread td { background: #f2f8ff; font-weight: 600; }
.row-group td { background: #f1f5fb; font-weight: 700; color: var(--navy); font-size: 13px; padding: 7px 14px; }
.cell-thumb { width: 54px; height: 38px; object-fit: cover; border-radius: 6px; }
.cell-icon .ic { width: 22px; height: 22px; color: var(--blue); }
.qno { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 8px; background: var(--navy); color: #fff; font-size: 13.5px; padding: 0 6px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef2f7; color: #334155; white-space: nowrap; text-decoration: none !important; }
.b-ok, .st-confirmed { background: #e3f5ec; color: #146c45; }
.st-completed { background: #e6eefb; color: #1e4c8f; }
.st-pending { background: #fff3d6; color: #8a5a00; }
.st-cancelled { background: #fde8e6; color: #9b2c1f; }
.st-no_show { background: #eceff3; color: #475569; }
.b-mute { background: #f1f3f6; color: #8a96a6; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }

/* Page actions / filters */
.page-actions { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 3px; flex-wrap: wrap; }
.seg a { padding: 6px 12px; border-radius: 7px; color: var(--ink); font-size: 13.5px; }
.seg a.on { background: var(--navy); color: #fff; }
.seg a:hover { text-decoration: none; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; padding: 14px 16px; }
.filters .field { margin: 0; min-width: 130px; }
.filters .field.grow { flex: 1; min-width: 200px; }
.filters label { font-size: 12px; }
.search-inline, .inline-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.search-inline input, .search-inline select, .inline-form select, .inline-form input { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; }
.bulk { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: -8px; margin-bottom: 18px; padding: 10px 14px; background: #fff; border: 1px solid var(--line); border-radius: 0 0 var(--r) var(--r); font-size: 13.5px; }
.bulk select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.pager { display: flex; gap: 6px; justify-content: center; margin: 14px 0; flex-wrap: wrap; }
.pager a, .pager span { min-width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--line); background: #fff; padding: 0 8px; }
.pager .on { background: var(--blue); color: #fff; border-color: var(--blue); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { display: inline-flex; gap: 6px; align-items: center; padding: 8px 14px; border-radius: 9px; background: #fff; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.tabs a.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.tabs a:hover { text-decoration: none; }

/* Forms */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .full, .f-pair.full { grid-column: 1 / -1; }
.f-pair { display: contents; }
.f-pair.full { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.f-pair.full:not(.stack) > .field.full { grid-column: auto; }
.f-pair.stack { grid-template-columns: 1fr; }
.field label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 5px; color: #334155; }
.field .req { color: var(--err); }
.field input[type=text], .field input[type=email], .field input[type=url], .field input[type=tel], .field input[type=number], .field input[type=date], .field input[type=time], .field input[type=password], .field input[type=search], .field select, .field textarea {
  width: 100%; padding: 9px 11px; border: 1px solid #cfd9e5; border-radius: 8px; font: inherit; font-size: 14.5px; background: #fff; color: var(--ink);
}
.field input[type=color] { width: 70px; height: 40px; border: 1px solid #cfd9e5; border-radius: 8px; padding: 3px; background: #fff; }
.field textarea { resize: vertical; min-height: 70px; line-height: 1.55; }
.field textarea.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
.field .help { display: block; color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.5; }
.field-bool { display: flex; flex-direction: column; justify-content: center; }
.switch { display: inline-flex !important; align-items: center; gap: 10px; cursor: pointer; font-weight: 500 !important; margin: 0 !important; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch span { width: 40px; height: 22px; border-radius: 999px; background: #cbd5e1; position: relative; transition: background .15s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; inset-inline-start: 3px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: inset-inline-start .15s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::after { inset-inline-start: 21px; }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.switch em { font-style: normal; font-size: 14px; color: var(--ink); }
.upl { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border: 1px dashed #cfd9e5; border-radius: 8px; padding: 10px; }
.upl .thumb { width: 96px; height: 64px; object-fit: contain; background: #f4f7fb; border-radius: 6px; }
.upl .rm { font-weight: 400 !important; font-size: 13px; display: inline-flex !important; gap: 4px; margin: 0 !important; }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick label { margin: 0 !important; cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 8px; color: var(--navy); }
.icon-pick input:checked + span { border-color: var(--blue); background: #eaf3fe; color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 30%, transparent); }
.form-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid #f2c9c4; border-radius: var(--r); background: #fff; margin-bottom: 20px; flex-wrap: wrap; }

/* Rich text editor */
.rte-wrap { border: 1px solid #cfd9e5; border-radius: 8px; overflow: hidden; background: #fff; }
.rte-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 5px; border-bottom: 1px solid var(--line); background: #f8fafc; }
.rte-bar button { border: 0; background: none; min-width: 32px; height: 30px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; color: #334155; padding: 0 7px; }
.rte-bar button:hover, .rte-bar button.on { background: #e6eef8; color: var(--blue); }
.rte-area { min-height: 220px; max-height: 560px; overflow-y: auto; padding: 12px 14px; outline: none; font-size: 15px; line-height: 1.7; }
.rte-area h2 { font-size: 21px; } .rte-area h3 { font-size: 17px; }
.rte-area img, .rte-area iframe { max-width: 100%; }
.rte-area blockquote { border-inline-start: 3px solid var(--blue); margin: 8px 0; padding: 4px 12px; background: #f5f9ff; }
.rte-src { width: 100%; min-height: 220px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; border: 0 !important; border-radius: 0 !important; display: none; }
.rte-wrap.src .rte-src { display: block; }
.rte-wrap.src .rte-area { display: none; }

/* Settings */
.settings-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.settings-nav { background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 8px; position: sticky; top: 76px; }
.settings-nav a { display: flex; gap: 9px; align-items: center; padding: 9px 10px; border-radius: 8px; color: var(--ink); font-size: 14px; }
.settings-nav a.on { background: #eaf3fe; color: var(--blue); font-weight: 600; }
.settings-nav a:hover { text-decoration: none; background: #f5f8fc; }

/* Schedules */
.sched { display: grid; gap: 8px; }
.sched-day { display: grid; grid-template-columns: 120px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe; }
.sched-day.has { background: #fff; border-color: #cfe0f5; }
.sched-name { font-weight: 700; color: var(--navy); }
.sched-rows { display: flex; flex-direction: column; gap: 6px; }
.sched-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sched-row label { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); }
.sched-row input { padding: 6px 8px; border: 1px solid #cfd9e5; border-radius: 7px; font: inherit; }
.sched-row input[type=number] { width: 80px; }
.sched-off { color: #9aa8b8; font-size: 13px; }
.sched-day.has .sched-off { display: none; }

/* Appointment page */
.appt-head { display: grid; grid-template-columns: auto 1fr; gap: 12px 24px; align-items: center; }
.appt-head .ref { font-size: 26px; font-weight: 700; letter-spacing: .12em; color: var(--navy); direction: ltr; display: inline-block; margin-inline-end: 8px; }
.appt-head .btn-row { grid-column: 1 / -1; }

/* Media */
.upload-zone { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; border-style: dashed; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.media-item { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; }
.media-thumb { aspect-ratio: 4/3; background: #f2f5f9; display: grid; place-items: center; }
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-meta { padding: 8px 10px 0; font-size: 12.5px; display: flex; justify-content: space-between; gap: 6px; }
.media-meta small { color: var(--muted); }
.media-act { display: flex; justify-content: space-between; padding: 8px 10px 10px; gap: 6px; }
.msg-body { background: #f8fafc; border-radius: 10px; padding: 16px; margin: 16px 0; white-space: normal; font-size: 15px; }

/* Login */
.login-body { display: grid; place-items: center; min-height: 100vh; background: radial-gradient(800px 500px at 80% 0%, color-mix(in srgb, var(--blue) 35%, transparent), transparent), var(--navy); padding: 20px; }
.login-card { width: 100%; max-width: 410px; background: #fff; border-radius: 16px; padding: 30px 28px; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.login-head { text-align: center; margin-bottom: 18px; }
.login-head img { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 10px; display: block; }
.login-head h1 { font-size: 19px; margin-bottom: 2px; }
.login-head p { color: var(--muted); margin: 0; }
.login-card .field { margin-bottom: 14px; }
.login-card .field input { padding: 11px 12px; }
.login-foot { text-align: center; font-size: 13.5px; margin: 14px 0 0; color: var(--muted); }

@media (max-width: 1100px) {
  .grid-2 { grid-template-columns: 1fr; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; display: flex; flex-wrap: wrap; gap: 4px; }
}
@media (max-width: 860px) {
  .side { position: fixed; inset-inline-start: 0; top: 0; transform: translateX(-100%); transition: transform .2s; }
  [dir="rtl"] .side { transform: translateX(100%); }
  body.side-open .side { transform: none; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .side-toggle { display: inline-grid; }
  .top { padding: 10px 14px; }
  .top-link span, .uname { display: none; }
  .content { padding: 16px 14px 50px; }
  .form-grid, .f-pair.full { grid-template-columns: 1fr; }
  .sched-day { grid-template-columns: 1fr; }
  .appt-head { grid-template-columns: 1fr; }
}
