:root {
    color-scheme: light;
    --primary: #2f5d8c;
    --primary-dark: #24486f;
    --primary-soft: #e8f0f8;
    --accent: #5d7894;
    --surface-muted: #eef2f6;
    --ink: #1f2933;
    --muted: #64748b;
    --line: #d8e0e8;
    --panel: #ffffff;
    --page: #f6f8fb;
    --danger: #b42318;
    --success: #067647;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    height: 100%;
}

body {
    background: var(--page);
    color: var(--ink);
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    margin: 0;
}

a {
    color: inherit;
}

.auth-shell {
    align-items: center;
    background:
        linear-gradient(90deg, rgba(18, 49, 86, 0.1) 0%, rgba(246, 250, 255, 0.2) 45%, rgba(246, 250, 255, 0.42) 100%),
        url("../images/imatt_bg.png") center / cover no-repeat;
    display: flex;
    justify-content: flex-end;
    min-height: 100vh;
    overflow: hidden;
    padding: clamp(24px, 5vw, 68px);
    position: relative;
}

.auth-shell::after {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(240, 247, 255, 0.36) 58%, rgba(240, 247, 255, 0.52) 100%);
    content: "";
    inset: 0;
    pointer-events: none;
    position: absolute;
}

.site-shell {
    display: grid;
    grid-template-columns: 218px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: #ffffff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow-y: auto;
    position: sticky;
    top: 0;
}

.sidebar-brand {
    border-bottom: 1px solid var(--line);
    padding: 18px 18px 16px;
}

.sidebar-brand span {
    color: var(--muted);
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    margin-bottom: 4px;
    text-transform: uppercase;
}

.sidebar-brand strong {
    color: var(--primary);
    display: block;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.1;
}

.module-nav {
    display: grid;
    gap: 4px;
    padding: 12px 10px;
}

.module-link {
    align-items: center;
    border-radius: 6px;
    color: #334155;
    display: flex;
    font-size: 13px;
    font-weight: 600;
    gap: 10px;
    min-height: 34px;
    padding: 8px 10px;
    text-decoration: none;
}

.module-link:hover {
    background: var(--primary-soft);
    color: var(--primary);
}

.module-link.is-active {
    background: var(--primary);
    color: #ffffff;
}

.module-icon {
    flex: 0 0 16px;
    font-size: 14px;
    text-align: center;
}

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

