:root {
    --hq-primary: #123B5E;
    --hq-primary-dark: #0C2A44;
    --hq-primary-soft: #1D5688;
    --hq-accent: #E0793F;
    --hq-accent-soft: #F2A868;
    --hq-plum: #6D4C91;
    --hq-bg: #F4F6F8;
    --hq-surface: #FFFFFF;
    --hq-text: #14202B;
    --hq-muted: #5B6B7A;
    --hq-muted-soft: #8C99A6;
    --hq-divider: #E4E9ED;
    --hq-success: #1F8A5F;
    --hq-warning: #B7791F;
    --hq-danger: #C0392B;
    --hq-info: #2C7BA6;

    --hq-shadow-sm: 0 1px 2px rgba(18, 59, 94, .05), 0 1px 3px rgba(20, 32, 43, .05);
    --hq-shadow-md: 0 8px 22px rgba(18, 59, 94, .10), 0 2px 6px rgba(20, 32, 43, .06);
    --hq-shadow-lg: 0 20px 44px rgba(18, 59, 94, .16), 0 6px 14px rgba(20, 32, 43, .08);

    --hq-radius: 12px;
    --hq-radius-lg: 18px;
}

* {
    box-sizing: border-box;
}

html, body, .mud-typography {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif !important;
}

html, body {
    background: var(--hq-bg);
    color: var(--hq-text);
    margin: 0;
    direction: rtl;
}

.mud-appbar, .mud-drawer, .mud-paper, .mud-table {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
}

/* ---------- Page heading ---------- */
.hq-page-title {
    font-weight: 800;
    color: var(--hq-text);
    display: inline-block;
    position: relative;
    padding-bottom: .5rem;
    margin-bottom: 1.25rem;
}
.hq-page-title::after {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    bottom: 0;
    width: 52px;
    height: 3px;
    border-radius: 2px;
    background: linear-gradient(90deg, var(--hq-primary), var(--hq-accent));
}

/* ---------- Stat tiles ---------- */
.hq-stat-tile {
    border-radius: var(--hq-radius-lg) !important;
    border-top: 3px solid var(--hq-primary);
    padding: 1.25rem 1.4rem !important;
    min-height: 110px;
    position: relative;
    overflow: hidden;
    transition: transform .18s ease, box-shadow .18s ease;
}
.hq-stat-tile:hover { transform: translateY(-2px); box-shadow: var(--hq-shadow-md) !important; }
.hq-stat-tile.hq-accent { border-top-color: var(--hq-accent); }
.hq-stat-tile .hq-stat-value {
    font-size: 2.3rem;
    font-weight: 800;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    color: var(--hq-text);
}
.hq-stat-tile.hq-accent .hq-stat-value { color: var(--hq-accent); }
.hq-stat-tile .hq-stat-label {
    color: var(--hq-muted);
    font-weight: 500;
}
.hq-stat-tile .hq-stat-icon {
    position: absolute;
    inset-inline-end: .9rem;
    top: .8rem;
    opacity: .12;
    color: var(--hq-primary);
}

