html, body {
    margin: 0;
    font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
    background: #f4efe6;
    color: #1e1c1a;
}

a, .btn-link {
    color: inherit;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

.page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    background: linear-gradient(180deg, #111827 0%, #172033 100%);
    color: #f8fafc;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-shell {
    padding: 1.5rem 1rem;
}

.brand-block {
    margin-bottom: 2rem;
}

.brand-link {
    color: #f8fafc;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-caption {
    margin: 0.35rem 0 0;
    color: rgba(248, 250, 252, 0.72);
    font-size: 0.9rem;
}

.nav-links {
    display: grid;
    gap: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.75rem 0.9rem;
    border-radius: 0.85rem;
    color: rgba(248, 250, 252, 0.84);
    text-decoration: none;
    font-weight: 600;
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.nav-link-secondary {
    margin-top: 1rem;
    color: rgba(248, 250, 252, 0.6);
}

main {
    display: grid;
    grid-template-rows: auto 1fr;
}

.top-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    background: rgba(255, 252, 247, 0.88);
    backdrop-filter: blur(8px);
}

.top-row-meta {
    color: #6b7280;
    font-size: 0.92rem;
}

.content-shell {
    padding: 1.5rem;
}

.portal-page {
    display: grid;
    gap: 1.25rem;
}

.portal-login {
    min-height: calc(100vh - 9rem);
    place-items: center;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 1rem;
}

.portal-card {
    background: #fffdf8;
    border: 1px solid rgba(30, 28, 26, 0.08);
    border-radius: 1.25rem;
    padding: 1.25rem;
    box-shadow: 0 18px 44px rgba(29, 33, 46, 0.08);
}

.portal-card-error {
    border-color: rgba(153, 27, 27, 0.18);
    color: #991b1b;
}

.portal-card-success {
    border-color: rgba(22, 101, 52, 0.18);
    color: #166534;
}

.portal-card-table {
    padding: 0;
    overflow: hidden;
}

.eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #b45309;
}

.body-copy {
    color: #57534e;
    max-width: 58ch;
}

.primary-action {
    border: 0;
    border-radius: 999px;
    background: #1f2937;
    color: #f9fafb;
    padding: 0.8rem 1.15rem;
    font: inherit;
    font-weight: 700;
}

.primary-action:disabled {
    opacity: 0.45;
}

.primary-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #1f2937;
    color: #f9fafb;
    padding: 0.8rem 1.15rem;
    font-weight: 700;
    text-decoration: none;
}

.secondary-action-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.14);
    padding: 0.55rem 0.85rem;
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
}

.secondary-action-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid rgba(17, 24, 39, 0.14);
    background: white;
    color: inherit;
    padding: 0.55rem 0.85rem;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
}

.portal-table {
    width: 100%;
    border-collapse: collapse;
}

.portal-table th,
.portal-table td {
    padding: 0.95rem 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    vertical-align: middle;
}

.portal-table th {
    background: #f9f4eb;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #78716c;
}

.portal-table tbody tr:hover {
    background: rgba(180, 83, 9, 0.03);
}

.actions-cell {
    width: 1%;
}

.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: #fffaf0;
}

.pager-button {
    border: 1px solid rgba(17, 24, 39, 0.14);
    background: white;
    color: #1f2937;
    border-radius: 999px;
    padding: 0.65rem 0.95rem;
    font: inherit;
    font-weight: 600;
}

.pager-button:disabled {
    opacity: 0.45;
}

.portal-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.tab-chip {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(180, 83, 9, 0.08);
    color: #9a3412;
    font-size: 0.92rem;
    font-weight: 600;
    text-decoration: none;
}

.tab-chip-link {
    opacity: 0.78;
}

.tab-chip-active {
    background: #9a3412;
    color: #fff7ed;
}

.overview-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) 1fr;
    gap: 1rem;
}

.overview-counters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.agent-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.metric-card {
    display: grid;
    gap: 0.35rem;
    padding: 1rem;
    border: 1px solid rgba(30, 28, 26, 0.08);
    border-radius: 1rem;
    background: #fffdf8;
    box-shadow: 0 18px 44px rgba(29, 33, 46, 0.08);
}

.metric-card strong {
    font-size: 1.9rem;
    line-height: 1;
}

.metric-label {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #78716c;
}

.summary-list {
    display: grid;
    gap: 0.85rem;
    margin: 1rem 0 0;
}

.summary-list div {
    display: grid;
    gap: 0.2rem;
}

.summary-list dt {
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #78716c;
}

.summary-list dd {
    margin: 0;
}

.agent-summary-list code {
    font-size: 0.92rem;
}

.empty-state {
    display: grid;
    place-items: center;
    min-height: 180px;
    text-align: center;
    color: #57534e;
}

.chat-thread {
    display: grid;
    gap: 0.9rem;
}

.chat-bubble {
    display: grid;
    gap: 0.65rem;
    max-width: min(78ch, 100%);
    padding: 1rem 1.1rem;
    border-radius: 1.15rem;
    border: 1px solid rgba(30, 28, 26, 0.08);
}

.chat-bubble p {
    margin: 0;
    white-space: pre-wrap;
}

.chat-bubble-incoming {
    justify-self: start;
    background: #fffaf0;
}

.chat-bubble-outgoing {
    justify-self: end;
    background: #1f2937;
    color: #f9fafb;
}

.chat-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    font-size: 0.8rem;
    color: #78716c;
}

.chat-bubble-outgoing .chat-meta {
    color: rgba(249, 250, 251, 0.75);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.5);
    backdrop-filter: blur(3px);
    z-index: 40;
}

.modal-shell {
    position: fixed;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 1.5rem;
    z-index: 50;
}

.modal-card {
    width: min(620px, calc(100vw - 2rem));
}

.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: start;
    margin-bottom: 1rem;
}

.modal-close {
    border: 0;
    background: transparent;
    color: #57534e;
    font: inherit;
    font-weight: 600;
}

.modal-form-grid {
    display: grid;
    gap: 1rem;
}

.form-field {
    display: grid;
    gap: 0.4rem;
}

.form-field label {
    font-size: 0.86rem;
    font-weight: 700;
    color: #44403c;
}

.text-input {
    width: 100%;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 0.9rem;
    background: white;
    padding: 0.8rem 0.95rem;
    font: inherit;
    color: inherit;
    box-sizing: border-box;
}

.modal-actions {
    display: flex;
    justify-content: end;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.blazor-error-boundary {
    background: #991b1b;
    color: white;
    padding: 1rem;
    border-radius: 1rem;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

@media (max-width: 900px) {
    .page {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

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

    .overview-grid,
    .overview-counters,
    .agent-grid {
        grid-template-columns: 1fr;
    }

    .portal-table,
    .portal-table thead,
    .portal-table tbody,
    .portal-table tr,
    .portal-table th,
    .portal-table td {
        display: block;
    }

    .portal-table thead {
        display: none;
    }

    .portal-table tr {
        padding: 1rem;
        border-bottom: 1px solid rgba(17, 24, 39, 0.08);
    }

    .portal-table td {
        padding: 0.25rem 0;
        border: 0;
    }

    .actions-cell {
        margin-top: 0.75rem;
    }

    .pager {
        align-items: stretch;
        flex-direction: column;
    }

    .chat-bubble {
        max-width: 100%;
    }

    .chat-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .modal-header,
    .modal-actions {
        align-items: stretch;
        flex-direction: column;
    }
}
