:root {
    --cae-bg: #ededed;
    --cae-panel: #f5f5f5;
    --cae-panel-elevated: #ffffff;
    --cae-border: #d7d7d7;
    --cae-border-strong: #203973;
    --cae-text: #3d3d3d;
    --cae-text-secondary: #5c5c5c;
    --cae-text-muted: #7a7a7a;
    --cae-primary: #203973;
    --cae-primary-hover: #ed254e;
    --cae-primary-text: #f5f5f5;
    --cae-secondary: #66c3ff;
    --cae-bg2: #d4cdab;
    --cae-success: #2e7d32;
    --cae-success-bg: #c8f0c8;
    --cae-warning: #b78100;
    --cae-warning-bg: #f7e6a8;
    --cae-error: #ed254e;
    --cae-error-bg: #f8c9d2;
    --cae-info-bg: #d6e6f8;
    --cae-selection: #e8eef8;
    --cae-selection-border: #203973;
    --cae-font: "Poppins", "Noto Sans Sinhala", "Nirmala UI", "Iskoola Pota", "Latha", "Noto Sans Tamil", system-ui, sans-serif;
    --cae-text-title: 1.25rem;
    --cae-text-body: 0.95rem;
    --cae-text-small: 0.85rem;
    --cae-text-micro: 0.75rem;
    --cae-weight-regular: 400;
    --cae-weight-medium: 500;
    --cae-weight-semibold: 600;
    --cae-weight-bold: 700;
    --cae-line-tight: 1.25;
    --cae-line-normal: 1.4;
    --cae-radius-sm: 6px;
    --cae-radius-md: 8px;
    --cae-control-height: 2.25rem;
    color: var(--cae-text);
    background: var(--cae-bg);
    font-family: var(--cae-font);
    font-size: 16px;
    line-height: var(--cae-line-normal);
    --ink: var(--cae-text);
    --muted: var(--cae-text-secondary);
    --line: var(--cae-border);
    --surface: var(--cae-panel-elevated);
    --canvas: var(--cae-bg);
    --sidebar: var(--cae-panel);
    --sidebar-text: var(--cae-primary);
    --accent: var(--cae-primary);
    --accent-dark: var(--cae-primary-hover);
    --danger: var(--cae-error);
    --ok: var(--cae-success);
    --focus: var(--cae-secondary);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    background: var(--cae-bg);
    color: var(--cae-text);
}

.skip {
    position: absolute;
    left: 0.75rem;
    top: 0.75rem;
    padding: 0.4rem 0.7rem;
    background: #fff;
    color: var(--ink);
    border-radius: 6px;
    transform: translateY(-150%);
    z-index: 50;
}

.skip:focus { transform: none; }

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

a { color: var(--accent); }
a:hover { color: var(--accent-dark); }

button, input, select, textarea { font: inherit; color: inherit; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    min-height: var(--cae-control-height);
    padding: 5px 12px;
    margin: 0;
    background: var(--cae-primary);
    color: var(--cae-primary-text);
    border: none;
    border-radius: var(--cae-radius-md);
    outline: 3px solid var(--cae-bg);
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-bold);
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms ease-in-out;
}

button:hover, .button:hover {
    background: var(--cae-primary-hover);
    color: var(--cae-primary-text);
    text-decoration: none;
}

button:focus-visible, .button:focus-visible {
    outline: 3px solid var(--cae-secondary);
    outline-offset: 1px;
}

.button-secondary,
.button-ghost,
.is-gate .button-ghost {
    background: var(--cae-bg);
    color: var(--cae-text);
    outline: 3px solid var(--cae-border);
}

.button-secondary:hover,
.button-ghost:hover,
.is-gate .button-ghost:hover {
    background: var(--cae-bg2);
    color: var(--cae-text);
}

.button-danger {
    min-width: 0;
    background: var(--cae-panel-elevated);
    color: var(--cae-error);
    outline: 3px solid var(--cae-error-bg);
}

.button-danger:hover { background: var(--cae-error-bg); color: var(--cae-error); }

.button-amber {
    background: var(--cae-warning-bg);
    color: #5c4200;
    outline: 3px solid var(--cae-warning);
}

.button-amber:hover {
    background: var(--cae-warning);
    color: #fff;
    outline-color: var(--cae-warning);
}

.preview-chrome .button-amber {
    color: #5c4200;
}

.preview-chrome .button-amber:hover {
    color: #fff;
}

.preview-chrome .button-danger {
    background: var(--cae-error);
    color: #fff;
    outline: 3px solid #c41e3a;
}

.preview-chrome .button-danger:hover {
    background: #c41e3a;
    color: #fff;
}

#cae-app button,
#cae-app button:hover,
#cae-app button:focus-visible {
    min-height: 0;
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    border: 0;
    border-radius: 0;
    outline: none;
    font-size: inherit;
    font-weight: inherit;
    transition: none;
}

