/* Talent Management — design tokens and components. Light/dark via [data-theme] or system preference. */
:root {
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f0f3f8; --border: #dfe4ec; --text: #1a2233; --muted: #5b6678;
  --primary: #4b1fd6; --primary-hover: #3a14b3; --primary-soft: #ede8fb; --on-primary: #ffffff;
  --success: #158a4c; --success-soft: #e3f5ea; --warning: #b26b00; --warning-soft: #fff3dc; --danger: #c62828; --danger-soft: #fde8e8; --info-soft: #e6f1ff;
  --l1: #ddd3fa; --l2: #b39cf2; --l3: #7448e6; --l4: #3a0f9e;
  --heat-0: transparent; --heat-max: #4b1fd6;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
  --sidebar-w: 232px; --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141c; --surface: #171e29; --surface-2: #1f2836; --border: #2b3546; --text: #e6ebf3; --muted: #97a3b6;
    --primary: #a184ff; --primary-hover: #b8a3ff; --primary-soft: #2a1f52; --on-primary: #0b0620;
    --success: #43c576; --success-soft: #133322; --warning: #f0b24a; --warning-soft: #3a2b0c; --danger: #ff6b6b; --danger-soft: #3d1717; --info-soft: #172640;
    --l1: #2e2450; --l2: #5a3fb0; --l3: #8b6cff; --l4: #cdbdff;
    --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141c; --surface: #171e29; --surface-2: #1f2836; --border: #2b3546; --text: #e6ebf3; --muted: #97a3b6;
  --primary: #a184ff; --primary-hover: #b8a3ff; --primary-soft: #2a1f52; --on-primary: #0b0620;
  --success: #43c576; --success-soft: #133322; --warning: #f0b24a; --warning-soft: #3a2b0c; --danger: #ff6b6b; --danger-soft: #3d1717; --info-soft: #172640;
  --l1: #2e2450; --l2: #5a3fb0; --l3: #8b6cff; --l4: #cdbdff;
  --shadow: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 600; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* layout */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; padding: 4px 8px 16px; }
