:root {
  --bg: #0f1419;
  --panel: #1a2027;
  --panel-2: #222b35;
  --line: #2e3a47;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4493f8;
  --green: #2ea043;
  --yellow: #d4a72c;
  --red: #e5534b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 40px;
  width: 340px;
  text-align: center;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .subtitle { color: var(--muted); margin: 0 0 24px; }
.login-card label { display: block; text-align: left; margin-bottom: 6px; color: var(--muted); }
.login-card input {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
  margin-bottom: 16px; font-size: 15px;
}
.login-card button {
  width: 100%; padding: 11px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:disabled { opacity: 0.6; cursor: default; }
.error { color: var(--red); margin: 12px 0 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; }
.controls { display: flex; align-items: center; gap: 16px; }
.brand-filter { color: var(--muted); }
.brand-filter select {
  margin-left: 6px; padding: 6px 10px; border-radius: 6px;
  background: var(--bg); color: var(--text); border: 1px solid var(--line);
}
.last-sync { color: var(--muted); font-size: 13px; }
.controls button {
  padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); cursor: pointer;
}
.controls button:hover { background: var(--line); }
.controls button:disabled { opacity: 0.6; cursor: default; }
.controls .ghost { background: transparent; }

main { padding: 24px; max-width: 1500px; margin: 0 auto; }
.loading { color: var(--muted); padding: 40px; text-align: center; }
section { margin-bottom: 40px; }
h2 { font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
h2 .count { color: var(--muted); font-weight: 400; margin-left: 6px; }
.empty { color: var(--muted); padding: 20px; }

/* ---------- Timeline ---------- */
.timeline { display: flex; flex-direction: column; }
.tl-row {
  display: grid;
  grid-template-columns: 220px 110px 110px 1fr;
  align-items: center;
  border-bottom: 1px solid var(--line);
  min-height: 38px;
}
.tl-head { color: var(--muted); font-weight: 600; border-bottom: 2px solid var(--line); }
.tl-label {
  padding: 6px 10px 6px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tl-brand, .tl-pct { padding: 6px 8px; }
.tl-track-head, .tl-track { position: relative; height: 100%; }
.months { display: grid; grid-template-columns: repeat(12, 1fr); height: 100%; }
.month-col {
  border-left: 1px solid var(--line); text-align: center; font-size: 12px;
  color: var(--muted); padding-top: 4px;
}
.months.bg { position: absolute; inset: 0; }
.month-col .yr { display: block; font-size: 10px; opacity: 0.6; }
.bar {
  position: absolute; top: 50%; transform: translateY(-50%); height: 20px;
  border-radius: 4px; cursor: pointer; display: flex; align-items: center;
  padding: 0 8px; overflow: hidden; box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.bar:hover { filter: brightness(1.15); }
.bar-date { font-size: 11px; color: #fff; white-space: nowrap; font-weight: 600; }
.bar.green { background: var(--green); }
.bar.yellow { background: var(--yellow); }
.bar.red { background: var(--red); }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px;
  font-weight: 600; cursor: help; border: 1px solid transparent;
}
.badge.green { background: rgba(46,160,67,0.15); color: #56d364; border-color: rgba(46,160,67,0.4); }
.badge.yellow { background: rgba(212,167,44,0.15); color: #e3b341; border-color: rgba(212,167,44,0.4); }
.badge.red { background: rgba(229,83,75,0.15); color: #ff7b72; border-color: rgba(229,83,75,0.4); }

/* ---------- Backlog table ---------- */
table.backlog { width: 100%; border-collapse: collapse; }
table.backlog th {
  text-align: left; color: var(--muted); font-weight: 600;
  padding: 8px 10px; border-bottom: 2px solid var(--line); font-size: 13px;
}
table.backlog td { padding: 7px 10px; border-bottom: 1px solid var(--line); }
table.backlog tr:hover td { background: var(--panel); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.set-date {
  padding: 4px 12px; border-radius: 6px; border: 1px solid var(--accent);
  background: transparent; color: var(--accent); cursor: pointer; font-size: 13px;
}
.set-date:hover { background: var(--accent); color: #fff; }

/* ---------- Tooltip ---------- */
.tooltip {
  position: absolute; z-index: 100; background: #000; border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; pointer-events: none; min-width: 200px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.tooltip ul { list-style: none; margin: 8px 0 0; padding: 0; }
.tooltip li { padding: 2px 0; font-size: 12px; }
.tooltip .ok { color: #56d364; }
.tooltip .no { color: var(--muted); }

/* ---------- Inline date editor ---------- */
.date-editor {
  position: absolute; z-index: 200; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  display: flex; align-items: center; gap: 8px; box-shadow: 0 6px 20px rgba(0,0,0,0.5);
}
.date-editor input[type="date"] {
  padding: 6px 8px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text);
}
.date-editor button {
  padding: 6px 12px; border-radius: 6px; border: 0; cursor: pointer; font-size: 13px;
}
.date-editor .save { background: var(--accent); color: #fff; }
.date-editor .clear { background: var(--panel); color: var(--muted); border: 1px solid var(--line); }
.date-editor .cancel { background: transparent; color: var(--muted); }
.date-editor .status { color: var(--muted); font-size: 12px; }
