/* GreenArrow Project — light/dark theme via tokens. data-theme on <html> wins over the OS. */
:root {
  --app-header-h: 53px;
  color-scheme: light;
  --bg: #f6f7f5;
  --surface: #ffffff;
  --surface-2: #f0f2ee;
  --border: #e1e4dd;
  --text: #15171a;
  --text-2: #4d5257;
  --text-muted: #80868b;
  --accent: #1f8a4c;
  --accent-ink: #ffffff;
  --danger: #c8342f;
  --danger-bg: #fdecea;
  --warn-bg: #fff4dc;
  --warn-ink: #7a4b00;
  --ok-bg: #e5f5ea;
  --ok-ink: #145c32;
  --wtd-bg-l: .93; --wtd-ink-l: .40; --wip-bg-l: .50; --wip-ink: #ffffff;
  --done-bg: #d9f2e1; --done-ink: #145c32;
  --skip-bg: #ebecee; --skip-ink: #5b6168;
  --chart-surface: #fcfcfb;
  --grid: #e6e7e3;
  --series-summary: #0b0b0b;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #6250d6;
  --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 16px rgb(0 0 0 / 6%);
  --radius: 10px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --bg: #111312; --surface: #1a1c1b; --surface-2: #222524; --border: #2e3230;
    --text: #eceeea; --text-2: #b9bdb7; --text-muted: #868b86;
    --accent: #3fb36d; --accent-ink: #08130c;
    --danger: #ff6b63; --danger-bg: #3a1716; --warn-bg: #3a2c10; --warn-ink: #f5cd7a;
    --ok-bg: #12301f; --ok-ink: #8fe0ad;
    --wtd-bg-l: .80; --wtd-ink-l: .30; --wip-bg-l: .48; --wip-ink: #ffffff;
    --done-bg: #143222; --done-ink: #8fe0ad; --skip-bg: #2a2d2c; --skip-ink: #a3a8a4;
    --chart-surface: #1a1a19; --grid: #2c2d2a; --series-summary: #f0efec;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111312; --surface: #1a1c1b; --surface-2: #222524; --border: #2e3230;
  --text: #eceeea; --text-2: #b9bdb7; --text-muted: #868b86;
  --accent: #3fb36d; --accent-ink: #08130c;
  --danger: #ff6b63; --danger-bg: #3a1716; --warn-bg: #3a2c10; --warn-ink: #f5cd7a;
  --ok-bg: #12301f; --ok-ink: #8fe0ad;
  --wtd-bg-l: .80; --wtd-ink-l: .30; --wip-bg-l: .48; --wip-ink: #ffffff;
  --done-bg: #143222; --done-ink: #8fe0ad; --skip-bg: #2a2d2c; --skip-ink: #a3a8a4;
  --chart-surface: #1a1a19; --grid: #2c2d2a; --series-summary: #f0efec;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #0ca30c; --series-7: #9085e9;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 4px 16px rgb(0 0 0 / 30%);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.45; }
a { color: inherit; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0; }
.muted { color: var(--text-muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Header & nav */
.app-header {
  position: sticky; top: 0; z-index: 20; height: var(--app-header-h); box-sizing: border-box;
  display: flex; align-items: center; gap: 24px;
  padding: 10px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink); font-size: 13px; }
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--text-2); font-weight: 500; }
.tab:hover { background: var(--surface-2); }
.tab[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }

main { padding: 20px 24px 60px; max-width: 1800px; margin: 0 auto; }

/* Buttons & inputs */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.05); background: var(--accent); }
.btn-danger { color: var(--danger); }
.btn-small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn[disabled] { opacity: .6; cursor: default; }
.btn-icon { width: 32px; padding: 0; justify-content: center; }
input, select { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; height: 30px; padding: 0 8px; }
input:focus, select:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { color: var(--text-2); font-size: 12px; font-weight: 500; }
.field { display: flex; flex-direction: column; gap: 4px; }
.button_to { display: inline; }

/* Toolbar */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.team-picker { margin: 0; }
.team-picker select { font-size: 15px; font-weight: 600; }
.sync-status { display: inline-flex; align-items: center; gap: 8px; color: var(--text-2); }
.spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Flash & banners */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash-notice { background: var(--ok-bg); color: var(--ok-ink); }
.flash-alert { background: var(--danger-bg); color: var(--danger); }
.flash-warn { background: var(--warn-bg); color: var(--warn-ink); }
.flash ul { margin: 6px 0 0; padding-left: 18px; }

/* Cards & tables */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; }
.card-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-body { padding: 16px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; color: var(--text-2); font-weight: 600; background: var(--surface); position: sticky; top: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }

/* Status report */
/* Fixed layout so the table always fits the window: the project column takes a share of the
   width, the number and initiative columns are fixed, and the phase columns split the rest. */
