:root {
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --card: rgba(255, 255, 255, .94);
    --blue: #2563eb;
    --blue-deep: #1d4ed8;
    --green: #047857;
    --red: #b91c1c;
    --amber: #b45309;
    --shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

* { font-family: "Cairo", "Segoe UI", Tahoma, sans-serif; }

html { font-size: 15px; }

body {
    min-height: 100vh;
    font-weight: 500;
    line-height: 1.65;
    color: var(--ink);
    background:
        radial-gradient(1200px 600px at 12% 0%, rgba(37, 99, 235, .22), transparent 55%),
        radial-gradient(900px 500px at 100% 10%, rgba(14, 165, 233, .18), transparent 50%),
        radial-gradient(800px 500px at 40% 100%, rgba(124, 58, 237, .12), transparent 55%),
        linear-gradient(180deg, #f8fafc 0%, #eef2ff 55%, #f8fafc 100%);
}

a { color: var(--blue-deep); text-decoration: none; }
a:hover { color: var(--blue); }

.page {
    width: min(1180px, calc(100% - 28px));
    margin: 22px auto 48px;
}

.app-nav {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
    backdrop-filter: blur(12px);
}

.nav-inner {
    width: min(1180px, calc(100% - 28px));
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    margin-inline-end: auto;
}

.brand img { height: 52px; width: auto; }
.brand strong { display: block; font-weight: 700; line-height: 1.1; }
.brand small { color: var(--muted); font-weight: 600; }

.nav-links, .nav-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.nav-links a, .tool-btn, .locale-switch button {
    border: 1px solid transparent;
    background: transparent;
    color: #334155;
    font-weight: 600;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: .92rem;
}

.nav-links a.active, .nav-links a:hover, .tool-btn:hover {
    background: #eff6ff;
    color: var(--blue-deep);
}

.locale-switch { display: flex; gap: 4px; }
.locale-switch button {
    border-color: var(--line);
    background: #fff;
    padding: 6px 10px;
}
.locale-switch button.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

.user-chip { text-align: end; line-height: 1.15; }
.user-chip strong { display: block; font-size: .92rem; }
.user-chip span { color: var(--muted); font-size: .78rem; font-weight: 600; }

.icon-btn {
    position: relative;
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 0;
    color: var(--ink);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn:hover, .icon-btn.show {
    background: #eff6ff;
    color: var(--blue-deep);
    border-color: #bfdbfe;
}

.notify-menu { min-width: 320px; }
.menu-panel { min-width: 220px; }
.menu-panel form { margin: 0; }
.menu-links, .menu-links-divider { display: none; }
.menu-user {
    padding: 8px 10px 10px;
    line-height: 1.2;
}
.menu-user strong { display: block; font-weight: 700; }
.menu-user span { color: var(--muted); font-size: .78rem; font-weight: 600; }
.menu-panel .dropdown-item {
    width: 100%;
    border: 0;
    background: transparent;
    text-align: start;
    color: var(--ink);
}
.menu-panel .dropdown-item.active,
.menu-panel .dropdown-item:hover {
    background: #eff6ff;
    color: var(--blue-deep);
}

.badge-count {
    position: absolute;
    top: -6px;
    inset-inline-start: -6px;
    background: #dc2626;
    color: #fff;
    border-radius: 999px;
    min-width: 18px;
    height: 18px;
    font-size: .7rem;
    display: grid;
    place-items: center;
    padding: 0 4px;
}

.dropdown-menu {
    border-radius: 14px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    min-width: 320px;
    padding: 8px;
}

.dropdown-item {
    border-radius: 10px;
    font-weight: 500;
    white-space: normal;
    padding: 8px 10px;
}

.dropdown-item.unread { background: #eff6ff; }

.card-panel, .auth-card {
    background: var(--card);
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.card-panel { padding: 18px; margin-bottom: 16px; }
.card-panel h2, .section-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin: 0 0 14px;
}

.page-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.page-head h1 { font-weight: 700; font-size: 1.35rem; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); font-weight: 500; }
.page-head p strong { color: var(--ink); font-weight: 700; }

.btn-primary {
    background: linear-gradient(135deg, var(--blue), var(--blue-deep));
    border: none;
    border-radius: 12px;
    font-weight: 600;
    padding: 10px 14px;
    box-shadow: 0 10px 22px rgba(37, 99, 235, .2);
}

.btn-primary:hover { opacity: .96; background: linear-gradient(135deg, var(--blue), var(--blue-deep)); }

.btn-soft, .btn-outline-secondary {
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    background: #fff;
    color: #334155;
}

.row-actions { display: flex; gap: 8px; align-items: stretch; width: 100%; }
.row-actions .btn { flex: 1 1 0; text-align: center; }
.btn-compact { padding: 6px 12px; border-radius: 10px; font-size: .82rem; white-space: nowrap; line-height: 1.4; }
.row-actions form { margin: 0; flex: 1 1 0; display: flex; }
.row-actions form .btn { width: 100%; }
.btn-text-danger {
    background: none;
    border: none;
    padding: 0;
    color: var(--red);
    font-weight: 700;
}
.btn-text-danger:hover { color: #991b1b; }

.btn-danger-soft {
    border-radius: 12px;
    font-weight: 600;
    border: 1px solid #fecaca;
    background: #fff;
    color: var(--red);
}

.form-label { font-weight: 600; color: #334155; margin-bottom: 6px; }
.form-control, .form-select {
    border-radius: 12px;
    border: 1px solid #cbd5e1;
    font-weight: 500;
    padding: 10px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: rgba(37, 99, 235, .55);
    box-shadow: 0 0 0 .2rem rgba(37, 99, 235, .15);
}
.hint { color: var(--muted); font-size: .82rem; font-weight: 500; margin-top: 6px; }
.field-error { color: var(--red); font-weight: 600; font-size: .82rem; margin-top: 4px; }

.stat-grid, .detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}
.stat-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat {
    display: block;
    padding: 16px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line);
    color: var(--ink);
}
.stat b { display: block; font-size: 1.6rem; font-weight: 700; }
.stat span { color: var(--muted); font-weight: 600; font-size: .86rem; }
.stat.blue { background: linear-gradient(180deg, #eff6ff, #fff); }
.stat.amber { background: linear-gradient(180deg, #fffbeb, #fff); }
.stat.green { background: linear-gradient(180deg, #ecfdf5, #fff); }
.stat.is-selected { border-color: #93c5fd; box-shadow: 0 0 0 3px #dbeafe; }
.stat-grid.activity-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
button.stat {
    width: 100%;
    text-align: inherit;
    cursor: pointer;
    font: inherit;
    color: inherit;
}
.live-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    margin-inline-end: 6px;
    border-radius: 50%;
    background: #16a34a;
    box-shadow: 0 0 0 4px #dcfce7;
    vertical-align: middle;
}
.online-modal { border: none; border-radius: 18px; }
.online-modal .modal-header { align-items: flex-start; border-bottom: 1px solid var(--line); }
.online-modal h2 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.online-modal .modal-header p { margin: 4px 0 0; color: var(--muted); font-size: .82rem; font-weight: 600; }
.online-person {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.online-person:last-child { border-bottom: none; }
.online-person .meta, .online-state .meta { color: var(--muted); font-size: .78rem; font-weight: 600; }
.online-state { text-align: end; }
.activity-last {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #047857;
    border-radius: 14px;
    padding: 10px 14px;
    font-weight: 600;
    margin-bottom: 14px;
}

.table { --bs-table-bg: transparent; }
.table thead th { color: var(--muted); font-size: .82rem; font-weight: 600; }
.table td { font-weight: 500; vertical-align: middle; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 600; direction: ltr; unicode-bidi: isolate; }

.status-badge, .role-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .78rem;
    font-weight: 700;
    background: #e2e8f0;
    color: #334155;
}
.tone-blue { background: #dbeafe; color: #1d4ed8; }
.tone-green { background: #d1fae5; color: #047857; }
.tone-red { background: #fee2e2; color: #b91c1c; }
.tone-amber { background: #fef3c7; color: #b45309; }
.tone-slate { background: #e2e8f0; color: #334155; }

.stepper {
    list-style: none;
    display: flex;
    gap: 8px;
    padding: 0;
    margin: 0 0 16px;
    overflow-x: auto;
}
.stepper li {
    flex: 1 0 auto;
    min-width: 110px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px 10px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--muted);
}
.stepper li.is-current { background: #eff6ff; color: var(--blue-deep); border-color: #bfdbfe; }
.stepper li.is-done { background: #ecfdf5; color: var(--green); border-color: #a7f3d0; }
.stepper li.is-stopped { background: #fef2f2; color: var(--red); border-color: #fecaca; }

.layout-show {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 16px;
    align-items: start;
}

.detail span { display: block; color: var(--muted); font-size: .78rem; font-weight: 600; }
.detail p { margin: 2px 0 12px; font-weight: 600; white-space: pre-wrap; }

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.panel-head .panel-title { margin: 0; }
.panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
}
.panel-title::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--pip, var(--blue));
    box-shadow: 0 0 0 4px var(--pip-ring, #dbeafe);
    flex: 0 0 auto;
}
.pip-blue { --pip: #2563eb; --pip-ring: #dbeafe; }
.pip-cyan { --pip: #0891b2; --pip-ring: #cffafe; }
.pip-violet { --pip: #7c3aed; --pip-ring: #ede9fe; }
.pip-green { --pip: #059669; --pip-ring: #d1fae5; }

.fact-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.fact {
    min-width: 0;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 10px 12px;
}
.fact.is-wide,
.fact-grid .fact:last-child:nth-child(odd) { grid-column: 1 / -1; }
.fact span { display: block; color: var(--muted); font-size: .76rem; font-weight: 700; margin-bottom: 3px; }
.fact p { margin: 0; font-weight: 700; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.fact.is-empty p { color: #94a3b8; font-weight: 600; }
.panel-foot {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed #e2e8f0;
    color: var(--muted);
    font-size: .82rem;
    font-weight: 600;
}

.price-hero {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    color: #fff;
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 12px;
}
.price-hero span { display: block; font-weight: 700; opacity: .85; font-size: .82rem; }
.price-hero strong { font-size: 1.5rem; font-weight: 700; direction: ltr; unicode-bidi: isolate; }

.choice {
    display: flex;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #fff;
    font-weight: 600;
    cursor: pointer;
}
.choice:has(input:checked) { border-color: #93c5fd; background: #eff6ff; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li {
    display: grid;
    grid-template-columns: 28px minmax(0, 1fr);
    column-gap: 12px;
}
.flow-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.flow-dot {
    width: 14px;
    height: 14px;
    margin-top: 18px;
    border-radius: 50%;
    background: var(--flow);
    box-shadow: 0 0 0 5px var(--flow-ring);
    flex: 0 0 auto;
}
.flow-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--flow);
    min-height: 22px;
}
.flow-link::before {
    content: "";
    width: 2px;
    flex: 1;
    min-height: 8px;
    margin-top: 4px;
    border-radius: 2px;
    background: currentColor;
    opacity: .4;
}
.flow-link svg { flex: 0 0 auto; margin: 2px 0 4px; }
.flow-card {
    background: var(--flow-wash);
    border: 1px solid var(--flow-line);
    border-inline-start: 4px solid var(--flow);
    border-radius: 16px;
    padding: 12px 14px;
    margin-bottom: 8px;
}
.flow-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}
.flow-card strong { display: block; font-weight: 700; line-height: 1.4; }
.flow-card .meta { color: var(--muted); font-size: .8rem; font-weight: 500; margin-top: 2px; }
.flow-card .notes {
    margin: 8px 0 0;
    padding-top: 8px;
    border-top: 1px dashed var(--flow-line);
    font-weight: 600;
    white-space: pre-wrap;
}
.flow-amount, .flow-extra {
    display: inline-block;
    margin-top: 8px;
    background: #fff;
    border: 1px solid var(--flow-line);
    border-radius: 999px;
    padding: 2px 10px;
    font-weight: 700;
    font-size: .85rem;
    color: var(--flow);
}
.flow-extra { border-radius: 10px; color: var(--ink); font-weight: 600; }
.flow-created { --flow: #64748b; --flow-wash: #f8fafc; --flow-ring: #e2e8f0; --flow-line: #e2e8f0; }
.flow-submit { --flow: #2563eb; --flow-wash: #eff6ff; --flow-ring: #dbeafe; --flow-line: #bfdbfe; }
.flow-price { --flow: #7c3aed; --flow-wash: #f5f3ff; --flow-ring: #ede9fe; --flow-line: #ddd6fe; }
.flow-payer_approve { --flow: #059669; --flow-wash: #ecfdf5; --flow-ring: #d1fae5; --flow-line: #a7f3d0; }
.flow-payer_reject { --flow: #d97706; --flow-wash: #fffbeb; --flow-ring: #fef3c7; --flow-line: #fde68a; }
.flow-supplies_available { --flow: #0891b2; --flow-wash: #ecfeff; --flow-ring: #cffafe; --flow-line: #a5f3fc; }
.flow-supplies_unavailable { --flow: #dc2626; --flow-wash: #fef2f2; --flow-ring: #fee2e2; --flow-line: #fecaca; }
.flow-preop_approve { --flow: #4f46e5; --flow-wash: #eef2ff; --flow-ring: #e0e7ff; --flow-line: #c7d2fe; }
.flow-preop_reject { --flow: #e11d48; --flow-wash: #fff1f2; --flow-ring: #ffe4e6; --flow-line: #fecdd3; }
.flow-schedule { --flow: #ea580c; --flow-wash: #fff7ed; --flow-ring: #ffedd5; --flow-line: #fed7aa; }
.flow-patient_accept { --flow: #15803d; --flow-wash: #f0fdf4; --flow-ring: #dcfce7; --flow-line: #bbf7d0; }
.flow-patient_reschedule { --flow: #ca8a04; --flow-wash: #fefce8; --flow-ring: #fef9c3; --flow-line: #fde047; }
.flow-amend { --flow: #be185d; --flow-wash: #fdf2f8; --flow-ring: #fce7f3; --flow-line: #fbcfe8; }
.flow-card .notes.was {
    color: var(--muted);
    font-weight: 500;
    margin-top: 8px;
    border-top: none;
    padding-top: 0;
}
.amend-box {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--line);
}
.amend-box h3 { font-size: .98rem; font-weight: 700; margin: 0 0 6px; }

.file-list { display: flex; flex-direction: column; gap: 10px; }
.file-item {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 8px;
    background: #fff;
}
.file-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }

.callout {
    background: #fffbeb;
    border: 1px solid #fde68a;
    color: #92400e;
    border-radius: 12px;
    padding: 10px 12px;
    font-weight: 600;
    margin-bottom: 12px;
}

.form-actions {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.form-actions .btn {
    min-width: 190px;
    padding: 12px 22px;
    border-radius: 14px;
}

.file-drop {
    display: block;
    cursor: pointer;
}
.file-drop input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
}
.file-drop-face {
    display: block;
    text-align: center;
    border: 1.5px dashed #93c5fd;
    background: linear-gradient(180deg, #f8fbff, #fff);
    border-radius: 16px;
    padding: 22px 16px;
}
.file-drop:hover .file-drop-face,
.file-drop:focus-within .file-drop-face {
    border-color: #2563eb;
    background: #eff6ff;
}
.file-drop-face strong {
    display: block;
    color: #1d4ed8;
    font-weight: 700;
    margin-bottom: 4px;
}
.file-drop-face span {
    color: var(--muted);
    font-size: .85rem;
    font-weight: 500;
}
.file-drop-list {
    list-style: none;
    margin: 10px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.file-drop-list li {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 12px;
    font-weight: 600;
    text-align: start;
}

.alert { border-radius: 12px; font-weight: 600; }
.empty { color: var(--muted); font-weight: 600; padding: 12px 0; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 12px; }
.auth-card { width: min(440px, 100%); padding: 30px 26px; }
.auth-logo { display: block; height: 140px; margin: 0 auto 8px; }
.auth-card h1 { text-align: center; font-weight: 700; font-size: 1.4rem; margin: 8px 0 4px; }
.auth-card .sub { text-align: center; color: var(--muted); font-weight: 500; margin-bottom: 18px; }
.auth-foot { text-align: center; color: #94a3b8; font-weight: 500; margin-top: 14px; font-size: .85rem; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs a {
    border-radius: 999px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid var(--line);
    font-weight: 600;
    color: #334155;
}
.tabs a.active { background: #eff6ff; color: var(--blue-deep); border-color: #bfdbfe; }

@media (max-width: 980px) {
    .nav-inner { flex-wrap: nowrap; gap: 10px; }
    .nav-links { display: none; }
    .menu-links, .menu-links-divider { display: block; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .layout-show { display: flex; flex-direction: column; }
    .action-col { order: -1; }
}
@media (max-width: 640px) {
    .detail-grid, .stat-grid:not(.activity-stats), .fact-grid { grid-template-columns: 1fr; }
    .stat-grid.activity-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