.workspace-topbar {
    align-items: center;
    background: var(--primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    color: #ffffff;
    display: flex;
    flex-shrink: 0;
    justify-content: space-between;
    min-height: 46px;
    padding: 0 18px;
}

.breadcrumb {
    align-items: center;
    display: flex;
    font-size: 13px;
    gap: 7px;
}

.breadcrumb span {
    color: #dbe9eb;
}

.breadcrumb-separator {
    color: #cfe0f1;
    font-size: 17px;
    line-height: 1;
}

.account-menu {
    position: relative;
}

.account-menu summary {
    align-items: center;
    border-radius: 999px;
    cursor: pointer;
    display: flex;
    font-size: 13px;
    font-weight: 700;
    gap: 8px;
    list-style: none;
    padding: 5px 8px 5px 5px;
}

.account-menu summary::-webkit-details-marker {
    display: none;
}

.account-menu summary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.user-avatar {
    align-items: center;
    background: #ffffff;
    border-radius: 50%;
    color: var(--primary);
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    height: 26px;
    justify-content: center;
    width: 26px;
}

.user-name {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-chevron {
    border-bottom: 2px solid currentColor;
    border-right: 2px solid currentColor;
    display: inline-block;
    height: 6px;
    margin-left: 2px;
    transform: rotate(45deg) translateY(-1px);
    transition: transform 140ms ease;
    width: 6px;
}

.account-menu[open] .account-chevron {
    transform: rotate(225deg) translateY(-1px);
}

.account-dropdown {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 30px rgba(31, 41, 51, 0.16);
    color: var(--ink);
    min-width: 230px;
    padding: 10px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 10;
}

.account-meta {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 2px;
    padding: 8px 8px 10px;
}

.account-meta strong {
    font-size: 13px;
}

.account-meta span {
    color: var(--muted);
    font-size: 12px;
}

.account-dropdown button {
    align-items: center;
    background: var(--surface-muted);
    border: 1px solid var(--surface-muted);
    border-radius: 6px;
    color: var(--ink);
    cursor: pointer;
    display: flex;
    font: inherit;
    font-size: 13px;
    gap: 9px;
    justify-content: flex-start;
    margin-top: 8px;
    min-height: 34px;
    padding: 7px 9px;
    width: 100%;
}

.account-dropdown button:hover {
    background: var(--primary-soft);
    border-color: var(--primary-soft);
    color: var(--primary);
}

.page-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 28px;
}

.auth-panel,
.content-panel,
.page-header,
.metric-grid,
.welcome-card {
    margin-left: auto;
    margin-right: auto;
    max-width: 1280px;
}

.auth-panel {
    background: rgba(255, 255, 255, 0.68);
    backdrop-filter: blur(22px) saturate(130%);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 14px;
    box-shadow: 0 24px 70px rgba(28, 61, 102, 0.22);
    margin: 0;
    max-width: 420px;
    padding: 30px;
    position: relative;
    width: 100%;
    z-index: 1;
}

.login-panel {
    margin-right: clamp(10px, 4vw, 72px);
}

.login-brand {
    margin-bottom: 24px;
}

.login-brand .eyebrow {
    color: #416b98;
}

.login-brand h1 {
    color: #17395d;
    font-size: 30px;
    letter-spacing: 0;
}

.login-brand p {
    color: #49657f;
    line-height: 1.55;
    margin: 8px 0 0;
}

.login-form {
    gap: 16px;
}

.floating-field {
    display: block;
    position: relative;
}

.floating-field input {
    background: rgba(255, 255, 255, 0.74);
    border-color: rgba(111, 143, 176, 0.45);
    border-radius: 9px;
    color: #17395d;
    font-weight: 600;
    min-height: 52px;
    padding: 20px 14px 8px;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
    width: 100%;
}

.floating-field input:focus {
    background: rgba(255, 255, 255, 0.92);
    border-color: #3b74ad;
    box-shadow: 0 0 0 4px rgba(47, 93, 140, 0.15);
}

.floating-field input:-webkit-autofill,
.floating-field input:-webkit-autofill:hover,
.floating-field input:-webkit-autofill:focus {
    -webkit-text-fill-color: #17395d;
    box-shadow: 0 0 0 1000px rgba(255, 255, 255, 0.92) inset;
    transition: background-color 9999s ease-out;
}

.floating-field span {
    color: #627b95;
    font-size: 13px;
    font-weight: 700;
    left: 14px;
    pointer-events: none;
    position: absolute;
    top: 17px;
    transition: color 150ms ease, font-size 150ms ease, top 150ms ease;
}

.floating-field input:focus+span,
.floating-field input:not(:placeholder-shown)+span,
.floating-field.has-value span {
    color: #2f5d8c;
    font-size: 11px;
    top: 7px;
}

.password-field input {
    padding-right: 48px;
}

.password-toggle {
    background: transparent;
    border: 0;
    border-radius: 8px;
    color: #5d7894;
    height: 36px;
    min-height: 36px;
    padding: 0;
    position: absolute;
    right: 8px;
    top: 8px;
    width: 36px;
}

.password-toggle:hover,
.password-toggle:focus {
    background: rgba(47, 93, 140, 0.12);
    border-color: transparent;
    color: #24486f;
}

.login-submit {
    background: #2f5d8c;
    border-color: #2f5d8c;
    border-radius: 9px;
    box-shadow: 0 14px 26px rgba(47, 93, 140, 0.24);
    min-height: 46px;
    margin-top: 2px;
    width: 100%;
}

.login-footer {
    border-top: 1px solid rgba(111, 143, 176, 0.28);
    color: #5d7894;
    display: flex;
    flex-wrap: wrap;
    font-size: 11px;
    font-weight: 700;
    gap: 6px 10px;
    justify-content: space-between;
    margin-top: 22px;
    padding-top: 14px;
    text-transform: uppercase;
}

.password-panel {
    max-width: 460px;
}

.welcome-card,
.content-panel,
.metric-card {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.04);
}

