:root {
    --color-primary: #0f766e;
    --color-primary-dark: #0b5c56;
    --color-bg: #f4f6f8;
    --color-surface: #ffffff;
    --color-text: #111827;
    --color-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-error: #b91c1c;
    --color-error-bg: #fef2f2;
    --radius: 12px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Auth */

.auth-card {
    width: 100%;
    max-width: 380px;
    margin: auto;
    padding: 32px 24px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.auth-logo {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.auth-brand h1 {
    font-size: 18px;
    margin: 0;
}

.auth-subtitle {
    color: var(--color-muted);
    font-size: 14px;
    margin: 0 0 24px;
}

.auth-status {
    font-size: 13px;
    color: var(--color-primary-dark);
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 8px 12px;
    border-radius: 8px;
    margin: 0 0 16px;
}

.auth-status-error {
    color: var(--color-error);
    background: var(--color-error-bg);
    border-color: #fecaca;
}

.auth-tabs {
    display: flex;
    gap: 4px;
    background: var(--color-bg);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
}

.auth-tab.is-active {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.auth-forgot {
    text-align: center;
    margin: 4px 0 0;
}

.auth-forgot a {
    font-size: 13px;
    color: var(--color-primary);
}

.dev-hint {
    font-size: 13px;
    color: var(--color-primary-dark);
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    padding: 8px 12px;
    border-radius: 8px;
    margin: -8px 0 20px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
}

input[type="email"],
input[type="text"] {
    padding: 12px 14px;
    font-size: 16px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    color: var(--color-text);
    width: 100%;
}

input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.field-error {
    color: var(--color-error);
    font-size: 13px;
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--color-bg);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.btn-link {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 14px;
    cursor: pointer;
    padding: 0;
}

.auth-resend {
    text-align: center;
    margin-top: 16px;
}

/* Dashboard */

.dashboard {
    max-width: 720px;
    margin: 0 auto;
    padding: 20px 16px 48px;
    width: 100%;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 24px;
    gap: 12px;
    flex-wrap: wrap;
}

.dashboard-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-app-name {
    font-weight: 700;
}

.dashboard-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.dashboard-user-email {
    font-size: 14px;
    color: var(--color-muted);
}

.dashboard-welcome h1 {
    margin: 0 0 4px;
    font-size: 24px;
}

.dashboard-welcome p {
    color: var(--color-muted);
    margin: 0 0 24px;
}

.dashboard-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.dashboard-card h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

.dashboard-card p {
    margin: 0;
    color: var(--color-muted);
    font-size: 14px;
}

@media (max-width: 480px) {
    .auth-card {
        margin: 24px 16px;
        box-shadow: none;
        border: 1px solid var(--color-border);
    }
}

/* App shell / topbar */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 20;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.hamburger-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--color-text);
    margin: 0 auto;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.topbar-app-name {
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.topbar-user-email {
    font-size: 13px;
    color: var(--color-muted);
    display: none;
}

@media (min-width: 560px) {
    .topbar-user-email {
        display: inline;
    }
}

/* Off-canvas nav */

.nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 29;
}

.nav-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.side-nav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--color-surface);
    box-shadow: 4px 0 16px rgba(0, 0, 0, 0.12);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 30;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.side-nav.is-open {
    transform: translateX(0);
}

.side-nav-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    font-weight: 700;
    border-bottom: 1px solid var(--color-border);
}

.nav-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
    padding: 0;
}

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

.nav-group {
    border-bottom: 1px solid var(--color-border);
}

.nav-group-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: none;
    border: none;
    font-size: 14px;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    color: var(--color-text);
}

.nav-caret {
    font-size: 11px;
    color: var(--color-muted);
    transition: transform 0.15s ease;
}

.nav-group-toggle.is-open .nav-caret {
    transform: rotate(90deg);
}

.nav-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.nav-submenu.is-open {
    max-height: 400px;
}

.nav-submenu li a {
    display: block;
    padding: 10px 16px 10px 32px;
    font-size: 14px;
    color: var(--color-muted);
    text-decoration: none;
}

.nav-submenu li a:hover,
.nav-submenu li a.is-active {
    color: var(--color-primary);
    background: var(--color-bg);
}

.nav-empty {
    padding: 10px 16px 10px 32px;
    font-size: 13px;
    color: var(--color-muted);
    font-style: italic;
}

.app-content {
    flex: 1;
    max-width: 960px;
    width: 100%;
    margin: 0 auto;
    padding: 20px 16px 48px;
}

/* Master data tables and forms */

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

.page-header h1 {
    margin: 0;
    font-size: 20px;
}

.data-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    /* A safety net only, for the rare over-long value — text wraps instead of scrolling now. */
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: normal;
    word-break: break-word;
}

.data-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-muted);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/*
 * Below 720px — phone width, and the width most PWA windows run at — a data table restyles into a
 * stack of cards, one per row, each cell showing its column label beside its value. Same markup,
 * each <td> just needs a data-label attribute; no JavaScript, so nothing added to the installed
 * app's bundle. This replaces horizontal scroll, which is easy to miss and awkward to control by
 * touch inside a page that already scrolls vertically, and gives row actions proper tap targets.
 */
@media (max-width: 720px) {
    .data-table-wrap {
        background: transparent;
        border: none;
        overflow-x: visible;
    }

    .data-table {
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .data-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        margin: -1px;
        padding: 0;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
        border: 0;
    }

    .data-table tr {
        display: block;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius);
    }

    /*
     * Label above, value below — not side by side. A pill-shaped status chip or a long label has
     * nowhere to shrink to in a side-by-side row and ends up wrapped letter by letter; stacking
     * gives both lines the card's full width, so nothing has to fight for horizontal space.
     */
    .data-table td {
        display: block;
        text-align: left;
    }

    .data-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 4px;
        font-size: 11px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--color-muted);
    }

    .data-table td:not([data-label])::before {
        content: none;
    }

    .data-table td.empty-state {
        display: block;
        text-align: center;
    }

    .data-table td.empty-state::before {
        content: none;
    }
}

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    /* A pill has nowhere to shrink to; it should keep its shape in a narrow table column, not wrap. */
    white-space: nowrap;
}

.badge-yes {
    background: #ecfdf5;
    color: #047857;
}

.badge-no {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-status-completed {
    background: #ecfdf5;
    color: #047857;
}

.badge-status-in-progress {
    background: #fffbeb;
    color: #b45309;
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.row-actions form {
    display: inline;
}

.row-actions-icons a,
.row-actions-icons .link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    color: var(--color-body);
    flex-shrink: 0;
}
.row-actions-icons a:hover,
.row-actions-icons .link-btn:hover {
    background: var(--color-surface-low);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
    text-decoration: none;
}
.row-actions-icons .link-btn:hover {
    border-color: var(--color-error);
    color: var(--color-error);
}
.row-actions-icons .material-symbols-outlined {
    font-size: 19px;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--color-error);
    cursor: pointer;
    text-align: left;
}
.link-btn:hover { text-decoration: underline; }

.empty-state {
    padding: 40px 16px;
    text-align: center;
    color: var(--color-muted);
}

.form-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 760px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
}

@media (min-width: 640px) {
    .form-grid.cols-2 {
        grid-template-columns: 1fr 1fr;
    }
}

textarea,
select {
    padding: 12px 14px;
    font-size: 15px;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    background: #fff;
    color: var(--color-text);
    width: 100%;
}

