:root {
    color-scheme: light;
    --bg: #f6f7f4;
    --panel: rgba(255, 255, 255, 0.96);
    --panel-subtle: #f2f5ef;
    --border: #d6ddd3;
    --text: #20312a;
    --muted: #5f7268;
    --heading: #15211b;
    --accent: #21654f;
    --accent-strong: #184a3a;
    --danger: #c8574d;
    --success: #21654f;
    --warning: #b37b22;
    --shadow: 0 18px 44px rgba(21, 33, 27, 0.08);
    --radius: 18px;
    --radius-sm: 12px;
    --matrix-name-width: 188px;
    --matrix-coverage-width: 94px;
    --matrix-skill-width: 72px;
    --heatmap-name-width: 184px;
    --heatmap-skill-width: 46px;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(33, 101, 79, 0.1), transparent 28%),
        radial-gradient(circle at right center, rgba(177, 190, 178, 0.18), transparent 22%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", "Helvetica Neue", sans-serif;
}

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

img {
    max-width: 100%;
    display: block;
}

code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
}

.auth-shell,
.portal-shell {
    min-height: 100vh;
}

.auth-wrap,
.portal-layout {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 56px;
}

.auth-wrap {
    display: grid;
    place-items: center;
    min-height: 100vh;
}

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

.auth-panel {
    width: min(560px, 100%);
    padding: 32px;
}

.auth-panel-wide {
    width: min(640px, 100%);
}

.auth-copy h1,
.portal-card h2,
.operator-hero h1 {
    margin: 8px 0 10px;
    font-size: clamp(1.9rem, 4vw, 2.6rem);
    line-height: 1.1;
    color: var(--heading);
}

.shell-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

.shell-main {
    min-width: 0;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 28px 20px;
    background: linear-gradient(180deg, #ebf1ea 0%, #dfe8de 100%);
    color: #20312a;
    border-right: 1px solid #cfd8ce;
}

.brand,
.sidebar-user,
.panel-header,
.panel-actions,
.topbar,
.portal-header,
.operator-hero,
.meta-row,
.bar-meta,
.restore-row,
.table-form,
.inline-form,
.question-card-head,
.choice-item,
.answer-option,
.nav-link,
.bar-row {
    display: flex;
    align-items: center;
}

.brand {
    gap: 14px;
    margin-bottom: 28px;
}

.brand-mark,
.avatar {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2ca377, #113c2e);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.brand-mark-image {
    overflow: hidden;
    background: rgba(255, 255, 255, 0.9);
}

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

.brand h1,
.portal-header h1,
.topbar h2,
.panel h3,
.panel h4 {
    margin: 0;
    color: var(--heading);
}

.sidebar h1,
.sidebar strong,
.sidebar p,
.sidebar a {
    color: inherit;
}

.brand-eyebrow,
.brand-subtitle,
.stat-label,
.eyebrow,
.muted,
.question-image-note {
    margin: 0;
    color: var(--muted);
}

.eyebrow,
.brand-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 700;
}

.sidebar-user {
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.68);
    border-radius: 16px;
    margin-bottom: 24px;
}

.nav {
    display: grid;
    gap: 8px;
}

.nav-link {
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: 14px;
    color: rgba(32, 49, 42, 0.86);
}

.nav-link.active,
.nav-link:hover {
    background: rgba(33, 101, 79, 0.12);
    color: var(--heading);
}

.sidebar-logout {
    margin-top: 24px;
}

.page-content,
.portal-content {
    width: min(1960px, calc(100% - 8px));
    margin: 0 auto;
    padding-bottom: 56px;
}

.page-content-workbook {
    width: calc(100% - 4px);
    padding-bottom: 28px;
}

.page-content-workbook > * + * {
    margin-top: 8px;
}

.topbar,
.portal-header,
.operator-hero,
.panel-header,
.panel-actions,
.bar-meta,
.restore-row,
.table-form,
.inline-form,
.question-card-head,
.choice-item,
.answer-option,
.bar-row {
    justify-content: space-between;
    gap: 16px;
}