/* ---------- Login ---------- */
.hq-login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background:
        radial-gradient(circle at 85% 12%, rgba(18, 59, 94, .12), transparent 55%),
        radial-gradient(circle at 5% 90%, rgba(224, 121, 63, .12), transparent 55%),
        var(--hq-bg);
}
.hq-login-card {
    background: var(--hq-surface);
    width: 100%;
    max-width: 430px;
    border-radius: var(--hq-radius-lg);
    box-shadow: var(--hq-shadow-lg);
    padding: 2.1rem 2.3rem;
    position: relative;
    overflow: hidden;
}
.hq-login-card::before {
    content: '';
    position: absolute;
    top: 0; inset-inline: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--hq-primary), var(--hq-accent));
}
.hq-login-logo {
    display: block;
    max-height: 64px;
    max-width: 200px;
    width: auto;
    object-fit: contain;
    margin: 0 auto 1rem;
}
.hq-login-title {
    font-weight: 800;
    font-size: 1.5rem;
    margin-top: .5rem;
}
.hq-login-subtitle {
    color: var(--hq-muted);
    font-size: .95rem;
    margin-bottom: 1.4rem;
}
.hq-lock-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.hq-lock-card {
    width: 100%;
    max-width: 380px;
    border-radius: var(--hq-radius-lg) !important;
    border: 1px solid var(--hq-divider);
}
.hq-field {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--hq-divider);
    border-radius: var(--hq-radius);
    font-family: inherit;
    font-size: 1rem;
    margin-bottom: 1rem;
    background: #fff;
}
.hq-field:focus { outline: none; border-color: var(--hq-primary); box-shadow: 0 0 0 3px rgba(18,59,94,.12); }
.hq-label { display: block; font-weight: 600; margin-bottom: .4rem; font-size: .92rem; }
.hq-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 100%;
    padding: 12px 18px;
    border: none;
    border-radius: var(--hq-radius);
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    background: var(--hq-primary);
    color: #fff;
    transition: background .15s ease;
}
.hq-btn:hover { background: var(--hq-primary-dark); }
.hq-alert {
    padding: .7rem 1rem;
    border-radius: var(--hq-radius);
    margin-bottom: 1rem;
    font-size: .92rem;
}
.hq-alert-error { background: #FBEAE6; color: var(--hq-danger); }

/* ---------- Sidebar (admin) ---------- */
.hq-drawer-brand {
    display: flex; align-items: center; gap: .7rem;
    padding: 1.1rem 1.15rem;
    border-bottom: 1px solid var(--hq-divider);
}
.hq-brand-mark {
    width: 38px; height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--hq-primary), var(--hq-primary-soft));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    flex: none;
}
.hq-brand-name {
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* Organization logo: width follows the image's aspect ratio, height is set
   per placement by the BrandLogo component. */
.hq-brand-logo {
    width: auto;
    max-width: 160px;
    object-fit: contain;
    flex: none;
}
.hq-nav-link.mud-nav-link-active {
    background: linear-gradient(90deg, rgba(18,59,94,.10), rgba(18,59,94,.02)) !important;
    color: var(--hq-primary) !important;
    font-weight: 700 !important;
    border-inline-end: 3px solid var(--hq-primary);
}

/* ---------- Kiosk ---------- */
.hq-kiosk-shell {
    min-height: 100vh;
    background: linear-gradient(160deg, var(--hq-primary) 0%, var(--hq-primary-dark) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: #fff;
}
.hq-kiosk-brand {
    margin-bottom: 1.5rem;
    text-align: center;
}
.hq-kiosk-brand .hq-brand-logo {
    max-width: 260px;
}
.hq-kiosk-title {
    font-size: 1.8rem;
    font-weight: 800;
    margin-bottom: 2rem;
    text-align: center;
}
.hq-kiosk-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.4rem;
    max-width: 980px;
    width: 100%;
}
.hq-kiosk-tile {
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.18);
    border-radius: var(--hq-radius-lg);
    padding: 2.2rem 1rem;
    text-align: center;
    font-size: 1.3rem;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    transition: transform .15s ease, background .15s ease;
}
.hq-kiosk-tile:hover:not(:disabled) { background: rgba(255,255,255,.18); transform: translateY(-3px); }
.hq-kiosk-tile:disabled { opacity: .5; cursor: not-allowed; }

.hq-kiosk-ticket-card {
    background: #fff;
    color: var(--hq-text);
    border-radius: var(--hq-radius-lg);
    padding: 2.6rem 2.4rem;
    text-align: center;
    max-width: 460px;
    box-shadow: var(--hq-shadow-lg);
}
.hq-kiosk-ticket-number {
    font-size: 4.5rem;
    font-weight: 800;
    color: var(--hq-primary);
    margin: .8rem 0;
    font-variant-numeric: tabular-nums;
}

