:root {
    --bg: #f5f7fa;
    --panel: #ffffff;
    --panel-soft: #f9fafb;
    --text: #1f2937;
    --muted: #64748b;
    --line: #d8dee8;
    --brand: #176b87;
    --brand-dark: #0f4f63;
    --accent: #7a5c00;
    --success: #1f7a4d;
    --warning: #9a5b00;
    --danger: #b42318;
    --shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    line-height: 1.45;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.topbar {
    align-items: center;
    background: #ffffff;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    min-height: 72px;
    padding: 12px 24px;
}

.brand {
    align-items: center;
    display: flex;
    gap: 12px;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    align-items: center;
    background: var(--brand);
    border-radius: 6px;
    color: #ffffff;
    display: inline-flex;
    font-weight: 700;
    height: 46px;
    justify-content: center;
    width: 46px;
}

.logo-mark {
    background: #ffffff;
    border: 1px solid var(--line);
    overflow: hidden;
}

.logo-mark img {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.brand strong {
    color: var(--text);
    display: block;
    font-size: 18px;
}

.brand span:last-child {
    color: var(--muted);
    display: block;
    font-size: 13px;
}

.topbar-actions {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    min-width: 0;
}

.profile-menu {
    flex: 0 0 auto;
    position: relative;
}

.profile-trigger {
    align-items: center;
    background: transparent;
    border: 0;
    cursor: pointer;
    display: inline-flex;
    padding: 0;
}

.profile-avatar {
    align-items: center;
    background: var(--brand);
    border: 2px solid #dbeafe;
    border-radius: 50%;
    color: #ffffff;
    display: inline-flex;
    font-size: 14px;
    font-weight: 800;
    height: 36px;
    justify-content: center;
    width: 36px;
}

.profile-trigger:hover .profile-avatar,
.profile-trigger[aria-expanded="true"] .profile-avatar {
    background: var(--brand-dark);
}

.profile-dropdown {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-width: 220px;
    padding: 8px;
    position: absolute;
    right: 0;
    top: calc(100% + 10px);
    z-index: 90;
}

.profile-dropdown[hidden] {
    display: none;
}

.profile-summary {
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
    padding: 8px 10px 10px;
}

.profile-summary strong,
.profile-summary span {
    display: block;
}

.profile-summary span {
    color: var(--muted);
    font-size: 13px;
}

.profile-menu-item {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    cursor: pointer;
    display: block;
    font: inherit;
    font-size: 14px;
    padding: 9px 10px;
    text-align: left;
    width: 100%;
}

.profile-menu-item:hover {
    background: #eef7fa;
    color: var(--brand);
    text-decoration: none;
}

.sr-only {
    height: 1px;
    margin: -1px;
    overflow: hidden;
    position: absolute;
    width: 1px;
}

.nav {
    background: transparent;
    border-bottom: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
    overflow: visible;
    padding: 0;
    position: relative;
    z-index: 40;
}

.nav a {
    background: #eef6ff;
    border: 1px solid #9ec5fe;
    border-radius: 8px;
    color: #0f3f71;
    align-items: center;
    display: inline-flex;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    min-height: 32px;
    padding: 6px 11px;
    white-space: nowrap;
}

.nav-label {
    display: inline-block;
}

.menu-badge {
    align-items: center;
    background: #e8eef5;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--brand);
    display: inline-flex;
    font-size: 11px;
    font-weight: 800;
    justify-content: center;
    line-height: 1;
    min-width: 22px;
    padding: 4px 6px;
}

.nav a.active {
    background: #2d74e7;
    border-color: #1f62d0;
    color: #ffffff;
}

.nav a:hover {
    background: #dcecff;
    color: #0b3768;
    text-decoration: none;
}

.nav a.active:hover {
    background: #1f62d0;
    color: #ffffff;
}

.nav-dropdown {
    padding-bottom: 6px;
    position: relative;
}

.nav-dropdown > button {
    align-items: center;
    background: #eef6ff;
    border: 1px solid #9ec5fe;
    border-radius: 8px;
    color: #0f3f71;
    cursor: pointer;
    display: inline-flex;
    gap: 7px;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    min-height: 32px;
    padding: 6px 11px;
    white-space: nowrap;
}

.dropdown-arrow {
    font-size: 10px;
    line-height: 1;
    margin-top: 1px;
}

.nav-dropdown.active > button,
.nav-dropdown:hover > button,
.nav-dropdown:focus-within > button {
    background: #2d74e7;
    border-color: #1f62d0;
    color: #ffffff;
}

.nav-dropdown-menu {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: none;
    min-width: 148px;
    padding: 6px;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 80;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.nav-dropdown-menu a {
    background: transparent;
    border: 0;
    border-radius: 6px;
    color: var(--text);
    display: flex;
    font-size: 13px;
    justify-content: flex-end;
    min-height: 32px;
    padding: 9px 10px;
    text-align: right;
    white-space: nowrap;
    width: 100%;
}

.nav-dropdown-menu a.active,
.nav-dropdown-menu a:hover {
    background: #eef7fa;
    color: var(--brand);
    text-decoration: none;
}

.page {
    margin: 0 auto;
    max-width: 1320px;
    padding: 24px 28px 44px;
}

.page-title {
    align-items: end;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 18px;
}

.page-title h1 {
    font-size: 26px;
    margin: 0 0 4px;
}

.page-title p {
    color: var(--muted);
    margin: 0;
}

.grid {
    display: grid;
    gap: 16px;
}

.metrics {
    grid-template-columns: repeat(6, minmax(130px, 1fr));
}

.audit-metrics {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.audit-filters {
    align-items: end;
    grid-template-columns: minmax(240px, 2fr) minmax(150px, 1fr) minmax(170px, 1fr) auto;
}

.filter-actions {
    margin: 0;
    white-space: nowrap;
}

.two-col {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.metric {
    min-height: 98px;
}

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

.metric strong {
    display: block;
    font-size: 26px;
}

.section-title {
    align-items: center;
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.section-title h2 {
    font-size: 18px;
    margin: 0;
}

.table-wrap {
    overflow-x: auto;
}

table {
    border: 1px solid #bdc7d4;
    border-collapse: collapse;
    width: 100%;
}

th,
td {
    border-bottom: 1px solid #c5ced9;
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
}

th {
    background: #e5eaf0;
    color: #3f4f63;
    font-size: 12px;
    text-transform: uppercase;
}

tbody tr:nth-child(even) td {
    background: #f5f7fa;
}

tbody tr:hover td {
    background: #eaf0f5;
}

tr:last-child td {
    border-bottom: 0;
}

.badge {
    border-radius: 999px;
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 9px;
    white-space: nowrap;
}

.approval-stage-badge {
    line-height: 1.25;
    max-width: 135px;
    text-align: center;
    white-space: normal;
}

.badge.neutral {
    background: #eef2f7;
    color: #42526b;
}

.badge.success {
    background: #dff6e9;
    color: var(--success);
}

.badge.warning {
    background: #fff1cf;
    color: var(--warning);
}

.badge.danger {
    background: #ffe4df;
    color: var(--danger);
}

.btn {
    align-items: center;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 700;
    min-height: 38px;
    padding: 8px 12px;
}

.btn:hover {
    background: var(--brand-dark);
    text-decoration: none;
}

.btn.secondary {
    background: #ffffff;
    color: var(--brand);
}

.btn.secondary:hover {
    background: #eef7fa;
}

.btn.danger-btn {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.btn.danger-btn:hover {
    background: #8f1c13;
}

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

.row-actions {
    align-items: center;
    display: flex;
    gap: 12px;
}

.icon-action-btn {
    align-items: center;
    background: transparent;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    height: 30px;
    justify-content: center;
    padding: 0;
    transition: background-color 0.15s ease, color 0.15s ease;
    width: 30px;
}

.icon-action-btn svg {
    fill: none;
    height: 22px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 22px;
}

.edit-icon-btn {
    color: #f5a000;
}

.edit-icon-btn:hover {
    background: #fff5d9;
    color: #d88900;
}

.view-icon-btn {
    color: #18a34a;
}

.view-icon-btn:hover {
    background: #e8f8ee;
    color: #14813b;
}

.delete-icon-btn {
    color: #df2638;
}

.delete-icon-btn:hover {
    background: #ffe8eb;
    color: #b91c2d;
}

.icon-action-btn:disabled {
    background: transparent;
    cursor: not-allowed;
    opacity: 0.35;
}

.filters {
    align-items: end;
    display: grid;
    gap: 12px;
    grid-template-columns: 2fr repeat(5, minmax(130px, 1fr)) auto;
    margin-bottom: 16px;
}

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

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

.field.full {
    grid-column: 1 / -1;
}

label {
    color: #334155;
    font-weight: 700;
}

.help-tip {
    align-items: center;
    background: #e8eef5;
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--brand);
    cursor: help;
    display: inline-flex;
    font-size: 11px;
    font-weight: 700;
    height: 18px;
    justify-content: center;
    margin-left: 4px;
    position: relative;
    vertical-align: middle;
    width: 18px;
}

.help-tip::after {
    background: #1f2937;
    border-radius: 6px;
    bottom: calc(100% + 8px);
    color: #ffffff;
    content: attr(data-tooltip);
    font-size: 12px;
    font-weight: 400;
    left: 50%;
    line-height: 1.35;
    opacity: 0;
    padding: 8px 10px;
    pointer-events: none;
    position: absolute;
    text-transform: none;
    transform: translateX(-50%) translateY(4px);
    transition: opacity 0.12s ease, transform 0.12s ease;
    visibility: hidden;
    white-space: normal;
    width: 240px;
    z-index: 20;
}

.help-tip::before {
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid #1f2937;
    bottom: calc(100% + 2px);
    content: "";
    left: 50%;
    opacity: 0;
    position: absolute;
    transform: translateX(-50%);
    visibility: hidden;
    z-index: 21;
}

.help-tip:hover::after,
.help-tip:focus::after,
.help-tip:hover::before,
.help-tip:focus::before {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    visibility: visible;
}

input,
select,
textarea {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 40px;
    padding: 9px 10px;
    width: 100%;
}

textarea {
    min-height: 96px;
    resize: vertical;
}

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

.narrow-card {
    max-width: 560px;
}

.flash {
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 12px 14px;
}

.flash.success {
    background: #dff6e9;
    color: var(--success);
}

.flash.warning {
    background: #fff3cd;
    color: #7a5a00;
}

.flash.error {
    background: #ffe4df;
    color: var(--danger);
}

body.is-processing {
    overflow: hidden;
}

.processing-overlay {
    align-items: center;
    background: rgba(246, 248, 251, 0.82);
    display: flex;
    inset: 0;
    justify-content: center;
    position: fixed;
    z-index: 3000;
}

.processing-overlay[hidden] {
    display: none;
}

.processing-panel {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 12px 30px rgba(23, 42, 67, 0.16);
    color: var(--text);
    display: flex;
    gap: 12px;
    max-width: calc(100vw - 32px);
    padding: 16px 20px;
}

.processing-spinner {
    animation: processing-spin 0.8s linear infinite;
    border: 3px solid #dbe6f2;
    border-radius: 50%;
    border-top-color: var(--brand);
    flex: 0 0 auto;
    height: 24px;
    width: 24px;
}

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

@media (prefers-reduced-motion: reduce) {
    .processing-spinner {
        animation-duration: 1.6s;
    }
}

.auth-page {
    align-items: center;
    display: flex;
    min-height: 100vh;
    background: #eeeeef;
}

.auth-shell {
    margin: 0 auto;
    max-width: 520px;
    padding: 24px;
    width: 100%;
}

.auth-brand {
    align-items: center;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 18px;
    text-decoration: none;
}

.auth-brand:hover {
    text-decoration: none;
}

.auth-brand strong {
    color: var(--text);
    display: block;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0;
    line-height: 1.1;
    text-align: center;
    text-transform: uppercase;
}

.auth-brand span:last-child {
    color: #64748b;
    display: block;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

.auth-logo {
    display: block;
    height: 96px;
    width: 96px;
}

.auth-logo img {
    display: block;
    height: 100%;
    object-fit: contain;
    width: 100%;
}

.auth-card h1 {
    margin: 0 0 6px;
}

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

.auth-card .field {
    margin-top: 14px;
    padding: 0 20px;
}

.auth-card {
    border-color: #98a6ba;
    border-radius: 10px;
    box-shadow: none;
    padding: 0 0 20px;
}

.auth-card-title {
    border-bottom: 1px solid #98a6ba;
    font-size: 18px;
    font-weight: 800;
    padding: 16px;
    text-align: center;
}

.auth-card label {
    color: #1f2937;
    font-size: 15px;
    font-weight: 800;
}

.auth-card input {
    background: #eaf2ff;
    border-color: #c6d3e4;
    font-size: 15px;
    min-height: 42px;
}

.auth-card input:focus {
    border-color: #2d74e7;
    box-shadow: 0 0 0 3px rgba(45, 116, 231, 0.18);
    outline: none;
}

.auth-submit {
    justify-content: center;
    margin: 18px auto 0;
    min-width: 140px;
    width: auto;
}

.auth-card .auth-submit {
    display: flex;
}

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

.auth-note {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-size: 13px;
    margin: 18px 0 0;
    padding: 10px;
    display: none;
}

.reset-link-box {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-top: 16px;
    overflow-wrap: anywhere;
    padding: 12px;
}

.modal-backdrop {
    align-items: center;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 22px;
    position: fixed;
    z-index: 100;
}

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

.modal {
    background: var(--panel);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
    max-height: calc(100vh - 44px);
    max-width: 760px;
    overflow-y: auto;
    padding: 18px;
    width: 100%;
}

.confirm-modal {
    max-width: 520px;
}

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

.modal-header {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    margin: -2px 0 16px;
    padding-bottom: 12px;
}

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

.modal-close {
    align-items: center;
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 50%;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    font-size: 16px;
    font-weight: 700;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.modal-close:hover {
    background: #eef2f7;
    color: var(--text);
}

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

.checkbox-field {
    justify-content: end;
}

.checkbox-field label {
    align-items: center;
    display: flex;
    gap: 8px;
    min-height: 40px;
}

.checkbox-field input {
    min-height: auto;
    width: auto;
}

.reviewer-option-list {
    background: #f7f9fc;
    border: 1px solid #b8c5d3;
    border-radius: 6px;
    display: grid;
    gap: 2px;
    max-height: 210px;
    overflow-y: auto;
    padding: 6px;
}

.reviewer-option {
    align-items: center;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    gap: 9px;
    min-height: 36px;
    padding: 6px 8px;
}

.reviewer-option:hover {
    background: #e7eef6;
}

.reviewer-option input {
    flex: 0 0 auto;
    min-height: auto;
    width: auto;
}

.review-plan-summary {
    background: #f4f8fc;
    border: 1px solid #b8c5d3;
    border-radius: 6px;
    margin-top: 16px;
    padding: 14px;
}

.review-plan-summary .section-title {
    margin-bottom: 12px;
}

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

.stat-list {
    display: grid;
    gap: 10px;
}

.stat-line {
    align-items: center;
    display: grid;
    gap: 10px;
    grid-template-columns: 150px minmax(0, 1fr) 42px;
}

.bar {
    background: #e8eef5;
    border-radius: 999px;
    height: 10px;
    overflow: hidden;
}

.bar span {
    background: var(--brand);
    display: block;
    height: 100%;
}

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

.guidance-list article {
    background: var(--panel-soft);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.guidance-list h3 {
    font-size: 16px;
    margin: 0 0 6px;
}

.guidance-list p {
    color: var(--muted);
    margin: 0;
}

@media (max-width: 1080px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .nav {
        justify-content: flex-start;
    }

    .metrics,
    .audit-metrics,
    .two-col,
    .filters,
    .form-grid,
    .guidance-list {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 640px) {
    .topbar {
        align-items: start;
        gap: 12px;
        padding: 14px 18px;
    }

    .topbar-actions {
        align-items: flex-start;
        flex-direction: column-reverse;
        gap: 10px;
    }

    .nav-dropdown-menu {
        left: 0;
        right: auto;
    }

    .page {
        padding: 18px;
    }
}