:focus-visible {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 2px;
}

.brand {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.brand strong {
    font-size: 1.15rem;
    letter-spacing: 0.01em;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.badge-local { background: var(--cae-info-bg); color: var(--cae-primary); }
.badge-super { background: var(--cae-warning-bg); color: var(--cae-warning); }

.app-frame {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    min-height: 100vh;
}

html.sidebar-closed .app-frame {
    grid-template-columns: 4.25rem minmax(0, 1fr);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 1.25rem 0.9rem 1rem;
    background: var(--cae-primary);
    color: var(--cae-primary-text);
    border-right: 1px solid var(--cae-border-strong);
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    flex-shrink: 0;
}

.sidebar .brand strong { color: var(--cae-primary-text); }

.sidebar-toggle {
    flex: 0 0 auto;
    width: 2rem;
    height: 2rem;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 1px solid rgba(245, 245, 245, 0.45);
    border-radius: var(--cae-radius-sm);
    outline: none;
    background: transparent;
    color: var(--cae-primary-text);
    font: inherit;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

html.sidebar-closed .sidebar {
    padding: 0.75rem 0.4rem;
    align-items: center;
}

html.sidebar-closed .sidebar .brand { justify-content: center; }

html.sidebar-closed .sidebar .brand strong,
html.sidebar-closed .sidebar .badge,
html.sidebar-closed .identity {
    display: none;
}

html.sidebar-closed .nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

html.sidebar-closed .sidebar nav,
html.sidebar-closed .sidebar-foot {
    width: 100%;
}

html.sidebar-closed .sidebar nav a,
html.sidebar-closed .sidebar-foot .button-ghost {
    justify-content: center;
    padding: 0.45rem;
    border-left-color: transparent;
}

.sidebar nav {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 0.15rem;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.45) transparent;
}

.sidebar nav a,
.sidebar-foot .button-ghost {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    position: relative;
}

.nav-icon {
    flex: 0 0 auto;
    width: 1.25rem;
    height: 1.25rem;
}

.sidebar nav a {
    color: var(--cae-primary-text);
    text-decoration: none;
    padding: 0.55rem 0.75rem;
    border-radius: var(--cae-radius-sm);
    border-left: 3px solid transparent;
    font-weight: var(--cae-weight-semibold);
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }

.sidebar nav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.16);
    border-left-color: #fff;
    color: #fff;
}

.sidebar-foot {
    flex-shrink: 0;
    margin-top: auto;
    display: grid;
    gap: 0.75rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(245, 245, 245, 0.24);
}

.sidebar .button-ghost {
    background: transparent;
    color: var(--cae-primary-text);
    outline: 2px solid rgba(245, 245, 245, 0.4);
}

.sidebar .button-ghost:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.identity { margin: 0; }
.identity span {
    display: block;
    font-size: var(--cae-text-micro);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: rgba(245, 245, 245, 0.72);
}
.identity strong {
    display: block;
    color: var(--cae-primary-text);
    font-weight: var(--cae-weight-semibold);
    overflow-wrap: anywhere;
}
.identity .badge { margin-top: 0.35rem; }

.workspace { min-width: 0; }

main {
    width: 100%;
    max-width: none;
    margin: 0;
    padding: 1.25rem 1.5rem 1.75rem;
}

.gate-main {
    display: grid;
    place-items: center;
    width: 100%;
    max-width: none;
    margin: 0;
    min-height: 100vh;
    padding: 2rem 1rem;
}

.gate-card {
    width: min(440px, 100%);
    background: var(--cae-panel-elevated);
    border: 1px solid var(--cae-border);
    border-radius: var(--cae-radius-md);
    box-shadow: 0 8px 24px rgba(32, 57, 115, 0.12);
    padding: 1.5rem 1.5rem 1.35rem;
}

.gate-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.gate-who { margin: -0.4rem 0 1rem; color: var(--muted); }

.page-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1rem;
    margin-bottom: 1.15rem;
}

.page-head h1 { margin-bottom: 0; }

.back {
    display: inline-block;
    margin-bottom: 0.35rem;
    font-size: 0.88rem;
    font-weight: 650;
    text-decoration: none;
}

h1 {
    font-size: 1.55rem;
    line-height: var(--cae-line-tight);
    margin: 0 0 0.75rem;
    color: var(--cae-primary);
    font-weight: var(--cae-weight-bold);
}
h2 { font-size: 1.05rem; margin: 0; color: var(--cae-primary); }
main > h2 { margin: 1.75rem 0 0.75rem; }
.check .hint, .check .muted { font-weight: 450; }

.lede, .meta, .hint { color: var(--muted); }
.lede { margin: 0 0 1rem; }
.meta { margin: 0.35rem 0 0; }
.hint { margin: 0; font-size: 0.92rem; }