.brand-logo { height: 34px; width: auto; max-width: 150px; object-fit: contain; }
.brand-logo.lg { height: 64px; max-width: 220px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-size: 14px; }
.brand-sub { font-size: 11px; font-weight: 500; color: var(--muted); }
.brand-login { justify-content: center; padding-bottom: 4px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #7a00b0, #1a00b0); display: grid; place-items: center; color: #fff; font-size: 14px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); padding: 14px 8px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.nav a.disabled { color: var(--muted); opacity: .6; cursor: default; }
.nav .icon { width: 18px; text-align: center; font-size: 14px; }
.sidebar-footer { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid var(--border); font-size: 12px; }
.main { flex: 1; min-width: 0; padding: 22px 28px 40px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* cards & grid */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12px; color: var(--muted); }
.kpi .value { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi.warn .value { color: var(--warning); }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .shell { flex-direction: column; } .sidebar { width: auto; flex: none; height: auto; position: static; } .grid-2, .grid-3 { grid-template-columns: 1fr; } .main { padding: 16px; } }

/* buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; line-height: 1.2; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 8px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=month], input[type=search], select, textarea {
  width: 100%; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field .error { font-size: 12px; color: var(--danger); margin-top: 3px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 160px; margin-bottom: 8px; }
.inline { display: inline; }
.checkbox { display: flex; align-items: center; gap: 6px; font-weight: 500; color: var(--text); font-size: 13px; }

/* tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1; }
tr:hover td { background: var(--surface-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact td, .table-compact th { padding: 5px 8px; }

/* badges */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; line-height: 1.5; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.success, .badge.validated, .badge.green { background: var(--success-soft); color: var(--success); }
.badge.warning, .badge.amber, .badge.disputed { background: var(--warning-soft); color: var(--warning); }
.badge.danger, .badge.error, .badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.info, .badge.self, .badge.valid_insert, .badge.valid_update { background: var(--info-soft); color: var(--primary); }
.badge.primary { background: var(--primary); color: var(--on-primary); }
.level { display: inline-flex; align-items: center; justify-content: center; min-width: 26px; height: 22px; border-radius: 6px; font-size: 12px; font-weight: 700; padding: 0 6px; color: #fff; }
.level-1 { background: var(--l1); color: var(--text); } .level-2 { background: var(--l2); } .level-3 { background: var(--l3); } .level-4 { background: var(--l4); }
:root[data-theme="dark"] .level-1, :root[data-theme="dark"] .level-2 { color: #fff; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--border); display: inline-block; }
.dots i.on { background: var(--primary); }

/* alerts */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid var(--border); background: var(--surface); }
.flash.success { background: var(--success-soft); color: var(--success); border-color: transparent; }
.flash.error { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.flash.info { background: var(--info-soft); color: var(--primary); border-color: transparent; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-radius: 8px; background: var(--warning-soft); color: var(--warning); margin-bottom: 14px; }
.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }

/* filters */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { margin: 0; flex: 1 1 150px; max-width: 220px; }
.filters .field.wide { flex-basis: 260px; max-width: 320px; }
.filters .checkbox { padding-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 500; }

/* skill picker */
.picker { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 900px) { .picker { grid-template-columns: 1fr; } }
.picker-list { max-height: 70vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.picker-cat { padding: 8px 10px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--surface-2); position: sticky; top: 0; }
.picker-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--border); }
.picker-item:hover { background: var(--surface-2); }
.picker-item.selected { color: var(--primary); font-weight: 600; }
.picker-item.selected::after { content: "✓"; margin-left: auto; }
.picker-item[hidden] { display: none; }
.skill-row { display: grid; grid-template-columns: 1.4fr .9fr .6fr .8fr .9fr .5fr auto; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 8px; background: var(--surface); }
.skill-row.invalid { border-color: var(--danger); }
.skill-row .name { font-weight: 600; }
.skill-row .cat { font-size: 11px; color: var(--muted); }
.skill-row label { margin-bottom: 2px; }
.skill-row select, .skill-row input { padding: 5px 8px; font-size: 13px; }
@media (max-width: 1000px) { .skill-row { grid-template-columns: 1fr 1fr; } }
.level-legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.level-legend div { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); font-size: 12px; }
.level-legend b { display: block; }
@media (max-width: 800px) { .level-legend { grid-template-columns: 1fr 1fr; } }
.sticky-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 0; margin-top: 12px; display: flex; gap: 10px; align-items: center; justify-content: flex-end; }

/* charts */
.chart { width: 100%; min-height: 220px; position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--text); font-family: var(--font); font-size: 11px; }
.chart .axis line, .chart .axis path { stroke: var(--border); }
.chart .gridline { stroke: var(--border); stroke-dasharray: 2 3; }
.tooltip { position: fixed; z-index: 50; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 9px; border-radius: 6px; font-size: 12px; box-shadow: var(--shadow); max-width: 260px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px; font-size: 12px; margin: 6px 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; user-select: none; }
.legend span.off { opacity: .4; text-decoration: line-through; }
.legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.heat { border-collapse: separate; border-spacing: 2px; font-size: 12px; }
.heat th { position: sticky; top: 0; background: var(--surface); font-size: 11px; padding: 4px 6px; text-align: center; white-space: nowrap; }
.heat th.row-head { text-align: left; left: 0; z-index: 2; }
.heat td { padding: 0; }
.heat td.name { width: 100%; padding: 3px 8px; white-space: nowrap; position: sticky; left: 0; background: var(--surface); z-index: 1; font-weight: 500; }
.heat td.cat { color: var(--muted); font-size: 11px; padding: 6px 8px 2px; }
.heat .cell { display: block; height: 26px; min-width: 64px; border-radius: 4px; text-align: center; line-height: 26px; font-weight: 600; cursor: pointer; color: var(--text); background: var(--surface-2); border: none; width: 100%; font: inherit; }
.heat .cell:hover { outline: 2px solid var(--primary); }
.heat .cell.hot { color: #fff; }
.rag { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.rag.green { background: var(--success); } .rag.amber { background: var(--warning); } .rag.red { background: var(--danger); }
.bar-track { background: var(--surface-2); border-radius: 4px; height: 8px; width: 100%; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); }
.team-grid td.cell { text-align: center; }
.team-grid .lvl { display: inline-block; width: 30px; height: 26px; line-height: 26px; border-radius: 6px; font-weight: 700; font-size: 12px; cursor: pointer; border: none; font: inherit; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; flex-wrap: wrap; }
.tabs a, .tabs button { padding: 8px 12px; border: none; background: none; font: inherit; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; }
.tabs a.active, .tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a:hover { text-decoration: none; color: var(--text); }
dialog { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); padding: 20px; max-width: 640px; width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10, 15, 25, .5); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
details summary { cursor: pointer; font-weight: 600; }
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-row > div { flex: 1 1 120px; }
.pill-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.pill-group button, .pill-group a { padding: 5px 10px; border: none; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; font-size: 12px; }
.pill-group .active { background: var(--primary); color: var(--on-primary); }
.pill-group a:hover { text-decoration: none; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; padding-bottom: 8px; }
.cred-table td { padding: 4px 8px; font-size: 12px; }
@media print { .sidebar, .filters, .actions, .sticky-bar { display: none !important; } .main { padding: 0; } .card { box-shadow: none; break-inside: avoid; } }