.topbar,
.portal-header {
    padding: 10px 6px 8px;
}

.topbar h2 {
    font-size: 1.32rem;
}

.topbar .eyebrow {
    font-size: 0.66rem;
}

.topbar .button {
    padding: 9px 14px;
    font-size: 0.84rem;
}

.portal-header-actions,
.button-group,
.topbar-actions,
.panel-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.license-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.license-badge-valid,
.license-status-valid {
    background: rgba(31, 122, 92, 0.12);
    color: var(--success);
}

.license-badge-expired,
.license-badge-missing,
.license-status-expired,
.license-status-missing {
    background: rgba(208, 151, 45, 0.16);
    color: #8d6115;
}

.license-badge-invalid,
.license-status-invalid {
    background: rgba(193, 75, 68, 0.12);
    color: var(--danger);
}

.page-content > * + *,
.portal-content > * + *,
.stack-sm > * + *,
.stack-md > * + *,
.stack-lg > * + *,
.stack-xl > * + * {
    margin-top: 20px;
}

.grid-cards {
    display: grid;
    gap: 20px;
}

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

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

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

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

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

.two-col-wide {
    grid-template-columns: 0.9fr 1.1fr;
}

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

.panel,
.stat-card,
.portal-card {
    padding: 22px;
}

.panel-subtle {
    background: var(--panel-subtle);
}

.panel-card {
    display: grid;
    gap: 16px;
}

.stat-value {
    display: block;
    margin-top: 8px;
    font-size: 2rem;
    font-weight: 700;
    color: var(--heading);
}

.stat-value.compact {
    font-size: 1.35rem;
}

.card-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card-link,
.card-link-form {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--panel-subtle);
}

.link-arrow {
    color: var(--accent);
    font-weight: 700;
}

.button {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 11px 18px;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

.button:hover {
    transform: translateY(-1px);
}

.button-primary {
    background: var(--accent);
    color: #fff;
}

.button-primary:hover {
    background: var(--accent-strong);
}

.button-secondary,
.button-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.button-full {
    width: 100%;
}

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

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 0.9rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

textarea {
    resize: vertical;
}

select,
option {
    color: var(--text);
    background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(33, 101, 79, 0.18);
    border-color: rgba(33, 101, 79, 0.45);
}

.checkbox,
.choice-item {
    gap: 10px;
}

.checkbox input,
.choice-item input {
    width: auto;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.checkbox-offset {
    margin-top: 32px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.alert-success {
    background: rgba(31, 122, 92, 0.12);
    color: var(--success);
}

.alert-danger {
    background: rgba(193, 75, 68, 0.12);
    color: var(--danger);
}

.license-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding: 16px 18px;
    border-radius: 16px;
    border: 1px solid rgba(208, 151, 45, 0.24);
    background: linear-gradient(135deg, rgba(208, 151, 45, 0.12), rgba(193, 75, 68, 0.08));
}

.license-banner-copy {
    display: grid;
    gap: 6px;
    max-width: 900px;
}

.license-banner-copy p {
    margin: 0;
}

.license-popup {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 40;
    width: min(380px, calc(100vw - 40px));
}

.license-popup-card {
    display: grid;
    gap: 12px;
    padding: 18px;
    border-radius: 18px;
    border: 1px solid rgba(193, 75, 68, 0.18);
    background: rgba(255, 255, 255, 0.96);
    box-shadow: 0 18px 36px rgba(39, 51, 68, 0.14);
}

.license-summary-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.license-summary-card {
    min-width: 0;
    display: grid;
    gap: 8px;
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.72);
}

.license-summary-card strong {
    color: var(--heading);
}

.license-status-pill {
    font-weight: 700;
}

.license-token {
    display: block;
    max-width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: rgba(39, 51, 68, 0.06);
    color: var(--heading);
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.92rem;
    white-space: nowrap;
    overflow-x: auto;
}

.chip,
.pill,
.timer-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 999px;
    font-size: 0.9rem;
    border: 1px solid var(--border);
    background: var(--panel-subtle);
}