textarea:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.radio-group {
    display: flex;
    gap: 20px;
    align-items: center;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 500;
    font-size: 14px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.form-section-title {
    font-size: 15px;
    margin: 24px 0 2px;
}

.form-card > .form-section-title:first-child {
    margin-top: 0;
}

.form-section-hint {
    font-size: 13px;
    color: var(--color-muted);
    margin: 0 0 16px;
}

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

.credential-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.credential-item:last-child {
    border-bottom: none;
}

.credential-meta {
    color: var(--color-muted);
    font-size: 13px;
}

.current-file {
    font-size: 13px;
    color: var(--color-muted);
    margin: 4px 0 0;
}

.current-file a {
    color: var(--color-primary);
}

.conditional-field {
    display: none;
}

.conditional-field.is-visible {
    display: block;
}

.pagination-wrap {
    margin-top: 16px;
}

/* Nia chat widget */

.nia-widget {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 40;
}

.nia-toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nia-toggle:hover {
    background: var(--color-primary-dark);
}

.nia-toggle-badge {
    font-weight: 700;
    font-size: 18px;
}

.nia-panel {
    position: fixed;
    right: 16px;
    bottom: 84px;
    width: 340px;
    max-width: calc(100vw - 32px);
    height: 480px;
    max-height: calc(100vh - 140px);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.nia-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.nia-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    flex-shrink: 0;
}

.nia-header-text {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
    flex: 1;
    min-width: 0;
}

.nia-subtitle {
    font-size: 12px;
    color: var(--color-muted);
}

.nia-close {
    border: none;
    background: transparent;
    font-size: 20px;
    line-height: 1;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0;
}

.nia-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nia-message {
    display: flex;
}

.nia-message-user {
    justify-content: flex-end;
}

.nia-message-assistant {
    justify-content: flex-start;
}

.nia-bubble {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.nia-message-user .nia-bubble {
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.nia-message-assistant .nia-bubble {
    background: var(--color-bg);
    color: var(--color-text);
    border-bottom-left-radius: 4px;
}

.nia-message-pending .nia-bubble {
    opacity: 0.6;
    font-style: italic;
}

.nia-error {
    margin: 0 16px 8px;
    font-size: 12px;
    color: var(--color-error);
}

.nia-bubble-text {
    display: block;
    /* Keep the line breaks the user typed, but not the template whitespace around them. */
    white-space: pre-wrap;
}

.nia-attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    color: inherit;
    font-size: 12px;
    text-decoration: underline;
    word-break: break-all;
}

.nia-message-assistant .nia-attachment-chip {
    background: #fff;
    border: 1px solid var(--color-border);
    color: var(--color-primary);
}

.nia-attachment-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin: 0 12px 8px;
    padding: 6px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 12px;
}

.nia-attachment-preview .nia-attachment-chip {
    margin: 0;
    background: none;
    border: none;
    text-decoration: none;
    color: var(--color-text);
}

.nia-attachment-remove {
    border: none;
    background: transparent;
    font-size: 16px;
    line-height: 1;
    color: var(--color-muted);
    cursor: pointer;
    padding: 0 2px;
    flex-shrink: 0;
}

.nia-attach-btn {
    border: none;
    background: transparent;
    color: var(--color-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    flex-shrink: 0;
}

.nia-attach-btn:hover {
    color: var(--color-primary);
}

.nia-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--color-border);
    flex-shrink: 0;
}

.nia-input-row input {
    flex: 1;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
}

.nia-input-row input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.nia-input-row .btn {
    padding: 10px 16px;
    font-size: 14px;
}

@media (max-width: 420px) {
    .nia-panel {
        right: 8px;
        left: 8px;
        width: auto;
        bottom: 80px;
    }

    .nia-widget {
        right: 8px;
        bottom: 8px;
    }
}

/* ===== Prototype design system (from Stitch exports in /UI) ===== */

:root {
    --color-primary: #0284C7;
    --color-primary-dark: #0369A1;
    --color-primary-soft: #E0F2FE;
    --color-navy: #0B192C;
    --color-ink: #0F172A;
    --color-bg: #F8FAFC;
    --color-surface: #FFFFFF;
    --color-surface-low: #F1F5F9;
    --color-text: #0F172A;
    --color-muted: #64748B;
    --color-body: #475569;
    --color-border: #E2E8F0;
    --color-border-strong: #CBD5E1;
    --color-error: #DC2626;
    --color-error-bg: #FEF2F2;
    --color-emerald: #10B981;
    --color-met: #15803D;
    --color-met-bg: #F0FDF4;
    --color-met-border: #BBF7D0;
    --color-not-met: #DC2626;
    --color-not-met-bg: #FEF2F2;
    --color-not-met-border: #FECACA;
    --color-partial: #D97706;
    --color-partial-bg: #FFFBEB;
    --color-partial-border: #FDE68A;
    --color-verify: #4F46E5;
    --color-verify-bg: #EEF2FF;
    --color-verify-border: #C7D2FE;
    --nia-gradient: linear-gradient(135deg, #0284C7, #10B981);
    --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.05), 0 1px 2px -1px rgba(15, 23, 42, 0.04);
    --shadow-hover: 0 4px 6px -1px rgba(15, 23, 42, 0.07), 0 2px 4px -2px rgba(15, 23, 42, 0.04);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-feature-settings: 'cv11';
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-smoothing: antialiased;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}

.app-shell {
    min-height: 100vh;
    display: block;
    background: var(--color-bg);
}

.side-nav {
    width: 288px;
    max-width: 85vw;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    box-shadow: none;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.side-brand {
    height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.side-logo {
    height: 32px;
    width: auto;
    display: block;
}

.side-nav-body {
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
}

.nav-section-label {
    padding: 12px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px;
    border-radius: var(--radius-sm);
    color: var(--color-body);
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link .material-symbols-outlined {
    color: var(--color-muted);
}

.nav-link:hover {
    background: var(--color-surface-low);
    color: var(--color-ink);
}

.nav-link.is-active {
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-weight: 600;
}

.nav-link.is-active .material-symbols-outlined {
    color: var(--color-primary-dark);
}

.nav-link.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.nav-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--color-primary-soft);
    color: var(--color-primary-dark);
    font-size: 11px;
    font-weight: 600;
}

.nav-badge.muted {
    background: var(--color-surface-low);
    color: var(--color-muted);
}

.side-footer {
    padding: 12px;
    border-top: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(241, 245, 249, 0.4);
}

.side-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.side-user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--color-primary-soft);
}

.side-user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    font-size: 13px;
}

.side-user-text span {
    color: var(--color-muted);
    font-size: 12px;
}

.side-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    border: none;
    background: none;
    padding: 6px 8px;
    color: var(--color-body);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.side-logout:hover {
    background: var(--color-surface-low);
    color: var(--color-ink);
}

.main-column {
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: 64px;
    padding: 0 16px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.hamburger-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--color-body);
    padding: 0;
}

.hamburger-btn span {
    width: auto;
    height: auto;
    background: none;
    margin: 0;
}

.topbar-search {
    flex: 1;
    max-width: 480px;
    display: flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 12px;
    background: var(--color-surface-low);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-muted);
    font-size: 14px;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user-email {
    display: none;
    font-size: 13px;
    color: var(--color-muted);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    gap: 6px;
}

.btn .material-symbols-outlined {
    font-size: 18px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 14px;
}

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

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-ink);
    border: 1px solid var(--color-border-strong);
}

.btn-secondary:hover {
    background: var(--color-surface-low);
}

.app-content {
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.notice {
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    margin: 0 0 16px;
    border: 1px solid transparent;
}

.notice-success {
    background: var(--color-met-bg);
    border-color: var(--color-met-border);
    color: var(--color-met);
}

.notice-error {
    background: var(--color-error-bg);
    border-color: #FECACA;
    color: var(--color-error);
}

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    /* A pill has nowhere to shrink to; it should keep its shape in a narrow table column, not wrap. */
    white-space: nowrap;
}

.status-chip .material-symbols-outlined {
    font-size: 15px;
}

.status-met { background: var(--color-met-bg); color: var(--color-met); border-color: var(--color-met-border); }
.status-not-met { background: var(--color-not-met-bg); color: var(--color-not-met); border-color: var(--color-not-met-border); }
.status-partial { background: var(--color-partial-bg); color: var(--color-partial); border-color: var(--color-partial-border); }
.status-verify { background: var(--color-verify-bg); color: var(--color-verify); border-color: var(--color-verify-border); }

@media (min-width: 1024px) {
    .side-nav {
        transform: none;
        position: fixed;
        z-index: 30;
    }

    .main-column {
        margin-left: 288px;
    }

    .hamburger-btn {
        display: none;
    }

    .topbar-user-email {
        display: block;
    }

    .nav-overlay {
        display: none;
    }

    .app-content {
        padding: 32px 32px 64px;
    }
}

@media (min-width: 640px) {
    .hide-sm {
        display: inline;
    }
}

@media (max-width: 639px) {
    .hide-sm {
        display: none;
    }
}

