:root {
    --bg: #090d14;
    --panel: #101722;
    --panel-2: #151e2b;
    --line: #263244;
    --text: #edf3fb;
    --muted: #8da0b7;
    --blue: #3a8bff;
    --brand-primary: #1f5aa6;
    --cyan: #31c6d4;
    --green: #35c46f;
    --amber: #e8a83a;
    --red: #ef5350;
    --radius: 8px;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    display: grid;
    grid-template-columns: 256px 1fr;
}

a { color: inherit; text-decoration: none; }

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #0d131d;
    border-right: 1px solid var(--line);
    padding: 22px 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 8px 22px;
    border-bottom: 1px solid var(--line);
}

.brand span {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    background: var(--brand-primary);
    border-radius: 8px;
    font-weight: 800;
}

.brand img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.brand strong { font-size: 18px; letter-spacing: 0; }

nav {
    display: grid;
    gap: 6px;
    margin-top: 22px;
}

nav a {
    color: var(--muted);
    padding: 11px 12px;
    border-radius: 6px;
    font-weight: 650;
}

nav a:hover,
nav a.active {
    color: var(--text);
    background: #172233;
}

.shell { padding: 24px; min-width: 0; }

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

.topbar p,
.eyebrow {
    margin: 0 0 3px;
    color: var(--cyan);
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 17px; margin-bottom: 14px; }

.userbar { display: flex; align-items: center; gap: 10px; color: var(--muted); }

.card,
.stat,
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.card { padding: 18px; min-width: 0; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.stat { padding: 18px; }
.stat span { color: var(--muted); text-transform: uppercase; font-size: 12px; font-weight: 800; }
.stat strong { display: block; font-size: 32px; margin-top: 6px; }

.grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

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

.auth-panel {
    max-width: 980px;
    margin: 8vh auto;
    padding: 32px;
    display: grid;
    grid-template-columns: 1fr 390px;
    gap: 28px;
    align-items: center;
}

.auth-panel h2 { font-size: 40px; margin-bottom: 12px; }
.auth-panel p { color: var(--muted); max-width: 520px; }

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

.form-grid h2,
.form-grid .wide,
.form-grid button { grid-column: 1 / -1; }

.form-stack { display: grid; gap: 14px; }
.compact { align-content: start; }

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

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

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

.btn {
    border: 1px solid var(--line);
    border-radius: 6px;
    min-height: 40px;
    padding: 9px 13px;
    background: var(--panel-2);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
    text-align: center;
}

.btn.mini {
    min-height: 30px;
    padding: 5px 9px;
    font-size: 12px;
}

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

.brand-badge {
    width: 42px;
    height: 42px;
    object-fit: contain;
}

.btn.discord {
    background: #5865f2;
    border-color: #5865f2;
}

.btn.ghost:hover,
.btn.primary:hover { filter: brightness(1.08); }

.alert {
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px 14px;
    margin-bottom: 14px;
    background: var(--panel-2);
}

.alert.success { border-color: color-mix(in srgb, var(--green) 55%, var(--line)); }
.alert.danger { border-color: color-mix(in srgb, var(--red) 55%, var(--line)); }
.alert.warning { border-color: color-mix(in srgb, var(--amber) 55%, var(--line)); }

.divider {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    font-weight: 800;
}

.divider::before,
.divider::after {
    content: "";
    height: 1px;
    background: var(--line);
}

code { color: var(--amber); }

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

.web-portals {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 14px;
}

.portal-card-web,
.department-admin-card {
    background: linear-gradient(180deg, rgba(18, 26, 39, .98), rgba(15, 22, 34, .98));
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
}

.portal-card-top {
    height: 3px;
    background: var(--portal-color, var(--brand-primary));
}

.portal-card-body {
    padding: 18px;
    display: grid;
    gap: 10px;
}

.portal-badge {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: color-mix(in srgb, var(--portal-color, var(--brand-primary)) 18%, #111827);
    border: 1px solid color-mix(in srgb, var(--portal-color, var(--brand-primary)) 28%, var(--line));
    font-weight: 800;
}

.portal-badge img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 14px;
}

.portal-card-web h3,
.portal-card-web p {
    margin: 0;
}

.portal-card-web p {
    color: var(--muted);
    min-height: 42px;
}

.portal-card-web.compact .portal-card-body {
    padding: 14px;
}

.portal-card-web.compact .portal-badge {
    width: 42px;
    height: 42px;
    border-radius: 10px;
}

.portal-card-web.compact h3 {
    font-size: 14px;
}

.portal-card-web.compact p {
    min-height: 34px;
    font-size: 12px;
}

.portal-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.portal-enter {
    display: block;
    margin: 0 18px 18px;
    min-height: 44px;
    padding: 11px 14px;
    border-radius: 8px;
    background: color-mix(in srgb, var(--portal-color, var(--brand-primary)) 18%, #162233);
    color: var(--portal-color, var(--brand-primary));
    border: 1px solid color-mix(in srgb, var(--portal-color, var(--brand-primary)) 22%, var(--line));
    font-weight: 800;
    text-align: center;
}

.portal-enter span {
    opacity: .82;
}

.portal-role-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--portal-color, var(--brand-primary)) 70%, #d8e3f3);
}