.pill-muted,
.pill-skill-0 {
    background: rgba(127, 145, 163, 0.12);
}

.pill-skill-1 {
    background: rgba(214, 96, 68, 0.18);
}

.pill-skill-2 {
    background: rgba(208, 151, 45, 0.2);
}

.pill-skill-3 {
    background: rgba(31, 122, 92, 0.18);
}

.pill-skill-4 {
    background: rgba(36, 111, 202, 0.18);
}

.pill-skill-5 {
    background: rgba(28, 92, 120, 0.2);
}

.pill-skill-6 {
    background: rgba(42, 113, 84, 0.22);
}

.pill-skill-7 {
    background: rgba(78, 103, 130, 0.24);
}

.pill-skill-8,
.pill-skill-9 {
    background: rgba(62, 88, 118, 0.24);
}

.pill-accent {
    background: rgba(31, 122, 92, 0.12);
}

.pill-success {
    background: rgba(31, 122, 92, 0.16);
}

.pill-danger {
    background: rgba(193, 75, 68, 0.16);
}

.table-wrap,
.matrix-table-wrap {
    overflow: auto;
}

.data-table,
.matrix-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

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

.data-table th,
.matrix-table th {
    color: var(--muted);
    font-size: 0.84rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.audit-panel {
    display: grid;
    gap: 20px;
}

.audit-panel-header {
    align-items: flex-end;
    gap: 24px;
}

.audit-meta {
    margin-top: 14px;
    gap: 10px;
}

.audit-search-form {
    align-items: flex-end;
    gap: 12px;
}

.audit-search-field {
    min-width: 240px;
}

.audit-table {
    min-width: 1160px;
}

.audit-table tbody tr {
    transition: background 140ms ease;
}

.audit-table tbody tr:hover {
    background: rgba(33, 101, 79, 0.035);
}

.audit-table td {
    padding-top: 18px;
    padding-bottom: 18px;
}

.audit-empty-state {
    color: var(--muted);
    font-size: 0.96rem;
}

.audit-when,
.audit-cell-stack {
    display: grid;
    gap: 6px;
}

.audit-when {
    min-width: 112px;
}

.audit-when strong,
.audit-cell-stack strong {
    color: var(--heading);
    font-size: 0.95rem;
    line-height: 1.35;
}

.audit-when span {
    color: var(--muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.audit-actor {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 168px;
}

.audit-avatar {
    width: 38px;
    height: 38px;
    border-radius: 13px;
    flex-shrink: 0;
    font-size: 0.82rem;
    letter-spacing: 0.06em;
}

.audit-label-pill {
    width: fit-content;
    max-width: 100%;
}

.audit-key,
.audit-entity-id {
    color: var(--muted);
    font-size: 0.76rem;
    line-height: 1.45;
    white-space: normal;
    word-break: break-word;
}

.audit-details {
    margin: 0;
    max-width: 760px;
    padding: 12px 14px;
    border: 1px solid rgba(127, 145, 163, 0.16);
    border-radius: 14px;
    background: linear-gradient(180deg, rgba(246, 247, 244, 0.92), rgba(237, 242, 238, 0.98));
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
}

.audit-details code {
    display: block;
    color: #31433b;
    font-size: 0.78rem;
    line-height: 1.6;
}

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

.matrix-table {
    min-width: 1180px;
}

.sticky-head {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f7faf6;
}

.sticky-col {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #ffffff;
    background-clip: padding-box;
}

.operator-cell {
    min-width: 180px;
}

.matrix-cell,
.heat-cell {
    display: grid;
    gap: 6px;
    width: 100%;
    min-width: 120px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid transparent;
    text-align: left;
    background: transparent;
    color: inherit;
}

.matrix-cell strong {
    font-size: 1.2rem;
}

.matrix-cell span,
.heat-cell {
    font-size: 0.8rem;
}

.skill-0 {
    background: rgba(127, 145, 163, 0.12);
}

.skill-1 {
    background: rgba(214, 96, 68, 0.18);
}

.skill-2 {
    background: rgba(208, 151, 45, 0.2);
}

.skill-3 {
    background: rgba(31, 122, 92, 0.18);
}

.skill-4 {
    background: rgba(36, 111, 202, 0.18);
}

.skill-5 {
    background: rgba(28, 92, 120, 0.2);
}

.skill-6 {
    background: rgba(42, 113, 84, 0.22);
}

.skill-7 {
    background: rgba(78, 103, 130, 0.24);
}

.skill-8,
.skill-9 {
    background: rgba(62, 88, 118, 0.24);
}

.legend,
.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.legend-item {
    display: inline-grid;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 14px;
}

.matrix-legend {
    gap: 8px;
}

.matrix-legend .legend-item {
    min-width: 118px;
    padding: 8px 10px;
}

.matrix-table-gap {
    height: 12px;
}

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

.timeline.compact {
    gap: 12px;
}

.timeline-tight {
    gap: 10px;
}

.timeline-tight .timeline-item {
    grid-template-columns: 12px 1fr;
    gap: 10px;
}

.timeline-tight .timeline-dot {
    width: 9px;
    height: 9px;
    margin-top: 5px;
    box-shadow: 0 0 0 4px rgba(31, 122, 92, 0.1);
}

.timeline-tight strong {
    font-size: 0.92rem;
}

.timeline-tight p,
.timeline-tight span,
.timeline-tight .muted {
    margin: 2px 0 0;
    font-size: 0.8rem;
    line-height: 1.45;
}

.timeline-compact {
    max-height: 560px;
    overflow: auto;
    padding-right: 4px;
}

.timeline-item {
    display: grid;
    grid-template-columns: 16px 1fr;
    gap: 14px;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 5px rgba(31, 122, 92, 0.12);
}

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

.bar-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    background: rgba(127, 145, 163, 0.12);
    overflow: hidden;
}

.bar-meta span {
    color: var(--muted);
    font-size: 0.82rem;
}

.bar-fill {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--accent), #57c49c);
}

.lead-text {
    font-size: 1.05rem;
    line-height: 1.7;
}

.pagination {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    padding-top: 18px;
}

.page-link {
    min-width: 38px;
    height: 38px;
    padding: 0 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    white-space: nowrap;
}

.page-link.is-nav {
    font-weight: 600;
}

.page-gap {
    min-width: 20px;
    text-align: center;
    color: var(--muted);
    font-weight: 700;
}

.page-link.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.modal {
    border: none;
    padding: 0;
    background: transparent;
}

.modal[open] {
    display: grid;
    place-items: center;
}

.modal::backdrop {
    background: rgba(9, 16, 24, 0.56);
}

.modal-card {
    width: min(620px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    overflow: auto;
    padding: 24px;
    display: grid;
    gap: 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

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

.question-card,
.answer-box {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 18px;
    background: var(--panel-subtle);
}

.answer-options,
.choice-list,
.operator-list {
    display: grid;
    gap: 10px;
}

.answer-option {
    border: 1px solid var(--border);
    padding: 12px 14px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
}

.answer-option.selected,
.choice-item {
    border-color: rgba(31, 122, 92, 0.28);
}

.choice-item {
    justify-content: flex-start;
    border: 1px solid var(--border);
    padding: 14px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
    cursor: pointer;
}

.choice-item span {
    flex: 1;
}

.choice-item:hover {
    border-color: rgba(33, 101, 79, 0.4);
    background: #fff;
}

.question-image {
    max-height: 220px;
    border-radius: 16px;
    margin: 12px 0;
    border: 1px solid var(--border);
}

.radar-chart {
    width: 100%;
    max-width: 420px;
    margin-inline: auto;
    display: block;
}

.radar-grid,
.radar-axis {
    fill: none;
    stroke: rgba(127, 145, 163, 0.28);
    stroke-width: 1;
}

.radar-shape {
    fill: rgba(31, 122, 92, 0.22);
    stroke: var(--accent);
    stroke-width: 3;
}

.radar-marker {
    fill: var(--accent-strong);
}

.radar-label {
    font-size: 12px;
    fill: var(--muted);
}

.radar-level-label {
    font-size: 11px;
    fill: var(--muted);
}

.clean-list {
    padding-left: 18px;
}

.operator-item,
.restore-row,
.table-form {
    gap: 10px;
}

.timer-chip {
    font-weight: 600;
}

.align-end {
    align-items: flex-end;
}

.workbook-wrap {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    position: relative;
}

.matrix-shell {
    padding: 12px 8px 14px;
}

.matrix-shell-compact {
    padding: 8px 4px 10px;
}

.matrix-shell .panel-header {
    align-items: flex-start;
    gap: 12px;
}

.matrix-shell .panel-header h3 {
    font-size: 1.55rem;
}

.matrix-shell .eyebrow {
    font-size: 0.66rem;
}

.matrix-shell .muted {
    font-size: 0.82rem;
}

.matrix-shell .button {
    padding: 7px 12px;
    font-size: 0.8rem;
}

.matrix-shell .matrix-table-wrap {
    height: calc(100vh - 228px);
    min-height: 600px;
    max-height: none;
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable both-edges;
}

.workbook-table {
    width: max-content;
    min-width: 100%;
    max-width: none;
    table-layout: fixed;
}

.workbook-col-name {
    width: var(--matrix-name-width);
}

.workbook-col-coverage {
    width: var(--matrix-coverage-width);
}

.workbook-col-skill {
    width: var(--matrix-skill-width);
}

.workbook-table th,
.workbook-table td {
    padding: 6px 4px;
}

.workbook-table thead tr:nth-child(2) .sticky-head {
    top: 34px;
}

.workbook-table .name-head,
.workbook-table .coverage-head,
.workbook-table .group-head,
.workbook-table .subhead {
    background: #f7faf6;
}

.workbook-table .sticky-col {
    box-shadow: 1px 0 0 rgba(214, 221, 211, 0.95);
    background: #ffffff;
    z-index: 4;
    isolation: isolate;
}

.workbook-table .sticky-coverage {
    left: var(--matrix-name-width);
    z-index: 5;
}

.workbook-table thead .sticky-coverage {
    z-index: 7;
}

.workbook-table thead .sticky-col,
.workbook-table thead .sticky-head {
    background: #f7faf6;
    z-index: 6;
    overflow: visible;
}

.workbook-table thead .name-head,
.workbook-table thead .coverage-head {
    z-index: 8;
    overflow: visible;
    vertical-align: middle;
}

.workbook-table tbody .sticky-col,
.workbook-table .matrix-summary-row .sticky-col {
    overflow: hidden;
}

.group-head {
    text-align: center;
    color: var(--heading);
    font-size: 0.66rem;
    border-bottom: 1px solid var(--border);
}

.subhead {
    min-width: var(--matrix-skill-width);
    width: var(--matrix-skill-width);
    padding: 5px 3px;
    font-size: 0.58rem;
    line-height: 1.1;
}

.sticky-summary {
    background: #f4f7f3;
}

.workbook-table .sticky-summary,
.workbook-table .matrix-summary-coverage.sticky-col {
    background: #f8faf8;
}

.workbook-table .coverage-cell.sticky-col {
    background: #eef4ef;
}

.matrix-summary-row th,
.matrix-summary-row td {
    padding: 6px 4px;
    background: #f8faf8;
    font-weight: 700;
}

.matrix-summary-gap td,
.matrix-summary-gap th {
    color: var(--danger);
}

.matrix-summary-coverage,
.matrix-summary-cell {
    text-align: center;
    white-space: nowrap;
}

.matrix-summary-coverage {
    background: #f8faf8;
}

.matrix-summary-button {
    width: 100%;
    border: 1px dashed rgba(33, 101, 79, 0.28);
    border-radius: 10px;
    padding: 5px 6px;
    min-height: 46px;
    background: rgba(33, 101, 79, 0.05);
    color: var(--heading);
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.84rem;
}

.matrix-summary-button:hover {
    border-color: rgba(33, 101, 79, 0.45);
    background: rgba(33, 101, 79, 0.09);
}

.operator-link {
    display: inline-block;
    color: var(--heading);
    font-weight: 700;
    margin-bottom: 4px;
    font-size: 0.76rem;
}

.operator-link-inactive {
    color: #5f6b65;
}

.operator-status {
    display: inline-flex;
    align-items: center;
    margin: 0 0 4px 8px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.63rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.operator-status-inactive {
    background: #e3e7e3;
    color: #5c6862;
}

.operator-meta {
    display: block;
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 500;
}

.coverage-cell {
    min-width: var(--matrix-coverage-width);
    width: var(--matrix-coverage-width);
    padding: 6px 4px !important;
    text-align: center;
    background: rgba(33, 101, 79, 0.06);
}

.coverage-cell strong {
    display: block;
    font-size: 0.82rem;
    color: var(--heading);
}

.coverage-cell span {
    color: var(--muted);
    font-size: 0.64rem;
}

.matrix-cell {
    min-width: 0;
    width: 100%;
    min-height: 46px;
    padding: 5px 3px;
    justify-content: center;
    border-color: rgba(33, 101, 79, 0.08);
    border-radius: 8px;
    gap: 3px;
}

.matrix-cell:hover {
    border-color: rgba(33, 101, 79, 0.28);
    transform: translateY(-1px);
}

.matrix-cell:disabled {
    cursor: not-allowed;
}

.matrix-cell strong {
    font-size: 0.82rem;
    line-height: 1;
}

.matrix-cell span {
    font-size: 0.55rem;
    line-height: 1.05;
}

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

.matrix-side.stack-lg > * + * {
    margin-top: 0;
}

.matrix-side-compact {
    gap: 12px;
}

.matrix-side-compact .panel {
    padding: 16px;
}

.matrix-side-compact .eyebrow {
    font-size: 0.64rem;
}

.matrix-side-compact .muted,
.matrix-side-compact li,
.matrix-side-compact p,
.matrix-side-compact label,
.matrix-side-compact input,
.matrix-side-compact button {
    font-size: 0.8rem;
}

.matrix-shell .matrix-legend {
    gap: 6px;
}

.matrix-shell .matrix-legend .legend-item {
    min-width: 100px;
    padding: 6px 8px;
}

.matrix-table-gap {
    height: 8px;
}

.matrix-shell .name-head {
    min-width: var(--matrix-name-width);
}

.matrix-shell .operator-cell {
    min-width: var(--matrix-name-width);
}

.matrix-operator-inactive .sticky-col,
.matrix-operator-inactive td {
    background: #f4f5f4;
}

.operator-cell-inactive,
.coverage-cell-inactive.sticky-col {
    background: #f0f2f0 !important;
}

.matrix-operator-inactive .coverage-cell strong,
.matrix-operator-inactive .coverage-cell span,
.matrix-operator-inactive .operator-meta {
    color: #64706a;
}

.matrix-cell-readonly,
.matrix-cell-readonly:hover,
.matrix-cell-readonly:focus {
    background: #ecefed !important;
    border-color: #d2d8d3 !important;
    color: #657169 !important;
    box-shadow: none;
    transform: none;
    opacity: 1;
}

.matrix-cell-readonly strong,
.matrix-cell-readonly span {
    color: inherit;
}

.matrix-shell .group-head,
.matrix-shell .name-head,
.matrix-shell .coverage-head,
.matrix-shell .subhead {
    white-space: normal;
}

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

.settings-row {
    display: grid;
    grid-template-columns: 140px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
}

.settings-level-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--border);
    font-weight: 700;
}

.settings-level-chip-add {
    background: rgba(33, 101, 79, 0.06);
}

.area-toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.area-toggle-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
    cursor: pointer;
}

.area-toggle-card input {
    width: auto;
    margin-top: 3px;
}

.area-toggle-card span {
    display: grid;
    gap: 4px;
}

.area-toggle-card small {
    color: var(--muted);
}

.builder-shell {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
}

.builder-toolbar,
.builder-helper,
.assignment-summary,
.machine-create-form,
.machine-edit-form,
.user-access-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.inline-form-compact {
    align-items: stretch;
}

.question-card {
    background: #fcfdfb;
}

.question-card h3,
.question-card h4 {
    color: var(--heading);
}

.operator-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

.operator-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
    cursor: pointer;
}

