:root {
  --bg: #f5f6f8; --card: #fff; --ink: #1d2330; --muted: #6b7385; --line: #e3e6ec;
  --accent: #9c1b2e; --accent-soft: #f6e5e8; --blue: #2f6db5; --ok: #2e7d4f; --warn: #b26a00;
  --radius: 10px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 14px; }
code { background: #eef0f4; padding: 1px 5px; border-radius: 4px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: var(--card);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 700; color: var(--accent); font-size: 17px; }
.brand span { color: var(--ink); font-weight: 400; }
.stepper { display: flex; gap: 6px; }
.stepper button { border: none; background: none; padding: 8px 14px; border-radius: 999px; color: var(--muted); cursor: pointer; font-size: 14px; }
.stepper button b { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--line); color: var(--ink); margin-right: 6px; font-size: 12px; }
.stepper button.active { background: var(--accent-soft); color: var(--accent); }
.stepper button.active b { background: var(--accent); color: #fff; }
.stepper button:disabled { opacity: .45; cursor: default; }

.step { padding: 20px 24px; max-width: 1500px; margin: 0 auto; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card-head h2 { margin: 0 0 4px; font-size: 18px; }
.card-head p { margin: 0 0 12px; }
.card-head.row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0; }
.toolbar label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
button, .btn, select, input[type=search], input[type=number], input[type=text], input[type=email], textarea {
  font: inherit; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 6px 10px; color: var(--ink); }
input[type=number] { width: 80px; }
input[type=search] { min-width: 220px; }
button, .btn { cursor: pointer; text-decoration: none; display: inline-block; }
button:hover, .btn:hover { border-color: #c5cad4; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; padding: 8px 16px; }
button.primary:disabled { opacity: .5; cursor: wait; }
button.ghost, .btn.ghost { background: transparent; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.paste { margin: 6px 0 10px; }
.paste summary { cursor: pointer; color: var(--blue); }
.paste textarea { width: 100%; margin: 8px 0; font-family: ui-monospace, Menlo, monospace; font-size: 12px; }

.table-wrap { overflow: auto; max-height: 52vh; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap.tall { max-height: calc(100vh - 260px); }
table.grid { border-collapse: collapse; width: 100%; }
.grid th, .grid td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.grid th { background: #fafbfc; position: sticky; top: 0; z-index: 1; font-weight: 600; font-size: 12px; color: var(--muted); white-space: nowrap; }
.grid th[data-sort] { cursor: pointer; }
.grid th.sorted::after { content: " ▾"; }
.grid th.sorted.asc::after { content: " ▴"; }
.grid td input { width: 100%; border-color: transparent; background: transparent; }
.grid td input:focus { border-color: var(--blue); background: #fff; outline: none; }
.grid td input.bad { border-color: #d33; background: #fff4f4; }
.grid .num { text-align: right; white-space: nowrap; }
.grid td.date { white-space: nowrap; }
.grid tr.proj { cursor: pointer; }
.grid tr.proj:hover { background: #fafbfd; }
.grid tr.proj.off { color: #9aa1af; }
.grid tr.detail td { background: #fbfbfd; padding: 12px 16px 16px 46px; }
.grid td.title { max-width: 460px; }
.del { border: none; background: none; color: var(--muted); font-size: 16px; padding: 0 6px; }

.actions { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.errors:empty { display: none; }
.errors { background: #fff7e8; border: 1px solid #f1d9a8; color: #7a4b00; border-radius: 8px; padding: 8px 12px; margin: 8px 0; font-size: 13px; }
.errors ul { margin: 4px 0 0 18px; padding: 0; }

.progress { margin-top: 14px; }
.progress .bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.progress .bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.progress .muted { margin-top: 6px; font-size: 13px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #eef1f6; border-radius: 99px; padding: 2px 9px; font-size: 12px; white-space: nowrap; }
.chip.feup { background: var(--accent-soft); color: var(--accent); }
.chip.mine { background: #e3eefb; color: var(--blue); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.detail-grid h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.mini { border-collapse: collapse; width: 100%; font-size: 13px; }
table.mini td, table.mini th { padding: 3px 8px 3px 0; border-bottom: 1px solid var(--line); text-align: left; }
table.mini th { color: var(--muted); font-weight: 600; font-size: 12px; }

/* graph */
.graph-layout { display: grid; grid-template-columns: 1fr 360px; gap: 16px; }
.graph-card { position: relative; padding: 10px 14px; }
#graph { height: calc(100vh - 190px); min-height: 480px; border: 1px solid var(--line); border-radius: 8px; background: #fcfcfd; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: none; border-radius: 0; padding: 7px 14px; }
.seg button.active { background: var(--accent); color: #fff; }
.legend { position: absolute; left: 26px; bottom: 34px; background: rgba(255,255,255,.92); border: 1px solid var(--line);
  border-radius: 8px; padding: 6px 10px; font-size: 12px; display: flex; flex-wrap: wrap; gap: 10px; max-width: 70%; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.legend .cat { cursor: pointer; padding: 1px 6px; border-radius: 99px; border: 1px solid transparent; user-select: none; }
.legend .cat:hover { border-color: var(--line); }
.legend .cat.on { border-color: #1d2330; font-weight: 600; }
.legend .cat.off { opacity: .45; }
.graph-stats { font-size: 12px; margin-top: 6px; }
.side { max-height: calc(100vh - 110px); overflow: auto; }
.side h3 { margin: 0 0 4px; font-size: 16px; }
.side .sub { color: var(--muted); margin-bottom: 12px; font-size: 13px; }
.plist { list-style: none; padding: 0; margin: 0; }
.plist li { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; cursor: pointer; }
.plist li:hover { border-color: var(--accent); background: var(--accent-soft); }
.plist li b { display: block; }
.plist li small { color: var(--muted); }

.modal { position: fixed; inset: 0; background: rgba(20,24,34,.45); display: grid; place-items: center; z-index: 20; padding: 20px; }
.modal-box { background: #fff; border-radius: 12px; max-width: 920px; width: 100%; max-height: 90vh; overflow: auto; padding: 24px 28px; position: relative; }
.modal-box h2 { margin: 0 24px 4px 0; font-size: 20px; }
.modal .close { position: absolute; top: 12px; right: 14px; border: none; font-size: 24px; background: none; }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 4px 14px; margin: 14px 0; font-size: 13px; }
.kv div:nth-child(odd) { color: var(--muted); }
.summary { white-space: pre-wrap; line-height: 1.5; font-size: 13px; background: #fafbfc; border-radius: 8px; padding: 10px 14px; }

@media (max-width: 1000px) {
  .graph-layout { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 10px 16px; }
  .step { padding: 16px; }
}

.stat { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.stat > .muted { font-size: 12px; margin-bottom: 4px; }
.stat-row { display: flex; justify-content: space-between; padding: 2px 0; }
.stat-row b { font-variant-numeric: tabular-nums; }
.side h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