.portal-role-text {
    color: #a8bad1;
    font-size: 12px;
    font-weight: 700;
}

.department-admin-list {
    display: grid;
    gap: 12px;
}

.department-admin-card {
    padding: 14px;
}

.department-admin-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.swatch {
    width: 14px;
    height: 14px;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,.2);
}

.portal-selector-shell {
    border: 1px solid #2b3a52;
    border-radius: 14px;
    overflow: hidden;
    background: linear-gradient(90deg, #1a3259 0%, #233860 55%, #1a2746 100%);
}

.portal-selector-hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    min-height: 170px;
    padding: 28px 34px;
    background:
        radial-gradient(circle at right center, rgba(255,255,255,.06), transparent 23%),
        linear-gradient(135deg, rgba(69, 114, 184, .12), rgba(17, 29, 49, .08));
}

.portal-selector-copy {
    display: flex;
    align-items: center;
    gap: 18px;
}

.portal-selector-avatar {
    width: 66px;
    height: 66px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(155, 188, 235, .38);
    color: #fff;
    font-size: 22px;
    font-weight: 800;
    overflow: hidden;
}

.portal-selector-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portal-selector-label {
    margin: 0 0 8px;
    color: #60a5fa;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
}

.portal-selector-hero h2 {
    margin: 0;
    font-size: 40px;
    color: #fff;
}

.portal-selector-hero h2 span {
    color: #7da8ff;
}

.portal-selector-hero p:last-child {
    margin: 8px 0 0;
    color: #a8bbd6;
    font-size: 18px;
}

.portal-selector-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(88px, 1fr));
    min-width: 266px;
    background: rgba(15, 23, 42, .38);
    border: 1px solid rgba(101, 131, 180, .42);
    border-radius: 14px;
    overflow: hidden;
}

.portal-selector-stats div {
    display: grid;
    place-items: center;
    gap: 4px;
    padding: 16px 18px;
    border-right: 1px solid rgba(101, 131, 180, .32);
}

.portal-selector-stats div:last-child {
    border-right: 0;
}

.portal-selector-stats strong {
    color: #fff;
    font-size: 32px;
}

.portal-selector-stats span {
    color: #b6c8e0;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
}

.portal-selector-grid {
    background: transparent;
    border-bottom: 0;
    padding: 22px 12px 0;
    gap: 16px;
}

.portal-selector-card {
    min-height: 260px;
}

.portal-selector-card .portal-card-body {
    justify-items: center;
    text-align: center;
    padding: 18px 18px 14px;
}

