:root {
  --bg: #f5f6f8; --panel: #fff; --text: #1d2330; --muted: #6b7280; --line: #e5e7eb;
  --accent: #2563eb; --accent-soft: #e8efff; --danger: #dc2626; --warn: #d97706; --ok: #16a34a;
  --side: #111827; --side-text: #cbd5e1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #171a21; --text: #e5e7eb; --muted: #9ca3af; --line: #2a2f3a;
    --accent: #60a5fa; --accent-soft: #1e2a44; --side: #0b0d11;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); text-decoration: none; }
code { font-size: 12px; }
.layout { display: flex; min-height: 100vh; }
.side { width: 190px; background: var(--side); color: var(--side-text); padding: 16px 10px; position: sticky; top: 0; height: 100vh; flex-shrink: 0; display: flex; flex-direction: column; }
.side .brand { font-weight: 700; font-size: 17px; color: #fff; padding: 4px 10px 16px; }
.side a { color: var(--side-text); padding: 8px 10px; border-radius: 6px; margin-bottom: 2px; }
.side a:hover { background: #1f2937; }
.side a.active { background: var(--accent); color: #fff; }
.side-foot { margin-top: auto; font-size: 11px; color: #6b7280; padding: 10px; }
main { flex: 1; padding: 24px 28px; min-width: 0; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.sub { color: var(--muted); margin-bottom: 18px; }
.bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.bar .grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.g2 { grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); }
.stat .n { font-size: 28px; font-weight: 700; }
.stat .l { color: var(--muted); }
button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text); padding: 6px 12px; border-radius: 6px; cursor: pointer; white-space: nowrap; display: inline-block; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.danger { color: var(--danger); }
button.sm, .btn.sm { padding: 2px 8px; font-size: 12px; }
input, select, textarea { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { width: 100%; min-height: 70px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; white-space: nowrap; background: var(--panel); position: sticky; top: 0; cursor: default; }
th.sortable { cursor: pointer; }
tr:hover td { background: var(--accent-soft); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { white-space: nowrap; text-align: right; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.tag.red { background: #fee2e2; color: #b91c1c; } .tag.yellow { background: #fef3c7; color: #92400e; } .tag.green { background: #dcfce7; color: #166534; } .tag.gray { background: #e5e7eb; color: #374151; }
.muted { color: var(--muted); }
.red { color: var(--danger); } .green { color: var(--ok); } .warn { color: var(--warn); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { color: var(--accent); border-color: var(--accent); font-weight: 600; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 20px; width: 100%; max-width: 640px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.form label.full { grid-column: 1 / -1; }
.form input, .form select { width: 100%; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast { position: fixed; bottom: 20px; right: 20px; background: #111827; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60; max-width: 420px; }
.toast.err { background: var(--danger); }
.hidden { display: none !important; }
.kanban { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.col { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px; min-height: 200px; }
.col.drag { outline: 2px dashed var(--accent); }
.col h3 { font-size: 13px; margin: 2px 4px 10px; display: flex; justify-content: space-between; }
.tcard { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; background: var(--bg); cursor: grab; }
.tcard .t { font-weight: 600; }
.tcard .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.phase-line { display: flex; gap: 0; margin: 8px 0 4px; }
.phase-line span { flex: 1; text-align: center; padding: 6px 4px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.phase-line span.done { background: var(--accent-soft); color: var(--accent); }
.phase-line span.cur { background: var(--accent); color: #fff; font-weight: 600; }
.drop { border: 2px dashed var(--line); border-radius: 10px; padding: 18px; text-align: center; color: var(--muted); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.empty { text-align: center; color: var(--muted); padding: 30px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
ul.plain li:last-child { border: 0; }
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .side { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .side .brand, .side-foot { display: none; }
  main { padding: 16px; }
  .form { grid-template-columns: 1fr; }
  .g2 { grid-template-columns: 1fr; }
}
