:root {
    --primary: #2255E8;
    --secondary: #0B1764;
    --bg: #F0F4FF;
    --sidebar-bg: #0B1764;
    --text: #0D0D1A;
    --hover: #F59E0B;
    --border: #E5E7EB;
    --muted: #6B7280;
    --shadow: 0 12px 35px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, system-ui, -apple-system, sans-serif;
    overflow-x: hidden;
}
a { color: var(--primary); text-decoration: none; }
.btn { font-weight: 600; border-radius: 10px; }
.btn-primary {
    --bs-btn-bg: var(--primary); --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--secondary); --bs-btn-hover-border-color: var(--secondary);
    --bs-btn-active-bg: var(--secondary); --bs-btn-active-border-color: var(--secondary);
}
.btn-outline-primary {
    --bs-btn-color: var(--primary); --bs-btn-border-color: var(--primary);
    --bs-btn-hover-bg: var(--primary); --bs-btn-hover-border-color: var(--primary);
}
.text-primary { color: var(--primary) !important; }
.bg-primary { background-color: var(--primary) !important; }

.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 1040;
    flex-direction: column; padding: 24px 18px; color: #fff;
    background: linear-gradient(180deg, var(--sidebar-bg), color-mix(in srgb, var(--sidebar-bg) 82%, #000));
}
.brand { display: flex; align-items: center; justify-content: center; min-height: 76px; padding: 7px; background: #fff; border-radius: 16px; }
.brand img { max-width: 185px; max-height: 62px; object-fit: contain; }
.sidebar-user { margin: 20px 8px 10px; color: rgba(255,255,255,.72); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.sidebar-nav { display: flex; flex-direction: column; gap: 6px; }
.sidebar-nav a, .sidebar-logout {
    display: flex; align-items: center; gap: 13px; padding: 12px 14px;
    color: rgba(255,255,255,.82); border-radius: 11px; transition: .2s ease;
}
.sidebar-nav a:hover, .sidebar-nav a.active { color: var(--sidebar-bg); background: #fff; transform: translateX(2px); }
.sidebar-nav i { width: 21px; text-align: center; font-size: 1.1rem; }
.sidebar-logout { margin-top: auto; }
.sidebar-logout:hover { color: #fff; background: rgba(255,255,255,.12); }
.main-column { display: flex; flex-direction: column; width: calc(100% - 264px); min-height: 100vh; margin-left: 264px; }
.topbar {
    position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 16px;
    min-height: 84px; padding: 14px 30px; background: rgba(255,255,255,.92);
    border-bottom: 1px solid rgba(15,23,42,.06); backdrop-filter: blur(12px);
}
.topbar h1 { margin: 2px 0 0; font-size: 1.35rem; font-weight: 750; }
.topbar-kicker { color: var(--primary); font-size: .7rem; font-weight: 800; letter-spacing: .12em; }
.topbar-meta { display: flex; align-items: center; gap: 18px; margin-left: auto; color: var(--muted); font-size: .82rem; }
.live-label { display: inline-flex; align-items: center; gap: 6px; color: #15803d; font-weight: 700; }
.live-label i { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px #dcfce7; }
.topbar-user { color: var(--text); font-weight: 600; }
.mobile-menu { padding: 8px; color: var(--text); font-size: 1.6rem; }
.content { flex: 1; padding: 28px 30px 45px; }
.app-footer { padding: 18px 30px; color: var(--muted); font-size: .78rem; text-align: center; background: #fff; border-top: 1px solid var(--border); }
.impersonation-banner { padding: 9px 20px; color: #713f12; background: #fef3c7; text-align: center; font-size: .86rem; }
.impersonation-banner a { margin-left: 8px; color: #92400e; font-weight: 700; }

.mobile-sidebar { width: 282px !important; color: #fff; background: var(--sidebar-bg); }
.mobile-sidebar .offcanvas-header img { max-width: 160px; max-height: 54px; padding: 5px; background: #fff; border-radius: 10px; }

.panel, .card {
    border: 1px solid rgba(15,23,42,.07); border-radius: 16px;
    background: #fff; box-shadow: 0 5px 22px rgba(15,23,42,.05);
}
.client-request-card {
    border: 2px dashed #cbd5e1;
    background: #f8fafc;
    box-shadow: none;
}
.client-request-stat { color: var(--text); }
.client-request-stat:hover { color: var(--text); border-color: var(--primary); }
.client-request-stat.has-pending {
    border-color: #f59e0b;
    background: #fffbeb;
    box-shadow: 0 6px 24px rgba(245,158,11,.14);
}
.client-request-stat.has-pending .stat-icon { color: #92400e; background: #fef3c7; }
.request-section { padding: 28px; }
.request-section-heading { display: flex; align-items: flex-start; gap: 15px; margin-bottom: 24px; }
.request-section-heading > span {
    display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px;
    color: #fff; background: var(--primary); border-radius: 12px; font-size: .8rem; font-weight: 800;
}
.request-section-heading h2 { margin: 0 0 4px; font-size: 1.05rem; font-weight: 780; }
.request-section-heading p { margin: 0; color: var(--muted); font-size: .82rem; }
.department-input-row { display: flex; align-items: flex-end; gap: 12px; padding: 15px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 13px; background: #fafbfc; }
.staff-count-field { width: 170px; flex: 0 0 170px; }
.remove-department { min-height: 46px; width: 46px; flex: 0 0 46px; }
.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 11px; }
.feature-option { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 11px; background: #fafbfc; font-size: .82rem; cursor: pointer; }
.feature-option:has(input:checked) { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 5%, white); }
.client-brand-preview {
    --client-primary: #2255E8; --client-secondary: #0B1764; --client-bg: #F0F4FF;
    overflow: hidden; min-height: 260px; border: 1px solid var(--border); border-radius: 16px; background: #fff; box-shadow: 0 8px 25px rgba(15,23,42,.08);
}
.client-preview-header { display: flex; justify-content: space-between; align-items: center; padding: 18px; color: #fff; background: var(--client-secondary); }
.client-preview-header span { font-size: .72rem; opacity: .75; }
.client-preview-body { display: grid; grid-template-columns: 65px 1fr; min-height: 205px; }
.client-preview-sidebar { background: var(--client-secondary); opacity: .94; }
.client-preview-main { padding: 22px; background: var(--client-bg); }
.client-preview-main div { height: 48px; margin-bottom: 13px; border-left: 4px solid var(--client-primary); border-radius: 9px; background: #fff; box-shadow: 0 4px 12px rgba(15,23,42,.07); }
.client-preview-main button { padding: 8px 14px; color: #fff; border: 0; border-radius: 8px; background: var(--client-primary); font-size: .75rem; font-weight: 700; }
.request-confirmation { max-width: 760px; padding: clamp(30px,6vw,60px); }
.confirmation-copy { max-width: 620px; margin: 24px auto 0; line-height: 1.75; }
.request-status-panel { padding: 28px; }
.request-progress { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); margin: 32px 0; }
.request-progress-step { position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; color: #94a3b8; text-align: center; font-size: .78rem; }
.request-progress-step::before { content: ""; position: absolute; top: 22px; right: 50%; width: 100%; height: 3px; background: #e2e8f0; transform: translateX(-50%); z-index: 0; }
.request-progress-step:first-child::before { display: none; }
.request-progress-step.complete::before { background: var(--primary); }
.request-progress-step .step-circle { position: relative; z-index: 1; display: grid; place-items: center; width: 46px; height: 46px; border: 3px solid #e2e8f0; border-radius: 50%; background: #fff; }
.request-progress-step.complete { color: var(--primary); }
.request-progress-step.complete .step-circle { color: #fff; border-color: var(--primary); background: var(--primary); }
.request-progress-step.current .step-circle { box-shadow: 0 0 0 6px color-mix(in srgb, var(--primary) 12%, transparent); }
.request-progress.is-live .request-progress-step.complete { color: #15803d; }
.request-progress.is-live .request-progress-step.complete::before { background: #22c55e; }
.request-progress.is-live .request-progress-step.complete .step-circle { border-color: #22c55e; background: #22c55e; }
.request-progress.is-live .request-progress-step.current .step-circle { box-shadow: 0 0 0 6px rgba(34,197,94,.14); }
.status-message { display: flex; align-items: center; gap: 12px; padding: 15px 17px; color: #1e3a8a; border-radius: 12px; background: #eff6ff; font-size: .88rem; }
.status-message.is-live { color: #166534; background: #dcfce7; }
.live-system-card { color: #14532d; border-color: #86efac; background: #f0fdf4; }
.request-logo-box { display: grid; place-items: center; min-height: 115px; padding: 18px; border: 1px solid var(--border); border-radius: 13px; background: #fff; }
.request-logo-box img { max-width: 100%; max-height: 90px; object-fit: contain; }
.color-swatch { display: inline-block; width: 44px; height: 44px; border: 1px solid rgba(15,23,42,.15); border-radius: 11px; box-shadow: inset 0 0 0 3px rgba(255,255,255,.45); }
.panel { padding: 22px; }
.panel-title { margin: 0; font-weight: 750; font-size: 1rem; }
.section-title { margin: 0; font-size: 1.12rem; font-weight: 750; }
.section-subtitle { margin: 5px 0 0; color: var(--muted); font-size: .86rem; }
.stat-card { height: 100%; padding: 20px; overflow: hidden; position: relative; }
.stat-card .stat-icon {
    display: grid; place-items: center; width: 45px; height: 45px;
    color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, white); border-radius: 13px;
}
.stat-card .stat-value { margin-top: 16px; font-size: 1.7rem; font-weight: 800; }
.stat-card .stat-label { color: var(--muted); font-size: .82rem; }
.stat-card::after {
    content: ""; position: absolute; right: -24px; bottom: -35px; width: 90px; height: 90px;
    background: color-mix(in srgb, var(--primary) 8%, white); border-radius: 50%;
}
.queue-card { height: 100%; overflow: hidden; }
.queue-card .card-body { padding: 20px; }
.queue-current { color: var(--primary); font-size: 2.3rem; line-height: 1; font-weight: 850; letter-spacing: -.05em; }
.queue-meta { color: var(--muted); font-size: .8rem; }
.token-pill { display: inline-flex; padding: 5px 9px; border: 1px solid var(--border); border-radius: 20px; font-size: .72rem; font-weight: 650; }
.progress { height: 7px; border-radius: 10px; }
.progress-bar { background-color: var(--primary); }
.welcome-card { position: relative; overflow: hidden; padding: 28px; border-left: 5px solid var(--primary); }
.welcome-card::after { content: ""; position: absolute; width: 220px; height: 220px; right: -90px; top: -110px; border-radius: 50%; background: color-mix(in srgb, var(--primary) 7%, white); }
.quick-action {
    display: flex; align-items: center; gap: 13px; height: 100%; padding: 18px;
    color: var(--text); transition: transform .2s, border-color .2s;
}
.quick-action:hover { color: var(--primary); border-color: var(--primary); transform: translateY(-3px); }
.quick-action .action-icon { display: grid; place-items: center; width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px; color: #fff; background: var(--primary); }
.quick-action strong { display: block; font-size: .88rem; }
.quick-action small { color: var(--muted); font-size: .72rem; }
.emergency-action .action-icon { background: #dc2626; }

.table { --bs-table-bg: transparent; margin-bottom: 0; }
.table > :not(caption) > * > * { padding: 14px 12px; border-bottom-color: #eef0f3; vertical-align: middle; }
.table thead th { color: var(--muted); font-size: .7rem; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
.table tbody { font-size: .85rem; }
.form-control, .form-select {
    min-height: 46px; border-color: #dfe3e8; border-radius: 10px; font-size: .9rem;
}
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--primary) 15%, transparent); }
.form-label { font-size: .82rem; font-weight: 650; }
.form-section { padding-bottom: 22px; margin-bottom: 22px; border-bottom: 1px solid var(--border); }
.form-section:last-child { border: 0; margin-bottom: 0; }
.icon-circle { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--primary); background: color-mix(in srgb, var(--primary) 10%, white); font-size: 1.3rem; }
.department-card { height: 100%; transition: .2s; }
.department-card:hover { transform: translateY(-4px); border-color: color-mix(in srgb, var(--primary) 45%, white); }
.doctor-avatar { display: grid; place-items: center; width: 54px; height: 54px; border-radius: 50%; color: #fff; background: linear-gradient(145deg, var(--primary), var(--secondary)); font-size: 1.25rem; font-weight: 800; }
.empty-state { padding: 38px 18px; color: var(--muted); text-align: center; }
.empty-state i { display: block; margin-bottom: 10px; font-size: 2rem; opacity: .55; }

.auth-shell { display: flex; flex-direction: column; min-height: 100vh; background: #fff; }
.auth-content { display: grid; grid-template-columns: minmax(350px, 42%) 1fr; flex: 1; }
.auth-panel { display: flex; align-items: center; justify-content: center; padding: 45px; }
.auth-card { width: min(100%, 440px); }
.auth-logo { max-width: 215px; max-height: 85px; object-fit: contain; margin-bottom: 28px; }
.auth-card h1 { color: var(--primary); font-size: 2rem; font-weight: 800; }
.auth-visual {
    position: relative; display: grid; place-items: center; overflow: hidden;
    padding: 55px; background: linear-gradient(145deg, var(--bg), #fff);
}
.auth-visual::before, .auth-visual::after { content: ""; position: absolute; border-radius: 50%; background: color-mix(in srgb, var(--primary) 9%, transparent); }
.auth-visual::before { width: 420px; height: 420px; right: -100px; top: -120px; }
.auth-visual::after { width: 300px; height: 300px; left: -100px; bottom: -100px; }
.auth-board { position: relative; z-index: 2; width: min(100%, 660px); padding: 30px; background: rgba(255,255,255,.85); border: 1px solid rgba(255,255,255,.8); border-radius: 24px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.auth-token { color: var(--primary); font-size: 4rem; font-weight: 850; letter-spacing: -.06em; }
.ecg { height: 80px; width: 100%; margin-top: 22px; color: var(--primary); }
.auth-footer { padding: 16px; color: var(--muted); text-align: center; font-size: .78rem; border-top: 1px solid var(--border); }

.token-main { padding: 34px; text-align: center; }
.success-check { display: grid; place-items: center; width: 62px; height: 62px; margin: 0 auto 13px; border-radius: 50%; color: #fff; background: #16a34a; font-size: 2rem; }
.token-number { color: var(--primary); font-size: clamp(3.8rem, 8vw, 6rem); line-height: 1; font-weight: 900; letter-spacing: -.07em; }
.detail-tile { height: 100%; padding: 15px; border: 1px solid var(--border); border-radius: 12px; text-align: left; }
.detail-tile small { display: block; color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.detail-tile strong { display: block; margin-top: 4px; font-size: .88rem; }
.tracking-token { animation: pulse-token 2s ease-in-out infinite; color: var(--primary); font-size: clamp(4rem, 10vw, 7rem); font-weight: 900; line-height: 1; letter-spacing: -.08em; }
@keyframes pulse-token { 50% { transform: scale(1.025); } }
.queue-line { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px; }
.queue-node { padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px; font-size: .76rem; font-weight: 700; }
.queue-node.now { color: #fff; background: var(--primary); border-color: var(--primary); transform: scale(1.07); }
.queue-node.you { color: #422006; background: #fbbf24; border-color: #f59e0b; transform: scale(1.07); }
.queue-node.served { color: #9ca3af; background: #f3f4f6; text-decoration: line-through; }
.tracking-stat { display: flex; align-items: center; gap: 12px; padding: 15px; }
.tracking-stat i { color: var(--primary); font-size: 1.25rem; }
.tracking-stat small { display: block; color: var(--muted); font-size: .7rem; }
.tracking-stat strong { font-size: .94rem; }
.time-slot { min-width: 96px; padding: 10px 14px; border: 1px solid var(--primary); border-radius: 9px; color: var(--primary); background: #fff; font-weight: 650; }
.time-slot:hover, .time-slot.selected { color: #fff; background: var(--primary); }
.time-slot.booked { color: #9ca3af; background: #f3f4f6; border-color: #e5e7eb; cursor: not-allowed; text-decoration: line-through; }
.payment-option { cursor: pointer; }
.payment-option input { position: absolute; opacity: 0; pointer-events: none; }
.payment-option .card { padding: 18px; border: 2px solid var(--border); transition: .2s; }
.payment-option input:checked + .card { color: var(--primary); border-color: var(--primary); background: color-mix(in srgb, var(--primary) 4%, white); }
.payment-option i { font-size: 1.6rem; }
.preview-dashboard { overflow: hidden; border: 1px solid var(--border); border-radius: 16px; background: #fff; }
.preview-head { display: flex; align-items: center; gap: 12px; padding: 18px; }
.preview-head img { width: 80px; height: 42px; object-fit: contain; }
.preview-body { display: grid; grid-template-columns: 55px 1fr; min-height: 230px; }
.preview-side { background: var(--preview-sidebar, var(--sidebar-bg)); }
.preview-content { padding: 20px; background: var(--preview-bg, #fff); }
.preview-mini-card { padding: 12px; border-radius: 10px; background: #fff; box-shadow: 0 4px 14px rgba(15,23,42,.08); }

@media (max-width: 991.98px) {
    .main-column { width: 100%; margin-left: 0; }
    .topbar { padding: 12px 18px; }
    .content { padding: 22px 18px 38px; }
    .topbar-meta #liveClock, .topbar-user { display: none; }
    .auth-content { grid-template-columns: 1fr; }
    .auth-visual { display: none; }
}
@media (max-width: 575.98px) {
    .topbar h1 { font-size: 1.12rem; }
    .topbar-kicker { font-size: .62rem; }
    .topbar-meta { gap: 8px; }
    .content { padding: 18px 12px 32px; }
    .panel { padding: 17px; border-radius: 13px; }
    .auth-panel { padding: 32px 20px; align-items: flex-start; }
    .auth-logo { max-width: 180px; }
    .btn.mobile-full, .content .btn-group-responsive .btn { width: 100%; }
    .page-actions { display: grid !important; grid-template-columns: 1fr; width: 100%; }
    .page-actions .btn { width: 100%; }
    .token-main { padding: 24px 14px; }
    .queue-node { padding: 8px 9px; }
    .request-section { padding: 18px; }
    .department-input-row { flex-wrap: wrap; }
    .staff-count-field { width: calc(100% - 58px); flex: 1 1 auto; }
    .feature-grid { grid-template-columns: 1fr; }
    .request-progress { gap: 4px; }
    .request-progress-step strong { font-size: .65rem; }
    .request-progress-step .step-circle { width: 38px; height: 38px; }
    .request-progress-step::before { top: 18px; }
}
@media print {
    .sidebar, .topbar, .app-footer, .no-print, .mobile-sidebar { display: none !important; }
    .main-column { width: 100%; margin: 0; }
    .content { padding: 0; }
    body { background: #fff; }
    .token-main { box-shadow: none; border: 0; }
}
