:root {
    --ink: #08131f;
    --ink-soft: #24384c;
    --navy-900: #04101d;
    --navy-800: #071c31;
    --blue-800: #0a2f5e;
    --blue-700: #0d3f80;
    --blue-600: #1058b8;
    --blue-500: #1f7bff;
    --blue-400: #4d97ff;
    --blue-100: #e7f1ff;
    --cyan-400: #22d3ee;
    --gold-500: #ffb020;
    --gold-400: #ffc74d;
    --gold-600: #f59300;
    --violet-500: #6d3bff;
    --grey-500: #7d8fa3;
    --muted: #5b6f83;
    --bg: #eef4fd;
    --card: #ffffff;
    --line: #e2ebf7;
    --red: #e02424;
    --green: #0f9d70;
    --amber: #c97a00;
    --radius: 24px;
    --radius-sm: 16px;
    --shadow: 0 18px 40px -18px rgba(10, 47, 94, 0.35), 0 2px 6px rgba(10, 47, 94, 0.06);
    --shadow-bold: 0 26px 60px -24px rgba(10, 47, 94, 0.55);
    --font: "SF Arabic", "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { background: #e9f1fc; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

body {
    background:
        radial-gradient(900px 480px at 100% -8%, rgba(31, 123, 255, 0.20), transparent 60%),
        radial-gradient(700px 420px at 0% 8%, rgba(34, 211, 238, 0.16), transparent 60%),
        radial-gradient(600px 380px at 50% 104%, rgba(255, 176, 32, 0.12), transparent 62%),
        linear-gradient(180deg, #f6faff 0%, #eaf2fd 55%, #e6eefb 100%);
    background-attachment: fixed;
    overscroll-behavior-y: none;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--blue-600); }

/* ---------- shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.appbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: calc(13px + env(safe-area-inset-top)) 16px 15px;
    background:
        radial-gradient(420px 160px at 88% -40%, rgba(255, 176, 32, 0.55), transparent 70%),
        radial-gradient(380px 200px at 6% 140%, rgba(34, 211, 238, 0.35), transparent 70%),
        linear-gradient(135deg, #04101d 0%, #0a2f5e 52%, #1058b8 100%);
    color: #fff;
    box-shadow: 0 14px 30px -14px rgba(4, 16, 29, 0.7);
    overflow: hidden;
}
.appbar::after {
    content: "";
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-500), var(--cyan-400), var(--violet-500), var(--gold-500));
    background-size: 300% 100%;
    animation: shift 9s linear infinite;
}
@keyframes shift { to { background-position: 300% 0; } }

.appbar-logo {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: #fff;
    padding: 4px;
    object-fit: contain;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35), 0 0 0 2px rgba(255, 255, 255, 0.18);
}
.appbar-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.appbar-title { font-size: 16.5px; font-weight: 800; letter-spacing: -0.2px; }
.appbar-sub { font-size: 11.5px; color: rgba(255, 255, 255, 0.75); }

.view {
    flex: 1;
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 18px 14px calc(104px + env(safe-area-inset-bottom));
}

.tabbar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 30;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
    background: rgba(4, 16, 29, 0.92);
    backdrop-filter: blur(16px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -14px 30px -18px rgba(4, 16, 29, 0.9);
}
.tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px 6px;
    border: none;
    background: none;
    border-radius: 16px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 11.5px;
    font-weight: 700;
    text-decoration: none;
    transition: color 0.18s ease, background 0.18s ease;
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.9; }
.tab.is-on {
    color: #fff;
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500) 60%, var(--cyan-400));
    box-shadow: 0 10px 24px -10px rgba(31, 123, 255, 0.9);
}
.tab-badge {
    position: absolute;
    top: 2px;
    inset-inline-end: 18%;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--gold-500);
    color: #20160a;
    font-size: 10px;
    font-weight: 800;
    display: grid;
    place-items: center;
}

/* ---------- generic ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack > * { animation: rise 0.42s cubic-bezier(0.2, 0.7, 0.3, 1) both; }
.stack > *:nth-child(2) { animation-delay: 0.05s; }
.stack > *:nth-child(3) { animation-delay: 0.1s; }
.stack > *:nth-child(4) { animation-delay: 0.14s; }
.stack > *:nth-child(5) { animation-delay: 0.18s; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
    .stack > * { animation: none; }
    .appbar::after, .call { animation: none; }
}

.card {
    position: relative;
    background: var(--card);
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid rgba(16, 88, 184, 0.09);
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.h2 { font-size: 19px; font-weight: 800; letter-spacing: -0.3px; }
.h2::before {
    content: "";
    display: inline-block;
    width: 5px;
    height: 17px;
    margin-inline-end: 8px;
    border-radius: 4px;
    vertical-align: -2px;
    background: linear-gradient(180deg, var(--blue-500), var(--cyan-400));
}
.h3 { font-size: 15.5px; font-weight: 800; }
.sub { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.hint { font-size: 11.5px; color: var(--muted); margin-top: 9px; }
.muted { font-size: 12.5px; color: var(--muted); }
.empty { font-size: 13px; color: var(--muted); padding: 14px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.spacer { flex: 1; }
.wide { grid-column: 1 / -1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 48px;
    padding: 0 18px;
    border: 1px solid rgba(16, 88, 184, 0.16);
    border-radius: 16px;
    background: #fff;
    color: var(--ink);
    font-size: 14px;
    font-weight: 800;
    text-decoration: none;
    transition: transform 0.1s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.btn:active { transform: scale(0.975); }
.btn-primary {
    background: linear-gradient(135deg, var(--gold-500) 0%, var(--gold-600) 100%);
    border-color: transparent;
    color: #241704;
    box-shadow: 0 16px 32px -14px rgba(245, 147, 0, 0.85);
}
.btn-primary:active { filter: brightness(0.97); }
.btn-soft {
    background: linear-gradient(135deg, var(--blue-600), var(--blue-500));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 14px 28px -14px rgba(31, 123, 255, 0.85);
}
.btn-ghost { background: transparent; border-color: transparent; color: var(--blue-600); }
.btn-sm { min-height: 38px; padding: 0 13px; font-size: 12.5px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.45; box-shadow: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
    min-height: 40px;
    padding: 0 15px;
    border-radius: 999px;
    border: 1.5px solid rgba(16, 88, 184, 0.16);
    background: #fff;
    color: var(--ink-soft);
    font-size: 13px;
    font-weight: 700;
    transition: transform 0.1s ease;
}
.chip:active { transform: scale(0.97); }
.chip.is-on {
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 12px 26px -12px rgba(31, 123, 255, 0.95);
}

.slots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.slot {
    min-height: 46px;
    border-radius: 14px;
    border: 1.5px solid rgba(16, 88, 184, 0.16);
    background: #fff;
    font-size: 13px;
    font-weight: 700;
}
.slot.is-on {
    background: linear-gradient(135deg, var(--blue-700), var(--blue-500));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 12px 26px -12px rgba(31, 123, 255, 0.95);
}
.slot:disabled { color: #b3c3d4; text-decoration: line-through; background: #f3f7fc; }

.field { display: flex; flex-direction: column; gap: 7px; }
.label { font-size: 12.5px; font-weight: 800; color: var(--ink-soft); }
.input, .select, .textarea {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1.5px solid rgba(16, 88, 184, 0.14);
    border-radius: 15px;
    background: #fbfdff;
    font-size: 15px;
    font-weight: 600;
}
.textarea { min-height: 88px; resize: vertical; line-height: 1.6; font-weight: 500; }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(31, 123, 255, 0.14);
}

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat {
    background: linear-gradient(160deg, #f7fbff, #eaf3ff);
    border: 1px solid rgba(16, 88, 184, 0.1);
    border-radius: 18px;
    padding: 13px 14px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.stat span { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat strong.is-due { color: var(--red); }

.pill { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px; background: #eef3f9; color: var(--muted); }
.pill-booked { background: #eaf1fb; color: #46628a; }
.pill-arrived { background: #fff3d6; color: var(--amber); }
.pill-in { background: #e4efff; color: var(--blue-600); }
.pill-seen { background: #dff7ec; color: var(--green); }
.pill-cancelled { background: #fde8e8; color: var(--red); }

.list { display: flex; flex-direction: column; }
.list-row { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: none; }
.grow { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }

.num {
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 14px;
    background: linear-gradient(150deg, var(--blue-700), var(--blue-500));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 10px 20px -12px rgba(31, 123, 255, 0.95);
}
.name-btn { background: none; border: none; padding: 0; font-weight: 800; font-size: 15px; color: var(--blue-700); text-align: start; }
.name-btn:active { opacity: 0.7; }

.search {
    width: 100%;
    min-height: 46px;
    padding: 10px 14px;
    border: 1.5px solid rgba(16, 88, 184, 0.14);
    border-radius: 15px;
    background: #fbfdff;
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 4px;
}

.badge { font-size: 11px; font-weight: 800; background: var(--gold-500); color: #241704; border-radius: 999px; padding: 4px 11px; }

/* ---------- patient ---------- */
.hero {
    position: relative;
    border-radius: 26px;
    padding: 20px;
    color: #fff;
    overflow: hidden;
    background:
        radial-gradient(360px 200px at 92% -10%, rgba(255, 176, 32, 0.5), transparent 70%),
        radial-gradient(320px 220px at 6% 120%, rgba(34, 211, 238, 0.45), transparent 70%),
        linear-gradient(140deg, #04101d 0%, #0a2f5e 48%, #1058b8 100%);
    box-shadow: var(--shadow-bold);
}
.hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    inset-inline-start: -70px;
    top: -90px;
    background: radial-gradient(circle, rgba(109, 59, 255, 0.45), transparent 65%);
}
.hero-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: relative; }
.hero h2 { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.hero h2::before { display: none; }
.hero p { font-size: 12.5px; color: rgba(255, 255, 255, 0.78); margin-top: 3px; }
.hero-numbers { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 16px; position: relative; }
.hero-num {
    background: rgba(255, 255, 255, 0.11);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 18px;
    padding: 12px 14px;
    backdrop-filter: blur(6px);
}
.hero-num span { font-size: 11.5px; color: rgba(255, 255, 255, 0.82); display: block; font-weight: 600; }
.hero-num strong {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -1.5px;
    background: linear-gradient(120deg, #ffffff 20%, var(--gold-400) 90%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-note { font-size: 11.5px; color: rgba(255, 255, 255, 0.82); margin-top: 12px; position: relative; }

.confirm {
    position: relative;
    border-radius: 26px;
    padding: 18px;
    color: #fff;
    display: flex;
    gap: 14px;
    align-items: center;
    overflow: hidden;
    background:
        radial-gradient(280px 160px at 100% 0%, rgba(255, 199, 77, 0.55), transparent 70%),
        linear-gradient(135deg, #0a2f5e, #1058b8 65%, #1f7bff);
    box-shadow: var(--shadow-bold);
    animation: pop 0.45s cubic-bezier(0.2, 0.8, 0.3, 1.1) both;
}
@keyframes pop { from { opacity: 0; transform: scale(0.96) translateY(8px); } to { opacity: 1; transform: none; } }
.confirm-num {
    min-width: 76px;
    padding: 12px;
    border-radius: 20px;
    background: linear-gradient(140deg, var(--gold-400), var(--gold-600));
    color: #241704;
    text-align: center;
    font-size: 40px;
    font-weight: 800;
    line-height: 1.05;
    box-shadow: 0 16px 30px -14px rgba(245, 147, 0, 0.9);
}
.confirm-body { display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; color: rgba(255, 255, 255, 0.88); }
.confirm-body strong { font-size: 17px; color: #fff; }
.confirm-code { font-size: 13px; letter-spacing: 0.6px; color: var(--gold-400); font-weight: 800; }

.result {
    margin-top: 12px;
    padding: 14px;
    border-radius: 18px;
    background: linear-gradient(150deg, #eaf3ff, #f7fbff);
    border: 1px solid rgba(16, 88, 184, 0.12);
    font-size: 13.5px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.result.is-bad { background: #fdecec; border-color: #f8d4d4; }

/* ---------- secretary ---------- */
.case { display: grid; grid-template-columns: auto 1fr; gap: 11px; padding: 14px 0; border-top: 1px solid var(--line); }
.case:first-child { border-top: none; }
.case-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.case-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.case-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 7px; }
.done { font-size: 12px; background: #f2f7fd; border-radius: 10px; padding: 5px 10px; align-self: flex-start; }
.pay { font-size: 12px; font-weight: 800; }
.pay.is-due { color: var(--red); }
.pay.is-ok { color: var(--green); }

.visit {
    grid-column: 1 / -1;
    background: linear-gradient(160deg, #f4f9ff, #eaf3ff);
    border: 1px solid rgba(16, 88, 184, 0.14);
    border-radius: 18px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 11px;
}
.visit-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.due-box { display: flex; flex-direction: column; gap: 2px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.due-box strong { font-size: 18px; color: var(--ink); font-weight: 800; }

.account { display: flex; flex-direction: column; }
.account > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.account dt { color: var(--muted); font-weight: 600; }
.account dd { font-weight: 800; }
.account > div.is-strong { border-bottom: none; font-size: 16px; padding-top: 13px; }
.account > div.is-strong dt { color: var(--ink); font-weight: 800; }

.quote {
    background: linear-gradient(150deg, #f4f9ff, #eaf3ff);
    border-inline-start: 4px solid var(--blue-500);
    border-radius: 14px;
    padding: 14px;
    font-size: 13.5px;
    line-height: 1.8;
    margin-bottom: 10px;
}

/* ---------- doctor ---------- */
.call {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background:
        radial-gradient(220px 120px at 100% 0%, rgba(255, 199, 77, 0.7), transparent 70%),
        linear-gradient(135deg, #241704, #4a2f06 55%, #7a4d05);
    color: #fff;
    border-radius: 20px;
    padding: 15px 17px;
    box-shadow: var(--shadow-bold);
    animation: callPulse 2.4s infinite;
}
@keyframes callPulse {
    0%, 100% { box-shadow: 0 18px 40px -20px rgba(122, 77, 5, 0.9), 0 0 0 0 rgba(255, 176, 32, 0.35); }
    50% { box-shadow: 0 18px 40px -20px rgba(122, 77, 5, 0.9), 0 0 0 10px rgba(255, 176, 32, 0); }
}
.call strong { display: block; font-size: 15px; font-weight: 800; }
.call span { font-size: 12.5px; color: rgba(255, 255, 255, 0.8); }
.call .btn-primary { background: linear-gradient(135deg, var(--gold-400), var(--gold-600)); }

.bars { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; }
.bars li { display: grid; grid-template-columns: 82px 1fr 72px; align-items: center; gap: 10px; font-size: 12.5px; }
.bars li strong { font-size: 11.5px; white-space: nowrap; }
.bar { height: 10px; background: #e9f1fb; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan-400), var(--blue-500)); border-radius: 999px; }

.services { display: flex; flex-direction: column; }
.services li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.services li:first-child { border-top: none; }
.service-name { font-size: 13.5px; font-weight: 700; }
.price-wrap { display: inline-flex; align-items: center; gap: 5px; }
.price-input { width: 76px; min-height: 40px; padding: 6px 8px; border: 1.5px solid rgba(16, 88, 184, 0.14); border-radius: 12px; text-align: center; font-size: 13.5px; font-weight: 700; background: #fbfdff; }

.toggle { width: 48px; height: 28px; border-radius: 999px; border: none; background: #dbe6f2; position: relative; padding: 0; transition: background 0.18s ease; }
.toggle span { position: absolute; top: 3px; inset-inline-start: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: inset-inline-start 0.18s ease; box-shadow: 0 2px 6px rgba(4, 16, 29, 0.25); }
.toggle.is-on { background: linear-gradient(135deg, var(--blue-600), var(--cyan-400)); }
.toggle.is-on span { inset-inline-start: 23px; }

/* ---------- patient file ---------- */
.file-card {
    border: 1.5px solid rgba(31, 123, 255, 0.35);
    box-shadow: 0 0 0 5px rgba(31, 123, 255, 0.08), var(--shadow-bold);
}
.history { display: flex; flex-direction: column; gap: 11px; margin-top: 13px; }
.history li { border-top: 1px solid var(--line); padding-top: 11px; display: flex; flex-direction: column; gap: 4px; }
.history li:first-child { border-top: none; padding-top: 0; }

/* ---------- lock ---------- */
.lock { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 15px; padding: 32px 20px; }
.lock-icon {
    width: 68px;
    height: 68px;
    border-radius: 22px;
    background: linear-gradient(150deg, var(--blue-700), var(--blue-500));
    display: grid;
    place-items: center;
    color: #fff;
    box-shadow: 0 18px 34px -16px rgba(31, 123, 255, 0.9);
}
.lock-icon svg { width: 30px; height: 30px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.pin-input { letter-spacing: 10px; text-align: center; font-size: 22px; font-weight: 800; }

/* ---------- toast ---------- */
.toast {
    position: fixed;
    inset-inline: 16px;
    bottom: calc(92px + env(safe-area-inset-bottom));
    margin: 0 auto;
    max-width: 420px;
    padding: 13px 17px;
    border-radius: 16px;
    background: rgba(4, 16, 29, 0.95);
    border: 1px solid rgba(255, 176, 32, 0.4);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 60;
    box-shadow: 0 18px 40px -18px rgba(4, 16, 29, 0.9);
}
.toast.is-on { opacity: 1; transform: translateY(0); }

/* ---------- responsive ---------- */
@media (min-width: 560px) {
    .slots { grid-template-columns: repeat(5, 1fr); }
    .stats { grid-template-columns: repeat(4, 1fr); }
    .case { grid-template-columns: auto 1fr auto; align-items: center; }
    .case-actions { grid-column: auto; justify-content: flex-end; }
    .card { padding: 20px; }
    .view { padding-inline: 20px; }
}

@media (min-width: 860px) {
    .appbar { padding-inline: 24px; }
    .view { padding-top: 22px; }
}
