/* PEM — design system: modern, minimal. */

/* Inter (variable, self-hosted so the app works without internet). */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-wght-normal.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('../fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-2: #f0f3f7;
    --border: #e3e8ef;
    --text: #1a2433;
    --text-2: #5b6779;
    --text-3: #8a95a6;

    --accent: #136f9e;
    --accent-hover: #0f5d85;
    --accent-soft: #e6f2f8;

    --success: #15803d;
    --success-soft: #e7f6ec;
    --warning: #b45309;
    --warning-soft: #fdf3e2;
    --danger: #c0392b;
    --danger-soft: #fbeceb;
    --info: #4f46e5;
    --info-soft: #eeedfc;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

    --sidebar-w: 248px;
    --topbar-h: 64px;
    --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { margin: 0; }

/* The hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }

body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- App shell ---------- */

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

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 40;
    transition: transform .2s ease;
}

.brand {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
}
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--accent); color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 13px; letter-spacing: .02em;
}
.brand-text strong { display: block; font-size: 15px; line-height: 1.2; }
.brand-text span { font-size: 11.5px; color: var(--text-3); }

.nav { padding: 16px 12px; flex: 1; overflow-y: auto; }
.nav-label {
    font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-3); padding: 12px 10px 6px;
}
.nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.disabled { opacity: .45; pointer-events: none; }
.nav a .soon { margin-left: auto; font-size: 10.5px; font-weight: 500; color: var(--text-3); }