.flash {
    margin: 0 0 1rem;
    padding: 0.75rem 0.9rem;
    background: var(--cae-info-bg);
    color: var(--cae-text);
    border: 1px solid var(--cae-border);
    border-left: 4px solid var(--cae-primary);
    border-radius: var(--cae-radius-md);
}

.flash-warn {
    background: #fff8e6;
    border-left-color: #c9a227;
}

form, .panel, table, dl.facts, .empty, .message-panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.panel {
    margin: 0 0 1rem;
    padding: 1.15rem 1.25rem 1.25rem;
}

.panel h2 {
    margin: 0 0 0.75rem;
}

.panel > * + h2 {
    margin-top: 1.35rem;
}

.panel > ul {
    margin: 0;
}

.panel > ul:not(.pick-list) {
    padding-left: 1.15rem;
}

.panel > ul:not(.pick-list) li {
    margin: 0.4rem 0;
}

.panel > form {
    margin-top: 1rem;
}

form {
    display: grid;
    gap: 0.85rem;
    margin: 0 0 1rem;
    padding: 1.1rem 1.15rem;
    max-width: 38rem;
}

form.inline, .is-gate form, form.upload-review-form {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
}

form.inline { display: block; }

.is-gate form { display: grid; gap: 0.85rem; }

.is-gate form.inline { display: block; width: auto; }

form button, form .button { justify-self: start; }

.field { display: grid; gap: 0.35rem; }

label {
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-semibold);
    color: var(--cae-primary);
}

input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="file"]),
select,
textarea {
    width: 100%;
    min-height: var(--cae-control-height);
    padding: 0.65rem 0.8rem;
    background: var(--cae-bg);
    color: var(--cae-text);
    border: 2px solid var(--cae-primary);
    border-radius: var(--cae-radius-md);
    font-size: var(--cae-text-body);
    font-weight: var(--cae-weight-semibold);
}

input[type="file"] {
    width: 100%;
    padding: 0.45rem 0.6rem;
    background: var(--cae-bg);
    color: var(--cae-text);
    border: 2px solid var(--cae-primary);
    border-radius: var(--cae-radius-md);
    font-weight: var(--cae-weight-semibold);
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    min-height: 0;
    margin-top: 0.2rem;
    padding: 0;
    accent-color: var(--cae-primary);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 1px;
    border-color: var(--cae-primary);
}

.check {
    display: flex;
    gap: 0.55rem;
    align-items: flex-start;
    font-weight: 450;
}

.check input {
    width: auto;
    min-height: 0;
    margin-top: 0.2rem;
    padding: 0;
}

.confirm {
    padding: 0.75rem 0.8rem;
    background: var(--cae-panel);
    border: 1px solid var(--cae-border);
    border-radius: var(--cae-radius-md);
}

fieldset {
    display: grid;
    gap: 0.45rem;
    margin: 0;
    padding: 0.75rem 0.9rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

legend { padding: 0 0.25rem; font-weight: 650; }

form.filters {
    max-width: none;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.25rem;
}

.appointment-actions {
    margin: 0 0 1.15rem;
}

table { width: 100%; border-collapse: collapse; overflow: hidden; }
th, td {
    text-align: left;
    padding: 0.7rem 0.85rem;
    vertical-align: top;
    border-top: 1px solid var(--line);
}
th {
    background: var(--cae-panel);
    color: var(--cae-primary);
    font-size: var(--cae-text-micro);
    font-weight: var(--cae-weight-bold);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    border-top: 0;
}
tbody tr:hover { background: var(--cae-selection); }
td a { font-weight: 650; text-decoration: none; }
td a:hover { text-decoration: underline; }
.nowrap { white-space: nowrap; }

dl.facts {
    display: block;
    width: 100%;
    max-width: none;
    margin: 0 0 1rem;
    padding: 0.35rem 0.35rem 0.5rem;
    overflow: hidden;
}

dl.facts > div {
    display: grid;
    grid-template-columns: 14rem minmax(0, 1fr);
    border-top: 1px solid var(--line);
}

dl.facts > div:first-child { border-top: 0; }

dl.facts dt, dl.facts dd {
    margin: 0;
    padding: 0.9rem 1.15rem;
}

dl.facts dt {
    color: var(--cae-primary);
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-bold);
}

.profile-marks {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: start;
    margin: 0;
}

