:root {
  --ink: #1C2321; --muted: #4F5855; --quiet: #5B6461; --ground: #F6F5F1; --card: #FFFFFF;
  --line: #E3E1DA; --line2: #D6D3CA; --soft: #EEECE6;
  --green: #2E5E3E; --gp: #1F5A8A; --sa: #D9822B; --sa-text: #A5521A;
  --good-bg: #E3F1E6; --good: #1E5631; --warn-bg: #FDECDD; --warn: #8A3B0C;
  --bad-bg: #FBE4E4; --bad: #8B1A1A; --info-bg: #E4EEF7; --info: #163F61;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--ground); font-size: 15px; }
h1, h2, h3 { margin: 0; }
h1 { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 28px; font-weight: 600; }
h2 { font-size: 17px; font-weight: 600; }
a { color: var(--gp); }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.muted { color: var(--muted); }
.small { font-size: 12px; color: var(--quiet); }

.top { background: var(--card); border-bottom: 1px solid var(--line); }
.top-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding-top: 14px; }
.brand { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; }
.brand-name { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 18px; font-weight: 600; }
.brand-sub, .who { font-size: 13px; color: var(--muted); }
.nav { display: flex; flex-wrap: wrap; gap: 2px; padding-top: 6px; }
.nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border-bottom: 3px solid transparent; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
.nav a.on { border-bottom-color: var(--green); color: var(--ink); font-weight: 600; }
.nav .badge { margin-left: 6px; }

.main { padding-top: 28px; padding-bottom: 56px; display: flex; flex-direction: column; gap: 22px; }
.main:focus { outline: none; }
.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.head p { margin: 6px 0 0; color: #3C4441; max-width: 760px; line-height: 1.5; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.row > .card { flex: 1 1 420px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 18px; display: flex; flex-direction: column; gap: 6px; }
.kpi .lbl { font-size: 13px; color: var(--muted); }
.kpi .val { font-family: 'Space Grotesk', Inter, sans-serif; font-size: 26px; font-weight: 600; }
.kpi .sub { font-size: 12px; color: var(--quiet); }
.c-gp { color: var(--gp); } .c-sa { color: var(--sa-text); } .c-warn { color: #9A3412; } .c-bad { color: #9F1D1D; } .c-good { color: var(--good); }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
label { font-size: 13px; font-weight: 500; color: var(--muted); }
input, select, textarea { height: 44px; padding: 0 12px; border: 1px solid var(--line2); border-radius: 8px; font: inherit; font-size: 15px; background: #fff; color: var(--ink); width: 100%; }
textarea { height: 80px; padding: 10px 12px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; }
input.num { text-align: right; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--ink); font-weight: 400; }
:focus-visible { outline: 3px solid #8CB3D9; outline-offset: 1px; }

.btn { min-height: 44px; padding: 0 18px; border: 1px solid var(--line2); border-radius: 8px; background: #fff; font: inherit; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 600; }
.btn.danger { color: #B42318; border-color: #E9B4AE; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.split { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }

.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; padding: 10px 8px; border-bottom: 1px solid var(--line2); white-space: nowrap; }
td { padding: 10px 8px; border-bottom: 1px solid var(--soft); vertical-align: middle; }
td.r, th.r { text-align: right; white-space: nowrap; }
td.b { font-weight: 600; }
tr.total td { font-weight: 600; background: var(--ground); }
tr.click { cursor: pointer; } tr.click:hover td { background: #FAFAF7; }
.empty { padding: 22px; text-align: center; color: var(--quiet); }

.chip { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.chip.good { background: var(--good-bg); color: var(--good); } .chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); } .chip.info { background: var(--info-bg); color: var(--info); }
.chip.neutral { background: var(--soft); color: #3C4441; }
.badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; align-items: center; justify-content: center; border-radius: 10px; background: #9A3412; color: #fff; font-size: 11px; font-weight: 700; }

.bar2 { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--soft); }
.bar2 .gp { background: var(--gp); } .bar2 .sa { background: var(--sa); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.legend span::before { content: ''; display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend .lgp::before { background: var(--gp); } .legend .lsa::before { background: var(--sa); }
.months { display: grid; grid-template-columns: repeat(12, minmax(34px, 1fr)); gap: 8px; align-items: end; height: 220px; border-bottom: 1px solid var(--line2); min-width: 500px; }
.months .m { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.months .m div { width: 40%; max-width: 18px; border-radius: 3px 3px 0 0; min-height: 0; }
.mlabels { display: grid; grid-template-columns: repeat(12, minmax(34px, 1fr)); gap: 8px; min-width: 500px; padding-top: 6px; font-size: 12px; color: var(--quiet); text-align: center; }

.preview { background: var(--ground); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.preview .line { display: flex; justify-content: space-between; gap: 12px; }
.note { background: #FFF8EC; border: 1px solid #F1D9B5; border-radius: 10px; padding: 12px 14px; font-size: 13px; color: #5A3410; line-height: 1.5; }
.alert { border-radius: 10px; padding: 12px 14px; font-size: 14px; font-weight: 500; }
.alert.warn { background: var(--warn-bg); color: var(--warn); } .alert.info { background: var(--info-bg); color: var(--info); }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.tabs button { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line2); background: #fff; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; color: var(--ink); }
.tabs button.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.toast { visibility: hidden; position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(120px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); transition: transform .2s; z-index: 10; }
.toast.show { visibility: visible; transform: translateX(-50%) translateY(0); }
.toast.err { background: #8B1A1A; }
dialog { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100% - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.2); }
dialog::backdrop { background: rgba(28,35,33,.4); }
.dlg-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }

.print-only { display: none; }
@media print {
  .no-print, .nav, .top, .toast { display: none !important; }
  .print-only { display: block; }
  body { background: #fff; }
  .card { border: 0; padding: 0; }
  .main { padding: 0; }
}
@media (max-width: 640px) {
  .wrap { padding-left: 14px; padding-right: 14px; }
  h1 { font-size: 24px; }
  .card { padding: 16px; }
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.preview .line b { white-space: nowrap; }
.field.span2 { grid-column: span 2; }
@media (max-width: 640px) { .field.span2 { grid-column: auto; } }