.portal-selector-card .portal-badge {
    width: 50px;
    height: 50px;
    border-radius: 12px;
}

.portal-selector-card h3 {
    font-size: 16px;
    color: #fff;
}

.portal-selector-card p {
    min-height: 54px;
    color: #a7b9d0;
    font-size: 14px;
}

.portal-flow-page,
.portal-ready-page {
    min-height: calc(100vh - 180px);
    display: grid;
    place-items: center;
    padding: 24px 12px;
}

.portal-flow-card,
.portal-ready-card {
    width: min(620px, 100%);
    background: #202c3f;
    border: 1px solid #364861;
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 24px 56px rgba(0, 0, 0, .28);
}

.portal-flow-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 22px 24px;
    background: color-mix(in srgb, var(--portal-color, var(--brand-primary)) 64%, #5c6470);
}

.portal-flow-header h2 {
    margin: 0 0 4px;
    color: #fff;
    font-size: 20px;
}

.portal-flow-header p {
    margin: 0;
    color: #e5edf8;
}

.portal-flow-body {
    padding: 26px 24px;
    display: grid;
    gap: 18px;
}

.portal-flow-title {
    text-align: center;
    display: grid;
    gap: 8px;
}

.portal-flow-title h3 {
    margin: 0;
    color: #fff;
    font-size: 20px;
}

.portal-flow-title p {
    margin: 0;
    color: #a5b9d4;
    line-height: 1.5;
}

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

.portal-flow-form .wide {
    grid-column: 1 / -1;
}

.portal-flow-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 24px;
    border-top: 1px solid #33465e;
    background: #1b2637;
}

.muted-btn {
    opacity: .8;
    pointer-events: none;
}

.portal-officer-list {
    display: grid;
    gap: 12px;
}

.portal-officer-option {
    margin: 0;
}

.portal-officer-pick {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 18px;
    border-radius: 14px;
    border: 1px solid #3b4f6b;
    background: #1f2b3d;
    color: #fff;
    cursor: pointer;
}

.portal-officer-pick:hover {
    border-color: #5b77a1;
    background: #24344b;
}

.portal-officer-avatar {
    width: 54px;
    height: 54px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: color-mix(in srgb, var(--portal-color, var(--brand-primary)) 58%, #15304e);
    font-weight: 800;
}

.portal-officer-copy {
    flex: 1;
    text-align: left;
    min-width: 0;
    display: grid;
    gap: 6px;
}

.portal-officer-copy strong {
    font-size: 16px;
}

.portal-officer-arrow {
    font-size: 28px;
    color: #8ea6c7;
}

.portal-ready-card {
    padding: 42px 28px;
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 18px;
    background: #141d2d;
}

.portal-ready-icon {
    width: 74px;
    height: 74px;
    display: grid;
    place-items: center;
    border-radius: 999px;
    background: rgba(31, 90, 166, .24);
    color: #8fb7ff;
    font-size: 34px;
}

.portal-ready-card h2 {
    margin: 0;
    font-size: 28px;
    color: #fff;
}

.portal-ready-card p {
    margin: 0;
    max-width: 520px;
    color: #a3b6d2;
    line-height: 1.55;
}

.portal-ready-summary {
    width: min(400px, 100%);
    display: grid;
    gap: 12px;
    padding: 18px;
    border: 1px solid #334761;
    border-radius: 12px;
    background: #202b3d;
    text-align: left;
}

.portal-ready-summary span {
    display: block;
    color: #83d470;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 4px;
}

.portal-ready-summary strong {
    color: #fff;
    font-size: 18px;
}

.portal-ready-actions,
.portal-ready-actions .btn {
    width: min(400px, 100%);
}

.portal-duty-button {
    min-height: 52px;
    font-size: 22px;
    background: #28c85a;
    border-color: #28c85a;
}

.portal-ready-back {
    color: #9eb4d1;
    font-weight: 700;
}

.department-management-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
}