.sidebar-footer { padding: 12px; border-top: 1px solid var(--border); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 16px;
    padding: 0 28px;
    background: rgba(245, 247, 250, .85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 18px; }
.topbar .spacer { flex: 1; }

.topbar .menu-toggle { display: none; }

.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.user-chip .meta { line-height: 1.25; }
.user-chip .meta strong { display: block; font-size: 13px; }
.user-chip .meta span { font-size: 12px; color: var(--text-3); }

.content { padding: 28px; max-width: 1400px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }

.backdrop { display: none; }

/* ---------- Cards & KPIs ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 0; }
.card-head h3 { font-size: 15px; }
.card-body { padding: 20px; }

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

.kpi { padding: 20px; display: flex; gap: 16px; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.kpi-icon .icon { width: 20px; height: 20px; }
.kpi-label { font-size: 13px; color: var(--text-2); }
.kpi-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.kpi-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.tone-accent  { background: var(--accent-soft);  color: var(--accent); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-info    { background: var(--info-soft);    color: var(--info); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-2); }
.empty-state .icon { width: 36px; height: 36px; color: var(--text-3); margin-bottom: 8px; }
.empty-state h4 { color: var(--text); margin-bottom: 4px; }

/* ---------- Forms & buttons ---------- */

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.input, select.input, textarea.input {
    width: 100%;
    height: 42px;
    padding: 0 14px;
    font: inherit; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: 10px 14px; min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.is-invalid { border-color: var(--danger); }

.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.input-icon .input { padding-left: 40px; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 40px; padding: 0 16px;
    font: inherit; font-weight: 500;
    border: 1px solid transparent; border-radius: var(--radius-sm);
    cursor: pointer; white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s;
}
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-icon { width: 40px; padding: 0; }
.btn-block { width: 100%; }
.btn-lg { height: 46px; font-size: 15px; }

.btn .spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.alert { padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: 16px; }
.alert-danger { background: var(--danger-soft); color: var(--danger); }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500;
}

/* ---------- Toasts ---------- */

.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
    min-width: 260px; max-width: 360px;
    padding: 12px 16px; border-radius: var(--radius-sm);
    background: var(--text); color: #fff; box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    animation: toast-in .2s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Toolbar & tables ---------- */

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.toolbar .input { height: 38px; width: auto; }
.toolbar .search { flex: 1 1 240px; max-width: 340px; }
.toolbar .search .input { width: 100%; }
.toolbar .spacer { flex: 1; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 12px 20px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table th {
    font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    color: var(--text-3); background: var(--surface-2);
}
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table th.sorted-asc::after { content: ' ↑'; }
.table th.sorted-desc::after { content: ' ↓'; }
.table tbody tr:hover { background: #fafbfd; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .muted { color: var(--text-3); font-size: 12.5px; }
.table .actions { text-align: right; }
.table .loading td, .table .empty td { text-align: center; color: var(--text-3); padding: 40px 20px; }

.cell-main strong { display: block; font-weight: 600; }
.cell-main span { color: var(--text-3); font-size: 12.5px; }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-sm.btn-icon { width: 32px; padding: 0; }
.btn-sm .icon { width: 16px; height: 16px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-muted   { background: var(--surface-2);    color: var(--text-2); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs button {
    background: none; border: 0; font: inherit; font-weight: 500; color: var(--text-2);
    padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; z-index: 60; display: none; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal.open { display: flex; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16, 24, 40, .4); }
.modal-dialog {
    position: relative; width: 100%; max-width: 560px;
    background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
    animation: modal-in .18s ease;
}
.modal-sm .modal-dialog { max-width: 420px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--border); }
body.modal-open { overflow: hidden; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-grid .span-2 { grid-column: span 2; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.required::after { content: ' *'; color: var(--danger); }

.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

/* ---------- Dashboard ---------- */

.dash-filters { display: flex; gap: 10px; flex-wrap: wrap; }
.dash-filters .input { height: 38px; width: auto; }
.dash-row { margin-top: 20px; }
.is-loading { opacity: .55; transition: opacity .15s; }

.kpi-tile { padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.kpi-tile .kpi-value { font-size: 30px; }
.kpi-of { font-size: 15px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.kpi-tile .kpi-sub { font-size: 12.5px; color: var(--text-2); margin-top: 2px; }

.meter { height: 6px; border-radius: 999px; background: var(--accent-soft); overflow: hidden; flex: 1; }
.meter-fill { height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s; }
.kpi-tile .meter { flex: none; margin-top: 6px; }

.attention { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 6px; font-size: 13px; }
.attention a { color: var(--text-2); }
.attention a:hover { color: var(--accent); }
.attention strong { color: var(--text); font-size: 15px; margin-right: 4px; }

.card-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--text-3); }
.chart-box { position: relative; height: 260px; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; background: var(--surface); color: var(--text-3); font-size: 13px; }

.table-compact th, .table-compact td { padding: 10px 20px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .rank { width: 36px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.row-link { cursor: pointer; }
.progress-cell { display: flex; align-items: center; gap: 10px; }
.progress-cell span { font-size: 12.5px; color: var(--text-2); min-width: 56px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Reports ---------- */

.report-picker { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.report-option {
    display: flex; gap: 14px; align-items: flex-start; text-align: left;
    padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface);
    font: inherit; color: var(--text); cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s;
}
.report-option:hover { border-color: #cfd6e0; }
.report-option.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.report-option strong { display: block; font-size: 14px; margin-bottom: 2px; }
.report-option small { color: var(--text-2); font-size: 12.5px; line-height: 1.45; }
.report-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; background: var(--surface-2); color: var(--text-2); }
.report-option.active .report-icon { background: var(--accent-soft); color: var(--accent); }

.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; padding: 18px 20px 12px; }
.report-head h3 { font-size: 16px; }
.report-meta { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.report-table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.report-note { padding: 12px 20px; font-size: 12.5px; color: var(--text-2); border-top: 1px solid var(--border); }
.print-only { display: none; }

@media (max-width: 1100px) {
    .report-option { align-items: center; padding: 12px 14px; }
    .report-option small { display: none; }
}

@media (max-width: 600px) {
    .report-picker { grid-template-columns: 1fr; gap: 8px; }
}

@media print {
    body { background: #fff; font-size: 11px; }
    .sidebar, .topbar, .backdrop, .no-print, .toast-stack { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; max-width: none; }
    .card { border: 0; box-shadow: none; }
    .table-wrap { overflow: visible; }
    .table th, .table td { padding: 5px 8px; white-space: normal; }
    .print-only { display: block; font-size: 11px; color: var(--text-2); }
    .badge { padding: 0; background: none !important; color: inherit !important; }
    @page { size: A4 landscape; margin: 12mm; }
}

/* ---------- Employee profile ---------- */

.profile-head { display: flex; align-items: center; gap: 18px; padding: 22px 24px; flex-wrap: wrap; }
.avatar-lg { width: 60px; height: 60px; font-size: 20px; }
.profile-id { flex: 1; min-width: 220px; }
.profile-id h2 { font-size: 22px; }
.profile-sub { color: var(--text-2); margin-top: 2px; }
.profile-tags { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 12.5px; color: var(--text-2); }
.profile-tags .dot { color: var(--text-3); }
.profile-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.kpi-tile .kpi-sub .badge { margin-right: 4px; }
.delta-up { color: var(--success); }
.delta-down { color: var(--danger); }

.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

.feedback { display: grid; gap: 16px; }
.feedback-block h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); margin-bottom: 6px; }
.feedback-block p { margin: 6px 0 0; white-space: pre-wrap; }
.feedback-block ul { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.feedback-block li strong { margin-right: 4px; }

.name-link { color: var(--text); }
.name-link:hover { color: var(--accent); }

/* ---------- Status chips ---------- */

.status-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.chip {
    display: inline-flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 14px; border-radius: 999px;
    background: var(--surface); border: 1px solid var(--border);
    font: inherit; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #cfd6e0; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-count { font-size: 12px; padding: 0 7px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); }
.chip.active .chip-count { background: rgba(255, 255, 255, .2); color: #fff; }

/* ---------- Evaluation form ---------- */

.back-link { display: inline-block; color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }

.alert-info { background: var(--accent-soft); color: var(--accent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert a { color: inherit; font-weight: 600; text-decoration: underline; }
.banner { margin-bottom: 20px; }

.eval-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.eval-kicker { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.eval-head h2 { font-size: 24px; margin: 4px 0 8px; }
.eval-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: var(--text-2); font-size: 13px; }

.eval-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.eval-main { display: grid; gap: 20px; min-width: 0; }
.eval-aside { position: sticky; top: calc(var(--topbar-h) + 20px); }

.section-title { display: flex; align-items: center; gap: 10px; padding: 18px 20px 0; font-size: 15px; font-weight: 600; }
.section-title span {
    width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
    background: var(--accent-soft); color: var(--accent); font-size: 13px;
}
.section-title-bare { padding: 0; }
.section-hint { color: var(--text-2); font-size: 13px; margin: 8px 0 14px; }

.info-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; margin: 0; }
.info-grid dt { font-size: 12px; color: var(--text-3); }
.info-grid dd { margin: 2px 0 0; font-weight: 500; }
.info-grid .span-2 { grid-column: span 2; }

.factor { margin-bottom: 14px; transition: border-color .15s; }
.factor:last-child { margin-bottom: 0; }
.factor.has-error { border-color: var(--danger); }
.factor-head { display: flex; justify-content: space-between; gap: 16px; padding: 18px 20px 0; }
.factor-head h4 { font-size: 15px; display: flex; align-items: center; gap: 8px; }
.factor.is-scored .factor-head h4::after {
    content: '✓'; font-size: 11px; width: 18px; height: 18px; border-radius: 50%;
    display: inline-grid; place-items: center; background: var(--success-soft); color: var(--success);
}
.factor-head p { margin: 4px 0 0; color: var(--text-2); font-size: 13px; }
.weight-chip { flex-shrink: 0; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; }
.factor-body { padding: 16px 20px 20px; }
.factor-error { color: var(--danger); font-size: 12.5px; margin-top: 8px; }
.factor-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.owner-chip { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }
.factor.is-locked { background: #fbfcfd; }
.factor.is-locked .factor-body { opacity: .75; }
.factor.is-locked .owner-chip { color: var(--text-2); font-weight: 500; }
.entered-by { margin-top: 10px; font-size: 12px; color: var(--text-3); }
.parts-list { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin: -6px 0 14px; font-size: 12px; color: var(--text-3); }
.parts-list .part.done { color: var(--success); font-weight: 500; }
.parts-mini { display: inline-flex; gap: 8px; font-size: 12px; color: var(--text-3); }
.parts-mini .done { color: var(--success); }
.factor-error:empty { display: none; }

/* Score picker: four bands from the paper form */
.picker { display: grid; grid-template-columns: 2fr 3fr 2fr 3fr; gap: 8px; }
.picker-band { border-radius: var(--radius-sm); padding: 8px; background: var(--surface-2); }
.picker-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; margin-bottom: 6px; text-align: center; }
.picker-buttons { display: flex; gap: 6px; }
.pick {
    flex: 1; height: 40px; border-radius: 7px; border: 1px solid var(--border); background: var(--surface);
    font: inherit; font-weight: 600; font-size: 15px; color: var(--text); cursor: pointer; transition: all .12s;
}
.pick:hover:not(:disabled) { border-color: currentColor; }
.band-dnm     { --band: var(--danger);  --band-soft: var(--danger-soft); }
.band-ni      { --band: var(--warning); --band-soft: var(--warning-soft); }
.band-meets   { --band: var(--accent);  --band-soft: var(--accent-soft); }
.band-exceeds { --band: var(--success); --band-soft: var(--success-soft); }
.picker-band .picker-label { color: var(--band); }
.picker-band .pick:hover:not(:disabled) { color: var(--band); }
.picker-band .pick.selected { background: var(--band); border-color: var(--band); color: #fff; }
.picker-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; font-size: 13px; }
.picker-value strong { font-size: 15px; }
.justification { margin-top: 14px; }
.justification label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }

.option-list { display: grid; gap: 8px; }
.option {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer;
    border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 13.5px;
}
.option:hover { background: #fafbfd; }
.option.selected { border-color: var(--accent); background: var(--accent-soft); }
.option input { accent-color: var(--accent); }
.option-score { width: 30px; height: 26px; border-radius: 6px; background: var(--surface-2); display: grid; place-items: center; font-weight: 600; flex-shrink: 0; }
.option.selected .option-score { background: var(--accent); color: #fff; }

.count-row { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: end; }
.range-table { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.range-table div {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px;
    border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12px; color: var(--text-2); text-align: center;
}
.range-table strong { font-size: 15px; color: var(--text); }
.range-table .selected { background: var(--accent); color: rgba(255, 255, 255, .85); }
.range-table .selected strong { color: #fff; }

.is-readonly .pick, .is-readonly .option { cursor: default; }
.is-readonly .input:disabled { background: var(--surface-2); color: var(--text); }

.btn-row { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

/* Summary (section C) */
.summary-card .card-body { padding-top: 14px; }
.total-block { text-align: center; padding: 8px 0 14px; }
.total-label { font-size: 12px; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.total-value { font-size: 44px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
#totalRating { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; min-height: 22px; font-size: 12.5px; }
.progress { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.progress-text { font-size: 12px; color: var(--text-3); margin: 6px 0 14px; text-align: center; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.summary-table th { text-align: left; font-weight: 500; color: var(--text-3); padding: 6px 0; border-bottom: 1px solid var(--border); }
.summary-table td { padding: 7px 0; border-bottom: 1px solid var(--border); }
.summary-table th:not(:first-child), .summary-table td:not(:first-child) { text-align: right; }
.summary-table tr.pending td { color: var(--text-3); }
.scale { margin-top: 14px; display: grid; gap: 4px; font-size: 12px; color: var(--text-2); }
.scale span { display: inline-block; width: 82px; color: var(--text-3); }
.scale-note { margin-top: 4px; color: var(--text-3); }
.summary-actions { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--border); }
.summary-actions .btn { flex: 1; }

/* ---------- Login ---------- */

.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }

.auth-aside {
    background: linear-gradient(155deg, #136f9e 0%, #0d4f73 100%);
    color: #fff;
    padding: 48px;
    display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside .brand-mark { background: rgba(255, 255, 255, .16); width: 40px; height: 40px; font-size: 15px; }
.auth-aside h2 { font-size: 34px; line-height: 1.2; font-weight: 700; max-width: 440px; letter-spacing: -.02em; }
.auth-aside p { color: rgba(255, 255, 255, .78); max-width: 420px; font-size: 15px; }
.auth-points { display: grid; gap: 14px; margin-top: 28px; }
.auth-points div { display: flex; gap: 12px; align-items: center; color: rgba(255, 255, 255, .9); }
.auth-points .icon { width: 20px; height: 20px; }
.auth-aside small { color: rgba(255, 255, 255, .6); }

.auth-main { display: grid; place-items: center; padding: 40px 24px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .lead { color: var(--text-2); margin: 0 0 28px; }
.auth-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 32px; }
.auth-mobile-brand strong { display: block; font-size: 15px; line-height: 1.2; }
.auth-mobile-brand span { font-size: 12px; color: var(--text-3); }

@media (max-width: 900px) {
    .auth-mobile-brand { display: flex; }
    .auth-main { place-items: start center; padding-top: 12vh; }
}

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
    .eval-layout { grid-template-columns: 1fr; }
    .eval-aside { position: static; }
    /* Keep the save buttons in reach on smaller screens. */
    .summary-actions { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: var(--surface); box-shadow: 0 -4px 16px rgba(16, 24, 40, .08); }
    body:has(.summary-actions:not([hidden])) .content { padding-bottom: 96px; }
}

@media (min-width: 861px) and (max-width: 1180px) {
    .summary-actions { left: var(--sidebar-w); }
}

@media (max-width: 700px) {
    .picker { grid-template-columns: 1fr 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .count-row { grid-template-columns: 1fr; }
    .range-table { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    .auth-page { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(16, 24, 40, .35); z-index: 35; }
    .main { margin-left: 0; }
    .topbar .menu-toggle { display: inline-flex; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px; }
    .user-chip .meta { display: none; }
    .grid-2 { grid-template-columns: 1fr; }
    .toolbar { padding: 14px 16px; }
    .toolbar .search { max-width: none; }
    .table th, .table td { padding: 12px 16px; }
}

@media (max-width: 560px) {
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .modal { padding: 0; }
    .modal-dialog { border-radius: 0; min-height: 100vh; }
}

/* ---------- Phones (raters use the system on mobile) ---------- */

/* Grid children may shrink below their content (wide tables no longer widen the page). */
.grid > * { min-width: 0; }

/* Running total in the fixed save bar; only shown when the bar is fixed (smaller screens). */
.bar-total { display: none; }

@media (max-width: 1180px) {
    .summary-actions { flex-wrap: wrap; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
    .bar-total { display: flex; align-items: center; justify-content: space-between; width: 100%; font-size: 13px; color: var(--text-2); }
    .bar-total strong { font-size: 18px; color: var(--text); margin-right: 6px; }
    body:has(.summary-actions:not([hidden])) .content { padding-bottom: 130px; }
}

@media (max-width: 860px) {
    /* 16px stops iPhones from zooming into a field when it is tapped. */
    .input, select.input, textarea.input { font-size: 16px; }
    .page-head h2 { font-size: 20px; }
    .page-head p { font-size: 13.5px; }

    /* One scrollable row of status chips instead of three wrapped rows. */
    .status-chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 14px; padding: 0 16px; }
    .status-chips::-webkit-scrollbar { display: none; }
    .chip { flex-shrink: 0; }

    .dash-filters { width: 100%; }
    .dash-filters .input { flex: 1 1 140px; }
}

@media (max-width: 640px) {
    /* Tables marked .table-cards become one card per row: label on the left, value on the right. */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
    .table-cards tbody tr:hover { background: none; }
    .table-cards td { padding: 4px 0; border: 0; white-space: normal; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
    .table-cards td[data-label]::before { content: attr(data-label); color: var(--text-3); font-size: 12.5px; text-align: left; flex-shrink: 0; }
    .table-cards td.cell-main { display: block; text-align: left; padding-bottom: 8px; }
    .table-cards td.cell-main strong { font-size: 15px; }
    .table-cards td.actions { padding-top: 10px; }
    .table-cards td.actions .btn { width: 100%; height: 42px; }
    .table-cards td.actions:empty, .table-cards td.actions .muted:only-child { display: none; }
    .table-cards tr.loading td, .table-cards tr.empty td { display: block; text-align: center; }
    .table-cards td.is-empty { display: none; }

    .toolbar select.input { flex: 1 1 100%; min-width: 0; }

    /* Compact tables (dashboard, profile) wrap instead of scrolling sideways. */
    .table-compact td, .table-compact th { white-space: normal; padding: 10px 14px; }

    /* Summary cards two by two. */
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .kpi-tile { padding: 14px; }
    .kpi-tile .kpi-value { font-size: 24px; }
    .kpi-label { font-size: 12.5px; }

    /* Evaluation form */
    .eval-head h2 { font-size: 21px; }
    .eval-kicker { font-size: 11px; }
    .info-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .factor-head { flex-direction: column; gap: 8px; padding: 16px 16px 0; }
    .factor-meta { flex-direction: row; align-items: center; gap: 10px; }
    .factor-body { padding: 14px 16px 16px; }
    .pick { height: 46px; font-size: 16px; }
    .picker-band { padding: 8px 6px; }
    .option { padding: 12px; min-height: 48px; }
    .range-table div { padding: 6px 2px; }

    /* Another person's factor (LR / HR part): just the result, not the full scoring controls. */
    .factor.is-locked .factor-head p,
    .factor.is-locked .picker, .factor.is-locked .picker-foot,
    .factor.is-locked .option-list, .factor.is-locked .count-row { display: none; }
    .factor.is-locked .factor-body { opacity: 1; padding-top: 8px; }

    /* Profile */
    .profile-head { padding: 18px 16px; gap: 14px; }
    .profile-actions { width: 100%; }
    .profile-actions .btn { flex: 1; }
    .avatar-lg { width: 48px; height: 48px; font-size: 17px; }
    .profile-tags { gap: 4px 12px; }
    .profile-tags .dot { display: none; }
}

.locked-summary { display: none; font-size: 13.5px; color: var(--text-2); }
@media (max-width: 640px) {
    .factor.is-locked .locked-summary { display: block; }
    .locked-summary strong { color: var(--text); font-size: 15px; margin-right: 4px; }
}