table.report { table-layout: fixed; min-width: 960px; }
/* No scroll container around the report, so its headers stick to the window, just under the app header. */
.report-wrap { overflow: visible; }
.report thead th { top: var(--app-header-h); z-index: 5; box-shadow: inset 0 -1px 0 var(--border); }
.report th, .report td { white-space: normal; overflow-wrap: anywhere; padding: 6px 8px; }
.report th { vertical-align: bottom; line-height: 1.25; overflow-wrap: break-word; hyphens: auto; }
.report .col-project { width: 19%; }
.report .col-points { width: 64px; }
.report .col-left { width: 62px; } /* fits a total like 187.5 */
/* Numbers never wrap; their columns are sized to fit them. */
.report td.num { white-space: nowrap; overflow-wrap: normal; }
.report th.num, .report td.num, .report .points-input { text-align: center; }
/* No spinner arrows on points, so the whole box shows the value (arrow keys still step it). */
.report .points-input { width: 100%; padding: 4px 6px; -moz-appearance: textfield; appearance: textfield; }
.report .points-input::-webkit-inner-spin-button,
.report .points-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.report th.phase-col { text-align: center; padding-left: 3px; padding-right: 3px; font-size: 11px; }
.group-row td { background: var(--surface-2); font-weight: 600; cursor: pointer; }
.group-row .caret { display: inline-block; transition: transform .15s; margin-right: 4px; }
tbody.collapsed .caret { transform: rotate(-90deg); }
tbody.collapsed tr.project-row, tbody.collapsed tr.done-row { display: none; }
.done-row td { color: var(--text-muted); font-size: 12px; font-style: italic; }
.done-row td:first-child { padding-left: 24px; }
.done-row a { color: inherit; text-decoration: none; }
.done-row a:hover { text-decoration: underline; }
.total-row td { font-weight: 700; border-top: 2px solid var(--border); }
.project-cell { display: flex; align-items: flex-start; gap: 2px; margin-left: -6px; }
.drag-handle {
  flex: none; cursor: grab; color: var(--text-muted); padding: 0 2px; border-radius: 4px;
  font-size: 15px; line-height: 20px; opacity: 0; user-select: none;
}
tr.project-row:hover .drag-handle, .group-row:hover .drag-handle, .drag-handle:focus-visible { opacity: 1; }
.drag-handle:hover { background: var(--surface-2); }
.drag-handle { touch-action: none; }
/* While dragging: rows slide out of the way (transform only, so it stays on the compositor);
   the lifted row follows the pointer with no transition. */
tbody.sorting { user-select: none; cursor: grabbing; }
tbody.sorting tr.project-row { transition: transform 140ms cubic-bezier(.2, 0, 0, 1); }
tbody.sorting tr.project-row:hover td { background: transparent; }
tbody.sorting tr.lifted { transition: none; position: relative; z-index: 6; filter: drop-shadow(0 6px 14px rgb(0 0 0 / .18)); }
tbody.sorting tr.lifted td { background: var(--surface); }
tbody.sorting tr.lifted .drag-handle { opacity: 1; cursor: grabbing; }
/* The same while dragging a whole initiative group (a <tbody>) within a team's table. */
table.sorting { user-select: none; cursor: grabbing; }
table.sorting > tbody { transition: transform 140ms cubic-bezier(.2, 0, 0, 1); }
table.sorting > tbody.lifted { transition: none; position: relative; z-index: 6; filter: drop-shadow(0 6px 14px rgb(0 0 0 / .18)); }
table.sorting > tbody.lifted td { background: var(--surface); }
table.sorting > tbody.lifted .group-row td { background: var(--surface-2); }
table.sorting > tbody.lifted .group-row .drag-handle { opacity: 1; cursor: grabbing; }
.project-name a { text-decoration: none; font-weight: 500; }
.project-name a:hover { text-decoration: underline; }
.badge-warn { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 600; cursor: help; }
.points-input { width: 64px; text-align: right; }
.hidden-status { color: var(--text-muted); font-size: 11px; text-transform: uppercase; margin-left: 6px; }
tr.is-hidden td { opacity: .6; }
.cell-error { color: var(--danger); font-size: 11px; white-space: normal; max-width: 200px; }