.department-admin-form-panel {
    align-content: start;
}

.department-management-heading h3 {
    margin: 0 0 8px;
    color: #fff;
    font-size: 24px;
}

.department-management-heading p {
    margin: 0 0 16px;
    color: #98abc5;
    line-height: 1.5;
}

.department-management-groups {
    display: grid;
    gap: 14px;
}

.department-group {
    display: grid;
    gap: 10px;
}

.department-group-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #dbe8fa;
    font-weight: 800;
}

.department-group-head span {
    min-width: 24px;
    min-height: 24px;
    display: grid;
    place-items: center;
    padding: 0 8px;
    border-radius: 999px;
    background: #152132;
    border: 1px solid #2c405f;
    color: #8ea8c9;
    font-size: 11px;
}

.department-group-list {
    display: grid;
    gap: 12px;
}

.department-management-card {
    border-left: 2px solid var(--portal-color, var(--brand-primary));
}

.department-card-identity {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.department-card-identity .portal-badge.small {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    flex: 0 0 auto;
}

.department-card-identity strong {
    color: #fff;
    display: block;
}

.department-card-identity strong span {
    color: #8ea6c7;
    font-weight: 700;
}

.department-card-identity p {
    margin: 4px 0 8px;
    color: #95a8c1;
}

.return-history-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.return-history-card,
.return-history-empty {
    min-height: 84px;
    padding: 12px 14px;
    border: 1px solid #41516f;
    border-radius: 6px;
    background: linear-gradient(180deg, #132033, #0f1827);
    display: grid;
    gap: 4px;
}

.return-history-card strong {
    font-size: 15px;
    color: #f6f9ff;
}

.return-history-card span,
.return-history-card small,
.return-history-empty {
    color: #a7b5c9;
}

.return-history-card.active {
    border-color: #8aa8d8;
    box-shadow: inset 0 0 0 1px rgba(138,168,216,.35);
}

@media (max-width: 1280px) {
    .web-portals,
    .dashboard-portal-row,
    .cad-stats-row,
    .leo-forms-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .department-management-shell { grid-template-columns: 1fr; }
    .cad-board,
    .leo-workspace { grid-template-columns: 1fr; }
    .leo-search-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
    body { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    .auth-panel,
    .grid.two,
    .grid.three,
    .web-portals,
    .stat-grid,
    .dashboard-portal-row,
    .cad-stats-row,
    .leo-forms-row { grid-template-columns: 1fr; }
    .portal-selector-hero,
    .portal-selector-copy,
    .portal-flow-footer { display: grid; }
    .portal-flow-form { grid-template-columns: 1fr; }
    .cad-subnav,
    .imperial-ribbon { flex-wrap: wrap; }
    .leo-search-grid { grid-template-columns: 1fr; }
}

th, td {
    border-bottom: 1px solid var(--line);
    padding: 10px 9px;
    text-align: left;
    vertical-align: middle;
    font-size: 13px;
}

th {
    color: var(--muted);
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .06em;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 850;
    border: 1px solid currentColor;
}

.badge.success { color: var(--green); }
.badge.warning { color: var(--amber); }
.badge.danger { color: var(--red); }
.badge.info { color: var(--cyan); }
.badge.muted { color: var(--muted); }
.muted { color: var(--muted); }

.call-board { display: grid; gap: 8px; }

.call-row {
    display: grid;
    grid-template-columns: 92px 1fr 2fr 120px 130px 88px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: #0b111a;
    border: 1px solid var(--line);
    border-radius: 6px;
}

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(3, 1fr); }
    .grid.three { grid-template-columns: 1fr; }
    .call-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
    body { grid-template-columns: 1fr; }
    .sidebar { position: static; height: auto; }
    nav { grid-template-columns: repeat(2, 1fr); }
    .shell { padding: 16px; }
    .topbar, .auth-panel { grid-template-columns: 1fr; display: grid; }
    .grid.two, .stat-grid, .form-grid { grid-template-columns: 1fr; }
}

.record-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
    padding: 18px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.record-header h2 {
    font-size: 26px;
    margin-bottom: 5px;
}

.record-header p { margin: 0; color: var(--muted); }

.record-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.license-list {
    display: grid;
    gap: 8px;
}

.license-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.2fr) minmax(120px, 1fr) 80px 150px 70px;
    gap: 8px;
    align-items: center;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #0b111a;
}

