
@font-face {
  font-family: "Wix Madefor Display";
  src: url("assets/wix.ttf") format("truetype");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "Instrument Sans";
  src: url("assets/instrument.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

@font-face {
  font-family: "Source Code Pro";
  src: url("assets/mono.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f4f6fa;
  --surface: #ffffff;
  --sidebar: #ffffff;
  --subtle: #f2f4fa;
  --hover: #e9edf7;
  --active: #e9edf8;
  --text: #191b23;
  --muted: #434655;
  --line: #dce0ea;
  --control-line: #788195;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #244aab;
  --focus: #255bd3;
  --on-primary: #ffffff;
  --brand-accent: #ffcc00;
  --chart-blue: #3b82f6;
  --chart-violet: #a855f7;
  --chart-amber: #fbbf24;
  --chart-green: #22c55e;
  --chart-track: #e5e8f1;
  --blue-bg: #e7efff;
  --blue-ink: #174594;
  --violet-bg: #f0e9ff;
  --violet-ink: #5d3493;
  --danger-bg: #fce7e9;
  --danger-ink: #932039;
  --amber-bg: #fff0c8;
  --amber-ink: #694500;
  --green-bg: #dcf4e7;
  --green-ink: #135b35;
  --shadow: 0 2px 6px #171c3510;
  --font-body: "Instrument Sans", system-ui, sans-serif;
  --font-display: "Wix Madefor Display", "Instrument Sans", system-ui, sans-serif;
  --font-data: "Source Code Pro", ui-monospace, Consolas, monospace;
}

body.dark {
  color-scheme: dark;
  --canvas: #11131b;
  --surface: #1d1f27;
  --sidebar: #191b23;
  --subtle: #252834;
  --hover: #2d3140;
  --active: #30384e;
  --text: #e1e2ed;
  --muted: #c3c6d7;
  --line: #3a3f50;
  --control-line: #8c95aa;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-text: #bad0ff;
  --focus: #a4c4ff;
  --chart-track: #33384b;
  --blue-bg: #243856;
  --blue-ink: #b9d0ff;
  --violet-bg: #392c53;
  --violet-ink: #e1caff;
  --danger-bg: #4a2734;
  --danger-ink: #ffc2cc;
  --amber-bg: #47391f;
  --amber-ink: #ffdf8a;
  --green-bg: #203d30;
  --green-ink: #a3ebbd;
  --shadow: 0 2px 6px #08091233;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 0;
  background: var(--canvas);
  color: var(--text);
  font: 400 0.875rem/1.45 var(--font-body);
  accent-color: var(--primary);
}

::selection { background: var(--blue-bg); color: var(--blue-ink); }

:where(h1, h2, h3, p, figure) { margin: 0; }

:where(h1, h2, h3) {
  color: var(--text);
  font-family: var(--font-display);
  line-height: 1.28;
}

h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -0.025em; }
h2 { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 0.9375rem; font-weight: 700; }

a { color: var(--primary-text); }
button, input, select, textarea { color: inherit; font: inherit; }
button, select, summary { cursor: pointer; }
button:disabled, select:disabled { cursor: default; opacity: 0.56; }
button { touch-action: manipulation; }
img, svg { max-width: 100%; }
svg { flex-shrink: 0; vertical-align: middle; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 5;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--surface);
  transform: translateY(calc(-100% - 12px));
}

.skip-link:focus { transform: none; }

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.sidebar {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 12px;
  padding: 12px 20px 0;
  background: var(--sidebar);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  width: fit-content;
  min-width: 120px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 8px;
}

body.dark .brand { background: #ffffff; }
.brand img { display: block; width: 132px; max-width: none; height: auto; }

.nav {
  display: flex;
  gap: 6px;
  margin-inline: -4px;
  padding: 4px 4px 9px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--control-line) transparent;
  overscroll-behavior-inline: contain;
}

.nav button {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px 13px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  white-space: nowrap;
  font-weight: 600;
}

.nav button:hover { background: var(--hover); color: var(--text); }

.nav button:is(.active, [aria-current="page"], [aria-pressed="true"]) {
  color: var(--primary-text);
  background: var(--active);
}

.side-foot { display: none; }
.workspace {
  display: grid;
  width: min(100%, 1440px);
  min-width: 0;
  gap: 20px;
  padding: 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  min-width: 0;
}

.topbar > *, #content { min-width: 0; }
.topbar .pick, .topbar .theme-button { border-color: var(--control-line); }
:is(#storage-note, #toast):empty { display: none; }

:where(#storage-note, .feedback, .error, .form-error) {
  color: var(--danger-ink);
}

#storage-note:not(:empty) {
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--danger-bg);
}