/* Phase cells */
.report td.phase-cell { text-align: center; padding: 4px 3px; position: relative; }
.phase { position: relative; display: block; container-type: inline-size; }
.phase > summary { list-style: none; cursor: pointer; }
.phase > summary::-webkit-details-marker { display: none; }
.pill {
  display: flex; align-items: center; gap: 4px; justify-content: center;
  max-width: 100%; padding: 2px 6px; border-radius: 999px; font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden;
}
.pill .state { flex: none; }
.pill .who { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
/* Narrow phase columns: the name goes under the state instead of being cut off. */
@container (max-width: 96px) {
  .pill { flex-direction: column; gap: 0; border-radius: 8px; line-height: 1.2; padding: 2px 4px; }
  .pill .who { max-width: 100%; font-size: 11px; }
  .pill .sep { display: none; }
}
/* WTD and WIP take the assignee's hue: a light tint for WTD, a dark fill for WIP. Hues are
   chosen to skip green (Done) and grey (Skipped). */
.pill-wtd, .pill-wip { --h: 0; --c: 0; }
.pill-wtd { background: oklch(var(--wtd-bg-l) calc(var(--c) * .45) var(--h)); color: oklch(var(--wtd-ink-l) var(--c) var(--h)); }
.pill-wip { background: oklch(var(--wip-bg-l) var(--c) var(--h)); color: var(--wip-ink); }
.pill-wtd.color-none { box-shadow: inset 0 0 0 1px var(--border); }
.color-blue { --h: 245; --c: .13; }  .color-red { --h: 25; --c: .14; }    .color-purple { --h: 305; --c: .13; }
.color-amber { --h: 75; --c: .11; }  .color-teal { --h: 195; --c: .10; }  .color-pink { --h: 355; --c: .14; }
.color-orange { --h: 50; --c: .13; } .color-indigo { --h: 275; --c: .13; } .color-cyan { --h: 220; --c: .11; }
.color-magenta { --h: 330; --c: .14; }
.pill-done { background: var(--done-bg); color: var(--done-ink); }
.pill-skipped { background: var(--skip-bg); color: var(--skip-ink); }
.pill-skipped .state { text-decoration: line-through; }
.pill-done .who, .pill-skipped .who { opacity: .6; font-weight: 400; }
.pill-idle { color: var(--text-muted); }
.pill-idle:hover { background: var(--surface-2); }
.popover {
  position: fixed; z-index: 30; top: 0; left: 0;
  width: 240px; padding: 12px; text-align: left; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.popover .actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* Move-to-initiative button after the project name (opens the same popover as a phase cell);
   faint until the row is hovered, like the drag handle. */
/* Row actions after the project name (move to initiative, mark done); faint until the row is hovered.
   One flex row so every icon sits on the same line whatever element wraps it. */
.row-actions { display: inline-flex; align-items: center; gap: 0; vertical-align: -4px; margin-left: 2px; }
.row-actions > .phase.move, .row-actions > .row-action-form { display: flex; container-type: normal; }
.row-action {
  display: inline-grid; place-items: center; width: 22px; height: 20px; padding: 0;
  border: 0; background: none; border-radius: 5px; color: var(--text-muted); opacity: 0; cursor: pointer;
}
.row-action svg { width: 14px; height: 14px; }
tr.project-row:hover .row-action, .row-action:focus-visible, details[open] > .row-action { opacity: 1; }
.row-action:hover, details[open] > .row-action { background: var(--surface-2); color: var(--text); }
tr.project-row:hover .row-action.is-disabled { opacity: .35; }
.row-action.is-disabled { cursor: help; }
.row-action.is-disabled:hover { background: none; color: var(--text-muted); }
.row-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.popover select { width: 100%; }

/* Settings */
.phase-table { width: auto; }
.phase-table input[type=text] { width: 260px; }
.phase-table input[type=number] { width: 80px; text-align: right; }
.weight-total { font-weight: 700; }
.weight-total.bad { color: var(--danger); }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 380px; text-align: center; }
.login .card-body { display: flex; flex-direction: column; gap: 16px; padding: 32px; }

/* Burndown */
.chart svg { max-width: 1400px; }
.viz-root { background: var(--chart-surface); border-radius: var(--radius); }
.chart-wrap { position: relative; padding: 12px 16px 16px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .axis-label { fill: var(--text-muted); font-size: 11px; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: var(--chart-surface); stroke-width: 2; }
.chart .scope-line { fill: none; stroke-width: 1.5; stroke-dasharray: 5 4; opacity: .8; }
.chart .crosshair { stroke: var(--text-muted); stroke-width: 1; }
.chart .end-label { font-size: 11px; fill: var(--text-2); }
.chart [data-series].is-off { display: none; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 10px; padding: 0; list-style: none; }
.legend button { all: unset; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); padding: 2px 4px; border-radius: 4px; }
.legend button:focus-visible { outline: 2px solid var(--accent); }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; }
.legend button[aria-pressed="false"] { opacity: .45; }
.legend button[aria-pressed="false"] .label { text-decoration: line-through; }
.legend button.is-selected .label { color: var(--text); font-weight: 600; }
.tooltip {
  position: absolute; pointer-events: none; z-index: 10; min-width: 160px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px;
}
.tooltip .t-date { font-weight: 600; margin-bottom: 4px; color: var(--text); }
.tooltip .t-row { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
.tooltip .t-row .v { margin-left: auto; color: var(--text); font-variant-numeric: tabular-nums; padding-left: 10px; }
.tooltip .swatch { width: 8px; height: 8px; border-radius: 50%; }
.burndown-table td.metric { color: var(--text-2); }
.burndown-table tr.block-start td { border-top: 2px solid var(--border); }
.burndown-table td.init { font-weight: 600; }
/* Alternate initiatives are shaded so each block of metric rows reads as one unit. */
.burndown-table tbody.initiative-block:nth-of-type(even) td { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.burndown-table tbody tr:hover td { background: var(--surface-2); }
.empty { padding: 40px; text-align: center; color: var(--text-muted); }
.people-color { display: flex; align-items: center; gap: 8px; }
.people-color form { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