.welcome-card {
    padding: 22px 24px;
}

.welcome-card h1 {
    font-size: 28px;
    margin: 0 0 8px;
}

.welcome-card p {
    color: var(--muted);
    margin: 0;
}

.welcome-card a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

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

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

.content-panel {
    padding: 20px;
}

.content-panel table {
    min-width: 960px;
}

.content-panel {
    overflow-x: auto;
}

.eyebrow {
    color: var(--accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 5px;
    text-transform: uppercase;
}

h1 {
    font-size: 24px;
    line-height: 1.2;
    margin: 0;
}

.review-title {
    align-items: center;
    display: flex;
    gap: 10px;
}

.review-title i {
    font-size: 22px;
}

.review-title span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.muted {
    color: var(--muted);
}

.form-stack {
    display: grid;
    gap: 14px;
}

label {
    color: var(--ink);
    display: grid;
    font-size: 13px;
    font-weight: 700;
    gap: 7px;
}

input,
select {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    padding: 9px 10px;
}

input:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(47, 93, 140, 0.14);
    outline: 0;
}

button,
.button {
    align-items: center;
    background: var(--primary);
    border: 1px solid var(--primary);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    gap: 6px;
    justify-content: center;
    min-height: 36px;
    padding: 8px 12px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

button:disabled,
.button[disabled],
.button.is-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    pointer-events: none;
}

.button.secondary {
    background: #ffffff;
    border-color: #9fb3c8;
    color: var(--primary-dark);
    box-shadow: 0 1px 2px rgba(31, 41, 51, 0.06);
}

.button.secondary:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.button.excel-button {
    background: #15803d;
    border-color: #15803d;
    color: #ffffff;
}

.button.excel-button:hover {
    background: #166534;
    border-color: #166534;
    color: #ffffff;
}

.alert {
    border-radius: 6px;
    font-size: 13px;
    margin: 14px auto;
    max-width: 980px;
    padding: 10px 12px;
}

.alert-error {
    background: #fef3f2;
    color: var(--danger);
}

.alert-success {
    background: #eef8f0;
    color: var(--success);
}

.toast-stack {
    display: grid;
    gap: 10px;
    max-width: 340px;
    position: fixed;
    right: 24px;
    bottom: 24px;
    width: min(340px, calc(100vw - 48px));
    z-index: 200;
}

.toast {
    align-items: center;
    animation: toast-in 180ms ease-out;
    background: #ffffff;
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(31, 41, 51, 0.16);
    color: var(--ink);
    display: flex;
    font-size: 13px;
    gap: 12px;
    justify-content: space-between;
    padding: 12px 12px 12px 14px;
}

.toast-success {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--danger);
}

.toast-close {
    align-items: center;
    background: var(--surface-muted);
    border-color: var(--surface-muted);
    border-radius: 50%;
    color: var(--muted);
    flex: 0 0 24px;
    font-size: 12px;
    height: 24px;
    min-height: 24px;
    padding: 0;
    width: 24px;
}

.toast-close:hover {
    background: var(--line);
    border-color: var(--line);
    color: var(--ink);
}

.toast.is-hiding {
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 180ms ease, transform 180ms ease;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-top: 16px;
}

.admin-metric-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

.metric-card {
    padding: 16px;
}

.metric-card span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-bottom: 8px;
}

.metric-card strong {
    color: var(--primary);
    font-size: 26px;
}