/* ---------- Employee call screen ---------- */
.hq-call-shell {
    max-width: 680px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Session bar: counter + clinic pickers, with the waiting count pinned to
   the side so the employee can see the queue depth without looking away. */
.hq-session-bar {
    background: linear-gradient(135deg, var(--hq-primary), var(--hq-primary-dark));
    color: #fff;
    border-radius: var(--hq-radius-lg);
    padding: 1rem 1.2rem;
    box-shadow: var(--hq-shadow-md);
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}
.hq-session-bar-fields {
    display: flex;
    gap: .8rem;
    flex: 1 1 320px;
    min-width: 0;
}
.hq-session-bar-fields > * {
    flex: 1 1 0;
    min-width: 0;
}
.hq-session-hint {
    display: flex;
    align-items: center;
    gap: .4rem;
    color: rgba(255, 255, 255, .85);
    font-size: .9rem;
}
.hq-session-waiting {
    text-align: center;
    padding: .3rem 1rem;
    border-radius: var(--hq-radius);
    background: rgba(255, 255, 255, .12);
    min-width: 84px;
}
.hq-session-waiting-count {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}
.hq-session-waiting-label {
    font-size: .78rem;
    color: rgba(255, 255, 255, .8);
}

/* The pickers sit on the bar's dark gradient, so their MudBlazor chrome
   has to be re-tinted for light-on-dark. */
.hq-session-select .mud-input-control .mud-input,
.hq-session-select .mud-input-control .mud-input-label,
.hq-session-select .mud-select-input .mud-input-slot {
    color: #fff !important;
}
.hq-session-select .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, .45) !important;
}
.hq-session-select .mud-input-control:hover .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, .8) !important;
}
.hq-session-select .mud-input-adornment .mud-icon-root,
.hq-session-select .mud-select-input .mud-input-adornment-end {
    color: rgba(255, 255, 255, .85) !important;
}

.hq-call-panel {
    border: 1px solid var(--hq-divider);
    border-radius: var(--hq-radius-lg) !important;
    padding: 1.2rem;
    display: flex;
    flex-direction: column;
    gap: .9rem;
}

/* Fixed-height stage so the buttons below never move when a ticket is
   called, served, or cleared. */
