:root {
    --ink: #0f2438;
    --muted: #66758a;
    --line: #dbe3ee;
    --card: #ffffff;
    --soft: #f5f8fb;
    --primary: #183e7a;
    --primary-dark: #0c254c;
    --accent: #e5aa48;
    --danger: #a32424;
    --success: #247044;
    --promarc-red: #ef1d24;
    --promarc-orange: #e28728;
    --promarc-green: #6fa042;
    --promarc-blue: #1b79ba;
    --promarc-purple: #9b63ac;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
    margin: 0;
    font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef4fa 100%);
    color: var(--ink);
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 14px 24px;
    background: rgba(255,255,255,.95);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(10px);
}

.brand-stack { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand {
    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--ink);
}
.brand:hover { text-decoration: none; }
.brand-logo {
    height: 42px;
    width: auto;
    display: block;
    object-fit: contain;
}
.brand-logo-promarc { height: 38px; }
.brand strong { display: block; font-size: 18px; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.brand-separator { width: 1px; height: 34px; background: var(--line); }
.topbar nav { display: flex; gap: 18px; flex-wrap: wrap; }
.topbar nav a { padding: 8px 0; }

.shell { max-width: 1180px; margin: 0 auto; padding: 28px; }
.footer { padding: 22px 28px 32px; color: var(--muted); text-align: center; }
.footer-branding { display: inline-flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap; }
.footer-branding img { height: 42px; width: auto; }

.hero, .empty-state, .form-card, .detail-card, .table-card, .card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(15,36,56,.04);
}
.hero { padding: 48px; }
.hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
    gap: 28px;
    align-items: center;
}
.hero h1, .page-title h1 { margin: 0 0 10px; font-size: 38px; letter-spacing: -0.02em; }
.hero p { max-width: 700px; font-size: 18px; color: var(--muted); }
.hero-panel {
    padding: 24px;
    border-radius: 18px;
    background: linear-gradient(180deg, #f5f9ff 0%, #eef6ff 100%);
    border: 1px solid #d7e6fb;
}
.hero-panel img { max-width: 100%; height: auto; display: block; margin: 0 auto 16px; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }
.muted { color: var(--muted); }
.page-title { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; margin-bottom: 22px; }
.inline-link { display: inline-flex; align-items: center; gap: 8px; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 10px; }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 12px;
    padding: 10px 16px;
    color: var(--ink);
    font-weight: 700;
    cursor: pointer;
}
.button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.button.primary:hover { background: var(--primary-dark); text-decoration: none; }
.button.secondary { background: #fff8ea; color: #78510b; border-color: #f0d59b; }

.cards { display: grid; gap: 18px; margin: 22px 0; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { padding: 22px; }
.card h3 { margin-top: 0; }
.card span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 7px; }
.card strong { font-size: 20px; }
.metric { font-size: 30px; font-weight: 800; color: var(--primary); margin-top: 6px; }

.table-card, .detail-card, .form-card, .empty-state { padding: 22px; margin-bottom: 22px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #f0f5f8; color: var(--primary-dark); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions.wide { justify-content: flex-end; }
.tag, .status {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 12px;
    background: #eaf2f6;
    color: var(--primary-dark);
    font-weight: 700;
}
.status.error { background: #fde8e8; color: var(--danger); }
.status.warning { background: #fff4dd; color: #885b05; }
.status.info { background: #eaf2f6; color: var(--primary-dark); }

form label { display: grid; gap: 7px; font-weight: 700; margin-bottom: 16px; }
input, select, textarea {
    width: 100%;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    font: inherit;
    background: #fff;
}
textarea { resize: vertical; }
.form-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.validation-summary { color: var(--danger); margin-bottom: 12px; }
.form-note {
    margin: -6px 0 16px;
    color: var(--muted);
    font-size: 13px;
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    margin: 14px 0;
    border: 1px solid var(--line);
    background: #fff;
}
.alert.success { background: #eaf8f0; color: var(--success); border-color: #ccead8; }
.alert.error { background: #fde8e8; color: var(--danger); border-color: #facaca; }
.alert.warning { background: #fff7e6; color: #805200; border-color: #f1d79a; }

.component-inputs { display: grid; gap: 12px; margin: 18px 0; }
.component-row {
    display: grid;
    grid-template-columns: 1.8fr 1fr .7fr .7fr;
    gap: 12px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fafcff;
}
.result-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 22px;
}
.result-grid div {
    padding: 14px;
    border-radius: 14px;
    background: #f6f9fc;
    border: 1px solid var(--line);
}
.result-grid span { display: block; color: var(--muted); font-size: 12px; }
.result-grid strong { font-size: 20px; }
.pass { color: var(--success); }
.fail { color: var(--danger); }

.app-loader {
    position: fixed;
    inset: 0;
    background: rgba(9, 19, 36, 0.52);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
}
.app-loader.visible { display: flex; }
.app-loader-card {
    width: min(156px, calc(100vw - 32px));
    min-height: 132px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff;
    border-radius: 18px;
    padding: 16px 13px 14px;
    text-align: center;
    border: 1px solid #d7e1ee;
    box-shadow: 0 14px 38px rgba(0,0,0,.18);
}
.app-loader-logo {
    width: min(98px, 100%);
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto 8px;
}
.app-loader-card h3 {
    margin: 7px 0 5px;
    font-size: 16px;
    line-height: 1.15;
}
.app-loader-card p {
    margin: 0;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.35;
}
.app-loader-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 4px 0 0;
}
.app-loader-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    animation: loaderBounce 1.2s infinite ease-in-out;
}
.app-loader-dots .red { background: var(--promarc-red); animation-delay: 0s; }
.app-loader-dots .orange { background: var(--promarc-orange); animation-delay: .1s; }
.app-loader-dots .green { background: var(--promarc-green); animation-delay: .2s; }
.app-loader-dots .blue { background: var(--promarc-blue); animation-delay: .3s; }
.app-loader-dots .purple { background: var(--promarc-purple); animation-delay: .4s; }

@keyframes loaderBounce {
    0%, 80%, 100% { transform: translateY(0) scale(.9); opacity: .65; }
    40% { transform: translateY(-8px) scale(1); opacity: 1; }
}

@media (max-width: 980px) {
    .hero-grid { grid-template-columns: 1fr; }
}

@media (max-width: 800px) {
    .topbar, .page-title { flex-direction: column; align-items: stretch; }
    .brand-stack { align-items: flex-start; }
    .brand-separator { width: 100%; height: 1px; }
    .cards.three, .result-grid, .component-row { grid-template-columns: 1fr; }
    .shell { padding: 18px; }
    .hero { padding: 28px; }
    .footer-branding { flex-direction: column; }
}
.checkbox-row {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    margin-bottom: 8px;
}
.checkbox-row input { width: auto; }
.checkbox-row span { font-weight: 500; }

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 14px 0 18px;
}
.checkbox-label {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fbfdff;
    margin-bottom: 0;
    font-weight: 700;
}
.checkbox-label input {
    width: auto;
}
.stage-card h2 {
    margin-top: 0;
}

@media (max-width: 800px) {
    .checkbox-grid { grid-template-columns: 1fr; }
}

.checkbox-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 700;
}
.checkbox-grid input[type="checkbox"] {
    width: auto;
}


.form-grid { display: grid; gap: 16px; margin-bottom: 18px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; margin: 12px 0 22px; }
.check-grid label { display: flex; align-items: center; gap: 8px; margin: 0; font-weight: 600; }
.check-grid input[type="checkbox"] { width: auto; }
.compact-form { display: grid; grid-template-columns: minmax(260px, 1fr) auto; align-items: end; gap: 16px; }
.compact-form label { margin: 0; }
@media (max-width: 900px) {
    .form-grid.two, .form-grid.three, .form-grid.four, .check-grid, .compact-form { grid-template-columns: 1fr; }
}

/* V20: Simple but powerful Subject Master */
.subject-entry-intro {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin: 0 0 18px;
}
.subject-entry-intro .step {
    display: grid;
    grid-template-columns: 38px 1fr;
    column-gap: 10px;
    align-items: center;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255,255,255,.72);
}
.subject-entry-intro .step span {
    grid-row: 1 / span 2;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    background: #eaf0f8;
    color: var(--primary);
}
.subject-entry-intro .step.active span { background: var(--primary); color: #fff; }
.subject-entry-intro .step strong { font-size: 15px; }
.subject-entry-intro .step small { color: var(--muted); }

.subject-simple-form {
    padding: 0;
    overflow: visible;
    background: transparent;
    border: 0;
    box-shadow: none;
}
.simple-section {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 18px;
    box-shadow: 0 8px 30px rgba(15,36,56,.04);
}
.simple-section.compact { padding-bottom: 18px; }
.section-heading {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    padding-bottom: 16px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.section-heading > div { display: flex; align-items: center; gap: 10px; }
.section-heading h2 { margin: 0; font-size: 22px; }
.section-heading p { margin: 3px 0 0; color: var(--muted); max-width: 520px; text-align: right; }
.section-number {
    width: 30px;
    height: 30px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}
.simple-grid { display: grid; gap: 16px; }
.simple-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.simple-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.simple-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.simple-grid label { margin-bottom: 0; }
.required { color: var(--danger); }
.field-hint { color: var(--muted); font-size: 12px; font-weight: 500; }
.field-validation { color: var(--danger); font-size: 12px; font-weight: 500; }

.friendly-options {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}
.friendly-options.compact-options { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.choice-card {
    display: flex;
    grid-template-columns: none;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
    cursor: pointer;
    min-height: 62px;
}
.choice-card:hover { border-color: #aec2dc; background: #f5f9ff; }
.choice-card input { width: auto; margin-top: 3px; }
.choice-card span { display: grid; gap: 2px; }
.choice-card strong { font-size: 13px; }
.choice-card small { color: var(--muted); font-size: 11px; font-weight: 500; }

.advanced-panel {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    margin-bottom: 18px;
    overflow: hidden;
}
.advanced-panel summary {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 18px 22px;
    cursor: pointer;
    font-weight: 800;
    background: #f7f9fc;
    list-style: none;
}
.advanced-panel summary::-webkit-details-marker { display: none; }
.advanced-panel summary::after { content: "+"; font-size: 24px; color: var(--primary); }
.advanced-panel[open] summary::after { content: "–"; }
.advanced-panel summary small { margin-left: auto; color: var(--muted); font-weight: 500; }
.advanced-content { padding: 22px; }
.advanced-content h3 { margin: 26px 0 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.advanced-content h3:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.sticky-form-actions {
    position: sticky;
    bottom: 12px;
    z-index: 8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 15px 18px;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 10px 35px rgba(15,36,56,.15);
}
.sticky-form-actions > div:first-child { display: grid; gap: 3px; }
.sticky-form-actions span { color: var(--muted); font-size: 12px; }

.setup-badge {
    display: inline-flex;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 800;
}
.setup-badge.complete { background: #e8f8ee; color: #17663b; }
.setup-badge.warning { background: #fff4d9; color: #825600; }
.setup-badge.attention { background: #fdeaea; color: #942727; }
.action-primary { color: #fff !important; background: var(--primary); border-radius: 8px; padding: 5px 8px; text-decoration: none !important; }

.assessment-status-card {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 18px 20px;
    border-radius: 18px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    background: #fff;
}
.assessment-status-card > div:first-child { display: flex; gap: 12px; align-items: center; }
.assessment-status-card p { margin: 4px 0 0; color: var(--muted); }
.assessment-status-card.complete { border-color: #b7dfc4; background: #f3fbf6; }
.assessment-status-card.attention { border-color: #efd39a; background: #fffaf0; }
.status-icon {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 900;
    font-size: 20px;
}
.component-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.component-card { border: 1px solid var(--line); border-radius: 16px; padding: 15px; background: #fbfdff; }
.component-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin-bottom: 10px; }
.component-card dl { display: grid; gap: 7px; margin: 0; }
.component-card dl div { display: flex; justify-content: space-between; gap: 10px; border-top: 1px dashed var(--line); padding-top: 7px; }
.component-card dt { color: var(--muted); }
.component-card dd { margin: 0; font-weight: 700; text-align: right; }
.empty-inline { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 16px; border: 1px dashed #b9c8d9; border-radius: 14px; background: #f9fbfd; }
.empty-inline p { margin: 0; color: var(--muted); }
.guidance-strip { display: flex; gap: 12px; align-items: flex-start; padding: 16px 18px; border-radius: 14px; background: #eef5ff; border: 1px solid #cbdcf5; }
.guidance-strip span { color: var(--muted); }
.table-card.flush { padding: 0; margin: 0; overflow: hidden; }
.button.danger { background: #fff; border-color: #e5b1b1; color: var(--danger); }

@media (max-width: 1050px) {
    .friendly-options, .friendly-options.compact-options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .component-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .subject-entry-intro, .simple-grid.two, .simple-grid.three, .simple-grid.four,
    .friendly-options, .friendly-options.compact-options, .component-cards { grid-template-columns: 1fr; }
    .section-heading, .sticky-form-actions, .assessment-status-card, .empty-inline { flex-direction: column; align-items: stretch; }
    .section-heading p { text-align: left; }
    .advanced-panel summary { align-items: flex-start; }
    .advanced-panel summary small { display: none; }
}
.is-muted { opacity: .55; }
.choice-card.standalone { min-height: auto; margin-top: 0; }
.component-selector { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.component-choice { display: flex; grid-template-columns: none; align-items: flex-start; gap: 10px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; cursor: pointer; }
.component-choice:hover { border-color: #aec2dc; background: #f4f8fd; }
.component-choice input { width: auto; margin-top: 3px; }
.component-choice span { display: grid; gap: 3px; }
.component-choice small { color: var(--muted); }
@media (max-width: 800px) { .component-selector { grid-template-columns: 1fr; } }

/* V21: Overall application shell with a sequenced left sidebar */
:root {
    --sidebar-width: 286px;
    --sidebar-bg: #0c2345;
    --sidebar-bg-soft: #12345f;
    --sidebar-text: #dce7f5;
    --sidebar-muted: #8fa7c5;
    --topbar-height: 72px;
}

.app-body {
    overflow-x: hidden;
}

.app-frame {
    min-height: 100vh;
    display: flex;
}

.app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(circle at 20% 0%, rgba(36, 111, 179, .22), transparent 34%),
        linear-gradient(180deg, #102f59 0%, var(--sidebar-bg) 58%, #081a33 100%);
    color: var(--sidebar-text);
    border-right: 1px solid rgba(255,255,255,.08);
    box-shadow: 14px 0 34px rgba(9, 28, 54, .12);
    z-index: 50;
    transition: transform .24s ease;
}

.sidebar-brand {
    min-height: 96px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-brand-link {
    min-width: 0;
    display: block;
    flex: 1 1 auto;
    color: #fff;
    background: #fff;
    border: 1px solid rgba(255,255,255,.55);
    border-radius: 14px;
    padding: 10px 12px;
    box-shadow: 0 8px 20px rgba(3, 13, 26, .18);
}
.sidebar-brand-link:hover { text-decoration: none; }
.sidebar-brand-link img,
.sidebar-brand-logo-landscape {
    display: block;
    width: min(100%, 248px);
    height: auto;
    object-fit: contain;
    background: transparent;
    padding: 0;
    border-radius: 0;
    margin: 0 auto;
}
.sidebar-close {
    display: none;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.1);
    color: #fff;
    font-size: 25px;
    line-height: 1;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 12px 12px 22px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar-section { margin-top: 12px; }
.sidebar-section:first-child { margin-top: 0; }
.sidebar-section-title {
    padding: 8px 11px 6px;
    color: var(--sidebar-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
}
.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 42px;
    margin: 3px 0;
    padding: 8px 11px;
    border-radius: 12px;
    color: var(--sidebar-text);
    font-size: 14px;
    font-weight: 650;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.sidebar-link:hover {
    background: rgba(255,255,255,.08);
    color: #fff;
    text-decoration: none;
    transform: translateX(2px);
}
.sidebar-link.active {
    background: linear-gradient(90deg, rgba(255,255,255,.17), rgba(255,255,255,.09));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.sidebar-link.active::after {
    content: "";
    position: absolute;
    right: 11px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent);
}
.nav-step, .nav-icon {
    width: 25px;
    height: 25px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 8px;
    background: rgba(255,255,255,.1);
    color: #d8e7f8;
    font-size: 11px;
    font-weight: 850;
}
.nav-step.highlight {
    background: rgba(229, 170, 72, .24);
    color: #ffd98f;
}
.sidebar-link.active .nav-step,
.sidebar-link.active .nav-icon {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.sidebar-footer {
    padding: 14px 18px 18px;
    border-top: 1px solid rgba(255,255,255,.1);
    text-align: center;
    color: var(--sidebar-muted);
}
.sidebar-footer > span {
    display: block;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: .09em;
}
.sidebar-footer img {
    display: block;
    width: 220px;
    max-width: 100%;
    max-height: 60px;
    object-fit: contain;
    margin: 10px auto 6px;
    padding: 5px 10px;
    border-radius: 10px;
    background: #fff;
}
.sidebar-footer small {
    display: block;
    font-size: 9px;
    line-height: 1.25;
}

.app-main {
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    min-height: 100vh;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: width .24s ease, margin-left .24s ease;
}
.app-topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    min-height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 11px 24px;
    background: rgba(255,255,255,.93);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 5px 22px rgba(15,36,56,.045);
    backdrop-filter: blur(12px);
}
.topbar-left, .topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.menu-toggle {
    width: 42px;
    height: 42px;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
}
.menu-toggle span {
    width: 19px;
    height: 2px;
    border-radius: 2px;
    background: var(--primary-dark);
}
.page-context span {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.page-context strong {
    display: block;
    margin-top: 2px;
    color: var(--ink);
    font-size: 18px;
}
.environment-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 11px;
    border: 1px solid #efd7a4;
    border-radius: 999px;
    background: #fff9ec;
    color: #79530a;
    font-size: 11px;
    font-weight: 800;
}
.environment-badge::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(229,170,72,.15);
}
.topbar-promarc {
    width: 220px;
    max-height: 66px;
    object-fit: contain;
}

.app-content {
    width: 100%;
    max-width: 1440px;
    flex: 1 0 auto;
    margin: 0 auto;
    padding: 26px 28px 34px;
}
.app-footer {
    margin-top: auto;
    padding-top: 18px;
    padding-bottom: 22px;
}
.sidebar-backdrop {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(3, 13, 26, .52);
    z-index: 45;
}

/* Wide data tables remain usable inside the content area. */
.table-card {
    overflow-x: auto;
}
.table-card table {
    min-width: 760px;
}

@media (max-width: 1100px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main {
        width: 100%;
        margin-left: 0;
    }
    .menu-toggle { display: flex; }
    .sidebar-close { display: grid; place-items: center; }
    .sidebar-backdrop.open { display: block; }
    body.sidebar-open { overflow: hidden; }
}

@media (max-width: 720px) {
    :root { --sidebar-width: min(88vw, 310px); }
    .app-topbar { padding: 10px 14px; }
    .app-content { padding: 18px 14px 28px; }
    .topbar-promarc { display: none; }
    .environment-badge { padding: 6px 9px; font-size: 10px; }
    .page-context span { display: none; }
    .page-context strong { font-size: 16px; }
    .hero h1, .page-title h1 { font-size: 30px; }
}

/* V13 rebuilt academic and examination core */
.cards.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-actions, .inline-form { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-actions form, .inline-form { margin: 0; }
.page-actions .button, .inline-form .button { white-space: nowrap; }
.button.small { padding: 7px 11px; border-radius: 9px; font-size: 12px; }
.button.success { background: var(--success); border-color: var(--success); color: #fff; }
.link-button { border: 0; padding: 0; background: transparent; color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; }
.link-button.danger { color: var(--danger); }
.alert.info { background: #eaf3ff; color: #174b80; border-color: #c9def6; }
.span-two { grid-column: span 2; }
.span-three { grid-column: span 3; }
.table-scroll { width: 100%; overflow-x: auto; }
.table-scroll table { min-width: 760px; }
td small, .compact-list span, .rule-block span { display: block; color: var(--muted); margin-top: 3px; }
.empty-cell { padding: 28px; color: var(--muted); text-align: center; }
.status-chip { display: inline-flex; padding: 4px 9px; border-radius: 999px; background: #eaf2f6; color: var(--primary-dark); font-size: 12px; font-weight: 800; }
.compact-list { display: grid; gap: 8px; margin-top: 16px; }
.compact-list > div { position: relative; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; background: #fbfdff; }
.compact-list form { display: inline-flex; margin-left: 8px; }
.metric-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0; }
.metric-card { padding: 15px; border: 1px solid var(--line); border-radius: 14px; background: var(--soft); }
.metric-card span { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 5px; font-size: 20px; }
.add-panel { margin-top: 16px; padding: 14px; border: 1px dashed #b9c8da; border-radius: 14px; background: #fbfdff; }
.add-panel > summary, details > summary { cursor: pointer; color: var(--primary); font-weight: 800; }
.add-panel[open] > summary { margin-bottom: 14px; }
.mini-form { display: grid; gap: 8px; min-width: 260px; padding-top: 10px; }
.mini-form label { margin: 0; }
.rule-block { padding: 14px; margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.rule-block .section-heading { padding-bottom: 10px; margin-bottom: 10px; }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.data-chip { display: inline-flex !important; align-items: center; gap: 6px; margin: 0 !important; padding: 7px 10px; border-radius: 999px; background: #eaf2f6; color: var(--primary-dark) !important; font-size: 12px; font-weight: 800; }
.data-chip form { display: inline-flex; }
.data-chip button { border: 0; background: transparent; cursor: pointer; color: var(--danger); font-size: 16px; line-height: 1; }
.row-muted { background: #f5f6f8; color: var(--muted); }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset:disabled { opacity: .72; }
code { overflow-wrap: anywhere; color: #29445f; }

@media (max-width: 900px) {
    .cards.two, .metric-grid { grid-template-columns: 1fr; }
    .span-two, .span-three { grid-column: auto; }
    .page-title { align-items: stretch; }
    .page-actions { justify-content: flex-start; }
}

/* V13 testing login: one account type, no role branching */
.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    background:
        radial-gradient(circle at 15% 10%, rgba(24, 62, 122, .16), transparent 34%),
        radial-gradient(circle at 88% 85%, rgba(229, 170, 72, .18), transparent 30%),
        linear-gradient(145deg, #eef4fb 0%, #f8fafc 48%, #edf2f7 100%);
}

.login-shell {
    width: min(100%, 470px);
}

.login-panel {
    background: rgba(255, 255, 255, .97);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 30px;
    box-shadow: 0 24px 70px rgba(15, 36, 56, .16);
}

.login-brand {
    display: grid;
    justify-items: start;
    gap: 10px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.login-brand img,
.login-brand-logo-landscape {
    width: min(100%, 360px);
    height: auto;
    object-fit: contain;
}

.login-brand-subtitle {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-top: 0;
}

.login-copy {
    margin: 24px 0 20px;
}

.login-copy h1 {
    margin: 14px 0 8px;
    font-size: 32px;
}

.login-copy p {
    margin: 0;
    color: var(--muted);
    line-height: 1.55;
}

.login-form {
    display: grid;
    gap: 4px;
}

.form-field {
    margin-bottom: 14px;
}

.form-field label {
    margin-bottom: 7px;
}

.form-field > span {
    display: block;
    color: var(--danger);
    font-size: 12px;
    margin-top: 6px;
}

.form-field small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

.login-check {
    display: flex;
    grid-template-columns: none;
    align-items: center;
    gap: 9px;
    margin: 1px 0 18px;
    font-weight: 600;
    color: var(--muted);
}

.login-check input {
    width: auto;
}

.login-submit {
    width: 100%;
    min-height: 46px;
}

.login-security-note {
    display: grid;
    gap: 4px;
    margin-top: 20px;
    padding: 13px 14px;
    border: 1px solid #f0d59b;
    border-radius: 14px;
    background: #fff8ea;
    color: #78510b;
}

.login-security-note span {
    font-size: 12px;
    line-height: 1.45;
}

.login-powered-by {
    display: grid;
    justify-items: center;
    gap: 7px;
    margin-top: 22px;
    color: var(--muted);
    text-align: center;
    font-size: 11px;
}

.login-powered-by img {
    height: 46px;
    width: auto;
}

.testing-user {
    display: grid;
    line-height: 1.1;
    text-align: right;
}

.testing-user span {
    color: var(--muted);
    font-size: 10px;
}

.testing-user strong {
    font-size: 13px;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-account-link,
.topbar-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 34px;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--primary-dark);
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.topbar-account-link:hover,
.topbar-logout:hover {
    background: #f3f7fb;
    text-decoration: none;
}

.logout-form {
    margin: 0;
}

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

.page-header h1 {
    margin: 4px 0 8px;
    font-size: 32px;
}

.page-header p {
    margin: 0;
    max-width: 760px;
    color: var(--muted);
    line-height: 1.5;
}

.content-card {
    padding: 24px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(15, 36, 56, .04);
}

.account-card {
    max-width: 680px;
}

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

@media (max-width: 900px) {
    .testing-user { display: none; }
    .topbar-account-link { display: none; }
}

@media (max-width: 560px) {
    .login-panel { padding: 22px 18px; border-radius: 20px; }
    .login-brand img,
    .login-brand-logo-landscape { width: min(100%, 280px); height: auto; }
    .login-copy h1 { font-size: 28px; }
    .topbar-promarc { display: none; }
    .topbar-logout { padding: 7px 9px; }
}

/* Clerk-friendly academic setup and examination work */
.cards.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.setup-overview, .selection-card, .setup-next-step {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(15,36,56,.04);
}
.setup-overview { padding: 22px; margin-bottom: 22px; }
.workflow-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
}
.workflow-step {
    display: grid;
    grid-template-columns: 34px 1fr;
    grid-template-rows: auto auto;
    column-gap: 10px;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fbfdff;
    color: var(--ink);
}
.workflow-step:hover { text-decoration: none; border-color: #adc3dc; background: #f3f8fd; }
.workflow-step > span {
    grid-row: 1 / span 2;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    font-weight: 850;
}
.workflow-step strong { align-self: end; font-size: 14px; }
.workflow-step small { color: var(--muted); font-weight: 500; line-height: 1.35; }
.operations-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 22px 0;
}
.operation-card {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    color: var(--ink);
}
.operation-card:hover { text-decoration: none; border-color: #adc3dc; background: #f8fbff; }
.operation-card .nav-icon { background: var(--primary); color: #fff; width: 38px; height: 38px; }
.operation-card strong, .operation-card small { display: block; }
.operation-card small { color: var(--muted); margin-top: 3px; font-weight: 500; }
.setup-next-step {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    margin: 20px 0;
    background: #f3f9f6;
    border-color: #cce6d5;
}
.setup-next-step strong, .setup-next-step span { display: block; }
.setup-next-step span { margin-top: 3px; color: var(--muted); }
.optional-section > summary, .inline-advanced > summary {
    cursor: pointer;
    color: var(--primary-dark);
    font-weight: 800;
}
.optional-section[open] > summary, .inline-advanced[open] > summary { margin-bottom: 16px; }
.inline-advanced {
    margin: 12px 0 18px;
    padding: 13px 15px;
    border: 1px dashed #b8c7d8;
    border-radius: 13px;
    background: #fbfdff;
}
.optional-label { color: var(--muted); font-size: 11px; font-weight: 600; }
.selection-card { padding: 20px; margin-bottom: 22px; }
.context-filter { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 12px; align-items: end; }
.context-filter label { margin: 0; }
.selected-context { display: flex; gap: 10px; align-items: center; margin-top: 14px; padding: 10px 12px; border-radius: 12px; background: #eef5ff; }
.selected-context span { color: var(--muted); font-size: 12px; }
.subject-layout { align-items: start; }
.sub-form { padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.sub-form h3 { margin-top: 0; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.result-actions form { margin: 0; }
.table-footer-action { margin-top: 14px; }
.technical-log { margin-top: 22px; }

@media (max-width: 1100px) {
    .workflow-grid, .operations-grid, .cards.four { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .context-filter { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 700px) {
    .workflow-grid, .operations-grid, .cards.four, .context-filter { grid-template-columns: 1fr; }
    .setup-next-step { flex-direction: column; align-items: stretch; }
}

/* V13 subject-entry redesign: clerk-facing assessment maxima and minima */
.subject-create-card {
    padding: 0;
    overflow: hidden;
}
.subject-create-card > .section-heading {
    padding: 24px 24px 18px;
    margin: 0;
}
.subject-create-card > .validation-summary {
    margin: 18px 24px 0;
}
.subject-create-card form {
    padding: 0 24px 24px;
}
.subject-form-section {
    padding: 24px 0;
    border-bottom: 1px solid var(--line);
}
.subject-form-section:last-of-type { border-bottom: 0; }
.subject-section-heading {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}
.subject-section-heading > span {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}
.subject-section-heading strong,
.subject-section-heading small { display: block; }
.subject-section-heading strong { font-size: 18px; }
.subject-section-heading small { color: var(--muted); margin-top: 3px; }
.assessment-pattern-field { max-width: 680px; }
.field-help {
    margin: 4px 0 16px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}
.assessment-marks-table {
    border: 1px solid var(--line);
    border-radius: 16px;
    overflow: hidden;
    background: #fff;
}
.assessment-marks-head,
.assessment-marks-row {
    display: grid;
    grid-template-columns: minmax(240px, 1.5fr) minmax(160px, .8fr) minmax(190px, .9fr);
    gap: 16px;
    align-items: center;
}
.assessment-marks-head {
    padding: 12px 16px;
    background: #eef4fa;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 13px;
}
.assessment-marks-row {
    padding: 16px;
    border-top: 1px solid var(--line);
}
.assessment-marks-row:first-child { border-top: 0; }
.assessment-marks-row label { margin: 0; }
.assessment-part-name strong,
.assessment-part-name small { display: block; }
.assessment-part-name small { color: var(--muted); margin-top: 4px; }
.mobile-field-label { display: none; }
.assessment-not-applicable { color: var(--muted); font-size: 14px; }
.combined-minimums {
    margin-top: 20px;
    padding: 18px;
    background: #f8fbfe;
    border: 1px solid var(--line);
    border-radius: 16px;
}
.combined-minimums h3 { margin: 0 0 5px; font-size: 17px; }
.is-hidden { display: none !important; }
.subject-total-strip {
    display: grid;
    grid-template-columns: minmax(220px, .7fr) minmax(280px, 1fr);
    gap: 18px;
    margin-top: 20px;
    padding: 18px;
    border: 1px solid #c9d9eb;
    border-radius: 16px;
    background: #f2f7fc;
    align-items: end;
}
.subject-total-strip > div {
    display: grid;
    gap: 3px;
}
.subject-total-strip > div span,
.subject-total-strip > div small { color: var(--muted); }
.subject-total-strip > div strong { font-size: 30px; color: var(--primary); }
.subject-total-strip label { margin: 0; }
.grade-assessment-block {
    max-width: 520px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f8fbfe;
}
.subject-save-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding-top: 22px;
}
.subject-save-bar strong,
.subject-save-bar span { display: block; }
.subject-save-bar span { margin-top: 4px; color: var(--muted); font-size: 13px; max-width: 680px; }

@media (max-width: 850px) {
    .assessment-marks-head { display: none; }
    .assessment-marks-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .mobile-field-label { display: block; }
    .subject-total-strip { grid-template-columns: 1fr; }
    .subject-save-bar { align-items: stretch; flex-direction: column; }
}

/* V13 fully configurable clerk-friendly Subject Master */
.subject-master-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
}
.supporting-master-links { display: flex; flex-wrap: wrap; gap: 10px; }
.context-card { margin-bottom: 24px; }
.context-selector {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr)) auto;
    gap: 14px;
    align-items: end;
}
.context-selector label { margin: 0; }
.selected-context {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 14px;
    background: #edf5ff;
    color: var(--primary-dark);
}
.selected-context span { color: var(--muted); }
.subject-editor-card { padding-bottom: 0; overflow: visible; }
.editor-heading { align-items: flex-start; }
.editor-step {
    padding: 26px 0;
    border-top: 1px solid var(--line);
}
.editor-step:first-of-type { border-top: 0; }
.editor-step-title {
    display: flex;
    align-items: center;
    gap: 13px;
    margin-bottom: 18px;
}
.editor-step-title > span {
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}
.editor-step-title h3,
.editor-step-title p { margin: 0; }
.editor-step-title h3 { font-size: 20px; }
.editor-step-title p { margin-top: 3px; color: var(--muted); font-size: 14px; }
.editor-step-title.with-action { align-items: flex-start; }
.editor-step-title.with-action > div:nth-child(2) { flex: 1; }
.editor-step-title.with-action > .button,
.editor-step-title.with-action > .inline-actions { margin-left: auto; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.wide-field { max-width: 760px; }
.friendly-callout {
    display: grid;
    gap: 3px;
    margin-top: 14px;
    padding: 14px 16px;
    border: 1px solid #cbdcf0;
    border-radius: 14px;
    background: #f4f8fd;
}
.friendly-callout strong { color: var(--primary-dark); }
.friendly-callout span { color: var(--muted); line-height: 1.45; }
.prominent-help {
    padding: 13px 15px;
    border-left: 4px solid var(--accent);
    background: #fff9ec;
    border-radius: 0 12px 12px 0;
}
.component-editor,
.condition-editor,
.display-row-editor { display: grid; gap: 14px; }
.component-card,
.condition-card,
.display-row-card {
    border: 1px solid #cbd8e8;
    border-radius: 16px;
    padding: 18px;
    background: #fff;
}
.component-card-head,
.condition-card-head,
.display-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 15px;
}
.component-card-head > div:first-child { display: grid; gap: 2px; }
.part-number,
.display-row-head > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.component-card-head strong { font-size: 17px; }
.row-actions { display: flex; gap: 6px; }
.icon-button {
    width: 34px;
    height: 34px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    color: var(--primary-dark);
    font-weight: 800;
    cursor: pointer;
}
.icon-button:hover { background: #eef4fa; }
.icon-button.danger { color: #a32929; }
.component-grid { grid-template-columns: 1.1fr .9fr 1.1fr .8fr .65fr .75fr; }
.component-grid label { margin: 0; }
.component-grid label small { display: block; margin: 2px 0 5px; color: var(--muted); font-weight: 400; }
.subject-total-panel {
    display: grid;
    grid-template-columns: auto auto 1fr;
    align-items: baseline;
    gap: 12px;
    margin-top: 14px;
    padding: 15px 18px;
    border-radius: 14px;
    background: #eef5fc;
}
.subject-total-panel strong { font-size: 28px; color: var(--primary); }
.subject-total-panel small { color: var(--muted); }
.condition-components { margin-top: 15px; }
.sub-label { display: block; margin-bottom: 7px; color: var(--muted); font-size: 13px; }
.component-choice-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.choice-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    padding: 8px 11px;
    border: 1px solid #cbd8e8;
    border-radius: 999px;
    background: #f8fbff;
    font-weight: 700;
    cursor: pointer;
}
.choice-chip input { width: auto; margin: 0; }
.rare-options {
    margin-top: 14px;
    border-top: 1px dashed #cbd8e8;
    padding-top: 12px;
}
.rare-options summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.rare-options summary span { color: var(--muted); font-weight: 400; }
.rare-options > div { margin-top: 14px; }
.empty-inline {
    padding: 16px;
    border: 1px dashed #cbd8e8;
    border-radius: 14px;
    color: var(--muted);
    text-align: center;
}
.optional-section > summary { font-size: 18px; font-weight: 800; cursor: pointer; }
.optional-content { margin-top: 18px; }
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 10px;
    margin-top: 14px;
}
.checkbox-grid label { display: flex; align-items: center; gap: 8px; margin: 0; }
.checkbox-grid input { width: auto; }
.review-step { padding-bottom: 10px; }
.subject-review {
    border: 1px solid #bed0e4;
    border-radius: 18px;
    overflow: hidden;
    background: #fff;
}
.review-header {
    padding: 17px 20px;
    background: #edf5ff;
}
.review-header strong,
.review-header span { display: block; }
.review-header strong { font-size: 18px; color: var(--primary-dark); }
.review-header span { margin-top: 3px; color: var(--muted); }
.review-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}
.review-columns > div { padding: 18px; border-left: 1px solid var(--line); }
.review-columns > div:first-child { border-left: 0; }
.review-columns h4 { margin: 0 0 10px; }
.review-columns ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.review-columns li { display: grid; gap: 2px; }
.review-columns li span { color: var(--muted); font-size: 13px; }
.sticky-save-bar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin: 24px -24px 0;
    padding: 16px 24px;
    border-top: 1px solid #cbd8e8;
    background: rgba(255,255,255,.96);
    backdrop-filter: blur(8px);
}
.sticky-save-bar strong,
.sticky-save-bar span { display: block; }
.sticky-save-bar span { margin-top: 2px; color: var(--muted); font-size: 13px; }
.subject-lifecycle-actions { display: flex; flex-wrap: wrap; gap: 10px; padding: 18px 0 4px; }
.status-chip.published { background: #e8f7ed; color: #176b37; }
.validation-summary:empty { display: none; }
.validation-summary ul { margin: 0 0 18px; }
.full-width { grid-column: 1 / -1; }

@media (max-width: 1250px) {
    .context-selector { grid-template-columns: repeat(2, minmax(180px, 1fr)); }
    .component-grid { grid-template-columns: repeat(2, minmax(220px, 1fr)); }
}
@media (max-width: 850px) {
    .subject-master-intro,
    .editor-step-title.with-action,
    .sticky-save-bar { flex-direction: column; align-items: stretch; }
    .context-selector { grid-template-columns: 1fr; }
    .editor-step-title.with-action > .button,
    .editor-step-title.with-action > .inline-actions { margin-left: 0; }
    .component-grid,
    .review-columns,
    .checkbox-grid { grid-template-columns: 1fr; }
    .review-columns > div { border-left: 0; border-top: 1px solid var(--line); }
    .review-columns > div:first-child { border-top: 0; }
    .subject-total-panel { grid-template-columns: 1fr; }
    .sticky-save-bar { position: static; margin: 20px 0 0; padding: 16px 0 0; }
}
.form-field { display: block; }
.field-label { display: block; margin-bottom: 7px; font-weight: 700; }
.weight-editor { margin-top: 14px; }
.weight-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.weight-grid label { margin: 0; }

/* V13 simplified clerk-facing Subject Master */
.compact-help { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: baseline; }
.compact-help a { margin-left: auto; font-weight: 700; }
.assessment-grid-head {
    display: grid;
    grid-template-columns: 1.35fr 1.1fr .62fr .82fr .62fr auto;
    gap: 10px;
    padding: 0 14px 8px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
}
.compact-component-editor { gap: 10px; }
.compact-assessment-row {
    display: grid;
    grid-template-columns: 1.35fr 1.1fr .62fr .82fr .62fr auto;
    gap: 10px;
    align-items: end;
    padding: 14px;
    border: 1px solid #cbd8e8;
    border-radius: 14px;
    background: #fff;
}
.compact-assessment-row > label { margin: 0; }
.compact-assessment-row input,
.compact-assessment-row select { min-height: 45px; }
.assessment-row-actions { align-self: center; white-space: nowrap; }
.assessment-more-options {
    grid-column: 1 / -1;
    border-top: 1px dashed #cbd8e8;
    padding-top: 10px;
}
.assessment-more-options summary { cursor: pointer; color: var(--primary); font-weight: 700; }
.assessment-more-options > div { margin-top: 12px; }
.mobile-field-label { display: none; }
.display-mode-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}
.display-mode-option {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    margin: 0;
    padding: 15px;
    border: 1px solid #cbd8e8;
    border-radius: 14px;
    background: #fff;
    cursor: pointer;
}
.display-mode-option:has(input:checked) {
    border-color: var(--primary);
    background: #eef5ff;
    box-shadow: 0 0 0 1px var(--primary) inset;
}
.display-mode-option input { width: auto; margin-top: 3px; }
.display-mode-option span { display: grid; gap: 4px; }
.display-mode-option strong { color: var(--primary-dark); }
.display-mode-option small { color: var(--muted); line-height: 1.35; }
.display-mode-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 7px 12px;
    margin-top: 13px;
    padding: 13px 15px;
    border-radius: 12px;
    background: #f4f8fd;
    color: var(--muted);
}
.display-mode-preview strong { color: var(--primary-dark); }
.special-display-layout { margin-top: 16px; }
.compact-heading { margin-bottom: 12px; }
.compact-heading h4 { margin: 0; font-size: 17px; }
.scheme-label-card { margin-bottom: 20px; }
.scheme-label-grid input { min-height: 44px; }

@media (max-width: 1250px) {
    .assessment-grid-head { display: none; }
    .compact-assessment-row { grid-template-columns: repeat(2, minmax(220px, 1fr)); align-items: end; }
    .mobile-field-label { display: block; margin-bottom: 7px; font-weight: 700; }
    .assessment-row-actions { justify-self: start; }
    .display-mode-options { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
    .compact-assessment-row { grid-template-columns: 1fr; }
    .assessment-more-options { grid-column: 1; }
    .compact-help a { margin-left: 0; width: 100%; }
}

.special-display-layout > summary {
    cursor: pointer;
    font-weight: 700;
    padding: .9rem 1rem;
    border: 1px solid var(--line);
    border-radius: .8rem;
    background: var(--soft);
}

.special-display-layout[open] > summary {
    margin-bottom: 1rem;
}

.special-display-content {
    padding-top: .25rem;
}

/* Published subject / editable working-copy lifecycle */
.subject-status-stack { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; }
.status-chip.draft-changes { background: #fff4d6; color: #805500; }
.working-copy-notice { margin: 0 0 18px; padding: 13px 15px; border: 1px solid #efd58d; border-radius: 10px; background: #fffaf0; color: #5e480d; }

/* Subject versioning: keep the unpublished editable copy visually distinct from
   the active published subject. */
.editable-copy-table-row td {
    background: #fffaf0;
    border-top: 1px dashed #e0bd64;
}
.editable-copy-table-row td:first-child {
    box-shadow: inset 4px 0 0 #d99b20;
}

/* Scheme of Examination · grade tables */
.grade-scheme-selection-card { margin-top: 18px; }
.grade-scheme-picker {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 20px;
}
.grade-scheme-picker label { margin: 0; }
.grade-scheme-list-wrap { border: 1px solid var(--line); border-radius: 14px; }
.grade-scheme-list-wrap table { min-width: 760px; }
.grade-table-purpose-guide {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin: 0 0 22px;
}
.grade-table-purpose-guide article {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 16px;
    border: 1px solid #d9e4ef;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 8px 24px rgba(18, 52, 86, .05);
}
.grade-table-purpose-guide strong { display: block; margin-bottom: 5px; color: var(--ink); }
.grade-table-purpose-guide p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.grade-table-purpose-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 30px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
}
.scheme-context-change { display: flex; align-items: center; justify-content: flex-end; }
.scheme-context-card {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
    gap: 14px;
    margin-bottom: 22px;
    padding: 18px 20px;
    border: 1px solid #d7e4f3;
    border-radius: 16px;
    background: linear-gradient(180deg, #f8fbff 0%, #f1f7fd 100%);
}
.scheme-context-card div { min-width: 0; }
.scheme-context-card span,
.scheme-context-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}
.scheme-context-card strong { display: block; margin: 4px 0; }
.grade-table-heading { align-items: flex-start; }
.grade-table-list-card .inline-actions form { margin: 0; }
.grade-table-empty {
    display: grid;
    gap: 7px;
    padding: 24px;
    border: 1px dashed #b9c9dc;
    border-radius: 14px;
    background: #f8fbff;
    color: var(--muted);
}
.grade-table-empty strong { color: var(--ink); }
.grade-default-tag { margin-left: 8px; background: #fff3d8; color: #72500d; }
.tiny-note { margin-top: 5px; font-size: 11px; }
.grade-table-actions { min-width: 190px; }
.danger-link { color: var(--danger) !important; }
.grade-table-editor-card { margin-top: 22px; }
.grade-table-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 16px 0 20px;
}
.grade-table-summary-grid div {
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--soft);
}
.grade-table-summary-grid span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.grade-table-main-fields { align-items: end; }
.grade-default-checkbox { align-self: stretch; display: flex !important; grid-template-columns: auto 1fr; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 16px; background: #fafcff; }
.grade-default-checkbox input { width: auto; }
.grade-band-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin: 20px 0 10px;
}
.grade-band-heading h3 { margin: 0 0 4px; }
.grade-band-heading p { margin: 0; }
.grade-band-table-wrap { border: 1px solid var(--line); border-radius: 14px; }
.grade-band-table { min-width: 1180px; }
.grade-band-table th { white-space: nowrap; font-size: 12px; }
.grade-band-table td { padding: 8px; vertical-align: middle; }
.grade-band-table input,
.grade-band-table select { min-width: 82px; padding: 8px 9px; border-radius: 9px; }
.grade-band-table td:nth-child(4) input { min-width: 135px; }
.grade-band-table td:nth-child(8) input,
.grade-band-table td:nth-child(9) input { min-width: 145px; }
.grade-credit-cell { text-align: center; }
.grade-credit-cell input[type="checkbox"] { width: auto; min-width: 0; }
.remove-grade-band {
    width: 30px;
    height: 30px;
    border: 1px solid #f0c4c4;
    border-radius: 50%;
    background: #fff4f4;
    color: var(--danger);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.grade-column-hidden { display: none; }
.classification-emphasis { background: #fff9ed; }
.grade-table-more-options { margin-top: 16px; }
.grade-table-validation-note {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 16px 0;
    padding: 12px 14px;
    border: 1px solid #cfe0f1;
    border-radius: 12px;
    background: #f5faff;
    color: var(--muted);
    font-size: 13px;
}
.grade-table-validation-note strong { color: var(--primary-dark); }
.grade-band-readonly-wrap { border: 1px solid var(--line); border-radius: 14px; }
.grade-band-readonly { min-width: 850px; }

@media (max-width: 900px) {
    .scheme-context-card,
    .grade-table-summary-grid,
    .grade-table-purpose-guide { grid-template-columns: 1fr 1fr; }
    .grade-scheme-picker { grid-template-columns: 1fr; }
    .grade-table-heading,
    .grade-band-heading { display: grid; }
}

@media (max-width: 620px) {
    .scheme-context-card,
    .grade-table-summary-grid,
    .grade-table-purpose-guide { grid-template-columns: 1fr; }
    .scheme-context-change { justify-content: flex-start; }
}

/* Examinis Core / Nidhi unified operator workspace */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.nidhi-topbar-control {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 6px 13px 6px 8px;
    border: 1px solid #cddcf0;
    border-radius: 14px;
    color: var(--primary-dark);
    background: linear-gradient(135deg, #f7fbff 0%, #eef5ff 56%, #fff8ec 100%);
    box-shadow: 0 7px 18px rgba(24, 62, 122, .08);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.nidhi-topbar-control:hover {
    text-decoration: none;
    transform: translateY(-1px);
    border-color: #9eb7d7;
    box-shadow: 0 10px 24px rgba(24, 62, 122, .14);
}
.nidhi-topbar-control.active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(229, 170, 72, .14);
}
.nidhi-topbar-mark {
    width: 36px;
    height: 36px;
    display: block;
    flex: 0 0 auto;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(14, 44, 88, .10);
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.65);
}
.nidhi-topbar-mark img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.nidhi-topbar-copy { display: grid; gap: 1px; line-height: 1.05; }
.nidhi-topbar-copy strong { font-size: 14px; letter-spacing: .01em; }
.nidhi-topbar-copy small { color: #61728a; font-size: 9px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }

.nidhi-workspace {
    display: grid;
    gap: 18px;
    width: 100%;
}
.nidhi-workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 24px;
    border: 1px solid #d4dfed;
    border-radius: 22px;
    background:
        radial-gradient(circle at 92% 10%, rgba(229, 170, 72, .18), transparent 29%),
        linear-gradient(135deg, #ffffff 0%, #f5f9ff 60%, #fffaf0 100%);
    box-shadow: 0 12px 36px rgba(15, 36, 56, .06);
}
.nidhi-identity-block {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 18px;
}
.nidhi-agent-emblem {
    width: 88px;
    height: 88px;
    display: block;
    flex: 0 0 auto;
    border-radius: 26px;
    background: #fff;
    box-shadow: 0 14px 28px rgba(15, 52, 101, .12);
    overflow: hidden;
}
.nidhi-agent-emblem img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.nidhi-overline {
    display: block;
    margin-bottom: 3px;
    color: #59718f;
    font-size: 11px;
    font-weight: 850;
    letter-spacing: .1em;
    text-transform: uppercase;
}
.nidhi-identity-block h1 {
    margin: 0;
    color: var(--primary-dark);
    font-size: clamp(30px, 4vw, 42px);
    line-height: 1;
    letter-spacing: -.04em;
}
.nidhi-identity-block p {
    max-width: 720px;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.5;
}
.nidhi-brand-lockup {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 14px;
    padding: 10px 12px;
    border: 1px solid #d6e2ef;
    border-radius: 16px;
    background: rgba(255,255,255,.88);
}
.nidhi-brand-lockup img {
    height: 42px;
    width: auto;
    display: block;
}
.nidhi-brand-lockup span {
    color: #526a84;
    font-size: 11px;
    font-weight: 750;
}
.nidhi-mode-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(170px, 1fr));
    gap: 8px;
    flex: 0 0 auto;
    padding: 6px;
    border: 1px solid #d7e1ee;
    border-radius: 18px;
    background: rgba(255,255,255,.88);
}
.nidhi-mode-option {
    position: relative;
    display: grid;
    grid-template-columns: 34px 1fr;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 62px;
    padding: 9px 10px;
    border: 1px solid transparent;
    border-radius: 13px;
    background: transparent;
    color: var(--ink);
    text-align: left;
    cursor: pointer;
}
.nidhi-mode-option:hover { background: #f4f7fb; }
.nidhi-mode-option.selected {
    border-color: #a8c0df;
    background: linear-gradient(135deg, #edf5ff, #fff);
    box-shadow: 0 7px 18px rgba(24, 62, 122, .08);
}
.nidhi-mode-option[data-mode="Play"].selected {
    border-color: #e6c47d;
    background: linear-gradient(135deg, #fff8e9, #fff);
}
.nidhi-mode-option .mode-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 11px;
    background: #e8f1fc;
    color: var(--primary);
    font-size: 15px;
}
.nidhi-mode-option[data-mode="Play"] .mode-icon { background: #fff1d2; color: #825800; }
.nidhi-mode-option > span:nth-child(2) { min-width: 0; display: grid; gap: 2px; }
.nidhi-mode-option strong { font-size: 14px; }
.nidhi-mode-option small { color: var(--muted); font-size: 10px; font-weight: 650; }
.mode-default,
.play-allowance {
    position: absolute;
    top: 5px;
    right: 7px;
    color: #526983;
    font-size: 8px;
    font-weight: 850;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.play-allowance { color: #855c08; }

.nidhi-context-strip {
    display: grid;
    grid-template-columns: 1.15fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 11px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255,255,255,.86);
}
.nidhi-context-strip > div { min-width: 0; padding: 2px 10px; border-right: 1px solid var(--line); }
.nidhi-context-strip span { display: block; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em; }
.nidhi-context-strip strong { display: block; overflow: hidden; margin-top: 3px; color: var(--ink); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.nidhi-workspace-grid {
    display: grid;
    grid-template-columns: minmax(360px, .92fr) minmax(480px, 1.35fr);
    gap: 18px;
    min-height: 650px;
}
.nidhi-conversation-card,
.nidhi-work-card {
    min-width: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 10px 32px rgba(15,36,56,.055);
    overflow: hidden;
}
.nidhi-panel-heading {
    min-height: 74px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fff, #fafcff);
}
.nidhi-panel-kicker {
    display: block;
    margin-bottom: 2px;
    color: #6f8297;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .09em;
    text-transform: uppercase;
}
.nidhi-panel-heading h2 { margin: 0; font-size: 18px; color: var(--primary-dark); }
.nidhi-connection-status {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 9px;
    border-radius: 999px;
    background: #edf8f1;
    color: #266544;
    font-size: 10px;
    font-weight: 800;
    white-space: nowrap;
}
.nidhi-connection-status i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #37a366;
    box-shadow: 0 0 0 4px rgba(55,163,102,.13);
}
.nidhi-mode-badge {
    display: inline-flex;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .08em;
}
.nidhi-mode-badge.fast { color: #174f88; background: #e9f3ff; }
.nidhi-mode-badge.play { color: #805707; background: #fff2d7; }

.nidhi-message-list {
    flex: 1 1 auto;
    min-height: 320px;
    max-height: 510px;
    overflow-y: auto;
    display: grid;
    align-content: start;
    gap: 15px;
    padding: 18px;
    background:
        linear-gradient(rgba(247,250,253,.72), rgba(247,250,253,.72)),
        radial-gradient(circle at 100% 0, rgba(35, 93, 157, .06), transparent 34%);
}
.nidhi-message {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    max-width: 92%;
}
.nidhi-message.user-message { justify-self: end; flex-direction: row; }
.nidhi-message-avatar {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 10px;
    background: linear-gradient(145deg, #12345f, #2b6da9);
    color: #fff;
    font-size: 12px;
    font-weight: 900;
    overflow: hidden;
}
.nidhi-message-avatar img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}
.user-message .nidhi-message-avatar { background: #e7edf5; color: #24415f; }
.nidhi-message-content {
    min-width: 0;
    padding: 11px 13px;
    border: 1px solid #d8e4f1;
    border-radius: 6px 15px 15px 15px;
    background: #fff;
    box-shadow: 0 5px 14px rgba(15,36,56,.04);
}
.user-message .nidhi-message-content {
    border-color: #c6d8ec;
    border-radius: 15px 6px 15px 15px;
    background: #eef5fd;
}
.message-error .nidhi-message-content { border-color: #efc5c5; background: #fff5f5; }
.nidhi-message-meta { display: flex; align-items: baseline; gap: 7px; margin-bottom: 5px; }
.nidhi-message-meta strong { font-size: 11px; }
.nidhi-message-meta span { color: var(--muted); font-size: 9px; }
.nidhi-message-content p { margin: 0; color: #26394d; font-size: 13px; line-height: 1.52; white-space: pre-wrap; }
.nidhi-thinking::after { content: ""; display: inline-block; width: 16px; height: 5px; margin-left: 8px; border-radius: 99px; background: linear-gradient(90deg, #8ba6c7 30%, transparent 30% 40%, #8ba6c7 40% 70%, transparent 70% 80%, #8ba6c7 80%); animation: nidhiThinking 1s infinite alternate; }
@keyframes nidhiThinking { from { opacity: .35; } to { opacity: 1; } }
.nidhi-system-notice {
    justify-self: center;
    max-width: 94%;
    padding: 8px 11px;
    border: 1px dashed #c7d4e3;
    border-radius: 12px;
    background: rgba(255,255,255,.8);
    color: #61738a;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
}

.nidhi-quick-actions {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-top: 1px solid var(--line);
    background: #fbfcfe;
}
.nidhi-quick-actions button {
    padding: 7px 9px;
    border: 1px solid #d6e1ed;
    border-radius: 999px;
    background: #fff;
    color: #355472;
    font: inherit;
    font-size: 10px;
    font-weight: 750;
    cursor: pointer;
}
.nidhi-quick-actions button:hover { border-color: #9db5d0; background: #f3f8fe; }
.nidhi-composer {
    padding: 13px;
    border-top: 1px solid var(--line);
    background: #fff;
}
.nidhi-composer textarea {
    min-height: 84px;
    border-color: #cbd9e8;
    border-radius: 15px;
    background: #fbfdff;
    line-height: 1.45;
}
.nidhi-composer textarea:focus { outline: 3px solid rgba(36, 94, 157, .12); border-color: #7199c5; }
.nidhi-composer-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 9px;
}
.nidhi-attachment-wrap { min-width: 0; display: flex; align-items: center; gap: 8px; }
.nidhi-attachment-button {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 7px 10px;
    border: 1px solid #d5e0eb;
    border-radius: 10px;
    background: #fff;
    color: #3c5875;
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}
.nidhi-attachment-button:hover { background: #f5f9fd; }
#nidhi-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.nidhi-file-name { max-width: 190px; overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.nidhi-send-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px;
    border: 0;
    border-radius: 11px;
    background: linear-gradient(135deg, #123b70, #245f9e);
    color: #fff;
    font: inherit;
    font-size: 11px;
    font-weight: 850;
    cursor: pointer;
    box-shadow: 0 7px 16px rgba(24, 62, 122, .18);
}
.nidhi-send-button:hover { filter: brightness(1.04); }
.nidhi-send-button:disabled { opacity: .55; cursor: wait; }

.nidhi-fast-workspace,
.nidhi-play-workspace {
    flex: 1 1 auto;
    padding: 18px;
}
.nidhi-work-hero {
    display: flex;
    align-items: flex-start;
    gap: 13px;
    padding: 15px;
    border: 1px solid #cfe0f3;
    border-radius: 16px;
    background: linear-gradient(135deg, #edf6ff, #f9fcff);
}
.nidhi-work-symbol {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 12px;
    background: #1e5591;
    color: #fff;
}
.nidhi-work-hero strong { display: block; font-size: 14px; color: #183d67; }
.nidhi-work-hero p { margin: 5px 0 0; color: #5b7188; font-size: 11px; line-height: 1.5; }
.nidhi-operation-state {
    position: relative;
    margin-top: 15px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}
.nidhi-operation-state::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: #9fb1c5;
}
.nidhi-operation-state[data-state="working"]::before { background: var(--accent); }
.nidhi-operation-state[data-state="ready"]::before,
.nidhi-operation-state[data-state="complete"]::before { background: #3d9d67; }
.nidhi-operation-state[data-state="error"]::before { background: var(--danger); }
.operation-state-label { display: block; color: var(--muted); font-size: 9px; font-weight: 850; text-transform: uppercase; letter-spacing: .08em; }
.nidhi-operation-state strong { display: block; margin-top: 5px; font-size: 17px; color: var(--primary-dark); }
.nidhi-operation-state p { margin: 6px 0 0; color: var(--muted); font-size: 11px; }
.nidhi-evidence-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px;
    margin-top: 12px;
}
.nidhi-evidence-grid:empty { display: none; }
.nidhi-evidence-grid > div {
    min-width: 0;
    padding: 11px;
    border: 1px solid #dce5ef;
    border-radius: 13px;
    background: #f8fafc;
}
.nidhi-evidence-grid span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; }
.nidhi-evidence-grid strong { display: block; overflow-wrap: anywhere; margin-top: 4px; color: #263d55; font-size: 12px; }
.nidhi-foundation-note {
    margin-top: 15px;
    padding: 14px 15px;
    border: 1px dashed #d5c28f;
    border-radius: 15px;
    background: #fffbf1;
}
.nidhi-foundation-note strong { color: #73510e; font-size: 12px; }
.nidhi-foundation-note p { margin: 5px 0 0; color: #7d6a43; font-size: 10px; line-height: 1.48; }

.nidhi-play-workspace { display: flex; flex-direction: column; gap: 12px; }
.nidhi-play-workspace[hidden] { display: none; }
.nidhi-play-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e2d2aa;
    border-radius: 14px;
    background: #fffaf0;
}
.nidhi-play-toolbar > div:first-child { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
.nidhi-play-toolbar strong { font-size: 12px; }
.nidhi-play-toolbar small { grid-column: 2; color: #806f4c; font-size: 9px; }
.play-status-dot { width: 8px; height: 8px; grid-row: 1 / span 2; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(229,170,72,.17); }
.play-controls { display: flex; gap: 6px; }
.play-controls button,
.play-controls a {
    padding: 6px 8px;
    border: 1px solid #d9c99e;
    border-radius: 8px;
    background: #fff;
    color: #6f531d;
    font: inherit;
    font-size: 9px;
    font-weight: 800;
}
.play-controls a:hover { text-decoration: none; background: #fff5df; }
.play-controls button:disabled { opacity: .45; }
.nidhi-play-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 525px;
    border: 1px solid #cfd9e5;
    border-radius: 16px;
    background: #edf2f7;
    overflow: hidden;
}
.nidhi-play-stage iframe { width: 100%; height: 100%; min-height: 525px; border: 0; background: #fff; }
.nidhi-play-overlay-note {
    position: absolute;
    right: 13px;
    bottom: 13px;
    left: 13px;
    display: grid;
    gap: 3px;
    padding: 10px 12px;
    border: 1px solid rgba(229,170,72,.7);
    border-radius: 12px;
    background: rgba(255,250,237,.94);
    box-shadow: 0 8px 22px rgba(67,50,14,.12);
    backdrop-filter: blur(8px);
}
.nidhi-play-overlay-note strong { color: #6f4e0e; font-size: 11px; }
.nidhi-play-overlay-note span { color: #786947; font-size: 9px; line-height: 1.4; }

@media (max-width: 1360px) {
    .nidhi-topbar-copy small { display: none; }
    .nidhi-topbar-control { padding-right: 10px; }
    .nidhi-workspace-grid { grid-template-columns: minmax(330px, .88fr) minmax(430px, 1.12fr); }
}
@media (max-width: 1180px) {
    .topbar-right { gap: 9px; }
    .nidhi-topbar-copy { display: none; }
    .nidhi-topbar-control { padding: 5px; border-radius: 12px; }
    .nidhi-workspace-header { align-items: stretch; flex-direction: column; }
    .nidhi-mode-control { width: 100%; }
}
@media (max-width: 980px) {
    .nidhi-workspace-grid { grid-template-columns: 1fr; }
    .nidhi-context-strip { grid-template-columns: 1fr 1fr; }
    .nidhi-context-strip > div { border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
    .nidhi-message-list { max-height: 440px; }
}
@media (max-width: 720px) {
    .nidhi-topbar-control { order: -1; }
    .nidhi-topbar-mark { width: 32px; height: 32px; }
    .nidhi-workspace-header { padding: 17px; border-radius: 18px; }
    .nidhi-identity-block { align-items: flex-start; gap: 12px; }
    .nidhi-agent-emblem { width: 64px; height: 64px; border-radius: 20px; }
    .nidhi-brand-lockup { display: grid; justify-items: start; gap: 7px; }
    .nidhi-brand-lockup img { height: 34px; }
    .nidhi-identity-block p { font-size: 12px; }
    .nidhi-mode-control { grid-template-columns: 1fr; }
    .nidhi-context-strip { grid-template-columns: 1fr; }
    .nidhi-workspace-grid { min-height: 0; }
    .nidhi-message-list { min-height: 300px; }
    .nidhi-composer-actions,
    .nidhi-play-toolbar { align-items: stretch; flex-direction: column; }
    .nidhi-attachment-wrap { flex-wrap: wrap; }
    .nidhi-send-button { justify-content: center; }
    .nidhi-evidence-grid { grid-template-columns: 1fr 1fr; }
    .play-controls { width: 100%; }
    .play-controls > * { flex: 1; text-align: center; }
}
@media (max-width: 480px) {
    .nidhi-evidence-grid { grid-template-columns: 1fr; }
    .nidhi-context-strip { padding: 10px; }
    .nidhi-panel-heading { min-height: 66px; padding: 13px; }
    .nidhi-fast-workspace,
    .nidhi-play-workspace,
    .nidhi-message-list { padding: 13px; }
}

/* Legacy academic master mapping */
.legacy-upload-card,
.legacy-batch-selector,
.legacy-mapping-section,
.legacy-safety-note {
    margin-top: 1rem;
}

.legacy-upload-form,
.legacy-inline-picker,
.legacy-mapping-toolbar,
.legacy-decision-buttons {
    display: flex;
    align-items: end;
    gap: .75rem;
    flex-wrap: wrap;
}

.legacy-upload-form label,
.legacy-inline-picker label {
    flex: 1 1 360px;
}

.legacy-upload-form input[type="file"] {
    min-height: 46px;
    padding: .55rem;
    background: #fff;
}

.legacy-mapping-summary {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .8rem;
    margin: 1rem 0;
}

.legacy-mapping-summary article {
    border: 1px solid var(--border, #d9e0ea);
    border-radius: 14px;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 8px 24px rgba(20, 47, 82, .06);
}

.legacy-mapping-summary span,
.legacy-mapping-summary small {
    display: block;
    color: var(--muted, #667085);
}

.legacy-mapping-summary strong {
    display: block;
    margin: .25rem 0;
    color: #17345a;
    font-size: 1.08rem;
}

.legacy-mapping-toolbar {
    margin: .9rem 0 1rem;
}

.legacy-mapping-section {
    border: 1px solid var(--border, #d9e0ea);
    border-radius: 16px;
    background: #fff;
    padding: 1rem;
    box-shadow: 0 12px 30px rgba(20, 47, 82, .06);
}

.legacy-mapping-table-wrap {
    max-height: 68vh;
    overflow: auto;
    border: 1px solid #e3e8ef;
    border-radius: 12px;
}

.legacy-mapping-table {
    min-width: 1180px;
}

.legacy-mapping-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #17345a;
    color: #fff;
}

.legacy-mapping-table td {
    vertical-align: top;
    min-width: 210px;
}

.legacy-mapping-table td:nth-child(4) {
    min-width: 330px;
}

.legacy-mapping-table td strong,
.legacy-mapping-table td span,
.legacy-mapping-table td small {
    display: block;
}

.legacy-mapping-table td small {
    margin-top: .2rem;
    color: var(--muted, #667085);
}

.mapping-reason {
    margin-top: .5rem !important;
    padding: .45rem .55rem;
    border-radius: 8px;
    background: #f5f8fc;
    color: #3b536f !important;
}

.confirmed-target {
    color: #14633a;
}

.mapping-status {
    display: inline-flex !important;
    align-items: center;
    width: fit-content;
    margin-bottom: .55rem;
    padding: .25rem .55rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

.mapping-status.confirmed { background: #e7f7ee; color: #14633a; }
.mapping-status.excluded { background: #f3f4f6; color: #4b5563; }
.mapping-status.suggested { background: #e8f1ff; color: #174ea6; }
.mapping-status.review { background: #fff4db; color: #8a5700; }
.mapping-status.unmapped { background: #fdecec; color: #a12b2b; }

.legacy-row-decision {
    display: grid;
    gap: .45rem;
}

.legacy-row-decision select,
.legacy-row-decision input[type="text"] {
    width: 100%;
    min-width: 290px;
}

.legacy-decision-buttons {
    gap: .4rem;
}

.button.danger-outline {
    border-color: #bd3838;
    color: #9f2727;
    background: #fff;
}

.button.danger-outline:hover {
    background: #fff0f0;
}

.legacy-selected-target {
    margin: .75rem 0;
    padding: .7rem .85rem;
    border-left: 4px solid #eb7d22;
    background: #fff8ef;
    border-radius: 8px;
}

.legacy-safety-note {
    padding: 1rem 1.1rem;
    border: 1px solid #f1c994;
    border-radius: 14px;
    background: #fff8ef;
}

.legacy-safety-note h3 {
    margin: 0 0 .35rem;
    color: #17345a;
}

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

@media (max-width: 1050px) {
    .legacy-mapping-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 640px) {
    .legacy-mapping-summary { grid-template-columns: 1fr; }
    .legacy-upload-form,
    .legacy-inline-picker,
    .legacy-mapping-toolbar { align-items: stretch; }
    .legacy-upload-form .button,
    .legacy-mapping-toolbar .button { width: 100%; }
}