.metric-card small {
    color: var(--muted);
    display: block;
    font-size: 12px;
    line-height: 1.35;
    margin-top: 6px;
}

.dashboard-placeholder {
    margin-top: 16px;
}

.dashboard-placeholder h2,
.placeholder-panel h2,
.settings-grid h2 {
    font-size: 16px;
    margin: 0 0 8px;
}

.filter-panel {
    padding: 14px;
}

.filter-form {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.filter-actions {
    align-items: center;
    display: flex;
    gap: 8px;
}

.section-heading-row {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.section-heading-row h2 {
    font-size: 17px;
    margin: 0;
}

.table-subtext {
    color: var(--muted);
    display: block;
    font-size: 12px;
    margin-top: 2px;
}

.history-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 150px);
    overflow: hidden;
}

.admin-history-panel {
    max-height: calc(100vh - 270px);
}

.history-table-scroll {
    min-height: 0;
    overflow: auto;
}

.history-table-scroll thead th {
    background: #ffffff;
    position: sticky;
    top: 0;
    z-index: 1;
}

.admin-history-table {
    min-width: 1040px;
    table-layout: fixed;
}

.admin-history-table th,
.admin-history-table td {
    padding: 9px 10px;
    vertical-align: middle;
}

.admin-history-table th:nth-child(1) {
    width: 36%;
}

.admin-history-table th:nth-child(2) {
    width: 16%;
}

.admin-history-table .status-column {
    width: 108px;
}

.admin-history-table th:nth-child(4) {
    width: 132px;
}

.admin-history-table .cost-column {
    width: 150px;
}

.admin-history-table .actions-column {
    width: 182px;
}

.admin-history-table .filename-cell {
    line-height: 1.35;
    min-width: 0;
    overflow-wrap: anywhere;
}

.admin-history-status-cell {
    white-space: nowrap;
}

.admin-status-chip {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    gap: 5px;
    line-height: 1;
    min-height: 23px;
    padding: 3px 8px;
}

.admin-status-dot {
    background: currentColor;
    border-radius: 50%;
    flex-shrink: 0;
    height: 6px;
    width: 6px;
}

.admin-review-flag {
    align-items: center;
    background: #fff7e6;
    border: 1px solid #f3d38b;
    border-radius: 50%;
    color: #946200;
    display: inline-flex;
    font-size: 11px;
    height: 23px;
    justify-content: center;
    margin-left: 4px;
    vertical-align: top;
    width: 23px;
}

.admin-history-cost-cell strong {
    color: var(--ink);
    display: block;
    font-size: 13px;
    line-height: 1.2;
}

.admin-history-table .table-actions {
    flex-wrap: nowrap;
}

.admin-history-table .table-actions .button {
    min-width: 0;
    padding: 7px 10px;
}

.placeholder-panel {
    align-items: center;
    display: grid;
    justify-items: center;
    min-height: 220px;
    text-align: center;
}

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

.settings-panel {
    max-width: 820px;
}

.settings-section-header {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
}

.settings-section-header h2 {
    font-size: 18px;
    margin: 0 0 6px;
}

.settings-module-panel {
    max-width: 900px;
}

.settings-module-list {
    display: grid;
    margin-top: 8px;
}

.settings-module-row {
    align-items: center;
    border-top: 1px solid var(--line);
    display: grid;
    gap: 14px;
    grid-template-columns: 40px minmax(0, 1fr) auto auto;
    padding: 14px 0;
}

.settings-module-row:last-child {
    border-bottom: 1px solid var(--line);
}