.operator-picker input {
    width: auto;
}

.operator-picker span {
    display: grid;
    gap: 2px;
}

.operator-picker small {
    color: var(--muted);
}

.user-access-form input[type="password"] {
    min-width: 220px;
}

.machine-create-form > input,
.machine-edit-form > input {
    flex: 1 1 140px;
}

.machine-edit-form .checkbox,
.user-access-form .checkbox {
    margin: 0 4px;
}

.review-card {
    gap: 18px;
}

.review-grid {
    align-items: stretch;
}

.review-answer-panel {
    display: grid;
    gap: 8px;
}

.answer-options-review .answer-option.correct-answer {
    border-color: rgba(31, 122, 92, 0.28);
    background: rgba(31, 122, 92, 0.12);
}

.answer-options-review .answer-option.wrong-answer {
    border-color: rgba(193, 75, 68, 0.32);
    background: rgba(193, 75, 68, 0.12);
}

.field-compact {
    max-width: 220px;
}

.export-shell {
    background: #f5f7f3;
}

.export-page {
    width: min(1100px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

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

.export-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.group-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 20px;
}

.group-stat-card {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.78);
}

.group-stat-card strong {
    color: var(--heading);
}

.group-stat-card span,
.group-stat-card small {
    color: var(--muted);
}

