:root {
  color-scheme: light;
  --bg: #eef2ef;
  --card: #ffffff;
  --card-2: #f6f8f7;
  --text: #101a14;
  --text-2: #2c3a32;
  --muted: #5a6960;
  --line: #d3dcd6;
  --brand: #14532d;
  --brand-2: #1f7a3f;
  --brand-ink: #ffffff;
  --brand-soft: #dcefe1;
  --brand-text: #14532d;
  --chip: #e7ece9;
  --warn: #b45309;
  --warn-soft: #fdf0d8;
  --warn-text: #7c3a06;
  --err: #b42318;
  --err-soft: #fdecea;
  --ok: #1e7d3a;
  --ok-soft: #e3f4e7;
  --info-soft: #e5eefb;
  --info-text: #1d4f91;
  --shadow: 0 1px 2px rgba(16, 40, 25, .06), 0 6px 20px rgba(16, 40, 25, .06);
  --radius: 12px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1411;
  --card: #1a221e;
  --card-2: #212b26;
  --text: #f4f8f5;
  --text-2: #d5e0d9;
  --muted: #a6b5ac;
  --line: #36423b;
  --brand-soft: #1f3a2a;
  --brand-text: #9fe3ad;
  --chip: #2b3530;
  --warn: #f59e0b;
  --warn-soft: #44330f;
  --warn-text: #ffd98a;
  --err: #ff8a80;
  --err-soft: #3d1c1a;
  --ok: #8fe0a3;
  --ok-soft: #1c3a26;
  --info-soft: #1b2a40;
  --info-text: #a9c8f5;
  --shadow: none;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-text); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0 0 4px; }