/* ===== Dashboard ===== */
.dash-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.dash-eyebrow { display: flex; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 12px; font-weight: 600; color: var(--color-muted); }
.dash-eyebrow .material-symbols-outlined { font-size: 16px; }
.dash-title { margin: 0; font-size: 28px; font-weight: 700; color: var(--color-ink); letter-spacing: -0.01em; }
.dash-sub { margin: 4px 0 0; color: var(--color-body); font-size: 14px; }
.kpi-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--color-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value { font-size: 30px; font-weight: 700; color: var(--color-ink); font-variant-numeric: tabular-nums; }
.kpi-foot { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-body); }
.kpi-foot .material-symbols-outlined { font-size: 16px; color: var(--color-primary); }
.dash-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.dash-wide { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.card-head h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--color-ink); }
.muted { color: var(--color-muted); }
.block { display: block; font-size: 12px; margin-top: 2px; }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--color-border); font-size: 14px; }
.list-row:first-of-type { border-top: none; }
.list-link { text-decoration: none; color: inherit; }
.list-link:hover strong { color: var(--color-primary-dark); }
.text-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--color-primary-dark); text-decoration: none; }
.text-link .material-symbols-outlined { font-size: 16px; }
.empty-state { color: var(--color-muted); font-size: 14px; margin: 8px 0 0; }
.nia-card { display: flex; gap: 16px; align-items: flex-start; border-color: var(--color-primary-soft); }
.nia-card-avatar { width: 64px; height: auto; flex-shrink: 0; }
.nia-card h2 { margin: 0 0 4px; font-size: 16px; color: var(--color-ink); }
.nia-card p { margin: 0 0 12px; font-size: 14px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 6px 12px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary-dark); font-size: 13px; font-weight: 500; }
@media (min-width: 768px) {
    .kpi-grid { grid-template-columns: repeat(4, 1fr); }
    .dash-grid { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .dash-title { font-size: 32px; }
}

[hidden] { display: none !important; }
.auth-logo-img { height: 36px; width: auto; display: block; }

/* ===== Tender review (split view) ===== */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--color-muted); margin-bottom: 12px; }
.crumbs a { color: var(--color-muted); text-decoration: none; }
.crumbs a:hover { color: var(--color-primary-dark); }
.crumbs .material-symbols-outlined { font-size: 16px; }
.review-head { margin-bottom: 16px; }
.review-head .dash-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.review-head .dash-sub .material-symbols-outlined { font-size: 16px; color: var(--color-muted); }
.notice-verify { display: flex; gap: 10px; align-items: flex-start; background: var(--color-verify-bg); border-color: var(--color-verify-border); color: var(--color-verify); }
.notice-verify .material-symbols-outlined { font-size: 20px; }
.review-split { display: grid; gap: 16px; grid-template-columns: 1fr; }
.review-full { display: block; }
.pane-card { margin-bottom: 16px; }
.pdf-frame { width: 100%; height: 60vh; min-height: 420px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-low); }
/* A preview alongside the facts, not the full-height reader the old single-column layout needed. */
.pdf-frame.pdf-thumb { height: 480px; }
.facts { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; margin: 0; font-size: 14px; }
.facts dt { color: var(--color-muted); }
.facts dd { margin: 0; font-weight: 600; color: var(--color-ink); text-align: right; font-variant-numeric: tabular-nums; }
.summary-text { font-size: 14px; color: var(--color-body); margin: 12px 0 0; }
.check-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 0; border-top: 1px solid var(--color-border); }
.check-row:first-of-type { border-top: none; }
.check-row p { margin: 2px 0 0; font-size: 14px; color: var(--color-ink); }
.kicker { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-muted); }
/*
 * Below desktop width, the point of this page — read Nia's analysis fast, decide eligibility, move
 * on — comes first. The PDF is a secondary "verify" reference, so it's visually pushed after the
 * analysis on a phone or a PWA window, even though it stays first in the markup for source order.
 */
@media (max-width: 1023px) {
    .review-source { order: 2; }
    .review-work { order: 1; }
}

.analysis-icon { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 8px; margin-right: 8px; vertical-align: middle; }
.analysis-icon .material-symbols-outlined { font-size: 16px; }
.analysis-icon.tone-blue { background: #E0F2FE; color: #0369A1; }
.analysis-icon.tone-orange { background: #FFEDD5; color: #C2410C; }
.analysis-icon.tone-red { background: #FEE2E2; color: #B91C1C; }
.analysis-icon.tone-purple { background: #EDE9FE; color: #6D28D9; }

.date-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.date-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--color-border); font-size: 14px; }
.date-list li:first-child { border-top: none; padding-top: 0; }
.date-list li span { color: var(--color-muted); }
.date-list li strong { color: var(--color-ink); font-variant-numeric: tabular-nums; text-align: right; }

.bullet-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; color: var(--color-ink); }

.analysis-subhead { margin: 14px 0 6px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-muted); }
.analysis-subhead:first-child { margin-top: 0; }

@media (min-width: 1024px) {
    .review-split-top { grid-template-columns: 5fr 7fr; align-items: stretch; }
    /* Match the PDF panel's height to the facts column next to it, which is naturally taller
       (two stacked cards) — rather than guessing a fixed number for the PDF on its own. */
    .review-split-top .review-source,
    .review-split-top .review-source .pane-card {
        height: 100%;
        display: flex;
        flex-direction: column;
        margin-bottom: 0;
    }
    .review-split-top .pdf-frame.pdf-thumb { flex: 1; height: auto; min-height: 480px; }
}

/* ===== Organization profile ===== */
.org-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.org-head .dash-sub { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.org-head .dash-sub .material-symbols-outlined { font-size: 16px; color: var(--color-muted); }
.org-chips { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.org-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
.org-kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; align-content: start; }
.kpi-value.small { font-size: 16px; line-height: 1.3; }
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 220px; padding: 8px 4px 0; border-bottom: 1px solid var(--color-border); }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; min-width: 0; }
.bar-value { font-size: 12px; font-weight: 600; color: var(--color-ink); margin-bottom: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar-track { flex: 1; width: 100%; max-width: 56px; display: flex; align-items: flex-end; background: var(--color-surface-low); border-radius: 8px 8px 0 0; }
.bar-fill { width: 100%; background: linear-gradient(180deg, #0284C7, #0369A1); border-radius: 8px 8px 0 0; }
.bar-label { margin-top: 8px; font-size: 12px; color: var(--color-muted); white-space: nowrap; }
@media (min-width: 1024px) {
    .org-grid { grid-template-columns: 7fr 5fr; }
    .org-creds { grid-column: 1 / -1; }
}

/* ===== Nia mobile page ===== */
.nia-page { max-width: 720px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; background: var(--color-surface); }
.nia-page-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--color-border); position: sticky; top: 0; background: rgba(255,255,255,0.95); z-index: 5; }
.nia-back { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; color: var(--color-body); text-decoration: none; }
.nia-back:hover { background: var(--color-surface-low); }
.nia-page-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--color-primary-soft); }
.nia-page-title { display: flex; flex-direction: column; line-height: 1.25; }
.nia-page-title strong { font-size: 16px; color: var(--color-ink); }
.nia-page-title span { font-size: 12px; color: var(--color-muted); display: flex; align-items: center; gap: 6px; }
.nia-online-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-emerald); display: inline-block; }
.nia-context { display: flex; gap: 8px; align-items: flex-start; margin: 12px 16px 0; padding: 10px 12px; background: var(--color-primary-soft); border-radius: var(--radius-sm); font-size: 13px; color: var(--color-primary-dark); }
.nia-context .material-symbols-outlined { font-size: 18px; }
.nia-suggest { padding: 12px 16px 4px; }
.nia-suggest .kicker { margin: 0 0 8px; }
.chip-btn { border: 1px solid var(--color-primary-soft); cursor: pointer; font: inherit; font-size: 13px; }
.chip-btn:hover { background: #BAE6FD; }
.nia-thread { flex: 1; padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; min-height: 260px; }
.nia-thread .nia-bubble { max-width: 85%; }
.nia-composer { position: sticky; bottom: 0; display: flex; align-items: center; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--color-surface); border-top: 1px solid var(--color-border); }
.nia-composer input[type="text"] { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border: 1px solid var(--color-border-strong); border-radius: 999px; font-size: 16px; background: var(--color-surface-low); }
.nia-composer input[type="text"]:focus { outline: none; border-color: var(--color-primary); background: var(--color-surface); box-shadow: 0 0 0 3px rgba(2,132,199,0.15); }
.nia-send { width: 44px; height: 44px; border-radius: 50%; padding: 0; justify-content: center; }
.nia-send .material-symbols-outlined { font-size: 20px; }
.nia-composer .nia-attach-btn { width: 40px; height: 40px; }
.nia-error { margin: 0 16px; }
.nia-attachment-preview { margin: 0 16px; }