.settings-module-icon {
    align-items: center;
    background: #eef4fb;
    border-radius: 8px;
    color: var(--primary);
    display: inline-flex;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.settings-module-copy h3 {
    font-size: 15px;
    margin: 0 0 4px;
}

.settings-module-copy p {
    margin: 0;
}

.settings-module-row .button {
    min-width: 104px;
}

.settings-modal-dialog {
    max-width: 760px;
}

.settings-modal-summary {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: space-between;
}

.settings-modal-summary p {
    margin: 0;
}

.settings-modal-dialog .settings-actions {
    justify-content: flex-end;
}

.switch-setting {
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    gap: 14px;
    padding: 14px;
}

.switch-setting input {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

.switch-track {
    background: #d9e2ec;
    border-radius: 999px;
    flex-shrink: 0;
    height: 26px;
    position: relative;
    transition: background 160ms ease;
    width: 48px;
}

.switch-track::after {
    background: #ffffff;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(31, 41, 51, 0.22);
    content: "";
    height: 20px;
    left: 3px;
    position: absolute;
    top: 3px;
    transition: transform 160ms ease;
    width: 20px;
}

.switch-setting input:checked + .switch-track {
    background: var(--primary);
}

.switch-setting input:checked + .switch-track::after {
    transform: translateX(22px);
}

.switch-copy {
    display: grid;
    gap: 3px;
}

.switch-copy small {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.checkbox-row {
    align-items: center;
    display: flex;
    font-weight: 600;
    gap: 8px;
}

.checkbox-row input {
    width: auto;
}

.settings-actions {
    justify-content: flex-start;
}

.settings-grid article {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.settings-grid p {
    margin: 0;
}

.status-pill {
    border-radius: 999px;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
}

.status-pill.is-active {
    background: #eef8f0;
    color: var(--success);
}

.status-pill.is-inactive {
    background: #f3eee8;
    color: var(--muted);
}

.status-pill.is-warning {
    background: #fff7e6;
    color: #946200;
}

.status-pending {
    background: #fff7e6;
    color: #946200;
}

.status-processing {
    background: var(--primary-soft);
    color: var(--primary);
}

.status-review_required {
    background: #eef2ff;
    color: #3730a3;
}

.status-approved,
.status-exported {
    background: #eef8f0;
    color: var(--success);
}

.status-failed {
    background: #fef3f2;
    color: var(--danger);
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.table-actions form {
    margin: 0;
}

.table-actions .button,
.table-actions button {
    min-width: 104px;
}

.page-header>button,
.modal-actions button,
.password-panel button {
    min-width: 126px;
}

.form-note {
    background: var(--primary-soft);
    border-radius: 6px;
    color: var(--muted);
    font-size: 12px;
    margin: 0;
    padding: 10px;
}

.password-panel {
    display: grid;
    gap: 18px;
}

.modal-backdrop {
    align-items: center;
    background: rgba(34, 31, 36, 0.48);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 22px;
    position: fixed;
    z-index: 100;
}

.modal-backdrop[hidden] {
    display: none;
}

.modal-dialog {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 24px 60px rgba(34, 31, 36, 0.28);
    max-width: 560px;
    padding: 20px;
    width: 100%;
}

.wide-modal {
    max-width: 1040px;
}

.preview-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: 360px minmax(0, 1fr);
}

.preview-grid h3 {
    font-size: 15px;
    margin: 0 0 10px;
}

.detail-table th {
    color: var(--muted);
    width: 130px;
}

.review-section {
    margin-top: 22px;
}

.review-section h2 {
    font-size: 16px;
    margin: 0 0 10px;
}

.hash-cell {
    font-family: Consolas, Monaco, monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}

.modal-header {
    align-items: flex-start;
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
}

.modal-header h2 {
    font-size: 20px;
    margin: 0;
}

.icon-button {
    align-items: center;
    border-radius: 50%;
    height: 34px;
    justify-content: center;
    padding: 0;
    width: 34px;
}

.form-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 4px;
}

table {
    border-collapse: collapse;
    font-size: 13px;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 10px;
    text-align: left;
}

th {
    color: #40565b;
    font-size: 12px;
}

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

.filename-cell {
    overflow-wrap: anywhere;
}

.filename-cell-inner {
    align-items: center;
    display: flex;
    gap: 8px;
    min-width: 0;
}

.filename-text {
    min-width: 0;
    overflow-wrap: anywhere;
}

.file-icon-pdf {
    color: #e03e2d;
    flex-shrink: 0;
    font-size: 15px;
}

.file-icon-img {
    color: #2563eb;
    flex-shrink: 0;
    font-size: 15px;
}

.inline-alert {
    background: #fef3f2;
    border-radius: 6px;
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 14px;
    padding: 10px 12px;
}

/* ── Document review ─────────────────────────────────────────── */

.doc-review-warning {
    align-items: center;
    background: #fff7e6;
    border: 1px solid #f6c000;
    border-radius: 8px;
    color: #946200;
    display: flex;
    font-size: 13px;
    font-weight: 600;
    gap: 10px;
    margin: 0 auto 18px;
    max-width: 1280px;
    padding: 10px 14px;
}

.doc-section {
    margin-bottom: 28px;
}

.doc-section:last-child {
    margin-bottom: 0;
}

.doc-section-header {
    align-items: center;
    display: flex;
    gap: 8px;
    justify-content: space-between;
    margin-bottom: 10px;
}

.doc-section-title {
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0;
    text-transform: uppercase;
}

.copy-section-button {
    align-items: center;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 7px;
    color: var(--muted);
    display: inline-flex;
    height: 30px;
    justify-content: center;
    min-height: 30px;
    min-width: 30px;
    padding: 0;
    width: 30px;
}

.copy-section-button:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.copy-section-button.is-copied {
    background: #ecfdf5;
    border-color: #86efac;
    color: #15803d;
}

.doc-fields-grid {
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 1px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    overflow: hidden;
}

.doc-field {
    background: var(--panel);
    padding: 10px 14px;
}

.doc-field dt {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    margin-bottom: 3px;
    text-transform: uppercase;
}

.doc-field dd {
    color: var(--ink);
    font-size: 13px;
    font-weight: 500;
    margin: 0;
    word-break: break-word;
}

.doc-table-scroll {
    overflow-x: auto;
}

.doc-table-notes,
.doc-notes-list {
    color: var(--muted);
    font-size: 12px;
    margin: 8px 0 0;
    padding-left: 18px;
}

/* ── Drag-and-drop uploader ──────────────────────────────────── */

.uploader {
    border: 2px dashed var(--line);
    border-radius: 14px;
    background: var(--page);
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: border-color 0.18s, background 0.18s;
    user-select: none;
}

.uploader:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.uploader.is-dragover {
    border-color: var(--primary);
    border-style: solid;
    background: var(--primary-soft);
}

.uploader.has-file {
    cursor: default;
    border-color: #6ee7b7;
    border-style: solid;
    background: #f0fdf4;
}

.uploader.is-processing {
    cursor: wait;
    border-color: var(--line);
    border-style: solid;
    background: var(--primary-soft);
}

.uploader-idle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    padding: 2.5rem 2rem;
}

.uploader-doc-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    margin-bottom: 1.1rem;
    transition: background 0.18s, color 0.18s;
}

.uploader:hover .uploader-doc-icon,
.uploader.is-dragover .uploader-doc-icon {
    background: #c7d2fe;
    color: var(--primary-dark);
}

.uploader-headline {
    font-size: 0.975rem;
    font-weight: 600;
    color: var(--ink);
    margin: 0 0 0.55rem;
}

.uploader-or {
    font-size: 0.825rem;
    color: var(--muted);
    margin: 0 0 0.65rem;
}

.uploader-browse {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.45rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--panel);
    color: var(--ink);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
    margin-bottom: 1.1rem;
}

