:root {
  --bg: #f4f6f9; --card: #fff; --text: #1a2233; --muted: #6b7587; --line: #e3e7ee;
  --primary: #2563eb; --danger: #dc2626; --ok: #059669; --warn: #d97706;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1420; --card: #181f2e; --text: #e8ecf4; --muted: #8e99ae; --line: #28324a; --primary: #4f8cff; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, "Segoe UI", sans-serif; }
.top { display: flex; align-items: center; gap: 24px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 18px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
nav button { border: 0; background: none; color: var(--muted); padding: 8px 14px; border-radius: 8px; font: inherit; cursor: pointer; }
nav button.active { background: var(--primary); color: #fff; }
.periodbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; flex-wrap: wrap; color: var(--muted); }
main { padding: 0 20px 40px; max-width: 1200px; margin: 0 auto; }
input, select, textarea, button { font: inherit; color: var(--text); }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.btn { background: var(--primary); color: #fff; border: 0; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 13px; }
.kpi .v { font-size: 22px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .s { font-size: 12px; color: var(--muted); margin-top: 2px; }
.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form .wide { grid-column: span 2; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 700; }
.tablewrap { overflow-x: auto; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.muted { color: var(--muted); }
.neg { color: var(--danger); } .pos { color: var(--ok); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.sp { justify-content: space-between; }
.bar { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 6px; }
.catrow { margin-bottom: 14px; }
.catrow .h { display: flex; justify-content: space-between; margin-bottom: 4px; gap: 8px; flex-wrap: wrap; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-top: 8px; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal[hidden], .toast[hidden] { display: none; }
.modal .box { background: var(--card); border-radius: 14px; padding: 20px; width: 100%; max-width: 560px; max-height: 92vh; overflow: auto; }
.alloc { display: grid; grid-template-columns: 1fr 80px 150px; gap: 8px; align-items: center; margin-bottom: 8px; }
.alloc input { width: 100%; text-align: right; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 20; }
.toast.err { background: var(--danger); color: #fff; }
.empty { text-align: center; color: var(--muted); padding: 24px; }
svg text { fill: var(--muted); font-size: 11px; }
.warn { color: var(--warn); }
.kpi .alt { font-size: 13px; font-weight: 600; color: #7c3aed; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (prefers-color-scheme: dark) { .kpi .alt { color: #a78bfa; } }

.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 10px; font-weight: 600; }
.badge.done { background: rgba(5,150,105,.15); color: var(--ok); }
.badge.planned { background: rgba(217,119,6,.15); color: var(--warn); }