/* ===== Form pages (prototype: Add/Edit Organization) ===== */
.page-head { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.page-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--color-primary-soft); color: var(--color-primary-dark); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.page-icon .material-symbols-outlined { font-size: 28px; }
.page-head .dash-title { font-size: 26px; }
.form-page { display: flex; flex-direction: column; gap: 20px; }
.form-section { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: var(--shadow-card); overflow: hidden; }
.form-section-band { display: flex; align-items: center; gap: 12px; padding: 14px 20px; }
.form-section-band h2 { margin: 0; font-size: 17px; font-weight: 600; }
.form-section-band p { margin: 2px 0 0; font-size: 13px; color: var(--color-body); }
.form-section-band .band-note { margin-left: auto; font-size: 13px; color: var(--color-body); }
.band-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255,255,255,0.7); flex-shrink: 0; }
.band-blue { background: #EFF6FF; color: #1E40AF; }
.band-blue h2 { color: #1E3A8A; }
.band-green { background: #ECFDF5; color: #047857; }
.band-green h2 { color: #065F46; }
.band-purple { background: #F5F3FF; color: #5B21B6; }
.band-purple h2 { color: #4C1D95; }
.band-amber { background: #FFFBEB; color: #B45309; }
.band-amber h2 { color: #92400E; }
.form-section-body { padding: 20px; }
.field-grid { display: grid; grid-template-columns: 1fr; gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label, .field > label { font-size: 14px; font-weight: 600; color: var(--color-ink); }
.req { color: var(--color-error); }
.input-wrap { display: flex; align-items: stretch; height: 44px; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); overflow: hidden; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.input-wrap:focus-within { border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(2,132,199,0.15); }
.input-wrap > .material-symbols-outlined { width: 44px; display: flex; align-items: center; justify-content: center; color: var(--color-muted); background: var(--color-surface-low); border-right: 1px solid var(--color-border); font-size: 18px; flex-shrink: 0; }
.input-wrap input { flex: 1; min-width: 0; border: none; padding: 0 12px; font: inherit; font-size: 15px; background: transparent; color: var(--color-ink); }
.input-wrap input:focus { outline: none; box-shadow: none; }
.input-wrap input::placeholder { color: #94A3B8; }
.radio-pills { display: flex; align-items: center; gap: 10px; height: 44px; }
.input-icon-tile { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--color-surface-low); display: inline-flex; align-items: center; justify-content: center; color: var(--color-muted); flex-shrink: 0; }
.pill-option { display: inline-flex; align-items: center; gap: 8px; padding: 0 16px; height: 44px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); font-size: 14px; font-weight: 500; cursor: pointer; background: var(--color-surface); }
.pill-option input { accent-color: var(--color-primary); width: 16px; height: 16px; margin: 0; }
.pill-option:has(input:checked) { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary-dark); }
.form-footer { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 20px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: var(--shadow-card); }
.form-footer .btn { height: 44px; padding: 0 20px; }
.form-footer .btn .material-symbols-outlined { font-size: 18px; }
.credential-add { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.field-action { justify-content: flex-end; }
.field-action .btn { height: 44px; }
@media (min-width: 768px) {
    .field-grid { grid-template-columns: 1fr 1fr; }
    .field-grid .field-wide { grid-column: 1 / -1; }
    .credential-add { grid-template-columns: 1fr 1fr 1fr auto; }
    .credential-add .field-action { align-self: end; }
}
.field-hint { margin: 0; font-size: 13px; color: var(--color-muted); }
.form-page select { flex: 1; min-width: 0; border: none; padding: 0 12px 0 0; font: inherit; font-size: 15px; background: transparent; color: var(--color-ink); appearance: auto; }
.form-page select:focus { outline: none; }
.textarea-box { width: 100%; border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); padding: 12px 14px; font: inherit; font-size: 15px; background: var(--color-surface); color: var(--color-ink); resize: vertical; min-height: 96px; }
.textarea-box:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(2,132,199,0.15); }
.dropzone { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px dashed #94A3B8; border-radius: 12px; background: var(--color-bg); cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.dropzone:hover { background: var(--color-primary-soft); border-color: var(--color-primary); }
.dropzone-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--color-primary-soft); color: var(--color-primary-dark); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.dropzone-text { display: flex; flex-direction: column; font-size: 14px; color: var(--color-body); line-height: 1.35; }
.dropzone-text strong { color: var(--color-primary-dark); }
.dropzone-text small { font-size: 12px; color: var(--color-muted); }
.conditional-field { display: none; }
.conditional-field.is-visible { display: flex; }

/* ===== Tender upload (prototype) ===== */
.page-icon-violet { background: #F3E8FF; color: #7C3AED; }
.field-optional { font-weight: 400; color: var(--color-muted); }
.nia-banner { display: grid; grid-template-columns: auto 1fr; gap: 16px; padding: 20px; background: linear-gradient(90deg, #EEF6FF, #F5F3FF); border-bottom: 1px solid var(--color-border); }
.nia-banner-avatar { width: 88px; height: 88px; object-fit: contain; }
.nia-banner-text strong { display: block; font-size: 17px; color: #1E3A8A; margin-bottom: 4px; }
.nia-banner-text p { margin: 0; font-size: 14px; color: var(--color-body); }
.nia-banner-note { grid-column: 1 / -1; display: flex; gap: 10px; padding-top: 14px; border-top: 1px dashed var(--color-border-strong); }
.nia-banner-note .material-symbols-outlined { color: var(--color-primary); }
.nia-banner-note strong { display: block; font-size: 14px; color: var(--color-ink); }
.nia-banner-note p { margin: 2px 0 0; font-size: 13px; color: var(--color-body); }
.dropzone-large { flex-direction: column; justify-content: center; text-align: center; padding: 36px 20px; gap: 10px; }
.dropzone-cloud { width: 72px; height: 72px; border-radius: 50%; background: #E0ECFF; color: #1D4ED8; display: inline-flex; align-items: center; justify-content: center; }
.dropzone-cloud .material-symbols-outlined { font-size: 36px; }
.dropzone-title { font-size: 15px; color: var(--color-body); }
.dropzone-title strong { color: var(--color-primary); }
.dropzone-large small { font-size: 13px; color: var(--color-muted); }
.hint-icon { font-size: 16px; vertical-align: -3px; }
.form-page .form-footer .btn-primary { min-width: 180px; }
@media (min-width: 768px) {
    .nia-banner { grid-template-columns: auto 1fr 1fr; align-items: start; }
    .nia-banner-note { grid-column: auto; border-top: none; border-left: 1px solid var(--color-border-strong); padding: 0 0 0 16px; padding-top: 0; }
}

/* ===== Nia popup (landscape, ~80% of screen) ===== */
.nia-toggle { width: 60px; height: 60px; padding: 0; background: #FFFFFF; border: 2px solid var(--color-primary-soft); box-shadow: 0 10px 15px -3px rgba(2,132,199,0.2), 0 4px 6px -4px rgba(2,132,199,0.15); overflow: hidden; }
.nia-toggle:hover { background: #FFFFFF; transform: translateY(-1px); }
.nia-toggle-avatar { width: 100%; height: 100%; object-fit: cover; }
.nia-backdrop { position: fixed; inset: 0; background: rgba(11,25,44,0.45); z-index: 40; }
.nia-panel { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); right: auto; bottom: auto; width: 80vw; height: 80vh; max-width: 1400px; max-height: 900px; min-width: 0; background: var(--color-surface); border-radius: 16px; box-shadow: 0 25px 50px -12px rgba(15,23,42,0.35); display: flex; flex-direction: column; overflow: hidden; z-index: 41; }
.nia-panel[hidden] { display: none !important; }
.nia-modal-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--color-border); flex-shrink: 0; }
.nia-modal-head .nia-close { margin-left: auto; width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-body); }
.nia-modal-head .nia-close:hover { background: var(--color-surface-low); }
.nia-modal-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr; }
.nia-rail { display: none; }
.nia-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.nia-main .nia-thread { flex: 1; min-height: 0; overflow-y: auto; padding: 20px 24px; }
.nia-main .nia-error { margin: 0 24px; }
.nia-main .nia-attachment-preview { margin: 0 24px; }
.nia-main .nia-composer { position: static; padding: 14px 24px; }
.nia-rail-chips { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.nia-rail-chips .chip-btn { text-align: left; border-radius: 12px; }
.nia-rail .nia-context { margin: 0 0 16px; }
.nia-rail .kicker { margin: 0 0 10px; }
@media (min-width: 900px) {
    .nia-modal-body { grid-template-columns: 300px 1fr; }
    .nia-rail { display: flex; flex-direction: column; gap: 4px; padding: 20px; background: var(--color-bg); border-right: 1px solid var(--color-border); overflow-y: auto; }
}
@media (max-width: 899px) {
    .nia-panel { top: 0; left: 0; transform: none; width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; }
    .nia-rail { display: none; }
    .nia-main .nia-thread { padding: 14px 16px; }
}
@media (max-width: 899px) {
    .nia-rail { display: flex; flex-direction: column; padding: 10px 16px; border-bottom: 1px solid var(--color-border); background: var(--color-bg); }
    .nia-rail .nia-context, .nia-rail .kicker { display: none; }
    .nia-rail-chips { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 8px; padding-bottom: 2px; }
    .nia-rail-chips .chip-btn { white-space: nowrap; flex-shrink: 0; }
}

/* ===== Nia launcher: bottom-left on every page ===== */
.nia-launcher { position: fixed; left: 16px; bottom: 16px; z-index: 35; }
.nia-launcher .nia-toggle { position: relative; }
@media (min-width: 1024px) {
    .nia-launcher { left: 304px; bottom: 24px; }
}
.nia-toggle { position: relative; }

/* ===== Nia launcher: bottom-right on every page ===== */
.nia-launcher { left: auto; right: 16px; }
@media (min-width: 1024px) {
    .nia-launcher { left: auto; right: 24px; bottom: 24px; }
}

/* ===== Nia tender analysis card ===== */
.nia-card { width: 100%; max-width: 560px; align-self: flex-start; background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary); border-radius: 12px; box-shadow: var(--shadow-card); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.nia-card-done { border-left-color: var(--color-met); }
.nia-card-needs_review { border-left-color: var(--color-partial); }
.nia-card-failed { border-left-color: var(--color-not-met); }
.nia-card-head { display: flex; align-items: center; gap: 12px; }
.nia-card-head strong { font-size: 15px; color: var(--color-ink); }
.nia-card-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--color-primary-soft); flex-shrink: 0; }
.nia-card-note { margin: 2px 0 0; font-size: 13px; color: var(--color-body); display: flex; align-items: center; gap: 4px; }
.nia-card-note .material-symbols-outlined { font-size: 15px; color: var(--color-met); }
.nia-card-warning { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--color-partial-bg); border: 1px solid var(--color-partial-border); color: #92400E; font-size: 13px; }
.nia-card-label { margin: 0; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-muted); }
.nia-count-list { list-style: none; margin: 0; padding: 0; }
.nia-count-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--color-border); font-size: 14px; color: var(--color-body); }
.nia-count-list li strong { color: var(--color-ink); font-variant-numeric: tabular-nums; }
.nia-card-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--color-border); }
.nia-progress-step { margin: 4px 0 0; font-size: 13px; color: var(--color-primary-dark); }
.nia-progress-bar { height: 6px; border-radius: 999px; background: var(--color-surface-low); overflow: hidden; }
.nia-progress-bar span { display: block; height: 100%; width: 35%; background: var(--nia-gradient); border-radius: 999px; animation: nia-slide 1.6s ease-in-out infinite; }
@keyframes nia-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.nia-card [data-retry] { align-self: flex-start; }

/* ===== Nia popup, redesigned to the Nia Assistant screen ===== */
.nia-panel.is-expanded { width: 96vw; height: 92vh; max-width: none; max-height: none; }
.nia-panel .nia-modal-head { gap: 14px; padding: 14px 20px; }
.nia-title-row { display: inline-flex; align-items: center; gap: 8px; }
.nia-badge { padding: 2px 10px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary-dark); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.nia-icon-btn { width: 36px; height: 36px; border: 1px solid transparent; background: transparent; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-body); cursor: pointer; flex-shrink: 0; }
.nia-icon-btn:hover { background: var(--color-surface-low); border-color: var(--color-border); }
.nia-head-meta { display: none; margin-left: auto; align-items: center; gap: 0; }
.nia-meta-item { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-left: 1px solid var(--color-border); min-width: 0; }
.nia-meta-item > .material-symbols-outlined { color: var(--color-primary); font-size: 22px; }
.nia-meta-item small { display: block; font-size: 11px; color: var(--color-muted); }
.nia-meta-item strong { display: block; font-size: 13px; color: var(--color-ink); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nia-modal-head > .nia-icon-btn:last-child { margin-left: 4px; }
.nia-modal-head .nia-head-meta + .nia-icon-btn { margin-left: 0; }
.nia-modal-head > .nia-head-meta:first-of-type { margin-left: auto; }
.nia-rail { padding: 16px; gap: 8px; }
.nia-context-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; box-shadow: var(--shadow-card); }
.nia-context-title { display: flex; align-items: center; gap: 8px; color: var(--color-primary-dark); }
.nia-context-title strong { font-size: 13px; color: var(--color-ink); }
.nia-context-title .nia-info { margin-left: auto; color: var(--color-muted); font-size: 18px; cursor: help; }
.nia-context-card p { margin: 6px 0 0; font-size: 13px; color: var(--color-body); }
.nia-rail-label { margin: 6px 4px 6px; font-size: 13px; font-weight: 600; color: var(--color-ink); }
.nia-suggest-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: 12px; font: inherit; font-size: 13px; color: var(--color-ink); cursor: pointer; box-shadow: var(--shadow-card); }
.nia-suggest-item:hover { border-color: var(--color-primary); }
.nia-suggest-item .material-symbols-outlined { color: var(--color-primary); font-size: 20px; }
.nia-welcome-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-left: 48px; }
.nia-suggest-pill { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: 999px; font: inherit; font-size: 13px; color: var(--color-ink); cursor: pointer; box-shadow: var(--shadow-card); }
.nia-suggest-pill:hover { border-color: var(--color-primary); }
.nia-suggest-pill .material-symbols-outlined { color: var(--color-primary); font-size: 18px; }
.nia-message-assistant { align-items: flex-start; gap: 10px; }
.nia-msg-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--color-primary-soft); flex-shrink: 0; }
.nia-message-assistant .nia-bubble { max-width: 620px; background: var(--color-surface); border: 1px solid var(--color-border); color: var(--color-ink); box-shadow: var(--shadow-card); }
.nia-main .nia-bubble-text + .nia-bubble-text { margin-top: 6px; }
.nia-main .nia-composer input[type="text"] { border-radius: 14px; height: 52px; font-size: 15px; background: var(--color-surface); }
.nia-main .nia-send { width: 52px; height: 52px; border-radius: 50%; background: var(--color-primary); color: #fff; display: inline-flex; align-items: center; justify-content: center; border: none; cursor: pointer; flex-shrink: 0; box-shadow: 0 4px 10px rgba(2,132,199,0.3); }
.nia-main .nia-send:hover { background: var(--color-primary-dark); }
.nia-main .nia-attach-btn { color: var(--color-body); }
.nia-panel.rail-hidden .nia-rail { display: none; }
.nia-panel.rail-hidden .nia-modal-body { grid-template-columns: 1fr; }
@media (min-width: 1100px) {
    .nia-head-meta { display: flex; }
}
@media (max-width: 899px) {
    .nia-modal-head .nia-head-meta { display: none; }
    .nia-welcome-chips { margin-left: 0; }
    .nia-rail { padding: 10px 16px; }
}
@media (max-width: 899px) {
    .nia-context-card, .nia-rail-label { display: none; }
    .nia-rail-chips { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; gap: 8px; }
    .nia-suggest-item { width: auto; flex-shrink: 0; white-space: nowrap; box-shadow: none; }
}
.nia-bubble-welcome { white-space: normal; padding: 14px 18px; }
.nia-bubble-welcome .nia-bubble-text { display: block; }
.nia-bubble-welcome .nia-bubble-text + .nia-bubble-text { margin-top: 10px; }
.nia-message-assistant .nia-bubble { white-space: normal; }

/* ===== Reports ===== */
.page-head-row { justify-content: space-between; flex-wrap: wrap; }
.report-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.report-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: inherit; }
.report-card strong { font-size: 16px; color: var(--color-ink); }
.report-card p { margin: 0; font-size: 14px; color: var(--color-body); }
.report-icon { width: 44px; height: 44px; border-radius: 12px; background: var(--color-primary-soft); color: var(--color-primary-dark); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 6px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.filter-pill { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-body); font-size: 13px; text-decoration: none; }
.filter-pill.is-active { background: var(--color-primary-soft); border-color: var(--color-primary); color: var(--color-primary-dark); font-weight: 600; }
@media (min-width: 768px) { .report-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .report-grid { grid-template-columns: repeat(4, 1fr); } }

