/* 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: 208px; --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; }
.rail { 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; }
.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; } .rail { width: auto; flex: none; height: auto; position: static; padding: 8px 10px; border-right: none; border-bottom: 1px solid var(--border); } .rail .brand { padding-bottom: 6px; } .rail .nav { display: flex; gap: 4px; overflow-x: auto; } .rail .nav-section { display: none; } .rail .nav a { white-space: nowrap; } .content { min-height: 0; } .crumbs { display: none; } .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 { .rail, .topbar, .modnav, .setupnav, .filters, .actions, .sticky-bar { display: none !important; } .main { padding: 0; } .card { box-shadow: none; break-inside: avoid; } }

/* shell: rail (modules) + top bar + module tabs */
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.nav .pill, .modnav .pill { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--danger-soft); color: var(--danger); }
.modnav .pill { margin-left: 6px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 28px; border-bottom: 1px solid var(--border); background: var(--surface); min-height: 48px; }
.crumbs { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.crumbs .here { color: var(--text); font-weight: 600; }
.crumbs .sep { opacity: .5; }
.topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.usermenu { position: relative; }
.usermenu > summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 8px 3px 4px; border-radius: 999px; }
.usermenu > summary::-webkit-details-marker { display: none; }
.usermenu > summary:hover, .usermenu[open] > summary { background: var(--surface-2); }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.who { font-size: 13px; font-weight: 500; }
.usermenu-panel { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.usermenu-id { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.usermenu-panel a, .usermenu-panel button { display: block; width: 100%; text-align: left; padding: 7px 10px; border: none; background: none; border-radius: 6px; font: inherit; color: var(--text); cursor: pointer; }
.usermenu-panel a:hover, .usermenu-panel button:hover { background: var(--surface-2); text-decoration: none; }
.usermenu-panel form { margin: 0; }
.modnav { display: flex; gap: 2px; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.modnav a { display: inline-flex; align-items: center; white-space: nowrap; padding: 10px 12px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.modnav a:hover { color: var(--text); text-decoration: none; }
.modnav a.active { color: var(--primary); border-bottom-color: var(--primary); }
.modnav a.setup { margin-left: auto; }
.setupnav { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 28px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.setupnav a { padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; color: var(--text); border: 1px solid var(--border); background: var(--surface); }
.setupnav a:hover { text-decoration: none; background: var(--surface-2); }
.setupnav a.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
@media (max-width: 860px) { .topbar, .modnav, .setupnav { padding-left: 16px; padding-right: 16px; } .who { display: none; } }

/* 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)); } }

/* insights: a chart is a drill-down too -- the whole plot is the click target */
a.chart-drill { display: block; color: inherit; text-decoration: none; border-radius: 8px; margin: 0 -6px; padding: 0 6px; transition: background .12s ease, box-shadow .12s ease; }
a.chart-drill:hover { background: var(--surface-2); text-decoration: none; box-shadow: inset 0 0 0 1px var(--primary); }
a.chart-drill:hover .drill-hint { opacity: 1; }
a.chart-drill:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.card-head a.badge { text-decoration: none; }
.card-head a.badge:hover { background: var(--primary-soft); color: var(--primary); }

/* timesheet grid: a row is a project, the seven cells are the daily entries */
.ts-grid td, .ts-grid th { padding: 6px 6px; }
.ts-grid th.day { text-align: center; min-width: 78px; }
.ts-grid th.day small { display: block; font-weight: 500; color: var(--muted); }
.ts-grid th.weekend, .ts-grid td.weekend { background: var(--surface-2); }
.ts-grid td.cell { text-align: center; }
.ts-grid td.cell input { width: 68px; text-align: right; padding: 5px 7px; font-variant-numeric: tabular-nums; }
.ts-grid td.cell input.err { border-color: var(--danger); background: var(--danger-soft); }
.ts-grid td.cell input.warn { border-color: var(--warning); background: var(--warning-soft); }
.ts-grid td.cell input:disabled { background: transparent; border-color: transparent; color: var(--text); }
.ts-grid td.rowtotal { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ts-grid td.rowhead { min-width: 250px; }
.ts-grid td.rowhead select { padding: 4px 6px; font-size: 13px; margin-bottom: 4px; }
.ts-grid td.rowhead input.desc { padding: 4px 6px; font-size: 12px; }
.ts-grid td.rowhead input.desc.err { border-color: var(--danger); background: var(--danger-soft); }
.ts-grid td.rowhead .fixed { font-weight: 600; }
.ts-grid td.rowhead .fixed small { display: block; font-weight: 400; color: var(--muted); }
.ts-grid tr.row-err td.rowhead { box-shadow: inset 3px 0 0 var(--danger); }
.ts-grid tr.totals td { background: var(--surface-2); font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }
.ts-grid tr.totals td.red { color: var(--danger); } .ts-grid tr.totals td.amber { color: var(--warning); }
.ts-grid td.rowact { white-space: nowrap; }
.ts-grid td.rowact button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 15px; padding: 2px 4px; }
.ts-grid td.rowact button:hover { color: var(--primary); }
.ts-total { font-size: 24px; font-weight: 700; line-height: 1.2; margin-top: 2px; }

/* Phone widths: the grid stays a real 7-day table (rewriting it as cards would lose the
   week-at-a-glance view people actually want), but the project column is pinned so a
   long horizontal scroll never loses the row's label, and everything is sized for a thumb. */
@media (max-width: 640px) {
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { justify-content: flex-start; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .gridform { grid-template-columns: 1fr; }
  .ts-grid th:first-child, .ts-grid td.rowhead { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 2px 0 4px -2px rgba(0,0,0,.15); }
  .ts-grid tr.weekend td:first-child, .ts-grid tr.weekend td.rowhead { background: var(--surface); }
  .ts-grid td.rowhead { min-width: 170px; max-width: 170px; }
  .ts-grid td.cell input { width: 54px; min-height: 34px; }
  .ts-grid th.day { min-width: 60px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
}
.ts-total.amber { color: var(--warning); } .ts-total.red { color: var(--danger); }
.ts-problems { margin: 0; padding-left: 18px; }
.ts-problems li { margin: 4px 0; }
.ts-problems .error { color: var(--danger); } .ts-problems .warning { color: var(--warning); }
.ts-savestate { font-size: 12px; color: var(--muted); }
.ts-savestate.unsaved { color: var(--warning); } .ts-savestate.failed { color: var(--danger); }
.badge.draft { background: var(--surface-2); color: var(--muted); }
.badge.submitted { background: var(--info-soft); color: var(--primary); }
.badge.approved { background: var(--success-soft); color: var(--success); }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.locked { background: var(--surface-2); color: var(--text); }
.badge.missing { background: var(--danger-soft); color: var(--danger); border: 1px dashed var(--danger); }


/* timesheet: the "add a project" bar sits above the grid so the first step is the first thing seen */
.ts-addbar { background: var(--primary-soft); border: 1px dashed var(--primary); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.ts-addbar-title { font-weight: 650; margin-bottom: 8px; }
.ts-addbar-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.ts-addbar-controls select { flex: 1 1 320px; max-width: 520px; }
.ts-addbar-controls form { margin: 0; }

/* side drawer for editing one record without leaving the list */
dialog.drawer { position: fixed; z-index: 100; inset: 0 0 0 auto; margin: 0; height: 100vh; max-height: 100vh; width: min(460px, 100vw); max-width: none;
  border-radius: 12px 0 0 12px; padding: 0; display: none; flex-direction: column; box-shadow: -12px 0 40px rgba(0,0,0,.25); }
dialog.drawer[open] { display: flex; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.form-sec { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.form-sec > h3 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.form-sec .field label, .form-sec > label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 3px; }
.form-sec .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-sec details > summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg label { margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 14px; font-size: 13px; font-weight: 500; color: var(--text); background: var(--surface); }
.seg input:checked + span { background: var(--primary); color: var(--on-primary); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: -2px; }