.hq-ticket-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    min-height: 128px;
    border-radius: var(--hq-radius);
    background: var(--hq-bg);
    border: 1px dashed var(--hq-divider);
    padding: .8rem;
}
.hq-current-ticket {
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--hq-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.hq-ticket-meta {
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    justify-content: center;
}
.hq-ticket-empty-icon {
    font-size: 2.6rem !important;
    color: var(--hq-divider);
}
.hq-ticket-empty-text {
    color: var(--hq-muted);
    font-size: .95rem;
}

.hq-service-timer {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .7rem;
    border-radius: 999px;
    background: rgba(44,123,166,.12);
    border: 1px solid rgba(44,123,166,.30);
    color: var(--hq-info);
}
/* Kept in the layout while idle so starting a service doesn't shift the
   row — just greyed out until the clock is running. */
.hq-service-timer.is-idle {
    opacity: .45;
}
.hq-service-timer-value {
    font-size: 1.1rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.hq-action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: .7rem;
}
@media (max-width: 480px) {
    .hq-action-grid { grid-template-columns: 1fr; }
    .hq-session-bar-fields { flex-basis: 100%; }
}
.hq-action-btn {
    min-height: 58px !important;
    font-size: 1rem !important;
    font-weight: 700 !important;
    border-radius: var(--hq-radius) !important;
}
.hq-action-primary {
    min-height: 66px !important;
    font-size: 1.1rem !important;
}
.hq-transfer-panel {
    border: 1px solid var(--hq-divider);
    border-radius: var(--hq-radius);
    padding: .9rem;
    background: var(--hq-bg);
}
.hq-notes-field {
    margin-top: .2rem;
}

/* ---------- Display board ---------- */
/* The board is a fixed, non-scrolling viewport: the header and the news
   ticker must stay visible at all times, and only the recent-calls list
   scrolls internally when there are more calls than fit. */
.hq-display-shell {
    height: 100vh;
    overflow: hidden;
    background: radial-gradient(circle at 20% 0%, #16456c 0%, #0A1F33 62%);
    color: #fff;
    padding: 1.6rem 2.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.hq-display-header,
.hq-ticker {
    flex: 0 0 auto;
}
.hq-display-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.hq-display-brand {
    display: flex; align-items: center; gap: .8rem;
    font-weight: 700;
    font-size: 1.4rem;
}
/* The kiosk and display screens are dark, and a logo drawn in dark ink on a
   transparent background would disappear on them — so it sits on a white
   plate. Drop these two rules if the organization supplies a light logo. */
.hq-display-brand .hq-brand-logo,
.hq-kiosk-brand .hq-brand-logo {
    background: #fff;
    border-radius: 10px;
    padding: 6px 10px;
}
.hq-display-dot {
    width: 12px; height: 12px; border-radius: 50%;
    background: #3FBF7F;
    box-shadow: 0 0 10px #3FBF7F;
    animation: hq-blink 1.6s ease-in-out infinite;
}
@keyframes hq-blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }
.hq-display-clock {
    font-variant-numeric: tabular-nums;
    color: #B9CBDA;
    font-size: 1.3rem;
}

.hq-display-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.6rem;
    flex: 1 1 auto;
    min-height: 0;
}
@media (max-width: 900px) {
    .hq-display-grid { grid-template-columns: 1fr; }
}

.hq-display-now {
    background: linear-gradient(160deg, rgba(18,59,94,.65), rgba(10,31,51,.55));
    border: 1px solid rgba(63,191,127,.35);
    border-radius: var(--hq-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.5rem;
    min-height: 0;
    overflow: hidden;
}
.hq-display-now-label {
    color: #9FC3DE;
    font-size: 1.3rem;
    font-weight: 600;
}
.hq-display-now-number {
    font-size: clamp(3rem, min(12vw, 18vh), 9rem);
    font-weight: 800;
    line-height: 1;
    margin: .5rem 0;
    text-shadow: 0 0 34px rgba(63,191,127,.55);
    font-variant-numeric: tabular-nums;
    animation: hq-pulse 1.7s ease-in-out infinite alternate;
}
@keyframes hq-pulse {
    from { text-shadow: 0 0 18px rgba(63,191,127,.35); }
    to   { text-shadow: 0 0 46px rgba(63,191,127,.85); }
}
.hq-display-now-window {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--hq-accent-soft);
    margin-top: .3rem;
}
.hq-display-recent {
    background: rgba(10,31,51,.55);
    border: 1px solid rgba(255,255,255,.10);
    border-radius: var(--hq-radius-lg);
    padding: 1.3rem 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: .65rem;
}
.hq-recent-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: rgba(255,255,255,.05);
    border-inline-start: 5px solid var(--hq-info);
    border-radius: 12px;
    padding: .65rem 1rem;
    /* Rows keep their height so the list scrolls instead of compressing
       them into an unreadable stack when the board is full. */
    flex: 0 0 auto;
}
.hq-recent-row .hq-recent-no {
    font-weight: 800;
    font-size: 1.5rem;
    min-width: 4.5ch;
    font-variant-numeric: tabular-nums;
}
.hq-recent-row .hq-recent-meta { flex: 1 1 auto; min-width: 0; }
.hq-recent-row .hq-recent-window {
    font-weight: 700;
    color: var(--hq-accent-soft);
    font-size: 1.05rem;
}
.hq-recent-row.is-serving { border-inline-start-color: var(--hq-info); }
.hq-recent-row.is-recall { border-inline-start-color: var(--hq-accent); }
/* Only the most recent call pulses — older rows stay static so the eye is
   drawn to the number being announced right now, not to every served row. */
.hq-recent-row.is-latest { animation: hq-glow 1.6s ease-in-out infinite alternate; }
@keyframes hq-glow {
    from { box-shadow: 0 0 0 1px rgba(224,121,63,.35); }
    to   { box-shadow: 0 0 0 3px rgba(224,121,63,.75); }
}