/* ===== Background tender processing ===== */
.processing-pill { display: inline-flex; align-items: center; padding: 6px 12px; border-radius: 999px; background: var(--color-primary-soft); color: var(--color-primary-dark); font-size: 13px; font-weight: 600; text-decoration: none; margin-right: 12px; white-space: nowrap; }
.processing-pill[hidden] { display: none; }
.tender-toasts { position: fixed; right: 16px; bottom: 16px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: 320px; }
.tender-toast { background: var(--color-surface); border: 1px solid var(--color-border); border-left: 4px solid var(--color-primary); border-radius: 10px; padding: 10px 14px; box-shadow: var(--shadow-card); color: var(--color-ink); font-size: 14px; text-decoration: none; }
.processing-banner .section-progress { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 6px; font-size: 14px; }
.processing-banner .section-progress li { display: flex; align-items: center; gap: 8px; }
.processing-banner .section-progress .material-symbols-outlined { font-size: 18px; color: var(--color-primary-dark); }

/* ===== Nia formatted replies ===== */
.nia-md { font-size: 14px; line-height: 1.55; }
.nia-md p { margin: 0 0 8px; }
.nia-md p:last-child, .nia-md ul:last-child, .nia-md ol:last-child { margin-bottom: 0; }
.nia-md ul, .nia-md ol { margin: 0 0 8px; padding-left: 20px; }
.nia-md li { margin-bottom: 4px; }
.nia-md strong { font-weight: 600; color: var(--color-ink); }
.nia-md .nia-md-heading { margin-top: 10px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-primary-dark); }