.btn, .dash-pills button, .dash-task-link, .dash-metric, .nav button {
  transition: background-color 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}

.btn {
  display: inline-flex;
  max-width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid var(--control-line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.btn:hover:not(:disabled) { background: var(--hover); }
.btn:active:not(:disabled), .dash-pills button:active { background: var(--active); }

.btn.primary, button.primary {
  border-color: transparent;
  background: var(--primary);
  color: var(--on-primary);
}

:is(.btn.primary, button.primary):hover:not(:disabled) { background: var(--primary-hover); }
.btn.quiet, .btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { width: 44px; padding-inline: 0; }

.panel, .card, .lane {
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
}

.panel {
  box-shadow: var(--shadow);
}

.panel-head, .toolbar, .form-row, .chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.panel-head, .toolbar { justify-content: space-between; }
.panel-head { margin-bottom: 14px; }
.panel-head > *, .toolbar > *, .form-row > * { min-width: 0; }

.grid, .stack, .lane, .task-card {
  display: grid;
  gap: 12px;
  align-content: start;
}

.grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }
.board { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.lane { background: var(--subtle); }

.task-card {
  width: 100%;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: start;
  overflow-wrap: anywhere;
}

button.task-card:hover { border-color: var(--focus); }

.field {
  display: grid;
  min-width: 0;
  gap: 6px;
  font-weight: 600;
}

:where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--control-line);
  border-radius: 8px;
  background: var(--surface);
  caret-color: var(--focus);
}

textarea { min-height: 88px; resize: vertical; }
:where(input, textarea)::placeholder { color: var(--muted); opacity: 1; }
:where(input, select, textarea)[aria-invalid="true"] { border-color: var(--danger-ink); }

:where(input[type="checkbox"], input[type="radio"]) {
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: middle;
}

.chips { gap: 4px; }

.chip {
  --chip-bg: var(--subtle);
  --chip-ink: var(--muted);
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-ink);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chip.danger { --chip-bg: var(--danger-bg); --chip-ink: var(--danger-ink); }
.chip.amber { --chip-bg: var(--amber-bg); --chip-ink: var(--amber-ink); }
.chip.blue { --chip-bg: var(--blue-bg); --chip-ink: var(--blue-ink); }
.chip.violet { --chip-bg: var(--violet-bg); --chip-ink: var(--violet-ink); }
.chip.green { --chip-bg: var(--green-bg); --chip-ink: var(--green-ink); }

:is(.workspace, #detail) .chip:is(.danger, .amber, .green, .blue, .violet) {
  background: var(--chip-bg);
  color: var(--chip-ink);
}

.empty {
  padding: 16px;
  border-radius: 10px;
  background: var(--subtle);
  color: var(--muted);
}

.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; }