.profile-sheet {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: 1.25rem;
    align-items: start;
    width: 100%;
    margin: 0 0 1rem;
    padding: 1.15rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.profile-sheet dl.facts {
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.profile-frame {
    display: grid;
    grid-template-rows: 9.25rem auto auto;
    align-content: start;
    gap: 0.45rem;
    width: 9.25rem;
    margin: 0;
}

.profile-portrait {
    display: grid;
    place-items: center;
    width: 9.25rem;
    height: 9.25rem;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--cae-radius-md);
}

.profile-portrait.is-empty {
    background: var(--cae-panel);
    border-style: dashed;
}

.profile-caption {
    margin: 0;
    color: var(--muted);
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-semibold);
    line-height: 1.3;
    text-align: center;
}

.profile-frame > .button-secondary {
    justify-self: stretch;
    width: 100%;
    min-height: 2.5rem;
    padding: 0.35rem 0.45rem;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
}

.profile-note {
    margin: 0;
    text-align: center;
}

.profile-portrait img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-frame form {
    display: grid;
    gap: 0.65rem;
    margin: 0;
    padding: 0;
    max-width: none;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.picture-dialog {
    width: min(32rem, calc(100vw - 2rem));
    padding: 1.25rem 1.35rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: inherit;
}

.picture-dialog::backdrop {
    background: rgba(16, 24, 40, 0.45);
}

.picture-dialog form {
    display: grid;
    gap: 0.85rem;
    margin: 0;
    padding: 0;
    max-width: none;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.tone-ok::before, .tone-bad::before, .tone-muted::before {
    content: "";
    display: inline-block;
    width: 0.55rem;
    height: 0.55rem;
    margin-right: 0.45rem;
    border-radius: 50%;
    background: var(--ok);
    transform: translateY(-0.05rem);
}

.tone-bad::before { background: var(--danger); }
.tone-muted::before { background: var(--cae-text-muted); }

.status, .chip {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 700;
    white-space: nowrap;
}

.status-on { background: var(--cae-success-bg); color: var(--cae-success); }
.status-off { background: var(--cae-error-bg); color: var(--cae-error); }
.chips { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.chip-group + .chip-group { margin-top: 0.45rem; }
.chip-label { display: block; margin-bottom: 0.15rem; color: var(--muted); font-size: 0.75rem; }
.grant-group {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 0.35rem 1rem;
}
.group-heading th { background: var(--cae-panel); font-size: var(--cae-text-small); }
.chip { background: var(--cae-selection); color: var(--cae-primary); font-weight: var(--cae-weight-semibold); }
.muted { color: var(--muted); }

.empty, .message-panel { padding: 1.15rem 1.2rem; color: var(--muted); }
.empty { border-style: dashed; }
.message-panel { color: var(--ink); }
.message-panel p { margin: 0.35rem 0 0; color: var(--muted); }

.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.task-card {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    height: 100%;
    padding: 1rem 1.05rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    color: inherit;
    text-decoration: none;
}

.task-card:hover { border-color: var(--cae-primary); color: inherit; }
.task-card strong { font-size: 1rem; }
.task-card span { color: var(--muted); font-size: 0.92rem; }

@media (max-width: 860px) {
    .app-frame { grid-template-columns: 1fr; }
    .sidebar {
        position: static;
        height: auto;
        gap: 0.9rem;
    }
    .sidebar nav {
        flex: none;
        flex-direction: row;
        flex-wrap: wrap;
        min-height: 0;
        overflow: visible;
    }
    .sidebar-foot {
        margin-top: 0;
        grid-template-columns: 1fr auto;
        align-items: center;
    }
    main { width: 100%; max-width: none; margin: 0; padding: 1rem; }
    .page-head, form.filters, .profile-sheet { display: grid; grid-template-columns: 1fr; }
    dl.facts > div { grid-template-columns: 1fr; }
    .page-head { align-items: start; }
    table { display: block; overflow-x: auto; }
    .transfer-board { grid-template-columns: 1fr; }
}

.transfer-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.pick-list {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.pick-list li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2.6rem;
    margin: 0;
    padding: 0.55rem 0.15rem;
    border-bottom: 1px solid var(--cae-border);
}

.pick-list a.picked {
    font-weight: 700;
}

.pick-list form {
    display: flex;
    margin: 0;
    padding: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    max-width: none;
    gap: 0;
}

.pick-list button {
    min-height: 2rem;
    padding: 2px 10px;
}

.upload-review-workspace {
    width: 100%;
    max-width: none;
    margin: 0;
}

form.upload-review-form {
    display: block;
    width: 100%;
}

.upload-review-scroll {
    width: 100%;
    overflow-x: auto;
}

table.upload-review {
    table-layout: fixed;
    width: 100%;
}

table.upload-review th:nth-child(1),
table.upload-review td.upload-review-row {
    width: 3.25rem;
    text-align: center;
    white-space: nowrap;
}

table.upload-review th:nth-child(3),
table.upload-review th:nth-child(4),
table.upload-review th:nth-child(5),
table.upload-review td.upload-review-pick {
    width: 22%;
}

table.upload-review th:nth-child(2),
table.upload-review td.upload-review-file {
    width: 18%;
}

table.upload-review th:nth-child(6),
table.upload-review td.upload-review-approve {
    width: 7.5rem;
    text-align: center;
    vertical-align: middle;
}

.upload-review-file .file-line {
    margin: 0 0 0.2rem;
    line-height: 1.35;
    font-size: var(--cae-text-small);
}

.upload-review-file .file-line:first-child {
    font-weight: var(--cae-weight-semibold);
    font-size: var(--cae-text-body);
}

.upload-review-file .file-meta {
    color: var(--cae-text-muted);
}

.upload-review-duplicate {
    background: var(--cae-warning-bg);
}

.pick-stack {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    align-items: stretch;
}

label.pick-btn {
    display: block;
    margin: 0;
    cursor: pointer;
}

.pick-btn-face {
    display: block;
    width: 100%;
    padding: 0.55rem 0.75rem;
    text-align: left;
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-medium);
    line-height: 1.35;
    color: var(--cae-text);
    background: transparent;
    border: 1px solid var(--cae-border);
    border-radius: var(--cae-radius-sm);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.pick-btn:hover .pick-btn-face {
    border-color: var(--cae-primary);
    background: var(--cae-selection);
}

.pick-btn input:focus-visible + .pick-btn-face {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 2px;
}

.pick-btn input:checked + .pick-btn-face {
    background: var(--cae-primary);
    border-color: var(--cae-primary);
    color: var(--cae-primary-text);
    font-weight: var(--cae-weight-semibold);
}

label.approve-toggle {
    display: inline-block;
    margin: 0;
    cursor: pointer;
}

.approve-btn {
    display: inline-block;
    min-width: 5.5rem;
    padding: 0.5rem 0.85rem;
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-semibold);
    text-align: center;
    color: var(--cae-text-muted);
    background: transparent;
    border: 1px solid var(--cae-border);
    border-radius: var(--cae-radius-sm);
    transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.approve-toggle:hover .approve-btn {
    border-color: var(--cae-primary);
}

.approve-input:checked + .approve-btn {
    background: var(--cae-success);
    border-color: var(--cae-success);
    color: #fff;
}

.approve-input:focus-visible + .approve-btn {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 2px;
}

.upload-review-toolbar {
    margin-top: 1rem;
}

button.pick-more {
    margin-top: 0.35rem;
    padding: 0;
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-semibold);
    color: var(--cae-primary);
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
}

button.pick-more:hover {
    text-decoration: underline;
}

button.pick-more.pick-more-has-selection {
    color: var(--cae-success);
}

.pick-more-dialog {
    width: min(28rem, calc(100vw - 2rem));
    max-height: min(28rem, calc(100vh - 2rem));
    padding: 0;
    border: 1px solid var(--cae-border);
    border-radius: var(--cae-radius-md);
    box-shadow: var(--cae-shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.18));
}

.pick-more-dialog::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

.pick-more-dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--cae-border);
}