.uploader-browse:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.uploader-hint {
    font-size: 0.75rem;
    color: var(--muted);
    margin: 0;
    letter-spacing: 0.01em;
}

.uploader-selected {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.75rem 2rem;
    width: 100%;
}

.uploader-file-row {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    background: var(--panel);
    border: 1px solid #d1fae5;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.uploader-file-thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.uploader-file-thumb.is-image {
    background: #dbeafe;
    color: #2563eb;
}

.uploader-file-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.uploader-file-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.uploader-file-size {
    font-size: 0.75rem;
    color: var(--muted);
}

.uploader-remove {
    width: 28px;
    height: 28px;
    min-height: unset;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--page);
    color: var(--muted);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.uploader-remove:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: var(--danger);
}

.uploader-auto-submit {
    font-size: 0.8rem;
    color: var(--primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-weight: 500;
}

.uploader-processing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2.5rem;
    width: 100%;
}

.uploader-spin-icon {
    font-size: 1.75rem;
    color: var(--primary);
}

.ai-check-loader {
    position: relative;
    width: 76px;
    height: 76px;
    border-radius: 50%;
    display: grid;
    place-items: center;
}

.ai-check-loader::before {
    content: "";
    position: absolute;
    inset: 4px;
    border-radius: 50%;
    border: 3px solid #dbeafe;
    border-top-color: var(--primary);
    border-right-color: #14b8a6;
    animation: ai-loader-spin 0.9s linear infinite;
}