.pad-top { margin-top: 14px; }

.card h3 {
    margin: 16px 0 8px;
    color: var(--muted);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

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

.checkline input,
.check-only input {
    width: auto;
    min-height: auto;
}

.permission-grid {
    display: grid;
    grid-template-columns: 120px repeat(8, minmax(120px, 1fr));
    gap: 8px;
    overflow-x: auto;
    align-items: center;
}

.permission-grid > * {
    min-width: 0;
    padding: 8px;
    border-bottom: 1px solid var(--line);
}

.check-only {
    display: flex;
    justify-content: center;
}

.settings-hero {
    position: relative;
    overflow: hidden;
    margin-bottom: 18px;
    border: 1px solid #33445d;
    border-radius: 12px;
    background: linear-gradient(135deg, #132847 0%, #1c355d 45%, #101d34 100%);
}

.settings-hero-backdrop {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at top right, rgba(59, 130, 246, 0.22), transparent 32%),
        linear-gradient(90deg, rgba(15, 23, 42, 0.08), rgba(15, 23, 42, 0.45));
    pointer-events: none;
}

.settings-hero-inner {
    position: relative;
    padding: 28px 30px;
}

.settings-hero-copy {
    max-width: 720px;
}

.settings-hero-label {
    margin: 0 0 6px;
    color: #8fc4ff;
    text-transform: uppercase;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
}

.settings-hero-title {
    margin: 0;
    font-size: 34px;
    color: #fff;
}

.settings-hero-text {
    margin: 10px 0 0;
    color: #c2d3ea;
    max-width: 640px;
    line-height: 1.55;
}

.settings-app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.settings-app-nav,
.settings-panel,
.settings-stat-card {
    background: #111b28;
    border: 1px solid #2a3850;
    border-radius: 12px;
}

.settings-app-nav {
    position: sticky;
    top: 20px;
    padding: 16px;
    display: grid;
    gap: 16px;
}

.settings-nav-group {
    display: grid;
    gap: 6px;
}

.settings-nav-label {
    color: #8ea6c7;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    padding: 2px 6px 8px;
}

.settings-app-nav a {
    display: flex;
    align-items: center;
    min-height: 40px;
    padding: 10px 12px;
    border-radius: 8px;
    color: #b9c8dd;
    font-weight: 700;
    background: transparent;
    border: 1px solid transparent;
}

.settings-app-nav a:hover,
.settings-app-nav a.active {
    background: #182639;
    color: #fff;
    border-color: #314866;
}

.settings-app-content {
    min-width: 0;
    display: grid;
    gap: 16px;
}

.settings-stat-row,
.settings-panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.settings-stat-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.settings-stat-card {
    padding: 18px;
}

.settings-stat-card span {
    display: block;
    color: #8ea6c7;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
}

.settings-stat-card strong {
    display: block;
    margin-top: 8px;
    color: #fff;
    font-size: 30px;
}

.settings-stat-card small {
    display: block;
    margin-top: 6px;
    color: #93a8c3;
    line-height: 1.45;
}

.settings-panel {
    padding: 18px;
    min-width: 0;
}

.settings-panel-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 16px;
}

.settings-panel-head h2 {
    margin-bottom: 6px;
    font-size: 22px;
    color: #fff;
}

.settings-panel-head p {
    margin: 0;
    color: #91a5c0;
    line-height: 1.5;
}

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

.settings-form-grid {
    gap: 14px;
}