.pick-more-dialog-title {
    margin: 0;
    font-size: var(--cae-text-base);
    font-weight: var(--cae-weight-semibold);
}

.pick-more-close {
    padding: 0.15rem 0.45rem;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--cae-text-muted);
    background: none;
    border: none;
    cursor: pointer;
}

.pick-more-close:hover {
    color: var(--cae-text);
}

.pick-stack-dialog {
    padding: 0.85rem 1rem 1rem;
    max-height: calc(28rem - 3.25rem);
    overflow: auto;
}

/* Live website preview (new tab) */
.preview-chrome {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 1.25rem;
    background: var(--cae-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
}

.preview-chrome__brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.preview-chrome__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.preview-chrome a {
    color: #fff;
}

.preview-chrome .button-ghost {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.45);
}

.preview-stage {
    padding: 0 1rem 2rem;
    max-width: 1120px;
    margin: 0 auto;
}

.is-preview {
    background: #f7f8fb;
}

.preview-path-banner {
    text-align: center;
    font-size: var(--cae-text-small);
    margin: 1rem 0 0.5rem;
}

.aims-editorial-preview--fullscreen {
    border: 0;
    box-shadow: none;
    max-width: none;
    padding: 1.5rem 0.5rem 2rem;
    background: transparent;
}

.aims-editorial-preview--fullscreen .aims-editorial-preview__figure {
    max-height: min(55vh, 520px);
}

.aims-editorial-preview--fullscreen .aims-editorial-preview__figure .feature-img {
    max-height: min(55vh, 520px);
}

.page-head.article-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    width: 100%;
}

.article-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.article-toolbar form.inline {
    margin: 0;
}

.article-preview-note {
    margin-top: 1rem;
}

.article-aside-heading {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: var(--cae-weight-semibold);
    color: var(--cae-primary);
}