.ai-check-loader::after {
    content: "";
    position: absolute;
    inset: 18px;
    border-radius: 50%;
    background: var(--panel);
    box-shadow: 0 0 0 1px var(--line), 0 0 28px rgba(67, 56, 202, 0.18);
    animation: ai-loader-pulse 1.3s ease-in-out infinite;
}

.ai-check-loader span {
    position: relative;
    z-index: 1;
    width: 32px;
    height: 3px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--primary), transparent);
    animation: ai-loader-scan 1.1s ease-in-out infinite;
}

@keyframes ai-loader-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes ai-loader-pulse {

    0%,
    100% {
        transform: scale(0.92);
        opacity: 0.78;
    }

    50% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ai-loader-scan {

    0%,
    100% {
        transform: translateY(-8px);
        opacity: 0.55;
    }

    50% {
        transform: translateY(8px);
        opacity: 1;
    }
}

.uploader-processing-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary);
    margin: 0;
}

.uploader-processing-sub {
    font-size: 0.78rem;
    color: var(--muted);
    margin: 0;
}

@media (max-width: 1180px) {
    .admin-metric-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 860px) {
    .site-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
        position: static;
    }

    .module-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .workspace-topbar,
    .page-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .page-content {
        padding: 20px 14px;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .filter-form {
        grid-template-columns: 1fr;
    }

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

    .section-heading-row {
        align-items: flex-start;
        flex-direction: column;
    }

    .history-panel,
    .admin-history-panel {
        max-height: calc(100vh - 180px);
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-module-row {
        align-items: flex-start;
        grid-template-columns: 40px minmax(0, 1fr);
    }

    .settings-module-row .status-pill,
    .settings-module-row .button {
        grid-column: 2;
        justify-self: start;
    }

    .switch-setting {
        align-items: flex-start;
    }

    .settings-modal-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .preview-grid {
        grid-template-columns: 1fr;
    }

    .account-dropdown {
        left: 0;
        right: auto;
    }

    .toast-stack {
        bottom: 14px;
        left: 14px;
        right: 14px;
        width: auto;
        max-width: none;
    }

    .auth-shell {
        align-items: center;
        justify-content: center;
        padding: 20px;
    }

    .auth-shell::after {
        background: rgba(238, 246, 255, 0.48);
    }

    .auth-panel {
        padding: 24px;
    }

    .login-panel {
        margin-right: 0;
    }
}

/* ── Admin User Management actions ───────────────────────────── */

.admin-user-panel {
    overflow-x: auto;
}

.admin-user-table {
    min-width: 1080px;
}

.admin-user-table th:last-child,
.admin-user-table td:last-child {
    width: 210px;
}

.admin-user-table .security-badges {
    align-items: flex-start;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.admin-user-table .table-actions {
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
    position: relative;
}

.admin-user-table .table-actions .button,
.admin-user-table .table-actions button {
    min-width: 88px;
}

.admin-user-table .action-menu {
    position: relative;
}

.admin-user-table .action-menu summary {
    list-style: none;
}

.admin-user-table .action-menu summary::-webkit-details-marker {
    display: none;
}

.admin-user-table .action-menu-trigger {
    padding-right: 28px;
    position: relative;
}

.admin-user-table .action-menu-trigger::after {
    border-bottom: 2px solid currentColor;
    border-right: 2px solid currentColor;
    content: "";
    height: 6px;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-60%) rotate(45deg);
    width: 6px;
}

.admin-user-table .action-menu[open] .action-menu-trigger {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-dark);
}