dialog {
  width: min(calc(100% - 24px), 640px);
  max-height: calc(100dvh - 24px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 14px 44px #0a102b44;
  overflow: auto;
  overscroll-behavior: contain;
}

dialog::backdrop { background: #0e142e80; }

.dashboard,
.dash-overview,
.dash-middle,
.dash-charts,
.dash-actions,
.dash-kpis,
.dash-rings,
.dash-small-kpis {
  display: grid;
  min-width: 0;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.dash-middle, .dash-charts, .dash-actions { align-content: start; }
.dash-kpis, .dash-rings, .dash-small-kpis { gap: 16px; }
.dash-charts { grid-row: 2; }
.dash-small-kpis { grid-row: 1; }

.dash-metric {
  display: grid;
  width: 100%;
  align-content: start;
  gap: 4px;
  padding: 16px 18px;
  text-align: start;
}

.dash-metric:hover { background: var(--subtle); border-color: var(--control-line); }
.dash-metric:active { background: var(--active); }
.dash-metric[aria-pressed="true"] { border-color: var(--focus); }
.dash-metric:focus-visible { outline-offset: 2px; }

.dash-metric-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-weight: 650;
}

.dash-icon {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  place-items: center;
  border-radius: 9px;
}

.dash-icon-violet { background: var(--violet-bg); color: var(--violet-ink); }
.dash-icon-danger { background: var(--danger-bg); color: var(--danger-ink); }
.dash-icon-amber { background: var(--amber-bg); color: var(--amber-ink); }
.dash-icon-blue { background: var(--blue-bg); color: var(--blue-ink); }

.dash-metric-number, .dash-ring-number {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.dash-metric-number { font-size: 2rem; line-height: 1.06; }
.dash-small-kpis .dash-metric-number { font-size: 1.625rem; }

.dash-caption {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
}

.dash-ring-panel {
  display: flex;
  min-height: 188px;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.dash-ring-number {
  display: block;
  margin-top: 4px;
  font-size: 1.625rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.dash-ring-detail {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}

.dash-legend {
  display: grid;
  flex: 1;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.75rem;
}

.dash-legend li {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 5px;
}

.dash-legend strong {
  color: var(--text);
  font-family: var(--font-data);
  font-weight: 600;
}

.legend-marker {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-blue { background: var(--chart-blue); }
.legend-violet { background: var(--chart-violet); }
.legend-amber { background: var(--chart-amber); }
.legend-green { background: var(--chart-green); }

.dash-ring {
  display: block;
  position: relative;
  flex: 0 0 84px;
  width: 84px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--ring, var(--chart-track));
}

.dash-ring-panel:last-child .dash-ring { flex-basis: 96px; width: 96px; }

.dash-ring::after {
  position: absolute;
  inset: 12px;
  border-radius: inherit;
  background: var(--surface);
  content: "";
}

.dash-panel-head {
  min-height: 42px;
  align-items: center;
  margin-bottom: 12px;
}

.dash-panel-head h2 { margin-bottom: 2px; }

.dash-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.dash-pills button {
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid var(--control-line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

.dash-pills button:hover { background: var(--hover); }
.dash-pills button[aria-pressed="true"] {
  border-color: var(--focus);
  background: var(--active);
  color: var(--primary-text);
}

.chart-empty {
  display: grid;
  min-height: 176px;
  place-items: center;
  text-align: center;
}

.chart-caption {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
  font: 500 0.6875rem/1.3 var(--font-data);
}

.chart-axis-y {
  display: flex;
  height: 176px;
  flex-direction: column;
  justify-content: space-between;
  padding-block: 5px;
  text-align: end;
}

.chart-series { position: relative; min-width: 0; }
.chart-guides {
  position: absolute;
  inset: 12px 0 auto;
  display: flex;
  height: 153px;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
}

.chart-guides i { width: 100%; border-top: 1px dashed var(--line); }

.chart-points, .chart-axis-x {
  display: grid;
  grid-template-columns: repeat(var(--buckets), minmax(0, 1fr));
  text-align: center;
}

.chart-points { position: relative; height: 176px; }
.chart-point { position: relative; min-width: 0; }
.chart-track {
  position: absolute;
  inset: 12px auto 12px 50%;
  display: flex;
  width: min(40%, 13px);
  align-items: flex-end;
  justify-content: stretch;
  border-radius: 999px;
  background: var(--chart-track);
  transform: translateX(-50%);
}

.chart-track i {
  width: 100%;
  height: var(--height);
  border-radius: 999px;
  background: var(--chart-blue);
}

.chart-value {
  position: absolute;
  bottom: calc(13px + var(--height) * 0.86);
  left: 50%;
  min-width: 1rem;
  color: var(--text);
  font-size: 0.6875rem;
  transform: translate(-50%, -2px);
  z-index: 1;
}

.dash-chart-line .chart-value {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--surface);
  transform: translate(-50%, -4px);
}

.chart-marker {
  position: absolute;
  bottom: calc(12px + var(--height) * 0.86);
  left: 50%;
  width: 7px;
  height: 7px;
  border: 1px solid var(--surface);
  border-radius: 50%;
  background: var(--chart-violet);
  transform: translate(-50%, 50%);
}

.chart-line {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 176px;
  overflow: visible;
}

.chart-line path {
  fill: none;
  stroke: var(--chart-violet);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3px;
}

.chart-axis-x {
  margin-top: 5px;
  font-variant-numeric: tabular-nums;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--control-line) transparent;
  overscroll-behavior-inline: contain;
}

.data-table {
  width: 100%;
  border-spacing: 0 8px;
  text-align: start;
  font-size: 0.8125rem;
}

.data-table th, .data-table td {
  padding: 8px;
  text-align: start;
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table th {
  padding-block: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
}

.data-table td { background: var(--subtle); }
.data-table tr td:first-child { border-radius: 8px 0 0 8px; }
.data-table tr td:last-child { border-radius: 0 8px 8px 0; }
.data-table time { font-size: 0.75rem; font-family: var(--font-data); color: var(--muted); }
.dash-event-label { display: block; margin-bottom: 2px; }

.priority-table { table-layout: fixed; }
.priority-table th:nth-child(1) { width: 24%; }
.priority-table th:nth-child(2) { width: 16%; }
.priority-table th:nth-child(3) { width: 19%; }
.priority-table th:nth-child(4) { width: 20%; }
.priority-table th:nth-child(5) { width: 21%; }
.priority-table tbody tr { position: relative; }
.priority-table tbody tr:is(:hover, :focus-within) td { background: var(--hover); }

.dash-task-link {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--primary-text);
  font-weight: 650;
  text-align: start;
  text-decoration: underline;
  text-underline-offset: 0.16em;
  overflow-wrap: anywhere;
}

.dash-task-link::after { position: absolute; inset: 0; border-radius: 8px; content: ""; }
.dash-task-link:focus-visible::after { box-shadow: inset 0 0 0 2px var(--focus); }
.task-history-table { min-width: 640px; }
.task-history-table th:first-child { width: 180px; }

@media (max-width: 639px) {
  .workspace { padding-inline: 16px; }
  .sidebar { padding-inline: 16px; }
  .panel, .card, .lane { padding: 16px; }
  .dash-metric { padding: 12px 14px; }
  .dash-metric-number { font-size: 1.75rem; }
  .dash-kpis, .dash-rings, .dash-small-kpis { gap: 10px; }
  .dash-overview, .dash-middle, .dash-actions { display: contents; }
  .dash-kpis { order: 1; }
  .dash-priority { order: 2; }
  .dash-rings { order: 3; }
  .dash-small-kpis { order: 4; }
  .dash-charts { order: 5; grid-row: auto; }
  .dash-history { order: 6; }
  .dash-small-kpis { grid-row: auto; }
  .dash-pills button, .topbar .theme-button, #detail .icon-btn { min-height: 44px; }
  .topbar .theme-button, #detail .icon-btn { min-width: 44px; }
  .chart-axis-x { font-size: 0.625rem; }

  .priority-table, .priority-table tbody { display: block; }

  .priority-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .priority-table tbody { display: grid; gap: 8px; }
  .priority-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    gap: 6px 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: var(--subtle);
  }

  .priority-table tbody td { padding: 0; background: transparent; }
  .priority-table tbody tr:is(:hover, :focus-within) { background: var(--hover); }
  .priority-table tbody tr:is(:hover, :focus-within) td { background: transparent; }
  .priority-table td:first-child, .priority-table td:last-child { grid-column: 1 / -1; }
  .priority-table td[data-label]::before {
    display: block;
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.6875rem;
  }

  .priority-table td:last-child::before { margin-bottom: 3px; }
}

@media (min-width: 640px) {
  .dash-kpis, .dash-rings, .dash-small-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dash-metric { min-height: 122px; }
  .dash-small-kpis .dash-metric { min-height: 112px; }
}

@media (min-width: 1024px) {
  .shell { grid-template-columns: 228px minmax(0, 1fr); }
  .workspace { padding: 24px; }
  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    gap: 24px;
    padding: 24px 20px 20px;
    border-bottom: 0;
    border-right: 1px solid var(--line);
    overflow-y: auto;
  }

  .brand { padding: 4px 8px; }
  .brand img { width: 145px; }
  .nav { flex-direction: column; overflow-x: visible; }
  .nav button { width: 100%; }
  .side-foot {
    display: grid;
    gap: 6px;
    margin-top: auto;
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--subtle);
  }

  .side-foot strong::before {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-inline-end: 6px;
    border-radius: 50%;
    background: var(--brand-accent);
    content: "";
  }

  .side-foot p { color: var(--muted); font-size: 0.75rem; }
  .side-foot .btn { margin-top: 4px; justify-self: start; }
}

@media (min-width: 1280px) {
  .dash-overview, .dash-middle { grid-template-columns: repeat(12, minmax(0, 1fr)); }
  .dash-overview > *, .dash-middle > * { grid-column: span 6; }
  .dash-charts { grid-area: 1 / 1 / auto / span 6; }
  .dash-actions { grid-area: 1 / 7 / auto / span 6; }
  .dash-ring-panel { min-height: 100%; }
  .dash-ring-detail { flex-wrap: wrap-reverse; }
  .dash-ring { margin-inline-start: auto; }
  .dash-legend { min-width: 98px; }
  .priority-table th, .priority-table td { padding-inline: 6px; }
}

@media (min-width: 1400px) {
  .dash-ring-detail { flex-wrap: nowrap; }
  .dash-legend { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