.settings-form-grid input[readonly] {
    background: #101824;
    color: #9fc0e8;
}

.settings-panel .table-wrap {
    margin: 0;
}

.settings-panel table th {
    background: #16263a;
}

.settings-panel table td {
    background: #0d141f;
}

@media (max-width: 1180px) {
    .license-row { grid-template-columns: 1fr 1fr; }
    .record-header { align-items: flex-start; flex-direction: column; }
    .record-actions { justify-content: flex-start; }
    .settings-app-shell,
    .settings-stat-row,
    .settings-panel-grid {
        grid-template-columns: 1fr;
    }

    .settings-app-nav {
        position: static;
    }
}

.imperial-shell {
    background: #111;
    border: 1px solid #333;
    min-height: calc(100vh - 120px);
}

.cad-shell {
    background: #111214;
    border-color: #37455f;
}

.imperial-ribbon {
    display: flex;
    gap: 10px;
    align-items: center;
    background: #203f72;
    border-bottom: 1px solid #45618f;
    padding: 8px;
}

.imperial-ribbon-large {
    padding: 10px 8px;
}

.tool {
    min-width: 100px;
    min-height: 70px;
    display: grid;
    place-items: center;
    border: 1px solid #5d75a1;
    border-radius: 6px;
    background: #243f6f;
    color: #fff;
    font-weight: 800;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    padding: 8px 10px;
}

.menu-strip {
    display: flex;
    gap: 22px;
    align-items: center;
    min-height: 28px;
    padding: 0 12px;
    background: #244b87;
    color: #eef5ff;
    font-size: 13px;
    font-weight: 700;
}

.cad-subnav {
    display: flex;
    gap: 18px;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    background: #1d4d92;
    border-bottom: 1px solid #486a99;
}

.cad-subnav a {
    color: #d7e7ff;
    font-weight: 700;
    font-size: 14px;
    padding: 8px 0;
}

.cad-subnav a.active,
.cad-subnav a:hover {
    color: #fff;
}

.dashboard-portal-row {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
    background: #14171c;
    border-bottom: 1px solid #2e3746;
}

.cad-stats-row {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    background: #101214;
    border-bottom: 1px solid #2b3240;
}

.cad-stat-panel {
    background: #172131;
    border: 1px solid #324664;
    border-radius: 6px;
    padding: 14px;
}

.cad-stat-panel span {
    display: block;
    color: #98afcb;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
}

.cad-stat-panel strong {
    display: block;
    margin-top: 6px;
    font-size: 28px;
    color: #fff;
}

.cad-board {
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(320px, .95fr);
    min-height: 420px;
}

.cad-board-main,
.cad-board-sidebar,
.cad-footer-board,
.leo-search-pane,
.leo-detail-pane {
    min-width: 0;
}

.cad-board-main {
    border-right: 1px solid #2d3542;
    background: #101112;
}

.cad-board-sidebar {
    display: grid;
    gap: 10px;
    padding: 10px;
    background: #17191d;
}

.cad-panel-card {
    background: #101317;
    border: 1px solid #303846;
}

.cad-panel-title {
    padding: 9px 12px;
    background: #173d78;
    color: #fff;
    font-weight: 800;
    border-bottom: 1px solid #40659d;
}

.cad-board-table {
    padding: 0;
}

.cad-board-table .table-wrap {
    margin: 0;
}

.cad-board-table table {
    min-width: 100%;
    background: #101112;
}

.cad-board-table th {
    background: #14376b;
    color: #eef5ff;
    font-size: 11px;
}

.cad-board-table td,
.cad-board-table th {
    border-bottom: 1px solid #2c3645;
    padding: 7px 8px;
    font-weight: 700;
}

.cad-form-grid {
    padding: 12px;
}

.cad-footer-board {
    background: #101112;
    border-top: 1px solid #2b3340;
}

.cad-main-board {
    background: #101112;
}

