/* Verb Cyber Compliance — Linen & Steel WCAG 2.2 AA Responsive Design System */
:root {
    --bg-linen: #F5F3EE;
    --bg-surface: #FFFFFF;
    --bg-subtle: #ECE8DF;
    --steel-primary: #3B5B78;
    --steel-dark: #2A4359;
    --text-primary: #1F2933;
    --text-secondary: #4A5568;
    --border-subtle: #D8D3C8;

    --status-compliant-bg: #E6F4EA;
    --status-compliant-fg: #137333;
    --status-warning-bg: #FEF7E0;
    --status-warning-fg: #9A5B00;
    --status-fail-bg: #FCE8E6;
    --status-fail-fg: #C5221F;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-linen);
    color: var(--text-primary);
    line-height: 1.5;
}

.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0);
}

.skip-link {
    position: absolute; left: -9999px; background: var(--steel-primary); color: #fff; padding: 8px 14px; z-index: 999;
}
.skip-link:focus { left: 10px; top: 10px; }

.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Sticky Top Navigation */
.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.topbar-inner {
    max-width: 1320px;
    margin: 0 auto;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.brand-link {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: var(--steel-primary);
    color: #fff;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.brand-text { display: flex; flex-direction: column; }
.brand-text strong { font-size: 15px; line-height: 1.2; }
.brand-text small { font-size: 11px; color: var(--text-secondary); }

.primary-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.nav-link {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 12px;
    border-radius: 6px;
    border: none;
    background: transparent;
    cursor: pointer;
    min-height: 36px;
}

.nav-link:hover { background: var(--bg-subtle); }
.nav-link.active { background: var(--steel-primary); color: #fff; font-weight: 600; }

.nav-dropdown { position: relative; }
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 190px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    padding: 6px;
    z-index: 200;
}
.nav-dropdown.open .dropdown-menu,
.nav-dropdown:hover .dropdown-menu { display: block; }
.dropdown-menu a {
    display: block;
    padding: 8px 12px;
    text-decoration: none;
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 13px;
}
.dropdown-menu a:hover { background: var(--bg-subtle); }

.actor-switcher select {
    padding: 7px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-linen);
    color: var(--text-primary);
    font-size: 13px;
    max-width: 280px;
}

.mobile-nav-toggle {
    display: none;
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-linen);
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.scope-ribbon {
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-subtle);
    padding: 8px 0;
    font-size: 13px;
}

.scope-ribbon-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.main-workspace { padding-top: 24px; padding-bottom: 40px; }

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

.page-header h1 { margin: 0 0 4px 0; font-size: 22px; }
.page-header p { margin: 0; color: var(--text-secondary); font-size: 14px; }

/* Cards & Grids */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 18px;
    margin-bottom: 20px;
}

.kpi-card { margin-bottom: 0; }
.kpi-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 28px; font-weight: 700; margin: 6px 0 4px 0; }
.kpi-sub { font-size: 12px; color: var(--text-secondary); }

.two-col-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 20px;
}