.article-review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 960px) {
    .article-review-layout {
        grid-template-columns: 1fr;
    }
}

.article-review-facts {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
    gap: 0.65rem 1.25rem;
    margin: 0 0 1.25rem;
}

.article-review-facts > div {
    margin: 0;
}

.article-review-facts dt {
    font-size: var(--cae-text-small);
    font-weight: var(--cae-weight-semibold);
    color: var(--cae-text-muted);
    margin: 0 0 0.15rem;
}

.article-review-facts dd {
    margin: 0;
}

.article-review-summary {
    line-height: 1.55;
    color: var(--cae-text);
}

.article-review-hero {
    margin: 0 0 1.25rem;
    border-radius: var(--cae-radius-md);
    overflow: hidden;
    border: 2px solid var(--cae-border, #c8d0dc);
}

.article-review-hero img {
    display: block;
    width: 100%;
    max-height: 420px;
    object-fit: cover;
    object-position: top;
}

.article-review-body {
    font-size: 1rem;
    line-height: 1.7;
    padding: 1rem 0 0;
    border-top: 1px solid var(--cae-border, #e2e8f0);
}

.article-review-aside h2 {
    margin: 0 0 0.65rem;
    font-size: 1.05rem;
}

.article-approve-form,
.article-reject-form {
    margin: 1rem 0 0;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    max-width: none;
}

.article-media-grid {
    grid-template-columns: 1fr;
}

.article-media-card a {
    display: block;
}

/* Articles — compose, preview (matches public editorial layout) */
form.article-compose-form {
    max-width: none;
    width: 100%;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
}

.article-workspace {
    width: 100%;
    max-width: none;
}

.article-compose-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr);
    gap: 1.25rem;
    align-items: start;
}

@media (max-width: 960px) {
    .article-compose-layout {
        grid-template-columns: 1fr;
    }
}

.article-compose-main.panel,
.article-compose-aside.panel,
.article-preview-panel.panel {
    margin: 0;
    max-width: none;
}

.article-compose-main.panel > h2,
.article-compose-aside.panel > h2,
.article-preview-panel.panel > h2 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
}

.article-compose-form .article-editor-field {
    margin-top: 0.25rem;
}

.article-submit-row {
    margin: 0.75rem 0 0;
}

.article-compose-advanced summary {
    cursor: pointer;
    font-weight: var(--cae-weight-semibold);
    color: var(--cae-primary);
}

.article-compose-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
}