.admin-user-table .action-menu[open] .action-menu-trigger::after {
    transform: translateY(-35%) rotate(225deg);
}

.admin-user-table .action-menu-panel {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 14px 30px rgba(31, 41, 51, 0.16);
    min-width: 210px;
    padding: 6px;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 30;
}

.admin-user-table .action-menu-panel form {
    margin: 0;
}

.admin-user-table .action-menu-item {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 6px;
    box-shadow: none;
    color: var(--ink);
    display: flex;
    font-size: 13px;
    font-weight: 700;
    justify-content: flex-start;
    min-height: 36px;
    min-width: 0;
    padding: 8px 10px;
    text-align: left;
    width: 100%;
}

.admin-user-table .action-menu-item:hover {
    background: var(--primary-soft);
    border-color: transparent;
    color: var(--primary-dark);
}

.admin-user-table .action-menu-item.is-warning {
    color: #946200;
}

.admin-user-table .action-menu-item.is-warning:hover {
    background: #fff7e6;
    color: #946200;
}

.admin-user-table .action-menu-item.is-danger {
    color: var(--danger);
}

.admin-user-table .action-menu-item.is-danger:hover {
    background: #fef3f2;
    color: var(--danger);
}

.admin-user-table .action-menu-item.is-success {
    color: var(--success);
}

.admin-user-table .action-menu-item.is-success:hover {
    background: #eef8f0;
    color: var(--success);
}

@media (max-width: 860px) {
    .admin-user-table {
        min-width: 980px;
    }

    .admin-user-table .table-actions {
        flex-wrap: nowrap;
    }

    .admin-user-table .action-menu-panel {
        left: 0;
        right: auto;
    }
}

.system-logs-panel .section-heading-row {
    margin-bottom: 14px;
}

.system-logs-scroll {
    overflow-x: auto;
}

.system-logs-table {
    border-collapse: collapse;
    min-width: 900px;
    table-layout: fixed;
    width: 100%;
}

.system-logs-table th,
.system-logs-table td {
    border-bottom: 1px solid var(--line);
    padding: 9px 10px;
    text-align: left;
    vertical-align: middle;
}

.system-logs-table thead th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.system-logs-table tbody tr:hover {
    background: var(--surface-muted);
}

.system-logs-table .when-col {
    width: 130px;
}

.system-logs-table .event-col {
    width: 140px;
}

.system-logs-table .ip-col {
    color: var(--muted);
    font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
    font-size: 12px;
    width: 130px;
}

.system-logs-table .browser-col {
    color: var(--muted);
    width: 100px;
}

.system-logs-table .when-col strong {
    color: var(--ink);
    display: block;
    font-size: 13px;
    line-height: 1.2;
}

.event-chip {
    align-items: center;
    border-radius: 999px;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    gap: 5px;
    line-height: 1;
    padding: 4px 9px;
}

.event-chip.event-auth {
    background: #e8f0f8;
    color: var(--primary-dark);
}

.event-chip.event-admin {
    background: #fff7e6;
    color: #946200;
}

.event-chip.event-docfile {
    background: #eef8f0;
    color: var(--success);
}

.event-chip.event-other {
    background: var(--surface-muted);
    color: var(--muted);
}

@media (max-width: 860px) {
    .system-logs-table {
        min-width: 820px;
    }
}
