/* OnTrack — single stylesheet, no build step. Light + dark via prefers-color-scheme. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e3e6eb;
  --text: #1b1f24;
  --muted: #667085;
  --accent: #0f7b5f;
  --accent-hover: #0b664e;
  --accent-soft: #e3f4ee;
  --on: #12805c;     --on-soft: #e3f4ec;
  --risk: #b25e09;   --risk-soft: #fdf0dc;
  --off: #c4320a;    --off-soft: #fde8e3;
  --done: #2c64c4;   --done-soft: #e5eefc;
  --idle: #667085;   --idle-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #222731;
    --border: #2e3440;
    --text: #e8eaee;
    --muted: #98a2b3;
    --accent: #3cc497;
    --accent-hover: #5bd3ab;
    --accent-soft: #163a2f;
    --on: #4fd3a0;     --on-soft: #143a2d;
    --risk: #f2b04f;   --risk-soft: #3d2c12;
    --off: #ff8466;    --off-soft: #43201a;
    --done: #7fa8ff;   --done-soft: #1c2a47;
    --idle: #98a2b3;   --idle-soft: #262b34;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0; display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
h2 { font-size: 1.1rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.strong { font-weight: 600; color: var(--text); }
.late { color: var(--off); font-weight: 600; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.main { padding-top: 24px; padding-bottom: 64px; }

/* Top bar */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 56px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px; background: var(--accent);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.18);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; left: 6px; top: 4px; width: 6px; height: 10px;
  border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
}
.nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; font-weight: 500; }
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--surface-2); }
.user-menu { display: flex; align-items: center; gap: 12px; }
.user-menu form { margin: 0; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--off); }

/* Page header */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.eyebrow a { color: var(--muted); }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 28px 0 10px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card + .card { margin-top: 12px; }
.table-card { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }

/* Messages */
.messages { margin-bottom: 16px; display: grid; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.msg-success { background: var(--on-soft); border-color: transparent; color: var(--on); }
.msg-error { background: var(--off-soft); border-color: transparent; color: var(--off); }
.msg-info, .msg-warning { background: var(--risk-soft); border-color: transparent; color: var(--risk); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-success { background: var(--on); }
.btn-danger { background: transparent; color: var(--off); border-color: var(--off); }
.btn-danger:hover { background: var(--off-soft); }
.btn-block { width: 100%; }
@media (prefers-color-scheme: dark) { .btn:not(.btn-secondary):not(.btn-ghost):not(.btn-danger) { color: #0d1512; } }

/* Stats */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-of { font-size: 1rem; color: var(--muted); font-weight: 500; }
.stat-label { color: var(--muted); font-size: .85rem; margin-bottom: 4px; }
.stat-off .stat-value { color: var(--off); }
.stat-risk .stat-value { color: var(--risk); }
.stat-on .stat-value { color: var(--on); }

/* Tables */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { text-align: center !important; color: var(--muted); padding: 28px !important; }
.is-done td { color: var(--muted); }
.is-done .task-title a { text-decoration: line-through; color: var(--muted); }
.is-mine td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.task-row td { font-weight: 500; }
.subtask-row td { font-size: .93rem; }
.subtask-row .task-title { padding-left: 28px; }
.branch { color: var(--muted); margin-right: 4px; }
.row-actions { white-space: nowrap; text-align: right !important; font-size: .85rem; }
.row-actions a, .row-actions form { margin-left: 10px; display: inline; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; vertical-align: middle; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.health-on_track { color: var(--on); background: var(--on-soft); }
.health-at_risk { color: var(--risk); background: var(--risk-soft); }
.health-off_track { color: var(--off); background: var(--off-soft); }
.health-complete { color: var(--done); background: var(--done-soft); }
.health-not_started { color: var(--idle); background: var(--idle-soft); }
h1 .badge { font-size: .85rem; }

.status { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .8rem; font-weight: 600; white-space: nowrap; }
.status-not_started { color: var(--idle); background: var(--idle-soft); }
.status-in_progress { color: var(--done); background: var(--done-soft); }
.status-blocked { color: var(--off); background: var(--off-soft); }
.status-done { color: var(--on); background: var(--on-soft); }
.tag { display: inline-block; font-size: .7rem; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; }
.tag-high { background: var(--off-soft); color: var(--off); }
.due.overdue { color: var(--off); font-weight: 600; }
.due.soon { color: var(--risk); font-weight: 600; }

/* Progress */
.progress { display: inline-flex; align-items: center; gap: 8px; min-width: 140px; width: 100%; }
.progress-track { flex: 1; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 60px; }
.progress-fill { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.progress-label { font-size: .8rem; color: var(--muted); width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }
.stat .progress { margin-top: 6px; }

/* Health reasons */
.reasons { border-left: 4px solid var(--border); }
.reasons ul { margin: 6px 0 0; padding-left: 20px; }
.health-border-on_track { border-left-color: var(--on); }
.health-border-at_risk { border-left-color: var(--risk); }
.health-border-off_track { border-left-color: var(--off); }
.health-border-complete { border-left-color: var(--done); }

/* Inline status editing */
.inline-update { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.inline-update select, .inline-update input { padding: 3px 6px; font-size: .85rem; border-radius: 6px; }
.pct-input { width: 4.2em; }
.status-select { font-weight: 600; min-width: 8.5em; }

/* Forms */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%; max-width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-color: var(--accent); }
input[type="checkbox"] { width: auto; }
.form-card { max-width: 760px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 600; font-size: .9rem; }
.field-title, .field-name, .field-description, .field-notes, .field-body, .field-email { grid-column: 1 / -1; }
.field-check { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 8px; }
.help { color: var(--muted); font-size: .8rem; }
.error { color: var(--off); font-size: .85rem; font-weight: 500; }
.has-error input, .has-error select, .has-error textarea { border-color: var(--off); }
.form-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.danger-zone { margin-top: 24px; max-width: 760px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); }
.segmented a { padding: 6px 14px; color: var(--muted); font-weight: 500; }
.segmented a.active { background: var(--surface-2); color: var(--text); }
.segmented a:hover { text-decoration: none; }

/* Task detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.update-card { border-color: var(--accent); }
.update-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.update-row label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: .85rem; }
.update-row select { min-width: 150px; }
.update-row input { width: 100px; }
.prose p:first-child { margin-top: 0; }
.prose p:last-child { margin-bottom: 0; }
.facts dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 12px; margin: 0; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0; }
.activity .event { font-size: .85rem; padding: 8px 0; border-top: 1px solid var(--border); }
.activity .event:first-of-type { border-top: 0; padding-top: 0; }
.comment { padding: 10px 0; border-bottom: 1px solid var(--border); }
.comment:first-child { padding-top: 0; }
.comment-meta { margin-bottom: 4px; }
.comment-form { margin-top: 14px; display: grid; gap: 8px; justify-items: start; }

/* Burn-up */
.chart-card { padding: 16px 16px 12px; }
.burnup { width: 100%; height: auto; display: block; }
.burnup .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; }
.burnup .axis { stroke: var(--border); stroke-width: 1; }
.burnup .line-total { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.burnup .line-earned { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.burnup .dot-earned { fill: var(--accent); }
.burnup .axis-label { fill: var(--muted); font-size: 11px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); margin-top: 6px; }
.key { display: inline-block; width: 16px; height: 0; border-top: 2.5px solid var(--accent); margin-left: 8px; }
.key:first-child { margin-left: 0; }
.key-total { border-top: 1.5px dashed var(--muted); }

/* Auth */
.auth-card { max-width: 400px; margin: 48px auto; padding: 28px; }
.auth-card h1 { margin-bottom: 14px; }
.auth-card form { display: grid; gap: 14px; margin-bottom: 12px; }
.auth-card .form-grid { grid-template-columns: 1fr; }

@media (max-width: 760px) {
  .topbar-inner { gap: 8px 16px; padding-top: 8px; padding-bottom: 8px; }
  .user-name { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  h1 { font-size: 1.35rem; }
  .table th, .table td { padding: 8px 10px; }
}