/* nav modules: each module owns its own pages, and its admin pages sit in a nested "Manage" group */
.nav-module { margin-bottom: 2px; }
.nav-module > summary { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; cursor: pointer;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text); list-style: none; }
.nav-module > summary::-webkit-details-marker { display: none; }
.nav-module > summary:hover { background: var(--surface-2); }
.nav-module[open] > summary { background: var(--surface-2); }
.nav-module > summary .icon { color: var(--muted); }
.nav-module[open] > summary .icon { color: var(--primary); }
.nav-module > summary .chev { margin-left: auto; font-size: 10px; color: var(--muted); transition: transform .12s ease; }
.nav-module[open] > summary .chev { transform: rotate(90deg); }
.nav-items { padding-left: 8px; margin-left: 12px; border-left: 2px solid var(--primary-soft); }
.nav-sub > summary { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer;
  font-size: 13px; font-weight: 500; color: var(--muted); list-style: none; }
.nav-sub > summary::-webkit-details-marker { display: none; }
.nav-sub > summary:hover { background: var(--surface-2); }
.nav-sub > summary .chev { margin-left: auto; font-size: 10px; }
.nav-sub[open] > summary .chev { transform: rotate(90deg); }
.nav-count { font-size: 11px; color: var(--muted); font-weight: 600; }
.nav a .pill { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--danger-soft); color: var(--danger); }

/* drill-down tiles: a KPI that is also a link to the rows behind it */
a.kpi.drill { display: block; color: inherit; transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease; }
a.kpi.drill:hover { text-decoration: none; border-color: var(--primary); box-shadow: 0 2px 10px rgba(75, 31, 214, .12); }
a.kpi.drill:hover .drill-hint { opacity: 1; }
a.kpi.drill:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.drill-hint { float: right; opacity: 0; font-size: 11px; color: var(--primary); transition: opacity .12s ease; }
dialog.drill-dialog { max-width: 1080px; }
dialog.drill-dialog table { font-size: 12.5px; }
dialog.drill-dialog th { position: sticky; top: 0; }
.kpi .baseline { font-size: 11px; color: var(--muted); margin-top: 3px; padding-top: 3px; border-top: 1px dashed var(--border); }

/* movement data grid: one form per row, opened in place */
.gridform { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px 10px; }
.gridform label { display: block; font-size: 11px; font-weight: 600; color: var(--muted); margin: 0; }
.gridform input, .gridform select { margin-top: 3px; padding: 5px 7px; font-size: 13px; }
@media (max-width: 1200px) { .gridform { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