.clean-dashboard {
    display: grid;
    gap: 12px;
}

.dashboard-status-board {
    padding: 0;
}

.leo-workspace {
    display: grid;
    grid-template-columns: 360px 1fr;
    min-height: 760px;
}

.leo-search-pane {
    background: #151719;
    border-right: 1px solid #313948;
}

.leo-detail-pane {
    background: #2f2f2f;
}

.leo-query-form {
    display: grid;
    gap: 12px;
    padding: 14px;
    background: #111214;
    border-bottom: 1px solid #2f3947;
}

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

.leo-query-actions {
    display: flex;
    gap: 10px;
}

.leo-result-list {
    display: grid;
    gap: 8px;
    padding: 12px;
    max-height: 320px;
    overflow-y: auto;
    background: #101214;
    border-bottom: 1px solid #2e3746;
}

.leo-result-card {
    display: grid;
    gap: 4px;
    padding: 10px 12px;
    background: #1b2636;
    border: 1px solid #34465f;
    border-radius: 6px;
}

.leo-result-card strong {
    color: #fff;
}

.leo-result-card span,
.leo-result-card small {
    color: #a6b7ce;
}

.leo-result-card.active {
    border-color: #7ea0d4;
    background: #203453;
}

.leo-document {
    margin: 10px;
    background: #111;
    border: 1px solid #777;
    min-height: 470px;
    padding: 18px;
}

.leo-document h2 {
    color: #fff;
    font-size: 28px;
    margin-bottom: 14px;
}

.leo-document pre {
    margin: 0;
    border: 1px solid #555;
    padding: 18px;
    background: #0e0e0e;
    color: #f1f1f1;
    white-space: pre-wrap;
    font-family: "Roboto Mono", Consolas, monospace;
    line-height: 1.45;
    min-height: 380px;
}

.leo-forms-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    padding: 0 10px 10px;
}

.leo-forms-row .card {
    background: #171717;
    border-color: #4a4a4a;
}