.compact-heatmap-wrap {
    background: rgba(255, 255, 255, 0.78);
}

.compact-heatmap-table {
    width: max-content;
    min-width: 100%;
    max-width: none;
}

.heatmap-col-name {
    width: var(--heatmap-name-width);
}

.heatmap-col-skill {
    width: var(--heatmap-skill-width);
}

.compact-heatmap-table th,
.compact-heatmap-table td {
    padding: 7px 6px;
}

.compact-heatmap-table .group-head {
    font-size: 0.68rem;
    padding-top: 9px;
    padding-bottom: 9px;
}

.compact-heatmap-table .subhead {
    min-width: var(--heatmap-skill-width);
    width: var(--heatmap-skill-width);
    font-size: 0.6rem;
    line-height: 1.2;
    padding: 7px 4px;
}

.compact-operator-cell {
    min-width: var(--heatmap-name-width);
    font-size: 0.82rem;
    line-height: 1.25;
}

.heat-cell-compact {
    min-width: 34px;
    padding: 6px 0;
    border-radius: 8px;
    text-align: center;
    font-size: 0.72rem;
    font-weight: 700;
}

.trend-stats-grid {
    gap: 12px;
}

.stat-card-compact {
    padding: 14px 16px;
}

.stat-card-compact .stat-value {
    margin-top: 4px;
    font-size: 1.2rem;
}

.stat-card-compact small {
    display: block;
    margin-top: 4px;
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--border);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.74);
    color: var(--muted);
}

@media (max-width: 1180px) {
    .shell-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
    }

    .matrix-layout,
    .builder-shell,
    .two-col,
    .two-col-wide,
    .three-col,
    .export-summary-grid,
    .grid-cards-5,
    .grid-cards-4,
    .grid-cards-3,
    .grid-cards-2 {
        grid-template-columns: 1fr;
    }

    .matrix-side {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .page-content,
    .portal-content,
    .auth-wrap,
    .portal-layout {
        width: min(100% - 24px, 100%);
    }

    .grid-two,
    .inline-form,
    .inline-form-compact,
    .table-form,
    .builder-toolbar,
    .machine-create-form,
    .machine-edit-form,
    .user-access-form,
    .export-header,
    .portal-header,
    .topbar,
    .operator-hero {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .button,
    .page-link {
        justify-content: center;
    }

    .license-popup {
        right: 12px;
        left: 12px;
        bottom: 12px;
        width: auto;
    }

    .settings-row {
        grid-template-columns: 1fr;
    }
}