h2 { font-size: 1.12rem; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.nowrap { white-space: nowrap; }

.top { background: linear-gradient(120deg, #14532d, #1f7a3f); color: var(--brand-ink); }
.top-in, .wrap { max-width: 1180px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top-in { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 18px; padding-top: 8px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; padding-bottom: 8px; color: inherit; text-decoration: none; }
.logo { flex: none; display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: #fff; }
.logo img { max-width: 31px; max-height: 31px; display: block; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 1.14rem; line-height: 1.15; }
.brand-text small { display: block; font-size: .72rem; opacity: .9; }
.tabs { display: flex; gap: 2px; align-self: flex-end; }
.tabs a { padding: 8px 16px; border-radius: 10px 10px 0 0; color: inherit; font-weight: 600; text-decoration: none; white-space: nowrap; }
.tabs a:hover { background: rgba(255, 255, 255, .14); }
.tabs a[aria-current="page"] { background: var(--bg); color: var(--brand-text); }
.top-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; padding-bottom: 8px; align-self: center; }
.who { font-size: .82rem; opacity: .92; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border: 1px solid rgba(255, 255, 255, .4); border-radius: 8px; background: rgba(255, 255, 255, .1); color: inherit; font-size: .82rem; text-decoration: none; cursor: pointer; }
.tool:hover { background: rgba(255, 255, 255, .22); }
.theme { padding: 0 7px; }

.wrap { padding-top: 18px; padding-bottom: 8px; }
.narrow { max-width: 760px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.page-head p { margin: 0; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px 22px; }
.card + .card { margin-top: 14px; }
.card-head { padding: 18px 22px 14px; border-bottom: 1px solid var(--line); }
.card-body { padding: 18px 22px 22px; }
.empty-state { padding: 36px 24px; text-align: center; }
.empty-state h1 { margin-bottom: 8px; }
.back { display: inline-flex; align-items: center; gap: 4px; margin-bottom: 10px; text-decoration: none; font-weight: 600; }
.back:hover { text-decoration: underline; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-weight: 600; font-size: .92rem; }
.field small { color: var(--muted); font-size: .82rem; }
.req { color: var(--err); margin-left: 2px; }
.input, .field input, .field select, .field textarea, .toolbar input, .toolbar select {
  width: 100%; min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; min-height: 96px; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .toolbar input:focus, .toolbar select:focus {
  outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(31, 122, 63, .18);
}
.field input[readonly] { background: var(--card-2); color: var(--muted); }
.invalid { border-color: var(--err) !important; box-shadow: 0 0 0 3px rgba(180, 35, 24, .12) !important; }
.ferr { color: var(--err); font-size: .84rem; }
.ferr:empty { display: none; }
.sep { height: 1px; background: var(--line); margin: 20px 0; }
.legend { margin: 0 0 12px; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 38px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--brand-2); background: var(--brand-soft); }
.btn-main { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn-main:hover { background: var(--brand-2); border-color: var(--brand-2); color: var(--brand-ink); }
.btn-danger { color: var(--err); }
.btn-danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: .86rem; }
.btn:disabled { opacity: .6; cursor: progress; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--brand-text); text-decoration: underline; cursor: pointer; }

.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; padding: 14px 16px; }
.toolbar .field { flex: 0 1 auto; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .field > span { font-size: .8rem; font-weight: 600; color: var(--muted); }
.toolbar input, .toolbar select { height: 38px; padding: 0 10px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; background: var(--chip); border-radius: 9px; }
.seg a, .seg button { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--text); font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap; }
.seg [aria-current="true"], .seg [aria-pressed="true"] { background: var(--brand); color: var(--brand-ink); font-weight: 650; }
.seg .n { margin-left: 6px; font-size: .78rem; opacity: .8; }

.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
.grid th { position: sticky; top: 0; background: var(--card-2); color: var(--muted); font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td { background: var(--card-2); }
.grid .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.grid .c { text-align: center; }
.grid tr.day td { background: var(--brand-soft); color: var(--brand-text); font-weight: 700; padding-top: 7px; padding-bottom: 7px; }
.grid tr.total td { background: var(--chip); font-weight: 600; }
.grid tr.grand td { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.grid tr.clickable { cursor: pointer; }
.grid .clip { max-width: 340px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.zap td { overflow-wrap: anywhere; }
.zap .w-who { min-width: 210px; }
.zap .w-doc { min-width: 150px; }
.zap .w-isp { min-width: 120px; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: .84rem; }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 650; white-space: nowrap; background: var(--chip); color: var(--text-2); }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .8; }
.b-new { background: var(--info-soft); color: var(--info-text); }
.b-work { background: var(--warn-soft); color: var(--warn-text); }
.b-done { background: var(--ok-soft); color: var(--ok); }
.b-late { background: var(--err-soft); color: var(--err); }
.alert { padding: 11px 14px; border-radius: 10px; margin-bottom: 4px; font-size: .94rem; }
.alert-ok { background: var(--ok-soft); color: var(--ok); }
.alert-err { background: var(--err-soft); color: var(--err); }
.alert-info { background: var(--info-soft); color: var(--info-text); }
.alert-warn { background: var(--warn-soft); color: var(--warn-text); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats .card + .card { margin-top: 0; }
.stat { padding: 12px 14px; }
.stat b { display: block; font-size: 1.4rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .84rem; }

.dl { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.prewrap { white-space: pre-wrap; }

.foot { max-width: 1180px; margin: 0 auto; padding: 20px 16px 32px; color: var(--muted); font-size: .82rem; }

@media (max-width: 760px) {
  .tabs { order: 3; width: 100%; overflow-x: auto; }
  .tabs a { padding: 8px 12px; }
  .brand-text small { display: none; }
  .who { display: none; }
  .wrap { padding-top: 14px; }
  .card-pad, .card-head, .card-body { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .dl { grid-template-columns: 1fr; gap: 2px; }
  .dl dd { margin-bottom: 8px; }
  .toolbar .field, .toolbar .grow { flex: 1 1 100%; }
  .actions .btn { flex: 1 1 auto; }
  table.grid.stack thead { display: none; }
  table.grid.stack, .grid.stack tbody, .grid.stack tr, .grid.stack td { display: block; width: 100%; }
  .grid.stack tr { padding: 10px 14px; border-bottom: 1px solid var(--line); }
  .grid.stack td { padding: 2px 0; border: 0; }
  .grid.stack td[data-l]::before { content: attr(data-l) ": "; color: var(--muted); font-size: .82rem; }
  .grid.stack tr.day { padding: 0; }
  .grid.stack tr.day td { padding: 7px 14px; }
  .grid .clip { max-width: none; }
  .grid.stack td.c { text-align: left; }
  .grid.stack td[data-l]:empty { display: none; }
  .seg { display: flex; flex-wrap: wrap; }
  .seg a, .seg button { flex: 1 1 auto; justify-content: center; }
  .toolbar .seg { display: flex; flex-wrap: nowrap; }
  .toolbar .seg a, .toolbar .seg button { flex: 1 1 0; justify-content: center; padding: 0 6px; }
  .head-actions { width: 100%; }
  .head-actions .btn { flex: 1 1 auto; }
}
@media print {
  .top, .toolbar, .actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; }
}

.suggest { position: relative; }
.suggest-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 264px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 8px 24px rgba(16, 40, 25, .16);
}
.suggest-list li { padding: 7px 10px; border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.suggest-list li:hover, .suggest-list li.active { background: var(--brand-soft); color: var(--brand-text); }
.suggest-list li.current { font-weight: 600; }