.article-featured-preview {
    margin: 0.75rem 0 0;
    border-radius: var(--cae-radius-md);
    overflow: hidden;
    border: 2px solid var(--cae-border, #c8d0dc);
    background: var(--cae-bg-muted, #f4f6f9);
}

.article-featured-preview img {
    display: block;
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    object-position: top;
}

.article-featured-preview figcaption {
    padding: 0.5rem 0.75rem;
    margin: 0;
}

.article-preview-panel {
    margin: 1.5rem 0 0;
    padding: 0;
    max-width: none;
}

.article-preview-panel--full {
    width: 100%;
}

.article-preview-panel > h2 {
    margin: 0 0 0.35rem;
}

.article-media-panel {
    max-width: none;
}

.article-media-grid {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}

.article-media-card {
    border: 2px solid var(--cae-border, #c8d0dc);
    border-radius: var(--cae-radius-md);
    overflow: hidden;
    background: var(--cae-bg);
}

.article-media-card.is-cleared {
    border-color: var(--cae-accent, #2d6a4f);
}

.article-media-card img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

.article-media-card__meta {
    display: grid;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem 0.85rem;
    font-size: var(--cae-text-small);
}

.article-media-card__status {
    font-weight: var(--cae-weight-semibold);
}

.article-public-json {
    margin: 1.5rem 0;
}

.article-public-json summary {
    cursor: pointer;
    font-weight: var(--cae-weight-semibold);
}

.article-public-url {
    margin: 0 0 0.75rem;
    font-size: var(--cae-text-small);
}

.article-public-url code {
    font-size: 0.92em;
}

/* Public article mirror inside AIMS (legacy editorial) */
.aims-editorial-preview {
    max-width: 1080px;
    margin: 0 auto;
    padding: 1rem 0.5rem 1.5rem;
    background: #fff;
    border: 2px solid var(--cae-border, #c8d0dc);
    border-radius: var(--cae-radius-md);
}

.aims-editorial-preview__hero {
    text-align: center;
    margin-bottom: 1rem;
}

.aims-editorial-preview__hero h2 {
    margin: 0 0 0.5rem;
    font-size: clamp(1.25rem, 2.5vw, 1.85rem);
    color: #203973;
    line-height: 1.25;
}

.aims-editorial-preview .editorial-meta {
    display: flex;
    justify-content: center;
    font-size: 0.9rem;
    color: #555;
}

.aims-editorial-preview .author-container h5 {
    margin: 0;
    font-weight: 600;
    font-size: 1rem;
}

.aims-editorial-preview .author-container .emphesis {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
}

.aims-editorial-preview__figure {
    width: 100%;
    max-height: 360px;
    overflow: hidden;
    margin: 0 0 1.25rem;
    border-radius: 16px;
}

.aims-editorial-preview__figure .feature-img {
    width: 100%;
    height: 100%;
    max-height: 360px;
    object-fit: cover;
    object-position: top;
    display: block;
}

.aims-editorial-preview__body {
    font-size: 1rem;
    line-height: 1.75;
    color: #222;
}

.aims-editorial-preview__body h2,
.aims-editorial-preview__body h3 {
    color: #203973;
    margin-top: 1.5rem;
}

.aims-editorial-preview__body a {
    color: #203973;
}

.aims-editorial-preview__body img {
    max-width: 100%;
    height: auto;
}

/* Article editor — Quill (Unicode / future SI-TA body) */
.article-editor-field .quill-aims,
.article-editor-field .ql-toolbar.ql-snow,
.article-editor-field .ql-container.ql-snow {
    width: 100%;
    box-sizing: border-box;
}

.article-editor-field .ql-toolbar.ql-snow {
    border-radius: 6px 6px 0 0;
    border-color: var(--cae-border, #c8d0dc);
    padding: 8px 10px;
    line-height: 1;
}

.article-editor-field .ql-container.ql-snow {
    border-radius: 0 0 6px 6px;
    border-color: var(--cae-border, #c8d0dc);
    font-family: inherit;
}

.quill-aims .ql-editor {
    min-height: 22rem;
    font-size: 1rem;
    line-height: 1.55;
}

.quill-aims .ql-editor.ql-blank::before {
    font-style: normal;
    color: var(--cae-text-muted, #6b7280);
}

/* Undo global AIMS button chrome inside Quill toolbar (avoids overlapping outlines) */
.article-editor-field .ql-toolbar.ql-snow button {
    display: inline-block;
    width: 28px;
    min-width: 28px;
    min-height: 0;
    height: 24px;
    padding: 3px 5px;
    margin: 0;
    background: transparent;
    color: #444;
    border: 1px solid transparent;
    border-radius: 3px;
    outline: none;
    box-shadow: none;
    font-size: 13px;
    font-weight: 400;
    line-height: 18px;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.article-editor-field .ql-toolbar.ql-snow button + button {
    margin-left: 2px;
}

.article-editor-field .ql-toolbar.ql-snow button:hover,
.article-editor-field .ql-toolbar.ql-snow button.ql-active {
    background: #e0e0e0;
    color: #444;
    outline: none;
}

.article-editor-field .ql-toolbar.ql-snow button:focus-visible {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 1px;
}

.article-editor-field .ql-toolbar.ql-snow .ql-formats {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 3px;
    margin-right: 10px;
    padding-right: 10px;
    border-right: 1px solid #ccc;
    vertical-align: middle;
}

.article-editor-field .ql-toolbar.ql-snow .ql-formats:last-child {
    border-right: 0;
    margin-right: 0;
    padding-right: 0;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker {
    height: 24px;
    font-size: 13px;
    color: #444;
    width: auto;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker.ql-header {
    min-width: 7.5rem;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-label {
    position: relative;
    display: block;
    width: 100%;
    height: 24px;
    line-height: 22px;
    padding: 1px 1.6rem 1px 6px;
    margin: 0;
    background: transparent;
    color: #444;
    border: 1px solid transparent;
    border-radius: 3px;
    outline: none;
    box-shadow: none;
    font-size: 13px;
    font-weight: 400;
    cursor: pointer;
    transition: background-color 0.12s ease;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-label::before {
    line-height: 22px;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-label svg {
    position: absolute;
    right: 3px;
    top: 50%;
    float: none;
    width: 18px;
    height: 18px;
    margin: 0;
    transform: translateY(-50%);
    pointer-events: none;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-label:hover {
    background: #e0e0e0;
    color: #444;
    outline: none;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-label:focus-visible {
    outline: 2px solid var(--cae-secondary);
    outline-offset: 1px;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker-options {
    border-color: var(--cae-border, #c8d0dc);
}

.article-editor-field .ql-toolbar.ql-snow .ql-stroke {
    stroke: #444;
}

.article-editor-field .ql-toolbar.ql-snow .ql-fill {
    fill: #444;
}

.article-editor-field .ql-toolbar.ql-snow .ql-picker.ql-expanded .ql-picker-label {
    border-color: #ccc;
}

.article-compose-aside .article-compose-actions {
    margin-top: 1.35rem;
    padding-top: 1rem;
    border-top: 1px solid var(--cae-border, #d7d7d7);
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.article-compose-aside .article-compose-actions form,
.article-compose-aside .field + .article-compose-actions {
    margin-top: 1.35rem;
}

/* Legacy editorial login (mirrored) */
body.is-gate.aims-login-shell,
body.is-gate:has(.aims-login-page) {
    background: #66c3ff;
}

.aims-login-page {
    display: flex;
    min-height: 100vh;
    width: 100%;
    margin: 0;
    padding: 1rem;
    justify-content: center;
    align-items: center;
    background-color: #66c3ff;
    max-width: none;
}

.aims-login-page .login-flash {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 24rem;
    z-index: 5;
}

.aims-login-container {
    display: flex;
    flex-direction: column;
    min-width: min(360px, 100%);
    max-width: 420px;
    width: 100%;
    background-color: var(--cae-panel);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 2px 2px 8px 4px rgba(0, 0, 0, 0.35);
}

.aims-login-container form {
    max-width: none;
    margin: 0;
    padding: 0;
    border: 0;
    box-shadow: none;
    background: transparent;
    gap: 0;
}

.aims-login-container .login-logo {
    display: flex;
    flex-direction: row;
    border-bottom: 5px solid var(--cae-primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
}

.aims-login-container .login-logo h2 {
    margin: 0;
    color: var(--cae-primary);
    font-size: 1.75rem;
}

.aims-login-container .login-logo p {
    line-height: 1.2;
    margin: 0.15rem 0 0;
    font-size: 0.85rem;
    color: var(--cae-text);
}

.aims-login-container .login-img {
    width: 30%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.aims-login-container .login-img img {
    width: 100%;
    max-width: 88px;
    height: auto;
}

.aims-login-container .login-txt {
    width: 70%;
    padding-left: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.aims-login-container .login-title {
    margin: 0.5rem 0 0.75rem;
    text-align: center;
    color: var(--cae-primary);
    font-size: 1.15rem;
}

.aims-login-container .input-box {
    width: 100%;
    margin-bottom: 0.25rem;
}

.aims-login-container .formInput {
    display: flex;
    flex-grow: 1;
    margin: 3px;
}

.aims-login-container .formInput input {
    width: 100%;
    background: var(--cae-bg);
    padding: 13px;
    border: 2px solid var(--cae-primary);
    border-radius: 8px;
    font-weight: 600;
    min-height: auto;
}

.aims-login-container .login-hlp {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 0.5rem 0 0.65rem;
    font-size: 0.8rem;
}

.aims-login-container .login-hlp label,
.aims-login-container .login-hlp a.login-hlp-disabled {
    color: var(--cae-text);
    font-size: 0.8rem;
    text-decoration: none;
}

.aims-login-container .login-hlp a.login-hlp-disabled {
    opacity: 0.85;
    cursor: default;
}

.aims-login-container .login-hlp .hint {
    font-size: 0.72rem;
}

.aims-login-container .button-area.center {
    display: flex;
    justify-content: center;
    margin-top: 10px;
}

.aims-login-container .button-blue {
    min-width: 130px;
    background-color: var(--cae-primary);
    color: var(--cae-panel);
    outline: 3px solid var(--cae-bg);
    border-radius: 8px;
    font-weight: 700;
}

.aims-login-container .button-blue:hover {
    background-color: var(--cae-primary-hover);
    color: var(--cae-panel);
}

.aims-login-container .login-copy {
    margin-top: 12px;
    font-size: 0.8rem;
    text-align: center;
    color: var(--cae-text-muted);
}

.aims-confirm-dialog .aims-confirm-message {
    margin: 0 0 0.25rem;
    line-height: 1.5;
    font-weight: 500;
}

.pub-view-switch {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin: 0 0 1rem;
    align-items: center;
}

.pub-view-switch a {
    text-decoration: none;
    padding: 0.35rem 0.65rem;
    border-radius: 6px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.pub-view-switch a.is-active {
    font-weight: 600;
    border-color: var(--accent, #1b6ec2);
    background: var(--surface-2, #eef3f8);
}

.pub-review-dialog {
    width: min(40rem, calc(100vw - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: inherit;
}

.pub-review-dialog::backdrop {
    background: rgba(16, 24, 40, 0.45);
}

.pub-review-dialog .pub-review-inner {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 2rem);
    padding: 1.25rem 1.35rem;
    gap: 0.75rem;
}

.pub-review-dialog .pub-review-scroll {
    overflow-y: auto;
    max-height: min(50vh, 22rem);
    padding-right: 0.25rem;
}

.pub-review-dialog h2 {
    margin: 0;
    font-size: 1.25rem;
}

.pub-review-dialog h3 {
    margin: 0 0 0.35rem;
    font-size: 1rem;
}

.pub-assign-list {
    margin: 0;
    padding-left: 1.25rem;
}