/* ===== Nia chat history ===== */
.nia-new-chat { display: flex; flex-shrink: 0; align-items: center; gap: 6px; width: 100%; margin: 8px 0 12px; padding: 8px 12px; border: 1px solid var(--color-primary); border-radius: 10px; background: var(--color-primary-soft); color: var(--color-primary-dark); font-size: 13px; font-weight: 600; cursor: pointer; }
.nia-chat-list { display: flex; flex-direction: column; flex-shrink: 0; gap: 4px; max-height: 260px; overflow-y: auto; }
.nia-chat-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; padding: 8px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; text-align: left; cursor: pointer; color: var(--color-ink); font-size: 13px; }
.nia-chat-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nia-chat-item small { font-size: 11px; color: var(--color-muted); }
.nia-chat-item:hover { background: var(--color-surface-muted, #F1F5F9); }
.nia-chat-item.is-active { border-color: var(--color-primary); background: var(--color-primary-soft); }
.nia-chat-bar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; overflow-x: auto; }
.nia-chat-bar .nia-new-chat { width: auto; margin: 0; white-space: nowrap; }
.nia-chat-bar .nia-chat-list { flex-direction: row; max-height: none; }
.nia-chat-bar .nia-chat-item { flex-direction: row; align-items: center; gap: 6px; white-space: nowrap; }

/* ===== Chat history page ===== */
.actions-col { white-space: nowrap; text-align: right; }
.inline-form { display: inline; margin: 0 0 0 6px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Nia popup redesign ===== */
.nia-new-chat { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; margin: 4px 0 14px; padding: 12px 14px; border: 0; border-radius: 12px; background: var(--color-primary); color: #fff; font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: 0 6px 16px rgba(2, 132, 199, 0.25); flex-shrink: 0; }
.nia-new-chat:hover { filter: brightness(1.05); }
.nia-rail-head { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.nia-rail-head .nia-rail-label { margin: 0; }
.nia-rail-head .nia-icon-btn { color: var(--color-muted); }
.nia-chat-search { width: 100%; margin: 6px 0 4px; padding: 8px 10px; border: 1px solid var(--color-border); border-radius: 10px; font: inherit; font-size: 13px; background: var(--color-surface); }
.nia-chat-list { gap: 6px; flex-shrink: 0; }
.nia-chat-row { position: relative; display: flex; align-items: stretch; border-radius: 12px; }
.nia-chat-row[hidden] { display: none; }
.nia-chat-row .nia-chat-item { flex: 1; min-width: 0; padding: 10px 12px; border-radius: 12px; background: var(--color-surface); border: 1px solid transparent; }
.nia-chat-row.is-active .nia-chat-item { background: var(--color-primary-soft); border-color: rgba(2, 132, 199, 0.35); }
.nia-chat-title { font-weight: 600; font-size: 13px; color: var(--color-ink); }
.nia-chat-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.nia-chat-meta small { font-size: 11px; color: var(--color-muted); }
.nia-tag { font-style: normal; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.nia-tag-tender { background: #FEE2E2; color: #B91C1C; }
.nia-tag-organization { background: #EDE9FE; color: #6D28D9; }
.nia-tag-project { background: #DCFCE7; color: #15803D; }
.nia-tag-general { background: #FFEDD5; color: #C2410C; }
.nia-chat-menu { position: relative; display: flex; align-items: flex-start; padding-top: 6px; }
.nia-chat-kebab { color: var(--color-muted); }
.nia-chat-menu-pop { position: absolute; right: 0; top: 34px; z-index: 5; min-width: 150px; padding: 6px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; box-shadow: var(--shadow-card); }
.nia-chat-menu-pop[hidden] { display: none; }
.nia-chat-delete { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 13px; color: #B91C1C; cursor: pointer; }
.nia-chat-delete:hover { background: #FEF2F2; }
.nia-all-chats { display: block; margin-top: 10px; font-size: 13px; color: var(--color-primary-dark); text-decoration: none; text-align: center; }

.nia-hero { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 16px 12px 8px; }
.nia-hero-avatar { width: 120px; height: 120px; object-fit: contain; }
.nia-hero h2 { margin: 6px 0 4px; font-size: 26px; font-weight: 700; color: var(--color-ink); }
.nia-hero p { margin: 0; font-size: 15px; color: var(--color-body); }

.nia-action-grid { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 14px 0 6px; }
.nia-action-card { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: var(--shadow-card); font: inherit; text-align: left; cursor: pointer; color: var(--color-ink); }
.nia-action-card:hover { border-color: var(--color-primary); }
.nia-action-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.nia-action-icon .material-symbols-outlined { font-size: 22px; }
.nia-tone-blue { background: #E0F2FE; color: #0369A1; }
.nia-tone-orange { background: #FFEDD5; color: #C2410C; }
.nia-tone-green { background: #DCFCE7; color: #15803D; }
.nia-tone-purple { background: #EDE9FE; color: #6D28D9; }
.nia-tone-red { background: #FEE2E2; color: #B91C1C; }
.nia-action-text { flex: 1; font-size: 14px; font-weight: 600; line-height: 1.35; }
.nia-action-arrow { color: var(--color-primary); }
@media (min-width: 640px) { .nia-action-grid { grid-template-columns: 1fr 1fr; } .nia-action-grid .nia-action-card:last-child:nth-child(odd) { grid-column: 1 / -1; } }

/* ===== Chat history page ===== */
.history-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.history-new { padding: 11px 18px; border-radius: 12px; box-shadow: 0 8px 18px rgba(2, 132, 199, 0.25); }
.history-toolbar { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
.history-search, .history-select { display: flex; align-items: center; gap: 8px; padding: 0 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; min-height: 46px; box-shadow: var(--shadow-card); color: var(--color-muted); }
.history-search input, .history-select select { flex: 1; border: 0; background: transparent; font: inherit; font-size: 14px; color: var(--color-ink); outline: none; min-width: 0; }
.history-group { margin-bottom: 22px; }
.history-group[hidden] { display: none; }
.history-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.history-group-head h2 { margin: 0; font-size: 18px; font-weight: 700; color: var(--color-ink); }
.history-count { font-size: 12px; color: var(--color-muted); background: var(--color-surface-muted, #EEF2F7); padding: 3px 10px; border-radius: 999px; }
.history-date { margin-left: auto; font-size: 13px; color: var(--color-muted); }
.history-row { display: grid; grid-template-columns: 52px minmax(0, 2fr) minmax(0, 1.4fr) 110px minmax(0, 1.3fr) auto; align-items: center; gap: 14px; padding: 12px 14px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: var(--shadow-card); margin-bottom: 10px; }
.history-row[hidden] { display: none; }
.history-icon { width: 46px; height: 46px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.history-icon .material-symbols-outlined { font-size: 22px; }
.history-tone-red { background: #FEE2E2; color: #B91C1C; }
.history-tone-purple { background: #EDE9FE; color: #6D28D9; }
.history-tone-orange { background: #FFEDD5; color: #C2410C; }
.history-tone-blue { background: #E0F2FE; color: #0369A1; }
.history-title { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.history-title strong { font-size: 14px; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-cell { display: flex; flex-direction: column; gap: 4px; font-size: 13px; min-width: 0; }
.history-cell strong { font-weight: 600; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--color-muted); }
.history-label .material-symbols-outlined { font-size: 15px; }
.history-actions { display: flex; align-items: center; gap: 8px; }
.history-menu { position: relative; }
.history-menu summary { list-style: none; cursor: pointer; width: 36px; height: 36px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--color-muted); border: 1px solid var(--color-border); background: var(--color-surface); }
.history-menu summary::-webkit-details-marker { display: none; }
.history-menu[open] summary { color: var(--color-primary-dark); border-color: var(--color-primary); }
.history-menu form { position: absolute; right: 0; top: 42px; z-index: 5; min-width: 170px; padding: 6px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 10px; box-shadow: var(--shadow-card); }
.history-delete { display: flex; align-items: center; gap: 6px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; font: inherit; font-size: 13px; color: #B91C1C; cursor: pointer; }
.history-delete:hover { background: #FEF2F2; }
.history-empty { padding: 30px; text-align: center; color: var(--color-muted); background: var(--color-surface); border: 1px dashed var(--color-border); border-radius: 16px; }
@media (max-width: 1000px) {
    .history-row { grid-template-columns: 46px minmax(0, 1fr) auto; }
    .history-row .history-cell { display: none; }
    .history-row .history-actions { grid-column: 2 / -1; justify-content: flex-start; }
}
@media (min-width: 760px) { .history-toolbar { grid-template-columns: 1fr 260px 200px; } }

/* ===== Login page redesign (scoped to .auth-split) ===== */
.auth-split { position: fixed; inset: 0; z-index: 50; display: grid; grid-template-columns: 1fr; overflow-y: auto; background: var(--color-canvas, #F8FAFC); font-family: 'Inter', system-ui, sans-serif; }
.auth-brand-panel { position: relative; display: none; flex-direction: column; justify-content: space-between; gap: 40px; padding: 48px 56px; overflow: hidden; background: linear-gradient(160deg, #EAF4FF 0%, #F5FAFF 55%, #E6F0FB 100%); }
.auth-brand-panel::before { content: ''; position: absolute; right: -120px; top: -80px; width: 520px; height: 520px; border-radius: 50%; background: radial-gradient(circle, rgba(2, 132, 199, 0.18), rgba(2, 132, 199, 0)); }
.auth-brand-panel::after { content: ''; position: absolute; right: 40px; bottom: -60px; width: 340px; height: 340px; border-radius: 40px; background: linear-gradient(160deg, rgba(14, 165, 233, 0.25), rgba(11, 25, 44, 0.12)); transform: rotate(-12deg); }
.auth-brand-logo { position: relative; z-index: 1; height: 44px; width: auto; align-self: flex-start; }
.auth-hero { position: relative; z-index: 1; max-width: 560px; }
.auth-hero h1 { margin: 0 0 14px; font-size: 44px; line-height: 1.12; font-weight: 800; color: var(--color-ink, #0B192C); }
.auth-hero h1 span { color: var(--color-primary, #0284C7); }
.auth-hero p { margin: 0; font-size: 16px; line-height: 1.6; color: var(--color-body, #475569); }
.auth-features { position: relative; z-index: 1; list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; max-width: 520px; }
.auth-features li { display: flex; align-items: flex-start; gap: 14px; }
.auth-features strong { display: block; font-size: 15px; color: var(--color-ink, #0B192C); }
.auth-features span:not(.auth-feature-icon) { font-size: 13px; color: var(--color-muted, #64748B); }
.auth-feature-icon { flex-shrink: 0; width: 44px; height: 44px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; }
.auth-feature-icon .material-symbols-outlined { font-size: 22px; }
.tone-blue { background: #E0F2FE; color: #0369A1; }
.tone-green { background: #DCFCE7; color: #15803D; }
.tone-purple { background: #EDE9FE; color: #6D28D9; }

.auth-form-panel { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card-modern { width: 100%; max-width: 440px; padding: 36px 34px; background: #fff; border: 1px solid #E2E8F0; border-radius: 22px; box-shadow: 0 20px 50px rgba(11, 25, 44, 0.08); }
.auth-card-brand { display: flex; justify-content: center; margin-bottom: 14px; }
.auth-card-logo { height: 40px; width: auto; }
.auth-card-title { margin: 0 0 22px; text-align: center; font-size: 16px; font-weight: 500; color: var(--color-muted, #64748B); position: relative; }
.auth-segment { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 5px; background: #F1F5F9; border-radius: 14px; margin-bottom: 22px; }
.auth-segment-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 10px; border: 1px solid transparent; border-radius: 10px; background: transparent; font: inherit; font-size: 14px; font-weight: 600; color: var(--color-muted, #64748B); cursor: pointer; }
.auth-segment-btn .material-symbols-outlined { font-size: 18px; }
.auth-segment-btn.is-active { background: #fff; border-color: rgba(2, 132, 199, 0.35); color: var(--color-primary, #0284C7); box-shadow: 0 2px 6px rgba(11, 25, 44, 0.06); }
.auth-form .form-group label { font-size: 13px; font-weight: 600; color: var(--color-ink, #0B192C); }
.auth-input { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 0 14px; height: 50px; border: 1px solid #CBD5E1; border-radius: 12px; background: #fff; }
.auth-input:focus-within { border-color: var(--color-primary, #0284C7); box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15); }
.auth-input > .material-symbols-outlined { color: var(--color-muted, #64748B); font-size: 20px; }
.auth-input input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: inherit; font-size: 15px; color: var(--color-ink, #0B192C); }
.auth-submit { width: 100%; height: 52px; margin-top: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 12px; font-size: 15px; font-weight: 600; box-shadow: 0 10px 22px rgba(2, 132, 199, 0.28); }
.auth-submit .material-symbols-outlined { font-size: 20px; }
.auth-note { margin: 16px 0 0; text-align: center; font-size: 13px; line-height: 1.5; color: var(--color-muted, #64748B); }
.auth-forgot { margin: 14px 0 0; text-align: center; font-size: 13px; }
.auth-forgot a { color: var(--color-primary, #0284C7); text-decoration: none; font-weight: 600; }

@media (min-width: 980px) {
    .auth-split { grid-template-columns: 1.1fr 0.9fr; }
    .auth-brand-panel { display: flex; }
}
@media (max-width: 979px) {
    .auth-hero h1 { font-size: 30px; }
    .auth-brand-panel { display: none; }
}

/* ===== Help page ===== */
.help-shell { min-height: 100vh; padding: 28px 20px 48px; background: var(--color-canvas, #F8FAFC); }
.help-back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px; color: var(--color-primary-dark); text-decoration: none; font-size: 14px; font-weight: 600; }
.help-page { max-width: 880px; margin: 0 auto; }
.help-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.help-head-icon { width: 52px; height: 52px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; background: var(--color-primary-soft); color: var(--color-primary-dark); font-size: 28px; }
.help-toc { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.help-toc a { padding: 6px 12px; border: 1px solid var(--color-border); border-radius: 999px; background: var(--color-surface); color: var(--color-primary-dark); text-decoration: none; font-size: 13px; }
.help-section { margin-bottom: 18px; padding: 20px 22px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 16px; box-shadow: var(--shadow-card); scroll-margin-top: 16px; }
.help-section h2 { margin: 0 0 10px; font-size: 18px; font-weight: 700; color: var(--color-ink); }
.help-section ul, .help-section ol { margin: 0; padding-left: 20px; font-size: 14px; line-height: 1.6; color: var(--color-body); }
.help-section li { margin-bottom: 8px; }
.help-section p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--color-body); }
.help-faq dt { margin-top: 12px; font-weight: 700; color: var(--color-ink); font-size: 14px; }
.help-faq dt:first-child { margin-top: 0; }
.help-faq dd { margin: 4px 0 0; font-size: 14px; line-height: 1.6; color: var(--color-body); }
.help-contact { background: var(--color-primary-soft); border-color: transparent; }
.auth-help-link { position: absolute; top: 22px; right: 28px; z-index: 60; display: inline-flex; align-items: center; gap: 6px; color: var(--color-primary, #0284C7); text-decoration: none; font-size: 14px; font-weight: 600; }
.auth-help-link .material-symbols-outlined { font-size: 20px; }
.auth-split { position: fixed; }
.help-contact-list { list-style: none; padding: 0; margin: 12px 0 0; display: grid; gap: 8px; }
.help-contact-list li { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.help-contact-list .material-symbols-outlined { color: var(--color-primary-dark); font-size: 20px; }
.help-contact-list a { color: var(--color-primary-dark); font-weight: 600; text-decoration: none; }

/* ===== Login page to match the approved design ===== */
.auth-split { background: #F4F7FB; }
.auth-brand-panel { background: url('../images/login-building.png') right bottom / 60% auto no-repeat, linear-gradient(160deg, #EAF4FF 0%, #F5FAFF 55%, #E6F0FB 100%); padding: 40px 56px 36px; }
.auth-brand-panel::before, .auth-brand-panel::after { display: none; }
.auth-brand-logo { height: 46px; }
.auth-hero { margin-top: 36px; }
.auth-hero h1 { font-size: 54px; line-height: 1.08; font-weight: 800; letter-spacing: -0.01em; }
.auth-hero h1 span { display: inline-block; }
.auth-hero p { margin-top: 18px; font-size: 19px; line-height: 1.5; color: #64748B; max-width: 560px; }
.auth-features { margin-top: 36px; gap: 22px; }
.auth-features strong { font-size: 17px; }
.auth-features span:not(.auth-feature-icon) { font-size: 15px; }
.auth-feature-icon { width: 56px; height: 56px; border-radius: 16px; }
.auth-feature-icon .material-symbols-outlined { font-size: 26px; }
.auth-stats { display: flex; align-items: center; gap: 22px; margin-top: 44px; flex-wrap: wrap; }
.auth-stats > div { display: flex; align-items: center; gap: 12px; padding-right: 22px; border-right: 1px solid #CBD5E1; }
.auth-stats > div:last-child { border-right: 0; }
.auth-stats .material-symbols-outlined { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; background: #E0F2FE; color: #0369A1; font-size: 22px; }
.auth-stats strong { display: block; font-size: 22px; font-weight: 800; color: var(--color-ink, #0B192C); }
.auth-stats small { font-size: 13px; color: #64748B; }
.auth-card-modern { padding: 40px 42px 36px; border-radius: 24px; }
.auth-card-logo { height: 46px; }
.auth-card-title { display: flex; align-items: center; gap: 14px; font-size: 16px; color: #64748B; margin-bottom: 26px; }
.auth-card-title::before, .auth-card-title::after { content: ''; flex: 1; height: 1px; background: #E2E8F0; }
.auth-card-title span { white-space: nowrap; }
.auth-segment { background: #F1F5F9; padding: 6px; border-radius: 16px; }
.auth-segment-btn { padding: 13px 10px; border-radius: 12px; font-size: 15px; }
.auth-input { height: 54px; }
.auth-submit { height: 56px; font-size: 16px; }
.auth-or { display: flex; align-items: center; gap: 14px; margin: 22px 0 18px; color: #94A3B8; font-size: 14px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: #E2E8F0; }
.auth-note { font-size: 14px; }
.auth-help-link { top: 26px; right: 36px; font-size: 15px; }
@media (max-width: 979px) {
    .auth-brand-panel { display: none; }
}

/* ===== Login layout fixes (match approved design) ===== */
.auth-features div > span { font-size: 15px; color: #64748B; }
.auth-features div > strong { font-size: 17px; }
.auth-feature-icon .material-symbols-outlined { font-size: 26px; color: inherit; }
.auth-input input, .auth-input input:focus { border: 0 !important; box-shadow: none !important; background: transparent !important; padding: 0; height: auto; }
.auth-brand-logo { mix-blend-mode: multiply; height: 52px; }
.auth-card-logo { mix-blend-mode: multiply; }
.auth-brand-panel { padding: 30px 56px 28px; }
.auth-hero { margin-top: 28px; }
.auth-hero h1 { font-size: clamp(40px, 4vw, 52px); white-space: nowrap; }
.auth-hero h1 span { display: block; }
.auth-hero p { margin-top: 14px; font-size: 18px; }
.auth-features { margin-top: 26px; gap: 14px; }
.auth-feature-icon { width: 52px; height: 52px; }
.auth-stats { margin-top: 26px; }
@media (max-height: 900px) {
    .auth-hero h1 { font-size: clamp(36px, 3.6vw, 46px); }
    .auth-features { gap: 10px; }
    .auth-stats { margin-top: 18px; }
}

/* ===== Login: match approved design, fit one screen ===== */
.auth-split { overflow: hidden; }
.auth-brand-panel { background: linear-gradient(160deg, #EEF5FD 0%, #F6F9FD 100%); padding: 34px 56px 30px; justify-content: flex-start; }
.auth-building { position: absolute; right: 0; bottom: 0; height: 88%; width: auto; max-width: 62%; object-fit: contain; object-position: right bottom; z-index: 0; opacity: 0.95; pointer-events: none; }
.auth-brand-panel > *:not(.auth-building) { position: relative; z-index: 1; }
.auth-brand-logo { mix-blend-mode: normal; height: 48px; }
.auth-hero { margin-top: 26px; }
.auth-hero h1 { font-size: clamp(40px, 3.9vw, 54px); line-height: 1.1; white-space: normal; }
.auth-hero h1 span { display: block; }
.auth-hero p { margin-top: 12px; font-size: 18px; line-height: 1.5; max-width: 620px; }
.auth-features { margin-top: 24px; gap: 14px; }
.auth-features li { align-items: center; }
.auth-feature-icon { width: 54px; height: 54px; border-radius: 16px; }
.auth-feature-icon .material-symbols-outlined { font-size: 26px !important; line-height: 1; }
.auth-stats { margin-top: 26px; gap: 18px; }
.auth-stats > div { padding-right: 18px; }
@media (max-height: 900px) {
    .auth-hero h1 { font-size: clamp(36px, 3.4vw, 46px); }
    .auth-features { gap: 10px; }
    .auth-feature-icon { width: 48px; height: 48px; }
    .auth-stats { margin-top: 16px; }
}

/* ===== Login: final fit for one screen ===== */
.auth-brand-panel { min-height: 100vh; justify-content: flex-start; padding: 28px 48px 24px; }
.auth-brand-logo { mix-blend-mode: multiply; height: 44px; }
.auth-building { height: 58%; max-width: 40%; right: 0; bottom: 0; opacity: 1; }
.auth-hero { margin-top: 22px; }
.auth-hero h1 { font-size: clamp(38px, 3.4vw, 48px); }
.auth-hero p { margin-top: 10px; font-size: 17px; max-width: 520px; }
.auth-features { margin-top: 22px; gap: 12px; max-width: 480px; }
.auth-feature-icon { width: 46px; height: 46px; border-radius: 14px; }
.auth-features strong { font-size: 16px; }
.auth-features div > span { font-size: 14px; }
.auth-stats { flex-wrap: nowrap; margin-top: 22px; gap: 0; max-width: 560px; }
.auth-stats > div { flex: 1 1 0; min-width: 0; padding: 0 14px; gap: 10px; }
.auth-stats > div:first-child { padding-left: 0; }
.auth-stats .material-symbols-outlined { width: 40px; height: 40px; font-size: 20px; flex-shrink: 0; }
.auth-stats strong { font-size: 20px; }
.auth-stats small { font-size: 12px; white-space: nowrap; }
@media (max-height: 1000px) {
    .auth-hero h1 { font-size: clamp(34px, 3vw, 42px); }
    .auth-features { gap: 8px; margin-top: 16px; }
    .auth-feature-icon { width: 42px; height: 42px; }
    .auth-stats { margin-top: 14px; }
}

/* ===== Assessibility report ===== */
.kpi-value-text { font-size: 15px; line-height: 1.3; }
.page-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ===== Credential rows on the organization form ===== */
.credential-heading { margin: 0 0 4px; }
.credential-hint { margin: 0 0 16px; }
.credential-row { display: grid; grid-template-columns: 1.4fr 1.2fr 1fr; gap: 14px; align-items: end; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px dashed var(--color-border); }
.credential-row:last-of-type { border-bottom: 0; }
.credential-row .field { margin: 0; }
.credential-add { margin-top: 6px; }
@media (max-width: 720px) {
    .credential-row { grid-template-columns: 1fr; gap: 10px; }
}
