:root {
  --bg0: #0f1714;
  --bg1: #16201c;
  --bg2: #1d2a25;
  --line: #2a3b34;
  --text: #e7eee9;
  --muted: #8aa297;
  --accent: #2dd4a8;
  --accent-dim: #1a9e7c;
  --plan: #5b7c8a;
  --danger: #f87171;
  --row-h: 56px;
  --label-w: min(360px, 42vw);
  --day-w: 28px;
  --radius: 10px;
  --font: "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1f3d33 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #243528 0%, transparent 50%),
    linear-gradient(180deg, var(--bg0), #0b1210 70%);
}

.app {
  max-width: 1600px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #0ea5e9);
  box-shadow: 0 0 0 1px rgba(45,212,168,.35);
}
.brand h1 {
  margin: 0; font-size: 1.45rem; letter-spacing: .02em; font-weight: 700;
}
.brand p { margin: 2px 0 0; color: var(--muted); font-size: .82rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.meta-text { color: var(--muted); font-size: .8rem; }

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
}
.filters label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .72rem; color: var(--muted); letter-spacing: .04em;
}
.filters label.grow { grid-column: span 1; }
.filters select,
.filters input,
.dialog label select,
.dialog label input {
  font: inherit;
  color: var(--text);
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}
.filters input { width: 100%; }

.legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin: 12px 0 8px; color: var(--muted); font-size: .8rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch {
  width: 12px; height: 12px; border-radius: 3px; display: inline-block;
}
.swatch.plan { background: var(--plan); }

.btn {
  font: inherit; cursor: pointer;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 12px;
}
.btn:hover { border-color: var(--accent-dim); }
.btn.primary {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: #04241a;
  font-weight: 600;
}
.btn.ghost { background: transparent; }

.loading, .error {
  margin-top: 16px; padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg1);
}
.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }

.gantt-shell {
  display: grid;
  grid-template-columns: var(--label-w) 1fr;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: color-mix(in srgb, var(--bg1) 92%, transparent);
  min-height: 320px;
}
.gantt-sidebar { border-right: 1px solid var(--line); background: var(--bg1); }
.sidebar-head, .timeline-head {
  height: 44px;
  display: flex; align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--line);
  font-size: .75rem;
  color: var(--muted);
  background: var(--bg2);
  position: sticky; top: 0; z-index: 2;
}
.timeline-head {
  overflow: hidden;
  padding: 0;
}
.day-scale {
  display: flex; height: 100%;
  min-width: max-content;
}
.day-cell {
  width: var(--day-w);
  flex: 0 0 var(--day-w);
  border-right: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  display: flex; flex-direction: column; justify-content: center; align-items: center;
  font-size: .65rem;
}
.day-cell.weekend { background: rgba(0,0,0,.18); }
.day-cell .d { color: var(--text); font-weight: 600; }
.day-cell .m { color: var(--muted); }

.sidebar-row, .timeline-row {
  height: var(--row-h);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 75%, transparent);
}
.sidebar-row {
  display: flex; flex-direction: column; justify-content: center;
  padding: 6px 12px; gap: 2px;
}
.sidebar-row.group {
  background: #20332c;
  font-weight: 600;
  font-size: .85rem;
}
.issue-key {
  font-family: var(--mono);
  font-size: .72rem;
  color: var(--accent);
}
.issue-summary {
  font-size: .78rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.issue-sub {
  font-size: .68rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.edit-btn {
  margin-left: auto;
  font-size: .68rem;
  padding: 2px 8px;
}
.row-top {
  display: flex; align-items: center; gap: 8px;
}

.gantt-main { overflow: auto; }
.timeline-body { min-width: max-content; }
.timeline-row {
  position: relative;
  min-width: max-content;
}
.timeline-row.group { background: #20332c; }
.grid-bg {
  position: absolute; inset: 0; display: flex; pointer-events: none;
}
.grid-day {
  width: var(--day-w); flex: 0 0 var(--day-w);
  border-right: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}
.grid-day.weekend { background: rgba(0,0,0,.12); }
.bars {
  position: relative;
  height: 100%;
  padding: 8px 0;
}
.bar-plan, .bar-actual-wrap {
  position: absolute;
  left: 0; height: 12px;
  border-radius: 4px;
}
.bar-plan {
  top: 8px;
  background: var(--plan);
  opacity: .9;
}
.bar-actual-wrap {
  top: 28px;
  display: flex;
  overflow: hidden;
  background: transparent;
}
.seg {
  height: 100%;
  min-width: 2px;
}
.seg[title] { cursor: help; }
.today-line {
  position: absolute; top: 0; bottom: 0; width: 2px;
  background: var(--accent);
  opacity: .7; z-index: 1; pointer-events: none;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg1);
  color: var(--text);
  padding: 0;
  width: min(420px, 92vw);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
#editForm {
  display: flex; flex-direction: column; gap: 10px;
  padding: 18px;
}
#editForm h2 { margin: 0; font-size: 1.05rem; }
.edit-key { margin: 0; font-family: var(--mono); color: var(--accent); }
#editForm label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: .78rem; color: var(--muted);
}
.dialog-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px;
}

@media (max-width: 960px) {
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  :root { --label-w: min(280px, 48vw); --day-w: 24px; --row-h: 60px; }
}
@media (max-width: 640px) {
  .filters { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}
