:root {
    --primary: #002b7f;
    --primary-light: #1746a2;
    --accent: #0ea5e9;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #64748b;
    --border: #dbe3ef;
    --sidebar-width: 268px;
    --sidebar-collapsed-width: 84px;
    --topbar-height: 64px;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08);
    --shadow-md: 0 8px 24px rgba(15, 23, 42, .10);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a { color: inherit; text-decoration: none; }

button, input, select, textarea { font: inherit; }

.topbar {
    position: fixed;
    inset: 0 0 auto 0;
    height: var(--topbar-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 500;
    box-shadow: var(--shadow);
}

.topbar-left,
.topbar-right,
.topbar-brand,
.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-logo {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary);
}

.topbar-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: .82rem;
    font-weight: 700;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
}

.topbar-user-info strong { font-size: .88rem; }
.topbar-user-info small { color: var(--text-muted); font-size: .76rem; }

.icon-button,
.topbar-action {
    min-height: 36px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    padding: 8px 12px;
    cursor: pointer;
}

.topbar-action:hover,
.icon-button:hover {
    background: var(--bg);
}

.sidebar {
    position: fixed;
    top: var(--topbar-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    background: #0b1736;
    color: #dbeafe;
    padding: 18px 14px;
    z-index: 400;
    overflow-y: auto;
    transition: width .18s ease, transform .18s ease;
}

.sidebar.collapsed { width: var(--sidebar-collapsed-width); }

.sidebar-nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: #e2e8f0;
    font-size: .9rem;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(14, 165, 233, .18);
    color: #fff;
}

.nav-section {
    margin: 18px 12px 8px;
    color: #93a4bd;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.sidebar.collapsed .nav-section,
.sidebar.collapsed .sidebar-footer {
    display: none;
}

.sidebar.collapsed .sidebar-nav a {
    justify-content: center;
    padding-left: 6px;
    padding-right: 6px;
    font-size: .72rem;
}

.sidebar-footer {
    margin-top: 28px;
    padding: 14px 12px;
    border-top: 1px solid rgba(255,255,255,.10);
    color: #93a4bd;
}

.main-content {
    min-height: 100vh;
    padding-top: var(--topbar-height);
    transition: margin-left .18s ease;
}

.main-content.sidebar-is-expanded { margin-left: var(--sidebar-width); }
.main-content.sidebar-is-collapsed { margin-left: var(--sidebar-collapsed-width); }

.content-area {
    max-width: 1440px;
    margin: 0 auto;
    padding: 24px;
}

.public-shell {
    min-height: 100vh;
    background: var(--bg);
}

.public-hero {
    min-height: 74vh;
    padding: 22px clamp(20px, 4vw, 56px) 64px;
    background:
        linear-gradient(rgba(0, 43, 127, .76), rgba(11, 23, 54, .84)),
        url("ictaz-logo.png") center 42% / 240px no-repeat,
        var(--primary);
    color: #fff;
}

.public-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-lockup {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
}

.brand-lockup img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    background: #fff;
    border-radius: 50%;
    padding: 5px;
}

.public-hero-content {
    max-width: 720px;
    margin-top: 14vh;
}

.eyebrow {
    margin: 0 0 12px;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-weight: 700;
    color: #bae6fd;
}

.public-hero h1 {
    margin: 0;
    font-size: clamp(2rem, 5vw, 4.4rem);
    line-height: 1.02;
}

.lead {
    max-width: 680px;
    color: #dbeafe;
    font-size: 1rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 26px;
}

.public-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding: 24px clamp(20px, 4vw, 56px) 48px;
}

.public-grid article,
.card {
    background: var(--surface);
    border: 1px solid rgba(219, 227, 239, .9);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.public-grid article {
    padding: 22px;
}

.public-grid h2 {
    margin: 0 0 8px;
    font-size: 1.05rem;
}

.public-grid p {
    margin: 0;
    color: var(--text-muted);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 430px;
    padding: 28px;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.login-brand img {
    width: 52px;
    height: 52px;
    object-fit: contain;
}

.login-brand h1 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary);
}

.login-brand p,
.login-note {
    margin: 3px 0 0;
    color: var(--text-muted);
    font-size: .9rem;
}

.login-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-button {
    justify-content: center;
    width: 100%;
    min-height: 44px;
}

.login-note {
    margin-top: 18px;
    line-height: 1.55;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
    padding: 20px;
    background: var(--surface);
    border: 1px solid rgba(219, 227, 239, .9);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-header h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 750;
}

.page-header p {
    margin: 5px 0 0;
    color: var(--text-muted);
}

.card {
    padding: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.card-title {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border: 0;
    border-radius: var(--radius);
    padding: 9px 16px;
    font-size: .9rem;
    font-weight: 650;
    cursor: pointer;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-light); color: #fff; }

.btn-outline {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-outline:hover { background: var(--bg); }
.btn-sm { min-height: 32px; padding: 6px 10px; font-size: .8rem; }

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: .9rem;
}

.alert-error {
    color: #991b1b;
    background: #fee2e2;
    border-left: 4px solid var(--danger);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid rgba(219, 227, 239, .9);
    border-left: 4px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
}

.stat-card span {
    display: block;
    font-size: 1.8rem;
    font-weight: 800;
}

.stat-card small {
    color: var(--text-muted);
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.stat-card.total { border-left-color: var(--primary); }
.stat-card.open { border-left-color: var(--accent); }
.stat-card.awaiting { border-left-color: var(--warning); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.accent { border-left-color: #7c3aed; }

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(320px, .8fr);
    gap: 18px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th {
    padding: 12px 14px;
    text-align: left;
    background: #f8fafc;
    color: var(--text-muted);
    font-size: .74rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

td small {
    display: block;
    color: var(--text-muted);
    margin-top: 2px;
}

tbody tr:hover {
    background: #f8fafc;
}

.queue-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.queue-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fbfdff;
}

.queue-item small {
    display: block;
    color: var(--text-muted);
    margin-top: 3px;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 4px 8px;
    border-radius: 999px;
    background: #e0f2fe;
    color: #075985;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

.empty-state {
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
}

.empty-state h2 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: 1.05rem;
}

.role-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.role-grid span {
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #f8fafc;
    font-weight: 700;
}

.loading-panel {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-muted);
}

#blazor-error-ui {
    background: #fff3cd;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: .75rem;
    top: .5rem;
}

.mobile-only { display: none; }

@media (max-width: 900px) {
    .topbar-user-info { display: none; }

    .sidebar {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.expanded {
        transform: translateX(0);
    }

    .main-content.sidebar-is-expanded,
    .main-content.sidebar-is-collapsed {
        margin-left: 0;
    }

    .mobile-only { display: block; }

    .sidebar-overlay {
        position: fixed;
        inset: var(--topbar-height) 0 0 0;
        background: rgba(15, 23, 42, .45);
        z-index: 350;
    }

    .content-grid,
    .public-grid {
        grid-template-columns: 1fr;
    }

    .page-header {
        align-items: flex-start;
        flex-direction: column;
    }
}

@media (max-width: 640px) {
    .content-area {
        padding: 16px;
    }

    .topbar {
        padding: 0 12px;
    }

    .topbar-title {
        display: none;
    }

    .public-hero-content {
        margin-top: 10vh;
    }

    .hero-actions {
        flex-direction: column;
    }
}