/* Accessible Badges (Icon + Text, never color alone) */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-compliant { background: var(--status-compliant-bg); color: var(--status-compliant-fg); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning-fg); }
.badge-non_compliant { background: var(--status-fail-bg); color: var(--status-fail-fg); }
.badge-unknown { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-role { background: #EBF2F7; color: var(--steel-dark); margin-left: 6px; }

/* Responsive Data Tables (reflow into stacked cards on narrow screens) */
.table-wrap { width: 100%; overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

table.data-table th,
table.data-table td {
    text-align: left;
    padding: 11px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

table.data-table th {
    background: var(--bg-linen);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Forms & Buttons */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
}

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 13px; font-weight: 600; }
.form-group input,
.form-group select,
.form-group textarea {
    padding: 8px 10px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    color: var(--text-primary);
    min-height: 38px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 6px;
    font-size: 13.5px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    min-height: 36px;
}

.btn-primary { background: var(--steel-primary); color: #fff; }
.btn-primary:hover { background: var(--steel-dark); }
.btn-secondary { background: var(--bg-linen); color: var(--text-primary); border-color: var(--border-subtle); }
.btn-secondary:hover { background: var(--bg-subtle); }

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid var(--border-subtle);
    background: #EBF4FF;
}

.mono { font-family: Consolas, Monaco, monospace; font-size: 12px; }

.portal-footer {
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    padding: 16px 0;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Mobile Breakpoint (< 820px) */
@media (max-width: 820px) {
    .two-col-grid { grid-template-columns: 1fr; }
    .mobile-nav-toggle { display: inline-flex; }
    .primary-nav { display: none; width: 100%; flex-direction: column; align-items: stretch; }
    .primary-nav.open { display: flex; }
    .actor-switcher, .actor-switcher select { width: 100%; max-width: 100%; }

    table.data-table thead { display: none; }
    table.data-table tr {
        display: block;
        border: 1px solid var(--border-subtle);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 8px;
        background: var(--bg-surface);
    }
    table.data-table td {
        display: flex;
        justify-content: space-between;
        gap: 12px;
        border-bottom: 1px solid #EFECE6;
        padding: 7px 6px;
    }
    table.data-table td:last-child { border-bottom: none; }
    table.data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 12px;
    }
}


/* Button Size & Danger Variants */
.btn-xs { padding: 5px 10px; font-size: 12px; min-height: 28px; }
.btn-danger { background: var(--status-fail-bg); color: var(--status-fail-fg); border-color: #F5C2C0; }
.btn-danger:hover { background: #F9D6D3; }

/* Sortable Table Headers */
a.sort-link {
    color: var(--text-secondary);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}
a.sort-link:hover { color: var(--steel-primary); text-decoration: underline; }

/* Visual Organizational Chart Diagram */
.org-chart-canvas {
    overflow-x: auto;
    padding: 16px 8px;
    background: var(--bg-linen);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.org-tree-list {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 22px 0 0 0;
    margin: 0;
    list-style: none;
    position: relative;
}

.org-chart-canvas > .org-tree-list {
    padding-top: 4px;
}

.org-tree-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 20px 8px 0 8px;
}

.org-chart-canvas > .org-tree-list > .org-tree-item {
    padding-top: 0;
}

/* Connector lines between Parent OU and Child OUs */
.org-tree-list .org-tree-list::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #B8B1A3;
    height: 22px;
}

.org-tree-list .org-tree-list > .org-tree-item::before,
.org-tree-list .org-tree-list > .org-tree-item::after {
    content: "";
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #B8B1A3;
    width: 50%;
    height: 20px;
}

.org-tree-list .org-tree-list > .org-tree-item::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #B8B1A3;
}

.org-tree-list .org-tree-list > .org-tree-item:only-child::after,
.org-tree-list .org-tree-list > .org-tree-item:only-child::before {
    display: none;
}

.org-tree-list .org-tree-list > .org-tree-item:only-child {
    padding-top: 0;
}

.org-tree-list .org-tree-list > .org-tree-item:first-child::before,
.org-tree-list .org-tree-list > .org-tree-item:last-child::after {
    border: 0 none;
}

.org-tree-list .org-tree-list > .org-tree-item:last-child::before {
    border-right: 2px solid #B8B1A3;
    border-radius: 0 6px 0 0;
}

.org-tree-list .org-tree-list > .org-tree-item:first-child::after {
    border-radius: 6px 0 0 0;
}

.org-node-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    border-radius: 10px;
    padding: 12px 14px;
    min-width: 245px;
    max-width: 280px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.org-node-card.selected {
    border-color: var(--steel-primary);
    box-shadow: 0 0 0 3px rgba(59, 91, 120, 0.18);
}

.org-node-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.org-node-title {
    font-weight: 700;
    font-size: 14px;
    color: var(--text-primary);
    text-decoration: none;
    display: block;
}
.org-node-title:hover { color: var(--steel-primary); text-decoration: underline; }

.org-node-code {
    font-size: 11px;
    color: var(--text-secondary);
}

.org-node-counts {
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-linen);
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}

.org-node-policy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    margin-bottom: 10px;
}

.org-node-actions {
    display: flex;
    gap: 6px;
    border-top: 1px solid #EFECE6;
    padding-top: 8px;
}

/* Policy Override Rows */
.override-row {
    display: grid;
    grid-template-columns: 1.4fr 110px 1fr;
    gap: 10px;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #EFECE6;
}
.override-row:last-of-type { border-bottom: none; }
.override-label { display: flex; flex-direction: column; font-size: 13px; }
.override-mode-select,
.override-row input,
.override-row select {
    padding: 6px 8px;
    border: 1px solid var(--border-subtle);
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
}
.override-row input:disabled,
.override-row select:disabled {
    background: var(--bg-linen);
    color: var(--text-secondary);
}

/* Native HTML5 Dialog Modals */
dialog.portal-modal {
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 0;
    width: min(760px, 94vw);
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
}
dialog.portal-modal::backdrop {
    background: rgba(31, 41, 51, 0.55);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
    background: var(--bg-linen);
}
.modal-body {
    padding: 20px;
    max-height: 75vh;
    overflow-y: auto;
}
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-linen);
}

