:root {
  --bg: #f5f6f8; --panel: #ffffff; --panel-2: #eef0f4; --text: #1d2433; --muted: #6a7487; --line: #dde1e8; --line-2: #eceff4;
  --accent: #2f6fdb; --accent-soft: #e5eefc; --bar: #4a86e8; --bar-done: #2a5db5; --crit: #d64545; --crit-done: #9b2b2b;
  --summary: #2b3a55; --ghost: #9aa3b5; --off: rgba(100, 110, 130, 0.07); --hol: rgba(214, 140, 60, 0.16);
  --today: #2f6fdb; --status: #1f9d6b; --good: #1f8a5b; --bad: #c93b3b; --sel: rgba(47, 111, 219, 0.1); --over: #d64545; --ok: #5b8def;
  --shadow: 0 1px 2px rgba(20, 30, 50, 0.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --panel: #1a2030; --panel-2: #222a3d; --text: #e4e8f1; --muted: #8e99b0; --line: #2d364b; --line-2: #252d40;
    --accent: #6aa0ff; --accent-soft: #223256; --bar: #5b8def; --bar-done: #3b64c0; --crit: #ec6a6a; --crit-done: #b04444;
    --summary: #a9b6d3; --ghost: #5d6880; --off: rgba(255, 255, 255, 0.035); --hol: rgba(230, 160, 80, 0.14);
    --today: #6aa0ff; --status: #3fc592; --good: #4cc790; --bad: #f07878; --sel: rgba(106, 160, 255, 0.14); --over: #ec6a6a; --ok: #5b8def;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 13px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; display: flex; flex-direction: column; }
button, select, input, textarea { font: inherit; color: inherit; }
button, select, summary { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer; }
button:hover:not(:disabled), summary:hover { background: var(--panel-2); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.08); background: var(--accent); }
button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
input, textarea, select { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.bad { color: var(--bad); }
.good { color: var(--good); }

.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; letter-spacing: 0.2px; }
.logo { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, var(--bar) 0 50%, var(--crit) 50%); display: inline-block; }
.proj-name { font-weight: 600; width: 230px; border-color: transparent; background: transparent; }
.proj-name:hover, .proj-name:focus { border-color: var(--line); background: var(--panel); }
.group { display: flex; align-items: center; gap: 4px; }
.group.dim { opacity: 0.4; pointer-events: none; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-body { position: absolute; z-index: 20; top: 32px; left: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px; display: flex; flex-direction: column; gap: 2px; min-width: 170px; box-shadow: 0 6px 22px rgba(10, 20, 40, 0.18); max-height: 70vh; overflow: auto; }
.menu-body button { text-align: left; border: 0; background: transparent; }
.menu-body label { display: flex; gap: 6px; padding: 2px 6px; white-space: nowrap; cursor: pointer; }
.zoom { margin-left: auto; }

.tabs { display: flex; gap: 2px; padding: 0 14px; background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; padding: 8px 14px; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.split { flex: 1; min-height: 0; display: flex; background: var(--panel); }
.split[hidden], .other[hidden] { display: none; }
.pane { overflow: auto; position: relative; }
.tbl-pane { width: 830px; flex: none; overflow-x: scroll; overflow-y: scroll; scrollbar-width: none; outline: none; }
.tbl-pane::-webkit-scrollbar { display: none; }
.tbl-pane { overflow-x: auto; }
.gantt-pane { flex: 1; min-width: 0; overflow: scroll; }
.divider { width: 5px; flex: none; cursor: col-resize; background: var(--line); }
.divider:hover { background: var(--accent); }

.tbl { border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.tbl th { position: sticky; top: 0; z-index: 3; height: 44px; background: var(--panel-2); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line-2); text-align: left; padding: 0 6px; font-weight: 600; font-size: 12px; color: var(--muted); vertical-align: bottom; padding-bottom: 6px; }
.tbl td { height: 26px; padding: 0 6px; border-bottom: 1px solid var(--line-2); border-right: 1px solid var(--line-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: cell; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl td.ro { color: var(--muted); }
.tbl tr.summary td { font-weight: 600; background: var(--panel-2); }
.tbl tr.critical td[data-col="name"], .tbl tr.critical td[data-col="finish"] { color: var(--crit); }
.tbl tr.negfloat td[data-col="float"] { color: var(--bad); font-weight: 700; }
.tbl tr.sel-row td { background: var(--sel); }
.tbl td.sel { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--accent-soft); }
.tbl td.editing { padding: 0; }
.cell-input { width: 100%; height: 100%; border: 2px solid var(--accent); border-radius: 0; padding: 0 4px; background: var(--panel); }
.twist { border: 0; background: none; padding: 0; width: 16px; color: var(--muted); }
.twist-gap { display: inline-block; width: 16px; }
.dia { color: var(--summary); margin-right: 4px; }

.g-head { position: sticky; top: 0; z-index: 3; display: block; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.g-body { display: block; }
.g-head text { fill: var(--text); font-size: 11px; }
.g-head .hs { fill: var(--muted); }
.g-head .c { text-anchor: middle; }
.g-head .dim { opacity: 0.6; font-size: 9px; }
.hl { stroke: var(--line); stroke-width: 1; }
.rowline { stroke: var(--line-2); }
.vline { stroke: var(--line-2); }
.selrow { fill: var(--sel); }
.off { fill: var(--off); }
.hol { fill: var(--hol); }
.today { stroke: var(--today); stroke-width: 1.5; stroke-dasharray: 4 3; }
.status { stroke: var(--status); stroke-width: 1.5; }
text.mark { font-size: 10px; stroke: none; }
text.today { fill: var(--today); }
text.status { fill: var(--status); }
.bar.task, .bar.critical { stroke: none; }
.bar.task { fill: var(--bar); }
.bar.critical { fill: var(--crit); }
.bar-g .done { fill: var(--bar-done); }
.bar-g.critical .done { fill: var(--crit-done); }
.bar-g .bar, .bar-g .done { cursor: grab; }
.handle { fill: transparent; cursor: ew-resize; }
.bar-g:hover .handle { fill: rgba(255, 255, 255, 0.5); }
.ms { fill: var(--summary); }
.ms.critical { fill: var(--crit); }
.sum { fill: var(--summary); }
.sumdone { fill: var(--accent); opacity: 0.7; }
.ghost { fill: var(--ghost); opacity: 0.8; }
.dep { fill: none; stroke: var(--muted); stroke-width: 1.1; }
.dep.crit { stroke: var(--crit); }
.mk { fill: var(--muted); }
.mk.crit { fill: var(--crit); }
.lbl { font-size: 11px; fill: var(--muted); pointer-events: none; }
.lbl.bold { font-weight: 600; fill: var(--text); }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }

.status { display: flex; gap: 18px; padding: 6px 14px; background: var(--panel); border-top: 1px solid var(--line); font-size: 12px; flex-wrap: wrap; }
.status b { color: var(--muted); font-weight: 600; margin-right: 4px; }
.grow { flex: 1; }

.other { flex: 1; overflow: auto; padding: 16px; }
.panel-wrap { max-width: 1280px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.card h2 { margin: 0 0 10px; font-size: 16px; }
.card h3 { margin: 0 0 8px; font-size: 14px; }
.card h3 small { font-weight: 400; margin-left: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.controls { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 6px; }
.controls label { display: flex; align-items: center; gap: 6px; }
.controls input[type="number"] { width: 90px; }
.chart-scroll { overflow-x: auto; }
.chart { display: block; max-width: 100%; }
table.kv, table.form-table { border-collapse: collapse; width: 100%; }
.kv th, .kv td, .form-table th, .form-table td { padding: 5px 8px; border-bottom: 1px solid var(--line-2); text-align: left; }
.kv th, .form-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.kv td.num, .kv th.num { text-align: right; }
.form-table input { width: 100%; }
.form-table input.wide { min-width: 240px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.stat { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--panel-2); }
.stat.accent { border-color: var(--accent); background: var(--accent-soft); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 12px; }
.chip { display: inline-block; background: var(--accent-soft); border-radius: 10px; padding: 1px 8px; margin: 2px 2px; font-size: 12px; }
.chip.warn { background: rgba(214, 69, 69, 0.15); color: var(--bad); }
.barcell { width: 55%; }
.bar-inline { display: block; height: 10px; border-radius: 3px; background: var(--crit); }

.chart text { fill: var(--muted); font-size: 10px; }
.chart .axis.r { text-anchor: end; }
.chart .axis.c { text-anchor: middle; }
.chart .grid { stroke: var(--line-2); }
.chart .axisline { stroke: var(--muted); }
.bar-ok { fill: var(--ok); }
.bar-over { fill: var(--over); }
.bar-ghost { fill: none; stroke: var(--text); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.55; }
.bar-pos { fill: var(--crit); }
.bar-neg { fill: var(--ok); }
.cap { fill: none; stroke: var(--text); stroke-width: 1.4; stroke-dasharray: 5 3; }
.curve { fill: none; stroke: var(--accent); stroke-width: 2.2; }
.guide { stroke: var(--muted); stroke-dasharray: 3 3; }
.p50 { stroke: var(--good); stroke-width: 2; } .p80 { stroke: var(--accent); stroke-width: 2; } .p95 { stroke: var(--bad); stroke-width: 2; } .det { stroke: var(--text); stroke-dasharray: 4 3; }
.chart text.mk-label { font-size: 11px; font-weight: 600; }
.chart text.p50 { fill: var(--good); stroke: none; } .chart text.p80 { fill: var(--accent); stroke: none; } .chart text.p95 { fill: var(--bad); stroke: none; } .chart text.det { fill: var(--text); stroke: none; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 18px 22px; min-width: 380px; }
dialog::backdrop { background: rgba(10, 15, 30, 0.45); }
.settings { display: flex; flex-direction: column; gap: 12px; }
.settings h2 { margin: 0; }
.settings label { display: flex; flex-direction: column; gap: 4px; }
.settings label.inline { flex-direction: row; display: inline-flex; margin-right: 10px; }
.settings fieldset { border: 1px solid var(--line); border-radius: 8px; }
.actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast { position: fixed; left: 50%; bottom: 46px; transform: translate(-50%, 20px); background: #1f2a44; color: #fff; padding: 9px 16px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all 0.2s; max-width: 80vw; z-index: 50; box-shadow: 0 6px 24px rgba(0,0,0,0.3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a82f2f; }

@media print {
  @page { size: landscape; margin: 10mm; }
  body { display: block; height: auto; background: #fff; }
  .topbar .group, .tabs, .status, .divider, .toast { display: none !important; }
  .topbar { border: 0; padding: 0 0 6px; }
  .proj-name { border: 0; font-size: 16px; }
  .split { display: block; height: auto; }
  .pane, .tbl-pane, .gantt-pane { overflow: visible !important; width: auto !important; }
  .tbl-pane { margin-bottom: 12px; }
  .g-head, .tbl th { position: static; }
  .gantt-pane { zoom: 0.6; }
  .tbl td.sel { outline: 0; background: none; }
  .tbl tr.sel-row td { background: none; }
  .selrow { display: none; }
}
