/* Team Resource Manager - plain CSS, no inline styles (CSP: style-src 'self'). */
:root {
  --ink: #1b2430; --muted: #5d6b7a; --line: #dde3ea; --bg: #f4f6f9; --card: #fff;
  --brand: #1f3a5f; --brand-2: #2f6fb0; --accent: #e0a526;
  --ok: #1e7a4c; --ok-bg: #e3f4ea; --warn: #8a5a00; --warn-bg: #fff4d6; --bad: #a42828; --bad-bg: #fbe3e3; --info: #1f5a8a; --info-bg: #e3eef8;
  --plan: #f7f9fc; --commit: #f5f2fb;
  --radius: 8px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px; color: var(--ink); background: var(--bg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
a { color: var(--brand-2); }
h1 { font-size: 1.45rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 1.1rem 0 .5rem; color: var(--brand); }
small.block, .block { display: block; }
.muted { color: var(--muted); }
.error { color: var(--bad); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); } .neg { color: var(--bad); }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1.5rem; padding: 0 1.25rem; height: 52px; background: var(--brand); color: #fff; }
.brand { font-weight: 700; letter-spacing: .2px; white-space: nowrap; }
.brand span { color: var(--accent); }
.brand .ver { margin-left: .4rem; font-size: .72rem; font-weight: 600; color: #d7e2ef; background: rgba(255, 255, 255, .14); padding: .1rem .45rem; border-radius: 10px; text-decoration: none; vertical-align: 2px; }
.brand .ver:hover { background: rgba(255, 255, 255, .25); color: #fff; }
.login .ver-login { text-align: center; font-size: .75rem; margin: .9rem 0 0; }
#nav { display: flex; gap: .25rem; overflow-x: auto; flex: 1; }
#nav a { color: #d7e2ef; text-decoration: none; padding: .45rem .7rem; border-radius: 6px; white-space: nowrap; }
#nav a:hover { background: rgba(255, 255, 255, .1); color: #fff; }
#nav a.active { background: rgba(255, 255, 255, .18); color: #fff; font-weight: 600; }
.userbox { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.userbox .linklike { color: #fff; }
.userbox .role { font-size: .75rem; padding: .1rem .45rem; border-radius: 10px; background: rgba(255, 255, 255, .15); }
.userbox .btn.ghost { color: #fff; border-color: rgba(255, 255, 255, .35); }
main { padding: 1.25rem; max-width: 1800px; margin: 0 auto; outline: none; }

/* buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: .3rem; padding: .42rem .8rem; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; cursor: pointer; font: inherit; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: #b9c4d0; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn.primary:hover { background: #255d96; }
.btn.ghost { background: transparent; }
.btn.small { padding: .22rem .5rem; font-size: .85rem; }
.btn.block { width: 100%; justify-content: center; }
.btn.icon { font-size: 1.3rem; padding: .1rem .55rem; border: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--brand-2); cursor: pointer; font: inherit; text-align: left; }
.linklike:hover { text-decoration: underline; }
input, select, textarea { font: inherit; padding: .38rem .5rem; border: 1px solid #c8d1db; border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .linklike:focus-visible, a:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 1px; }
input.year { width: 5.5rem; }
input.pct { width: 4.5rem; }
input.winacct { width: 15rem; }
input[readonly] { background: transparent; }
label.check { display: inline-flex; align-items: center; gap: .3rem; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; }
.field > span { font-weight: 600; font-size: .85rem; }
.field small { color: var(--muted); }
.form-error { color: var(--bad); min-height: 1.2em; margin-bottom: .5rem; }
.row { display: flex; align-items: center; gap: .5rem; }
.row.wrap { flex-wrap: wrap; align-items: flex-end; }
.actions.left { justify-content: flex-start; }
.actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .75rem; flex-wrap: wrap; }
.inline-form { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin-top: .6rem; }
.form.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.span2 { grid-column: 1 / -1; }
.modal .form > .field input:not([type=checkbox]):not([type=file]), .modal .form > .field select, .card > .form > .field input[type=password] { max-width: 36rem; }

/* layout */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem 1.1rem; margin-bottom: 1rem; }
.card.error { color: var(--bad); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.two-col > section { margin-bottom: 1rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-bottom: .9rem; }
.toolbar h1 { margin-right: .75rem; }
.toolbar .spacer { flex: 1; }
.toolbar .filters { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .45rem .55rem; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.toolbar input.search { width: 15rem; }
.prio { display: inline-block; font-size: .66rem; font-weight: 700; padding: 0 .3rem; border-radius: 3px; margin-right: .35rem; vertical-align: 1px; color: #fff; }
.prio.p1 { background: #b42318; } .prio.p2 { background: #d9730d; } .prio.p3 { background: #5d6b7a; } .prio.p4 { background: #a3adb8; }
.member-list { columns: 3 14rem; margin: .5rem 0; }
.member-list label { display: block; padding: .15rem 0; break-inside: avoid; }
.period { display: inline-flex; align-items: center; gap: .25rem; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: .42rem .8rem; cursor: pointer; font: inherit; }
.seg button.on { background: var(--brand); color: #fff; }
.subnav { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--line); }
.subnav button { border: 0; background: none; padding: .5rem .8rem; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.subnav button.on { color: var(--brand); border-bottom-color: var(--brand-2); font-weight: 600; }
.loading { color: var(--muted); padding: 1.5rem; }
.banner { padding: .6rem .85rem; border-radius: 6px; margin-bottom: .75rem; border: 1px solid transparent; }
.banner ul { margin: .3rem 0 0 1.1rem; padding: 0; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: #f1dca1; }
.banner.info { background: var(--info-bg); color: var(--info); border-color: #c4dbef; }
.banner.ok { background: var(--ok-bg); color: var(--ok); border-color: #bfe3cd; }
.bad-row td { background: var(--bad-bg); color: var(--bad); }
textarea.mono { font-family: ui-monospace, Consolas, monospace; font-size: .85rem; width: 100%; max-width: none; }

/* login */
.login-wrap { min-height: 80vh; display: grid; place-items: center; }
.login { width: min(380px, 92vw); padding: 1.75rem; }
.login h1 { margin-bottom: .4rem; color: var(--brand); }
.login h1 span { color: var(--accent); }
.login .btn.win { margin-bottom: .75rem; }
.login .or { text-align: center; color: var(--muted); font-size: .8rem; margin: .25rem 0 .75rem; }
.login .btn.block + .btn.block { margin-top: .5rem; }

/* tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: .5rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; }
.table.compact th, .table.compact td { padding: .32rem .5rem; }
.table tfoot th, .table tfoot td { font-weight: 700; border-top: 2px solid var(--line); }
.muted-row td, .muted-row th { color: #98a3af; }
td.details { max-width: 420px; word-break: break-word; font-size: .8rem; }
.table-scroll.short { max-height: 260px; }
.table-scroll { overflow: auto; max-height: calc(100vh - 210px); border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }

/* main grid */
.grid { border-collapse: separate; border-spacing: 0; font-size: .85rem; }
.grid th, .grid td { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 0; background: #fff; }
.grid thead th { position: sticky; top: 0; z-index: 3; background: #eef2f7; padding: .35rem .4rem; font-weight: 600; }
.grid thead tr:first-child th { height: 52px; }
.grid thead tr:nth-child(2) th { top: 52px; height: 26px; }
.grid .sticky-col { position: sticky; left: 0; z-index: 2; min-width: 230px; max-width: 280px; text-align: left; padding: .35rem .55rem; }
.grid .sticky-col2 { position: sticky; left: 230px; z-index: 2; min-width: 64px; padding: .35rem .45rem; }
.grid thead .sticky-col, .grid thead .sticky-col2 { z-index: 5; }
.grid th.proj { font-weight: 600; }
.grid th.proj a { color: var(--ink); text-decoration: none; }
.grid th.proj a:hover { text-decoration: underline; }
.grid th.proj small, .grid .commit-row small { display: block; font-weight: 400; color: var(--muted); font-size: .75rem; }
.grid td.totals { padding: .35rem .45rem; white-space: nowrap; color: var(--muted); }
.person-head { min-width: 120px; text-align: center; }
.person-head .avail { display: flex; justify-content: center; gap: .45rem; font-weight: 400; font-size: .72rem; color: var(--muted); margin-top: .2rem; white-space: nowrap; }
.person-head.over { background: var(--bad-bg) !important; }
.person-head.over .rem { color: var(--bad); font-weight: 700; }
.grid th.sub { font-size: .72rem; color: var(--muted); text-align: center; }
.grid th.sub.closed { background: #f3e1e1; }
.grid td.pc { background: var(--plan); }
input.cell { width: 3.6rem; border: 0; border-radius: 0; padding: .4rem .3rem; text-align: right; background: transparent; font-variant-numeric: tabular-nums; }
input.cell:not([readonly]):hover { background: #eef5fd; }
input.cell:focus { background: #fff; outline: 2px solid var(--brand-2); outline-offset: -2px; }
input.cell.act { color: #234; }
input.cell.boxed { border: 1px solid #c8d1db; border-radius: 6px; width: 5.5rem; background: #fff; }
input.cell.boxed[readonly] { border-color: transparent; background: transparent; }
input.cell.var-over { background: var(--bad-bg); }
input.cell.var-under { background: var(--warn-bg); }
input.cell.saving { opacity: .5; }
input.cell.saved { background: var(--ok-bg); transition: background .6s; }
.flag-over { background: var(--bad-bg) !important; color: var(--bad); font-weight: 600; }
.flag-under { background: var(--warn-bg) !important; color: var(--warn); }
.group-row th { background: #e9eef5 !important; font-weight: 700; color: var(--brand); }
.commit-row th, .commit-row td { background: var(--commit) !important; color: #5b4d7a; font-style: italic; padding: .35rem .45rem; }
.grid.annual td { padding: .3rem .35rem; min-width: 2.6rem; }
.grid.annual td.yc { cursor: pointer; }
.grid.annual td.yc:hover { background: #eef5fd; }
.grid.annual .total { background: #f1f3f5; font-weight: 600; }
.grid.annual.editable td.pc { padding: 0; }
.grid.annual.editable input.cell { width: 2.9rem; padding: .3rem .25rem; }
.grid.annual td.locked { background: #f3eded; color: #8a7f7f; }
.grid.annual .monthlink { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.grid.annual .monthlink:hover { text-decoration: underline; }
.grid.annual th.sub.current { background: var(--accent); color: #1b2430; }
.grid.annual td.current { box-shadow: inset 2px 0 0 var(--accent), inset -2px 0 0 var(--accent); }
.grid.annual .newyear { border-left: 2px solid #9fb3c8; }
.grid.annual .summary-row th, .grid.annual .summary-row td { background: #f8fafc; }
.grid.annual .summary-row td.over { background: var(--bad-bg); }
.grid.annual .person-head.year .avail { font-size: .7rem; }
.spread-grid td input.cell { width: 4rem; }
.spread-grid input.cell.flag-over { outline: 2px solid var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin-top: .6rem; font-size: .8rem; color: var(--muted); align-items: center; }
.lg::before { content: ""; display: inline-block; width: .85rem; height: .85rem; border-radius: 3px; margin-right: .35rem; vertical-align: -2px; border: 1px solid rgba(0, 0, 0, .1); }
.lg.over::before, .lg.varover::before, .lg.h-over::before { background: var(--bad-bg); }
.lg.under::before { background: var(--warn-bg); }
.lg.avail::before { background: #9fc3e7; }
.lg.alloc::before { background: var(--brand); }
.lg.h-free::before { background: #cdebd8; } .lg.h-some::before { background: #e6f3d3; } .lg.h-busy::before { background: #fbecc4; } .lg.h-full::before { background: #f6d2a8; }

/* KPIs */
.kpis { display: flex; flex-wrap: wrap; gap: .6rem; }
.kpi { background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: .5rem .75rem; min-width: 105px; }
.kpi span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.kpi strong { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.kpi.big strong { font-size: 1.7rem; color: var(--brand); }
.kpi.neg strong { color: var(--bad); }

/* badges */
.badge { display: inline-block; padding: .08rem .5rem; border-radius: 10px; font-size: .74rem; font-weight: 600; background: #eef2f7; color: #445; margin-right: .25rem; white-space: nowrap; }
.badge.ok, .badge.active { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.onhold { background: var(--warn-bg); color: var(--warn); }
.badge.bad, .badge.closed { background: var(--bad-bg); color: var(--bad); }
.badge.info, .badge.pipeline { background: var(--info-bg); color: var(--info); }

/* bars - widths by class (no inline styles) */
.fitbar, .utilbar, .progress { display: inline-block; width: 90px; height: 8px; background: #edf1f5; border-radius: 4px; overflow: hidden; vertical-align: middle; }
.fitbar i, .utilbar i, .progress i { display: block; height: 100%; background: var(--brand-2); }
.utilbar i.over { background: var(--bad); } .utilbar i.under { background: var(--accent); }
.w0 { width: 0; } .w1 { width: 10%; } .w2 { width: 20%; } .w3 { width: 30%; } .w4 { width: 40%; } .w5 { width: 50%; }
.w6 { width: 60%; } .w7 { width: 70%; } .w8 { width: 80%; } .w9 { width: 90%; } .w10 { width: 100%; }

/* dashboard */
.headline { border-top: 4px solid var(--accent); }
.headline-top { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; align-items: flex-start; }
.chart { width: 100%; max-width: 900px; height: auto; display: block; margin-top: .5rem; }
.chart .gridline { stroke: #e7ecf1; }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart .axis.spare { font-weight: 700; fill: var(--ok); }
.chart .axis.spare.neg { fill: var(--bad); }
.chart .bar.avail { fill: #9fc3e7; }
.chart .bar.alloc { fill: var(--brand); }
.chart .bar.alloc.over { fill: var(--bad); }
.heatmap { border-collapse: collapse; font-size: .82rem; }
.heatmap th, .heatmap td { padding: .35rem .6rem; border: 1px solid #fff; text-align: center; }
.heatmap tbody th { text-align: left; background: #f8fafc; }
.h-free { background: #cdebd8; } .h-some { background: #e6f3d3; } .h-busy { background: #fbecc4; } .h-full { background: #f6d2a8; } .h-over { background: #f2b8b8; color: var(--bad); font-weight: 700; } .h-none { background: #eef0f2; color: #98a3af; }
ul.warnings { list-style: none; margin: 0; padding: 0; max-height: 360px; overflow: auto; }
ul.warnings li { padding: .45rem .6rem; border-left: 4px solid var(--info); background: var(--info-bg); margin-bottom: .35rem; border-radius: 4px; }
ul.warnings li.warning { border-color: var(--accent); background: var(--warn-bg); }
ul.warnings li.critical { border-color: var(--bad); background: var(--bad-bg); }
.month-strip { display: grid; grid-template-columns: repeat(12, 1fr); gap: .3rem; margin: .5rem 0 1rem; }
.mcell { text-align: center; padding: .35rem; background: #f4f6f9; border-radius: 4px; font-size: .8rem; }
.mcell span { display: block; color: var(--muted); }
.mcell.up { background: var(--info-bg); } .mcell.down { background: var(--warn-bg); }

/* project page */
.months-form { display: grid; grid-template-columns: repeat(12, 1fr); gap: .35rem; margin-top: .6rem; }
label.mini { display: flex; flex-direction: column; font-size: .75rem; color: var(--muted); gap: .2rem; }
label.mini input { width: 100%; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 35, .45); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: #fff; border-radius: 10px; width: min(520px, 100%); max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal.wide { width: min(1100px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; }
.modal-body { padding: 1rem; overflow: auto; }
.popup-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: stretch; }
.year-pick { display: flex; align-items: center; gap: .3rem; margin-left: auto; }

/* toasts */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .4rem; z-index: 200; max-width: 420px; }
.toast { padding: .65rem .9rem; border-radius: 6px; background: #263446; color: #fff; box-shadow: var(--shadow); }
.toast.success { background: var(--ok); } .toast.error { background: var(--bad); }

/* help */
.help-layout { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; align-items: start; }
.help-toc { position: sticky; top: 70px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; font-size: .85rem; }
.help-toc ul { list-style: none; padding: 0; margin: .4rem 0 0; }
.help-toc li { margin: .25rem 0; }
.help { max-width: 900px; line-height: 1.55; }
.help h1 { margin-bottom: .75rem; } .help h2 { margin-top: 1.6rem; padding-top: .4rem; border-top: 1px solid var(--line); }
.help pre { background: #f4f6f9; padding: .75rem; border-radius: 6px; overflow: auto; }
.help code { background: #f1f3f5; padding: 0 .25rem; border-radius: 3px; }
.help blockquote { border-left: 4px solid var(--accent); margin: .5rem 0; padding: .3rem .8rem; background: var(--warn-bg); }
.feature-group h3 { margin-top: 1rem; }
ul.features li { margin: .25rem 0; }

@media (max-width: 900px) {
  .two-col, .help-layout, .form.grid2 { grid-template-columns: 1fr; }
  .months-form { grid-template-columns: repeat(6, 1fr); }
  .topbar { height: auto; flex-wrap: wrap; padding: .5rem 1rem; gap: .5rem; }
  .grid .sticky-col { min-width: 160px; }
  .grid .sticky-col2 { left: 160px; }
}
@media print {
  .topbar, .toolbar, .subnav, #toasts { display: none !important; }
  .table-scroll { max-height: none; overflow: visible; }
}