@media (max-width: 720px) {
    .override-row { grid-template-columns: 1fr; }
}


/* Plain Non-Oval Status Indicators (for Role & Status columns without pill ovals) */
.status-text-active {
    color: var(--status-compliant-fg);
    font-weight: 600;
}
.status-text-inactive {
    color: var(--status-fail-fg);
    font-weight: 600;
}

/* View Toggle Group & Pagination */
.view-toggle-group {
    display: inline-flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.pagination-links {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.disabled-btn {
    opacity: 0.45;
    pointer-events: none;
}

/* Horizontal Overflow, String Truncation & Resizable Column Headers */
.horizontal-grid-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

table.resizable-grid {
    table-layout: fixed;
    border-collapse: collapse;
    min-width: 100%;
}

table.resizable-grid th,
table.resizable-grid td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    border-right: 1px solid #EFECE6;
}

table.resizable-grid th:last-child,
table.resizable-grid td:last-child {
    border-right: none;
}

table.resizable-grid th {
    padding-right: 16px;
    user-select: none;
}

.col-resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
    background: transparent;
}

.col-resizer::after {
    content: "";
    position: absolute;
    top: 22%;
    bottom: 22%;
    right: 3px;
    width: 2px;
    background: #C5BEB0;
    transition: background-color 0.15s ease;
}

.col-resizer:hover::after,
.col-resizer:focus::after,
.col-resizer.resizing::after {
    background: var(--steel-primary);
    width: 3px;
}

/* Keep horizontal off-screen scrolling on narrow viewports for resizable grids */
@media (max-width: 820px) {
    table.resizable-grid thead { display: table-header-group; }
    table.resizable-grid tr {
        display: table-row;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
    }
    table.resizable-grid td {
        display: table-cell;
        border-bottom: 1px solid var(--border-subtle);
        padding: 10px 12px;
    }
    table.resizable-grid td::before {
        content: none;
    }
}

/* Single-User Perspective Chain of Command Breadcrumb */
.chain-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    background: var(--bg-linen);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
}

.chain-arrow {
    color: var(--text-secondary);
    font-weight: 700;
}

.chain-pill {
    display: inline-flex;
    flex-direction: column;
    padding: 7px 12px;
    border-radius: 8px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-surface);
    color: var(--text-primary);
    text-decoration: none;
    font-size: 12.5px;
}

.chain-pill:hover {
    border-color: var(--steel-primary);
}

.chain-pill.active {
    border: 2px solid var(--steel-primary);
    background: #EBF2F7;
}

.chain-pill span {
    font-size: 11px;
    color: var(--text-secondary);
}


/* Archived Status Text Indicator */
.status-text-archived {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Frozen Leftmost Actions Column on Horizontal Scroll */
table.resizable-grid th.sticky-col-left,
table.resizable-grid td.sticky-col-left {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--bg-surface);
    box-shadow: 2px 0 6px -2px rgba(31, 41, 51, 0.14);
}

table.resizable-grid th.sticky-col-left {
    z-index: 4;
    background: var(--bg-linen);
}

table.resizable-grid tbody tr:hover td.sticky-col-left {
    background: #F9F8F5;
}

/* Floating Expanding Row Action Menu */
.row-action-menu {
    position: fixed;
    z-index: 500;
    min-width: 185px;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    box-shadow: 0 10px 26px rgba(31, 41, 51, 0.18);
    padding: 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.row-action-menu[hidden] {
    display: none;
}

.row-action-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
}

.row-action-item:hover:not(:disabled) {
    background: var(--bg-subtle);
}

.row-action-item:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.row-action-item.danger {
    color: var(--status-fail-fg);
    font-weight: 600;
}

.row-action-item.danger:hover:not(:disabled) {
    background: var(--status-fail-bg);
}

.row-action-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}


/* Header Account Controls */
.account-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Login & Authentication Screen */
body.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: var(--bg-linen);
}

.auth-shell {
    width: 100%;
    max-width: 440px;
}

.auth-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 12px;
    padding: 28px 26px;
    box-shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.auth-meta {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.auth-meta a {
    color: var(--steel-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-meta a:hover {
    text-decoration: underline;
}
