:root {
  --bg: #fff;
  --surface: #fff;
  --ink: #1c1c1a;
  --muted: #74746e;
  --line: #e3e3dd;
  --line-strong: #c9c9c1;
  --accent: #2f6b4f;
  --accent-soft: #e5efe9;
  --warn: #94570a;
  --warn-soft: #fbf0df;
  --neg: #a33a2b;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 13px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; margin: 0; }
.muted { color: var(--muted); }
.neg { color: var(--neg); }
.pos { color: var(--accent); }
.warn { color: var(--warn); }
.nowrap { white-space: nowrap; }

.top { display: flex; justify-content: space-between; align-items: center; height: 44px;
  padding: 0 20px; background: #fafaf8; border-bottom: 1px solid var(--line); }
.top-left, .top-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { font-weight: 600; color: var(--ink); }
.sep { color: var(--line-strong); }
.co { color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { color: var(--muted); }
.role { border: 1px solid var(--line-strong); padding: 1px 7px; font-size: 11.5px; color: var(--muted); }
.role-consultant { border-color: var(--accent); color: var(--accent); }

.tabs { display: flex; gap: 2px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; }
.tabs a { padding: 9px 12px 8px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }

main { padding: 16px 20px 40px; max-width: 1480px; }
main.narrow { max-width: 760px; }
.bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-bottom: 12px; }
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.filters label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.check input { margin: 0; }

input, select, textarea, button { font: inherit; color: inherit; }
input[type=date], input[type=text], input[type=email], input[type=number], select, textarea {
  height: 28px; padding: 3px 7px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 0; }
textarea { height: auto; resize: vertical; }
input.short { width: 78px; }
input.mid { width: 190px; }
button { height: 28px; padding: 0 11px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
  cursor: pointer; border-radius: 0; white-space: nowrap; }
button:hover { background: #33332f; }
button.primary { background: var(--accent); border-color: var(--accent); }
button.primary:hover { background: #255a42; }
button.ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
button.ghost:hover { border-color: var(--ink); }
button.link { background: none; border: 0; color: var(--muted); padding: 0; height: auto; }
button.link:hover { color: var(--ink); }
button.wide { width: 100%; }
form.inline { display: inline-flex; gap: 4px; align-items: center; margin: 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.flash { padding: 7px 11px; margin-bottom: 10px; border: 1px solid var(--line-strong); background: var(--surface); }
.flash-ok { border-color: var(--accent); background: var(--accent-soft); }
.flash-err { border-color: var(--neg); background: #fbebe8; color: var(--neg); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 0 0 12px 1px; }
.kpis > div { background: var(--surface); padding: 8px 12px; display: flex; flex-direction: column; gap: 1px;
  border: 1px solid var(--line); margin: -1px 0 0 -1px; }
.kpis span { color: var(--muted); font-size: 11.5px; }
.kpis b { font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpis small { color: var(--muted); font-size: 11.5px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: start; }
.cols-wide { grid-template-columns: 1.7fr 1fr; }
.panel { background: var(--surface); border: 1px solid var(--line); margin-bottom: 12px; }
.panel.scroll { overflow-x: auto; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 8px 10px; border-bottom: 1px solid var(--line); min-height: 40px; }
.panel-head.spaced { border-top: 1px solid var(--line); margin-top: 14px; }

table.grid { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.grid th { text-align: left; font-weight: 500; color: var(--muted); font-size: 11.5px; padding: 6px 8px;
  border-bottom: 1px solid var(--line-strong); background: #fafaf8; white-space: nowrap; }
.grid td { padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tbody tr:hover td { background: #fafaf6; }
.grid .num { text-align: right; white-space: nowrap; }
.grid .code { color: var(--muted); white-space: nowrap; width: 1%; }
.grid .total { background: #fafaf8; }
.grid tr.group td { padding-top: 10px; color: var(--muted); font-size: 11.5px; border-bottom: 0; }
.grid tr.sub td { border-top: 1px solid var(--line-strong); font-weight: 500; }
.grid tr.sum td { background: #f6f6f2; font-weight: 600; border-top: 1px solid var(--line-strong); }
.grid tfoot td { font-weight: 600; border-top: 2px solid var(--ink); border-bottom: 0; padding: 7px 8px; }
.grid tr.picked td { background: var(--accent-soft); }
.grid tr.done td { color: var(--muted); }
.grid tr.low td { background: #fffdf8; }
.grid td.empty { color: var(--muted); padding: 14px 8px; text-align: center; }
.grid .desc { max-width: 280px; }
.grid .hint { max-width: 300px; }
.grid .note { max-width: 420px; }
.grid .why { color: var(--muted); font-size: 11.5px; }
.grid .act { text-align: right; white-space: nowrap; width: 1%; }
.grid .act form + form { margin-left: 4px; }
.grid.wide .name { min-width: 210px; white-space: nowrap; }
.grid .pick select { max-width: 190px; }

.conf { display: inline-block; min-width: 38px; padding: 0 5px; text-align: center; font-size: 11.5px; }
.conf.hi { background: var(--accent-soft); color: var(--accent); }
.conf.lo { background: var(--warn-soft); color: var(--warn); }
.tag { display: inline-block; padding: 0 6px; font-size: 11.5px; border: 1px solid var(--line-strong); color: var(--muted); }
.tag-closed { border-color: var(--accent); color: var(--accent); }
.tag-open { border-color: var(--warn); color: var(--warn); }

.seg { display: inline-flex; border: 1px solid var(--line-strong); }
.seg a { padding: 3px 10px; color: var(--muted); }
.seg a.on { background: var(--ink); color: #fff; }
.seg a:hover { text-decoration: none; }

.note-form { display: grid; grid-template-columns: 130px 1fr auto; gap: 6px; padding: 10px; align-items: start; }
.access-form { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; padding: 10px 10px 0; }
.access-form label { display: flex; gap: 6px; align-items: center; color: var(--muted); }
.foot { color: var(--muted); font-size: 11.5px; margin: 8px 10px 10px; }
.empty-page { color: var(--muted); padding: 30px 0; }

.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.gate-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); padding: 26px 26px 20px; }
.gate-box h1 { margin: 14px 0 6px; font-size: 19px; }
.gate-box p { margin: 0 0 16px; }
.gate-box label { display: flex; flex-direction: column; gap: 5px; color: var(--muted); margin-bottom: 12px; }
.gate-box input { height: 34px; }
.gate-box button { height: 34px; }
.gate-box .foot { margin: 14px 0 0; }
.code-input { letter-spacing: 0.3em; font-size: 17px; }

@media (max-width: 1080px) {
  .cols, .cols-wide { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  main { padding: 12px 10px 30px; }
  .panel { overflow-x: auto; }
  .grid td, .grid th { white-space: nowrap; }
  .grid .desc, .grid .note, .grid .hint { white-space: normal; min-width: 180px; }
  .top { padding: 0 10px; }
  .tabs { padding: 0 6px; }
  .who { display: none; }
  .grid .desc, .grid .hint { max-width: 180px; }
  .note-form { grid-template-columns: 1fr; }
}

.grid.wide .total { position: sticky; right: 0; box-shadow: -1px 0 0 var(--line); }
.grid.wide tfoot .total { background: var(--surface); }

details.more { display: inline-block; vertical-align: top; margin-left: 4px; text-align: left; }
details.more summary { list-style: none; cursor: pointer; height: 28px; line-height: 26px; padding: 0 10px;
  border: 1px solid var(--line-strong); color: var(--ink); }
details.more summary::-webkit-details-marker { display: none; }
details.more[open] summary { border-color: var(--ink); }
details.more form { display: flex; margin-top: 4px; }