.hq-display-now-status {
    margin-top: .8rem;
    padding: .3rem 1rem;
    border-radius: 999px;
    font-size: 1rem;
    font-weight: 700;
}
.hq-recent-status {
    padding: .25rem .8rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 700;
    white-space: nowrap;
}
.hq-status-called { background: rgba(44,123,166,.25); color: #7FC3E8; }
.hq-status-inservice { background: rgba(63,191,127,.25); color: #7FE0AA; }
.hq-status-done { background: rgba(255,255,255,.12); color: #B9CBDA; }
.hq-status-skipped { background: rgba(224,121,63,.25); color: #F0AE84; }
.hq-status-transferred { background: rgba(151,111,196,.25); color: #C9AEE8; }

.hq-ticker {
    height: 3.2rem;
    border-radius: 14px;
    background: linear-gradient(90deg, rgba(18,59,94,.9), rgba(10,31,51,.9));
    border: 1px solid rgba(224,121,63,.4);
    position: relative;
    overflow: hidden;
    flex: none;
}
.hq-ticker-text {
    position: absolute;
    top: 50%;
    right: 0;
    transform: translate(100%, -50%);
    white-space: nowrap;
    font-weight: 600;
    font-size: 1.15rem;
    animation: hq-ticker-scroll linear infinite;
}
@keyframes hq-ticker-scroll {
    from { right: 0; transform: translate(100%, -50%); }
    to   { right: 100%; transform: translate(0, -50%); }
}

/* ---------- Status chips (shared) ---------- */
.hq-chip-waiting { background: rgba(183,121,31,.15) !important; color: var(--hq-warning) !important; }
.hq-chip-called, .hq-chip-inservice { background: rgba(44,123,166,.15) !important; color: var(--hq-info) !important; }
.hq-chip-done { background: rgba(31,138,95,.15) !important; color: var(--hq-success) !important; }
.hq-chip-skipped { background: rgba(224,121,63,.15) !important; color: var(--hq-accent) !important; }
.hq-chip-transferred { background: rgba(109,76,145,.15) !important; color: var(--hq-plum) !important; }
.hq-chip-cancelled { background: rgba(192,57,43,.15) !important; color: var(--hq-danger) !important; }

/* ---------- Permissions matrix ---------- */
.hq-perm-matrix-scroll {
    overflow-x: auto;
}
.hq-perm-matrix {
    border-collapse: collapse;
    width: 100%;
}
.hq-perm-matrix th, .hq-perm-matrix td {
    padding: .55rem .9rem;
    border-bottom: 1px solid var(--hq-divider);
    white-space: nowrap;
}
.hq-perm-matrix thead th {
    background: #F8FAFB;
    font-weight: 700;
    font-size: .88rem;
    text-align: center;
}
.hq-perm-matrix .hq-perm-col-label {
    text-align: start;
    font-weight: 600;
    font-size: .9rem;
    position: sticky;
    inset-inline-start: 0;
    background: var(--hq-surface);
    z-index: 1;
}
.hq-perm-matrix thead .hq-perm-col-label {
    background: #F8FAFB;
    z-index: 2;
}
.hq-perm-matrix .hq-perm-cell {
    text-align: center;
}
.hq-perm-role-head {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .3rem;
}

/* ---------- Branding settings ---------- */
.hq-brand-upload {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    flex-wrap: wrap;
}
.hq-brand-preview {
    width: 150px;
    height: 84px;
    border: 1px dashed var(--hq-divider);
    border-radius: var(--hq-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    padding: .5rem;
    flex: none;
}
.hq-brand-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* ---------- Receipt designer preview ---------- */
.hq-receipt-preview {
    background: #fff;
    color: #000;
    border: 1px dashed var(--hq-divider);
    border-radius: 6px;
    width: 280px;
    max-width: 100%;
    margin: 0 auto;
    padding: 14px 16px;
    font-family: Tahoma, Arial, sans-serif;
}

/* ---------- Misc ---------- */
.hq-empty { text-align: center; color: var(--hq-muted); padding: 2.5rem 1rem; }
.mud-table .mud-table-head .mud-table-cell { font-weight: 700 !important; background: #F8FAFB !important; }