.tool.active,
.tool:hover { background: #1c559d; }
.tool.success { color: #75ee98; }
.tool.danger { color: #ff5c5c; }
.tool.warning { color: #ffc233; }

.imperial-layout,
.forms-layout {
    display: grid;
    grid-template-columns: 248px 1fr;
    min-height: 720px;
}

.imperial-side,
.forms-side {
    border-right: 1px solid #555;
    background: #151515;
    padding: 12px;
    display: grid;
    align-content: start;
    gap: 12px;
}

.imperial-side h3 {
    background: #1e559c;
    margin: 0 -12px;
    padding: 7px 12px;
}

.imperial-side span,
.forms-side a {
    color: #fff;
    padding: 7px 10px;
    font-weight: 800;
}

.side-link {
    color: #fff;
    padding: 7px 10px;
    font-weight: 800;
}

.side-link.active {
    background: #243f6f;
}

.forms-side a {
    display: grid;
    min-height: 76px;
    place-items: center;
    border-bottom: 1px solid #333;
}

.imperial-work,
.forms-work {
    min-width: 0;
    background: #2f2f2f;
}

.imperial-actions,
.form-actionbar {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 260px)) auto auto;
    gap: 10px;
    align-items: end;
    padding: 12px;
    background: #303030;
    border-bottom: 1px solid #565656;
}

.return-list table {
    width: 100%;
    border-collapse: collapse;
    background: #101010;
}

.return-list th {
    background: #333;
    color: #fff;
    text-align: left;
}

.return-list td,
.return-list th {
    border-bottom: 1px solid #333;
    padding: 5px 8px;
    font-weight: 800;
}

.return-list tr.selected { background: #272727; }

.return-commandbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid #555;
    background: #252525;
}

.return-detail {
    margin: 4px;
    border: 1px solid #777;
    padding: 18px;
    background: #111;
}

.return-detail h2 { font-size: 28px; }

.return-detail pre {
    border: 1px solid #555;
    padding: 18px;
    white-space: pre-wrap;
    font-family: "Roboto Mono", Consolas, monospace;
    font-size: 18px;
    line-height: 1.45;
}

.form-tabs {
    display: flex;
    gap: 4px;
    padding: 0 8px;
    background: #202020;
}

.form-tabs span {
    background: #4a4a4a;
    padding: 6px 12px;
    border-radius: 6px 6px 0 0;
    font-weight: 800;
}

.form-actionbar {
    grid-template-columns: 1fr repeat(4, auto);
    border: 1px solid #555;
    border-radius: 6px;
    margin: 8px;
}

.form-actionbar strong { font-size: 24px; }

.citation-paper {
    width: min(1050px, calc(100% - 48px));
    margin: 30px auto;
    background: #fff;
    color: #000;
    padding: 42px 50px;
    display: grid;
    gap: 8px;
    font-family: Arial, sans-serif;
}

.citation-paper header {
    display: grid;
    gap: 12px;
    font-size: 21px;
    margin-bottom: 30px;
    justify-items: center;
    text-align: center;
}

.citation-paper .paper-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    border-top: 1px solid #222;
    border-left: 1px solid #222;
}

.citation-paper label {
    color: #000;
    border-right: 1px solid #222;
    border-bottom: 1px solid #222;
    padding: 4px;
    font-size: 12px;
}

.citation-paper input,
.citation-paper select,
.citation-paper textarea {
    background: #fff;
    color: #000;
    border: 0;
    border-radius: 0;
    min-height: 28px;
    padding: 2px;
    font-weight: 800;
}

.citation-paper .wide { grid-column: 1 / -1; }

.citation-paper h3 {
    margin: 8px 0 0;
    padding: 5px 8px;
    background: #f4f4f4;
    border: 1px solid #222;
    font-size: 14px;
}

.validation-panel {
    margin: 10px;
    padding: 14px;
    background: #171717;
    border: 1px solid #454545;
}

.validation-panel h3 {
    margin: 0 0 10px;
    color: #fff;
}

.validation-panel ul {
    margin: 0;
    padding-left: 18px;
    color: #ffcc66;
}

.form-meta-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 10px;
}

.violation-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.violation-panel {
    border: 1px solid #222;
    padding: 8px;
    background: #fff;
    display: grid;
    gap: 8px;
}

.violation-panel strong {
    font-size: 12px;
    color: #000;
}

.violation-row {
    display: grid;
    grid-template-columns: minmax(180px, .7fr) minmax(0, 1.3fr) auto;
    gap: 8px;
    align-items: center;
}

.violation-field {
    display: grid;
    gap: 4px;
    color: #000;
    font-size: 12px;
    font-weight: 700;
}

.citation-paper .violation-field select {
    border: 1px solid #222;
    min-height: 30px;
    padding: 4px 6px;
}

.violation-remove {
    min-width: 70px;
}

.cad-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

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

.cad-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}

.cad-modal-panel {
    position: relative;
    width: min(760px, calc(100% - 48px));
    margin: 56px auto;
    background: #1f1f1f;
    border: 1px solid #555;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(0, 0, 0, .45);
}

.cad-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px 8px;
    color: #fff;
}

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

.cad-modal-close {
    border: 0;
    background: transparent;
    color: #b9c5d9;
    font-size: 26px;
    cursor: pointer;
}

.cad-modal-body {
    padding: 0 22px 22px;
    color: #fff;
}

.cad-modal-body h3 {
    margin: 8px 0 12px;
    font-size: 14px;
}

.cad-modal-table table {
    width: 100%;
    min-width: 100%;
    background: #101010;
}

.cad-modal-table th {
    background: #3a3a3a;
    color: #fff;
    text-align: left;
}

.cad-modal-table td,
.cad-modal-table th {
    padding: 6px 10px;
    border-bottom: 1px solid #2d2d2d;
    font-weight: 700;
}
