/* Design tokens */
:root {
  --ink: #10262b;
  --ink-2: #3d555b;
  --mute: #6b8086;
  --paper: #f3f7f6;
  --surface: #ffffff;
  --line: #d9e4e2;
  --brand: #0a6a6f;
  --brand-dark: #06383c;
  --brand-soft: #e2f3f0;
  --mint: #34e0a1;
  --coral: #d9442f;
  --coral-soft: #fdecea;
  --amber: #f2b134;
  --ok: #0d8a5f;
  --ok-soft: #e1f6ee;
  --r: 10px;
  --font: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, system-ui, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.65;
  color: var(--ink); background: var(--paper); min-height: 100vh;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(2rem, 5.2vw, 3.4rem); line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); line-height: 1.3; font-weight: 700; }
h3 { font-size: 1.1rem; font-weight: 600; }
a { color: var(--brand); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; border-radius: 6px; }
.wrap { width: 100%; max-width: 1120px; margin-inline: auto; padding-inline: 20px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: var(--r); border: 1.5px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: #085a5f; }
.btn-mint { background: var(--mint); color: var(--brand-dark); }
.btn-mint:hover { background: #5beab8; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--coral-soft); color: var(--coral); border-color: #f4c5bf; }
.btn-danger:hover { background: #fadbd6; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .9rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.on-dark.btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
.on-dark.btn-ghost:hover { border-color: var(--mint); color: var(--mint); }

/* Header */
.site-header { position: sticky; top: 0; z-index: 20; background: rgba(243, 247, 246, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.15rem; color: var(--ink); text-decoration: none; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--brand); display: grid; place-items: center; }
.brand-mark svg { width: 22px; height: 22px; }
.nav { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.nav a:not(.btn), .nav button.link { color: var(--ink-2); text-decoration: none; padding: 8px 12px; border-radius: 8px; font-weight: 500; background: none; border: 0; font: inherit; cursor: pointer; }
.nav a:not(.btn):hover, .nav button.link:hover { background: var(--brand-soft); color: var(--brand); }
@media (max-width: 640px) { .nav .hide-sm { display: none; } }

/* Hero */
.hero { position: relative; background: var(--brand-dark); color: #fff; overflow: hidden; }
.hero .wrap { position: relative; z-index: 2; padding-block: clamp(56px, 11vw, 120px) clamp(120px, 18vw, 190px); }
.hero h1 { max-width: 16ch; }
.hero p.lead { margin-top: 18px; max-width: 46ch; font-size: 1.15rem; color: #c8e3e0; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 34px 0 0; padding: 0; list-style: none; color: #a9cfcb; font-size: .95rem; }
.facts li { display: flex; align-items: center; gap: 8px; }
.facts li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); flex: none; }

/* ECG line: the signature element */
.ecg { position: absolute; inset-inline: 0; overflow: hidden; direction: ltr; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.ecg svg { display: block; height: 100%; width: auto; max-width: none; animation: ecg-run var(--speed, 3.2s) linear infinite; }
.ecg path { fill: none; stroke: var(--ecg-color, var(--mint)); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.hero .ecg { bottom: 0; height: 130px; --ecg-color: var(--mint); }
@keyframes ecg-run { to { transform: translateX(-5%); } }

/* Sections */
.section { padding-block: clamp(48px, 8vw, 88px); }
.section-head { margin-bottom: 28px; }
.section-head p { color: var(--ink-2); margin-top: 8px; max-width: 60ch; }
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.doc-card { display: flex; flex-direction: column; gap: 14px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; font-size: 1.2rem; }
.doc-card .meta { color: var(--ink-2); font-size: .95rem; }
.doc-card .btn { margin-top: auto; }
.steps { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); counter-reset: s; padding: 0; margin: 0; list-style: none; }
.steps li { counter-increment: s; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.steps li::before { content: counter(s); display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; margin-bottom: 12px; }
.steps p { color: var(--ink-2); margin-top: 6px; }
.footer { background: var(--brand-dark); color: #a9cfcb; padding-block: 34px; font-size: .95rem; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 12px 24px; justify-content: space-between; align-items: center; }
.footer a { color: #a9cfcb; }
.empty { color: var(--mute); padding: 26px; text-align: center; border: 1.5px dashed var(--line); border-radius: 14px; background: var(--surface); }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label { font-weight: 600; font-size: .95rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; font: inherit; color: var(--ink);
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--r);
}
textarea.input { min-height: 84px; resize: vertical; }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(10, 106, 111, .18); }
.hint { color: var(--mute); font-size: .85rem; }
.form-error { background: var(--coral-soft); color: #a3301f; border: 1px solid #f4c5bf; border-radius: var(--r); padding: 10px 14px; margin-bottom: 14px; font-size: .95rem; }
.form-ok { background: var(--ok-soft); color: #0a6b49; border: 1px solid #b7e6d3; border-radius: var(--r); padding: 10px 14px; margin-bottom: 14px; }
.row { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .row { grid-template-columns: 1fr; } }

/* Tabs */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--paper); border-radius: 12px; margin-bottom: 22px; }
.tab { flex: 1; min-height: 42px; border: 0; background: transparent; border-radius: 9px; font: inherit; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tab[aria-selected="true"] { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(16, 38, 43, .12); }

/* Auth pages with animated backgrounds */
.auth { position: relative; min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; overflow: hidden; isolation: isolate; }
.auth-card { position: relative; z-index: 2; width: 100%; max-width: 440px; background: #fff; border-radius: 18px; padding: 30px 26px; box-shadow: 0 24px 60px rgba(0, 0, 0, .35); }
.auth-card .brand { margin-bottom: 18px; }
.auth-card h1 { font-size: 1.6rem; margin-bottom: 4px; }
.auth-card .sub { color: var(--ink-2); margin-bottom: 20px; }
.auth-top { position: absolute; top: 14px; inset-inline: 16px; z-index: 3; display: flex; justify-content: space-between; align-items: center; }
.auth-top a, .auth-top button { color: #d4ece8; background: none; border: 0; font: inherit; cursor: pointer; text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.auth-top a:hover, .auth-top button:hover { background: rgba(255, 255, 255, .12); }

/* customer: deep teal, ECG traces and drifting rings */
.bg-care { background: radial-gradient(ellipse at 20% 10%, #0d5258 0%, var(--brand-dark) 55%, #031f22 100%); }
.bg-care .ecg { height: 120px; opacity: .55; }
.bg-care .ecg.l1 { top: 12%; --speed: 4.2s; --ecg-color: var(--mint); }
.bg-care .ecg.l2 { top: 46%; --speed: 6s; opacity: .28; --ecg-color: #7ff0cb; }
.bg-care .ecg.l3 { bottom: 6%; --speed: 3.4s; opacity: .45; --ecg-color: var(--mint); }
.ring { position: absolute; border-radius: 50%; border: 2px solid rgba(52, 224, 161, .22); animation: drift 14s ease-in-out infinite alternate; z-index: 0; }
.ring.r1 { width: 320px; height: 320px; inset-inline-start: -90px; top: 30%; }
.ring.r2 { width: 220px; height: 220px; inset-inline-end: -40px; top: 8%; animation-duration: 18s; animation-delay: -4s; }
.ring.r3 { width: 140px; height: 140px; inset-inline-end: 14%; bottom: 10%; animation-duration: 11s; animation-delay: -7s; border-color: rgba(255, 255, 255, .14); }
@keyframes drift { from { transform: translate(0, 0) scale(1); } to { transform: translate(26px, -34px) scale(1.12); } }

/* admin: ink navy, scrolling grid and an amber monitor trace */
.bg-admin { background: #0b1220; }
.bg-admin::before { content: ''; position: absolute; inset: -60px; z-index: 0;
  background-image: linear-gradient(rgba(242, 177, 52, .08) 1px, transparent 1px), linear-gradient(90deg, rgba(242, 177, 52, .08) 1px, transparent 1px);
  background-size: 48px 48px; animation: grid-move 18s linear infinite; }
.bg-admin::after { content: ''; position: absolute; inset-inline: 0; height: 160px; top: -160px; z-index: 0;
  background: linear-gradient(180deg, transparent, rgba(242, 177, 52, .10), transparent); animation: scan 9s linear infinite; }
.bg-admin .ecg { top: 50%; height: 120px; transform: translateY(-50%); opacity: .5; --ecg-color: var(--amber); --speed: 3.6s; }
@keyframes grid-move { to { transform: translate(48px, 48px); } }
@keyframes scan { to { transform: translateY(calc(100vh + 320px)); } }
.badge-staff { display: inline-block; font-size: .8rem; font-weight: 600; background: #fff4d9; color: #7a5300; border-radius: 99px; padding: 2px 12px; margin-bottom: 10px; }

/* Booking page */
.page-title { padding-block: 34px 8px; }
.layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; padding-bottom: 60px; }
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }
.layout > * { min-width: 0; }
.step-title { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-title span { width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: .9rem; font-weight: 700; flex: none; }
.block { margin-bottom: 26px; }
.docs { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; text-align: start; font: inherit; color: inherit; width: 100%; }
.opt:hover { border-color: var(--brand); }
.opt[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.opt .avatar { width: 42px; height: 42px; font-size: 1rem; }
.opt small { color: var(--ink-2); display: block; }
.days { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; scrollbar-width: thin; }
.day { flex: none; min-width: 68px; padding: 8px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; text-align: center; cursor: pointer; font: inherit; color: inherit; }
.day b { display: block; font-size: 1.2rem; line-height: 1.2; }
.day small { color: var(--ink-2); font-size: .8rem; }
.day[aria-pressed="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.day[aria-pressed="true"] small { color: #cfeeea; }
.slots { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.slot { min-height: 42px; border: 1.5px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; color: var(--ink); }
.slot:hover { border-color: var(--brand); }
.slot[aria-pressed="true"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.summary { background: var(--brand-soft); border-radius: 12px; padding: 14px 16px; margin: 4px 0 16px; color: var(--brand-dark); font-weight: 500; }
.appt { display: flex; flex-direction: column; gap: 6px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.appt:last-child { border-bottom: 0; }
.appt .top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.badge { display: inline-block; font-size: .8rem; font-weight: 600; padding: 2px 10px; border-radius: 99px; white-space: nowrap; }
.badge.confirmed { background: var(--ok-soft); color: #0a6b49; }
.badge.cancelled { background: var(--coral-soft); color: #a3301f; }
.badge.past { background: #eceff0; color: var(--ink-2); }
.muted { color: var(--ink-2); font-size: .95rem; }
.success { text-align: center; padding: 10px 0; }
.success .tick { width: 60px; height: 60px; border-radius: 50%; background: var(--ok); margin: 0 auto 14px; display: grid; place-items: center; animation: pop .35s ease-out; }
.success .tick svg { width: 30px; height: 30px; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* Admin dashboard */
.admin-bar { background: #0b1220; color: #fff; }
.admin-bar .wrap { display: flex; align-items: center; gap: 14px; min-height: 62px; }
.admin-bar .brand { color: #fff; }
.admin-bar .nav button, .admin-bar .nav a { color: #d6dbe6; }
.stats { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-block: 24px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.stat b { display: block; font-size: 2rem; line-height: 1.1; color: var(--brand); }
.stat span { color: var(--ink-2); font-size: .92rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-bottom: 16px; }
.toolbar .field { margin: 0; min-width: 150px; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: #f7faf9; font-size: .9rem; color: var(--ink-2); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
.admin-tabs { margin-top: 6px; max-width: 360px; }
.doc-admin { margin-bottom: 18px; }
.doc-admin summary { cursor: pointer; display: flex; align-items: center; gap: 12px; list-style: none; }
.doc-admin summary::-webkit-details-marker { display: none; }
.doc-admin .body { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.week { display: grid; gap: 10px; margin-bottom: 14px; }
.day-row { display: grid; grid-template-columns: 110px 1fr; gap: 10px; align-items: start; padding: 8px 0; border-bottom: 1px dashed var(--line); }
@media (max-width: 520px) { .day-row { grid-template-columns: 1fr; } }
.periods { display: flex; flex-direction: column; gap: 8px; }
.period { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.period .input { width: 130px; min-height: 38px; padding: 4px 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-block: 10px; }
.chip { display: inline-flex; align-items: center; gap: 8px; background: #fff4d9; color: #7a5300; border-radius: 99px; padding: 4px 6px 4px 14px; font-size: .9rem; }
.chip button { border: 0; background: rgba(0, 0, 0, .08); border-radius: 50%; width: 22px; height: 22px; cursor: pointer; line-height: 1; }
[dir="rtl"] .chip { padding: 4px 14px 4px 6px; }
.inactive-tag { background: #eceff0; color: var(--ink-2); }

/* Toast */
.toast { position: fixed; inset-inline: 16px; bottom: 20px; margin-inline: auto; max-width: 420px; z-index: 50; padding: 12px 16px; border-radius: 12px; color: #fff; background: var(--ink); box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: pop .2s ease-out; }
.toast.err { background: var(--coral); }
.toast.ok { background: var(--ok); }

.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; margin: 18px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .ecg svg, .ring, .bg-admin::before, .bg-admin::after, .success .tick, .spinner { animation: none !important; }
}
.btn-block { width: 100%; }
.footer-space { height: 60px; }

/* Refinements */
.page-title h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.site-header .wrap, .admin-bar .wrap { flex-wrap: nowrap; }
.brand { white-space: nowrap; }
@media (max-width: 640px) {
  .site-header .wrap, .admin-bar .wrap { gap: 8px; }
  .nav { flex-wrap: nowrap; gap: 2px; }
  .nav a:not(.btn), .nav button.link { padding: 6px 8px; font-size: .92rem; }
  .brand { font-size: 1rem; }
  .admin-bar .badge-staff { display: none; }
}
