@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Regular.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Medium.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "DM Sans"; src: url("/fonts/DMSans-Bold.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Clash Display"; src: url("/fonts/ClashDisplay-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }

:root {
  /* Brandstein: --bs-black, --bs-charcoal, --bs-cream, --bs-red */
  --bs-black: #1a1a1a;
  --bs-charcoal: #2a2a2a;
  --bs-cream: #f5f2ed;
  --bs-cream-ink: #e8e0d4;
  --bs-red: #c42032;
  --bg: #f5f2ed;
  --panel: #ffffff;
  --ink: #1a1a1a;
  --muted: #6e6a63;
  --line: #e6e1d8;
  --hover: #f1ede6;
  --danger: #c42032;
  --sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --display: "Clash Display", "DM Sans", -apple-system, sans-serif;
  font-family: var(--sans);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); }
body { font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Boot ---------- */
#boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bs-black); color: var(--bs-cream-ink); font-size: 14px; letter-spacing: .1em; text-transform: uppercase; }

/* ---------- Login (Brandsteinin ilme, Sivujuonen rakenne) ---------- */
#login { position: fixed; inset: 0; overflow: auto; background: var(--bs-black); color: var(--bs-cream-ink); display: grid; grid-template-rows: .85fr auto 1.15fr; padding: 24px 16px; font-size: 17px; line-height: 1.6; }
#login .card { grid-row: 2; justify-self: center; width: min(26rem, 100%); background: var(--bs-charcoal); border: 3px solid var(--bs-red); border-radius: 1.15rem; padding: clamp(1.45rem, 2.2vw, 2.1rem); animation: fadeIn .5s ease both; }
#login .card > * { animation: rise .6s cubic-bezier(.16,1,.3,1) both; }
#login .card > *:nth-child(1) { animation-delay: 40ms; }
#login .card > *:nth-child(2) { animation-delay: 95ms; }
#login .card > *:nth-child(3) { animation-delay: 150ms; }
#login .card > *:nth-child(n+4) { animation-delay: 205ms; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@media (prefers-reduced-motion: reduce) { #login .card, #login .card > * { animation: none; } }
#login .brandmark { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
#login .brandmark img { width: 40px; height: 40px; border-radius: 10px; }
.eyebrow { font-size: .72rem; text-transform: uppercase; letter-spacing: .25em; color: #999; }
#login h1 { font-family: var(--display); font-weight: 600; font-size: clamp(1.75rem, 6vw, 2.5rem); letter-spacing: -.02em; line-height: 1.1; margin: 0 0 .6rem; color: var(--bs-cream); }
#login .lead { margin: 0 0 1.4rem; color: var(--bs-cream-ink); }
#login form { display: grid; gap: .55rem; margin: 0; }
#login label { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: #999; }
#login input { font-size: 16px; background: #111; color: var(--bs-cream); border: 1px solid #3a3a3a; border-radius: 12px; padding: .8rem 1rem; outline: none; }
#login input:focus { border-color: var(--bs-red); box-shadow: 0 0 0 3px rgba(196,32,50,.25); }
#login input.code { font-size: 1.6rem; letter-spacing: .4em; text-align: center; font-variant-numeric: tabular-nums; }
.pill { position: relative; overflow: hidden; isolation: isolate; border: 0; border-radius: 999px; min-height: 48px; padding: 0 1.4rem; font-weight: 600; cursor: pointer; background: var(--bs-red); color: var(--bs-cream); width: 100%; margin-top: .4rem; }
.pill::before { content: ""; position: absolute; inset: 0; background: var(--bs-cream); transform: translateY(101%); transition: transform 420ms cubic-bezier(.16,1,.3,1); z-index: -1; }
.pill:hover::before, .pill:focus-visible::before { transform: translateY(0); }
.pill:hover, .pill:focus-visible { color: var(--bs-black); }
.pill:disabled { opacity: .6; cursor: progress; }
.note { border-radius: 12px; padding: .75rem 1rem; font-size: .92rem; line-height: 1.45; margin: .9rem 0 0; }
.note.ok { background: #bcd6f9; color: #10213a; }
.note.err { background: #f6c9cf; color: #6d0f1b; }
#codeForm { margin-top: 1.2rem !important; padding-top: 1.2rem; border-top: 1px solid #3a3a3a; }
#login .foot { margin-top: 1.4rem; font-size: .85rem; color: #999; }

/* ---------- App ---------- */
#app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
aside { background: var(--bs-black); color: var(--bs-cream-ink); display: flex; flex-direction: column; height: 100vh; position: sticky; top: 0; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 18px 18px 8px; }
.side-head img { width: 30px; height: 30px; border-radius: 8px; }
.side-head b { font-family: var(--display); font-weight: 600; font-size: 19px; color: var(--bs-cream); letter-spacing: -.01em; }
aside h2 { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: #8a8a8a; margin: 18px 18px 6px; font-weight: 500; }
#wheelList { list-style: none; margin: 0; padding: 0 10px; overflow: auto; flex: 1; }
#wheelList li { padding: 9px 10px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
#wheelList li:hover { background: #262626; }
#wheelList li.active { background: var(--bs-cream); color: var(--bs-black); }
#wheelList li .count { margin-left: auto; font-size: 12px; opacity: .55; }
#wheelList li .ro { font-size: 10.5px; opacity: .6; text-transform: uppercase; letter-spacing: .08em; }
.side-foot { padding: 12px; border-top: 1px solid #2c2c2c; display: grid; gap: 6px; }
.side-foot .btn { background: transparent; border-color: #3a3a3a; color: var(--bs-cream-ink); }
.side-foot .btn:hover { background: #262626; }
.side-foot .btn.primary { background: var(--bs-red); border-color: var(--bs-red); color: var(--bs-cream); }
.whoami { font-size: 12.5px; color: #8a8a8a; padding: 2px 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 7px 13px; border-radius: 999px; cursor: pointer; font-size: 14px; white-space: nowrap; font-weight: 500; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--bs-red); color: #fff; border-color: var(--bs-red); }
.btn.primary:hover { background: #a91a2a; }
.btn.dark { background: var(--bs-black); color: var(--bs-cream); border-color: var(--bs-black); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.icon { padding: 6px 10px; }
.btn:disabled { opacity: .5; cursor: default; }

main { min-width: 0; display: flex; flex-direction: column; }
header.top { display: flex; align-items: center; gap: 10px; padding: 12px 22px; border-bottom: 1px solid var(--line); background: var(--panel); flex-wrap: wrap; position: sticky; top: 0; z-index: 10; }
#wheelTitle { font-family: var(--display); font-weight: 600; font-size: 22px; margin: 0 6px 0 0; letter-spacing: -.01em; }
#wheelSelect { display: none; border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: var(--panel); font-weight: 600; max-width: 60vw; }
.year { display: flex; align-items: center; gap: 0; font-weight: 600; }
.year span { min-width: 64px; text-align: center; font-variant-numeric: tabular-nums; }
.spacer { flex: 1; }
.tabs { display: flex; background: var(--hover); border-radius: 999px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 5px 13px; border-radius: 999px; cursor: pointer; font-size: 14px; font-weight: 500; }
.tabs button.on { background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.1); }
#search { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; background: var(--panel); width: 180px; }
.menu { position: relative; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; display: none; z-index: 30; min-width: 250px; }
.menu-list.open { display: block; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.menu-list button:hover { background: var(--hover); }
.menu-list hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

.view { flex: 1; padding: 18px 22px 40px; }
.wheel-layout { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px; align-items: start; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 12px; }
#wheel { width: 100%; height: auto; display: block; max-height: calc(100vh - 110px); user-select: none; -webkit-user-select: none; }
#timeline { width: 100%; height: auto; display: block; user-select: none; -webkit-user-select: none; }
.hint { font-size: 12.5px; color: var(--muted); text-align: center; margin: 6px 0 0; }

.legend { position: sticky; top: 78px; display: grid; gap: 14px; }
.legend h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.legend label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }
.legend .sw { width: 14px; height: 14px; border-radius: 4px; flex: none; }
.legend label .n { margin-left: auto; color: var(--muted); font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 3px 10px; font-size: 13px; cursor: pointer; }
.chips button.on { background: var(--bs-black); color: var(--bs-cream); border-color: var(--bs-black); }
.up-item { font-size: 13.5px; padding: 6px 0; cursor: pointer; display: grid; grid-template-columns: 10px 1fr; gap: 8px; align-items: start; }
.up-item:hover .t { text-decoration: underline; }
.up-item .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 5px; }
.up-item .d { color: var(--muted); font-size: 12px; }
.updated { font-size: 12px; color: var(--muted); }

.ev { cursor: pointer; }
.ev:hover .bar { filter: brightness(1.08); }
.can-edit .ring-bg, .can-edit .row-bg { cursor: copy; }
.can-edit .ring-bg:hover { opacity: .32; }

#tip { position: fixed; pointer-events: none; background: var(--bs-black); color: var(--bs-cream); padding: 8px 11px; border-radius: 10px; font-size: 13px; max-width: 300px; z-index: 60; display: none; line-height: 1.35; }
#tip .d { opacity: .7; font-size: 12px; }

.list-tools { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.list-tools select { border: 1px solid var(--line); border-radius: 999px; padding: 7px 12px; background: var(--panel); }
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; background: #faf8f4; }
tr.month td { background: #faf8f4; font-weight: 600; font-size: 13px; color: var(--muted); }
tbody tr.row { cursor: pointer; }
tbody tr.row:hover td { background: #fbfaf7; }
.chip { display: inline-flex; align-items: center; gap: 6px; }
.chip i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.tag { display: inline-block; font-size: 11.5px; background: var(--hover); border-radius: 999px; padding: 1px 8px; margin: 3px 4px 0 0; color: var(--muted); }
td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.notes { color: var(--muted); font-size: 13px; }
a.ext { color: inherit; }

dialog { border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 24px 70px rgba(0,0,0,.28); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(20,20,20,.45); }
dialog form, dialog .body { padding: 20px 22px; display: grid; gap: 12px; }
dialog h2 { margin: 0 0 2px; font-family: var(--display); font-weight: 600; font-size: 22px; letter-spacing: -.01em; }
.field { display: grid; gap: 4px; }
.field > span { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; background: #fff; width: 100%; font-size: 16px; }
.field textarea { min-height: 70px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.swatches button.on { border-color: var(--ink); box-shadow: inset 0 0 0 2px #fff; }
.swatches input[type=color] { width: 32px; height: 30px; padding: 0; border: 0; background: none; }
.actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; align-items: center; }
.ring-row { display: grid; grid-template-columns: 38px 1fr auto auto auto; gap: 6px; align-items: center; }
.ring-row input[type=color] { width: 38px; height: 36px; border: 1px solid var(--line); border-radius: 10px; padding: 2px; background: #fff; }
.ring-row input[type=text] { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 16px; min-width: 0; }
.scroll { display: grid; gap: 6px; max-height: 46vh; overflow: auto; }
.muted { color: var(--muted); font-size: 13.5px; }
.info-meta { color: var(--muted); font-size: 14px; }
.info-notes { white-space: pre-wrap; font-size: 15px; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.user-row .who b { display: block; }
.user-row .who small { color: var(--muted); }
.access-row { display: grid; grid-template-columns: 1fr 150px; gap: 8px; align-items: center; font-size: 14px; }
.access-row select { border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px; background: #fff; }
.codebox { font: 700 34px/1 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .2em; background: #f6f1e7; border-radius: 14px; padding: 18px; text-align: center; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--bs-black); color: var(--bs-cream); padding: 10px 16px; border-radius: 999px; font-size: 14px; z-index: 80; display: none; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
#toast.err { background: var(--bs-red); }

#printHead, #printLegend, #printFoot { display: none; }
#printLegend span { display: inline-flex; align-items: center; gap: 6px; }
#printLegend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; }
  #app { display: block; }
  aside, header.top, .legend, .hint, #listView, #timelineView, #tip, #toast { display: none !important; }
  .view { padding: 0; }
  .wheel-layout { display: block; }
  .card { border: 0; padding: 0; }
  #wheel { max-height: none; }
  #printHead { display: flex !important; justify-content: space-between; align-items: baseline; margin-bottom: 6mm; }
  #printHead h1 { font-family: var(--display); font-weight: 600; font-size: 24pt; margin: 0; }
  #printLegend { display: flex !important; flex-wrap: wrap; gap: 4mm 8mm; justify-content: center; margin-top: 6mm; font-size: 11pt; }
  #printFoot { display: block !important; margin-top: 8mm; font-size: 9pt; color: #666; }
}

@media (max-width: 980px) {
  #app { grid-template-columns: 1fr; }
  aside { display: none; }
  #wheelSelect { display: block; }
  #wheelTitle { display: none; }
  .wheel-layout { grid-template-columns: 1fr; }
  .legend { position: static; }
  header.top { padding: 10px 12px; gap: 8px; padding-top: max(10px, env(safe-area-inset-top)); }
  .view { padding: 12px 12px 40px; }
  #search { width: 100%; order: 10; }
  .card { padding: 6px; border-radius: 14px; }
  #wheel { max-height: none; }
}
@media (max-width: 560px) {
  .row2 { grid-template-columns: 1fr; }
  #addEventBtn .long { display: none; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

/* Oikeuksien mukaan näkyvät osat */
body:not(.staff) .staff-only { display: none !important; }
body:not(.editor) .edit-only { display: none !important; }
.mobile-only { display: none !important; }
@media (max-width: 980px) { .menu-list .mobile-only { display: block !important; } body:not(.staff) .menu-list .mobile-only.staff-only { display: none !important; } }

/* ---------- Osiot ---------- */
nav.sections { display: flex; gap: 4px; padding: 0 22px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
nav.sections::-webkit-scrollbar { display: none; }
nav.sections button { border: 0; background: transparent; padding: 11px 12px 10px; font-size: 14.5px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
nav.sections button:hover { color: var(--ink); }
nav.sections button.on { color: var(--ink); border-bottom-color: var(--bs-red); }
body:not(.sec-wheel) .wheel-only { display: none !important; }
body:not(.sec-budget) .budget-only { display: none !important; }
body:not(.sec-wheel):not(.sec-budget) .year-tool { display: none !important; }

.doc-view { max-width: 1100px; }
.doc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.doc-head h2 { font-family: var(--display); font-weight: 600; font-size: 26px; letter-spacing: -.01em; margin: 0; }
.doc-head .updated { margin-left: 4px; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.doc-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; }
.doc-card h3 { font-family: var(--display); font-weight: 600; font-size: 18px; margin: 0 0 8px; letter-spacing: -.005em; }
.doc-card.wide { grid-column: 1 / -1; }
.prose { font-size: 15px; line-height: 1.6; }
.prose p { margin: 0 0 .7em; }
.prose p:last-child, .prose ul:last-child { margin-bottom: 0; }
.prose ul { margin: 0 0 .7em; padding-left: 1.2em; }
.empty { background: var(--panel); border: 1px dashed var(--line); border-radius: 16px; padding: 28px; text-align: center; color: var(--muted); }
.empty .btn { margin-top: 12px; }
.sub { font-size: 11px; text-transform: uppercase; letter-spacing: .18em; color: var(--muted); font-weight: 600; margin: 26px 0 10px; }

.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.swatch { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.swatch .chipc { height: 96px; border-bottom: 1px solid var(--line); }
.swatch .body { padding: 12px 14px; font-size: 13.5px; display: grid; gap: 2px; }
.swatch .body b { font-size: 15px; margin-bottom: 2px; }
.swatch .hex { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; cursor: copy; justify-self: start; }
.swatch .hex:hover { text-decoration: underline; }
.swatch .use { color: var(--muted); margin-top: 4px; }
.font-card .name { font-size: 26px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 4px; }
.link-list { display: grid; gap: 8px; }
.link-item { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; }
a.link-item:hover { border-color: var(--ink); }
.link-item .ar { margin-left: auto; color: var(--muted); }
.link-item small { display: block; color: var(--muted); }
.person { display: grid; gap: 2px; font-size: 14.5px; }
.person b { font-size: 16px; }
.person a { color: inherit; }

/* Muokkaus */
.editor { display: grid; gap: 14px; }
.ed-block { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: grid; gap: 10px; }
.ed-block > h3 { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }
.ed-row { display: grid; gap: 6px; align-items: start; grid-template-columns: var(--cols) auto; padding: 10px 0; border-top: 1px solid var(--line); }
.ed-row:first-of-type { border-top: 0; }
.ed-row input, .ed-row textarea, .ed-plain { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #fff; font-size: 15px; width: 100%; min-width: 0; }
.ed-row textarea, textarea.ed-plain { min-height: 110px; resize: vertical; line-height: 1.5; }
.ed-row input[type=color] { padding: 2px; height: 38px; }
.ed-tools { display: flex; gap: 4px; }
.ed-tools .btn { padding: 5px 9px; }
.ed-bar { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); }
.hint-inline { font-size: 12.5px; color: var(--muted); }

/* Budjetti */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
.kpi span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); font-weight: 600; }
.kpi b { display: block; font-family: var(--display); font-weight: 600; font-size: 26px; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); }
.kpi input { font: inherit; font-family: var(--display); font-weight: 600; font-size: 24px; width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 2px 8px; margin-top: 4px; }
.meter { height: 6px; background: var(--hover); border-radius: 999px; margin-top: 8px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--ink); border-radius: 999px; }
.meter.over i { background: var(--bs-red); }
.chart-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; margin-bottom: 14px; }
.chart-legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
#budgetChart { width: 100%; height: auto; display: block; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.table-wrap table { border: 0; border-radius: 0; min-width: 980px; }
.btable td, .btable th { padding: 6px 6px; font-size: 13.5px; text-align: right; white-space: nowrap; }
.btable td:first-child, .btable th:first-child { text-align: left; position: sticky; left: 0; background: var(--panel); min-width: 190px; }
.btable th:first-child { background: #faf8f4; }
.btable input { width: 74px; border: 1px solid transparent; border-radius: 8px; padding: 5px 6px; text-align: right; background: transparent; font-variant-numeric: tabular-nums; font-size: 13.5px; }
.btable input:hover { border-color: var(--line); }
.btable input:focus { border-color: var(--ink); background: #fff; outline: none; }
.btable td:first-child input { width: 100%; text-align: left; font-weight: 500; }
.btable tr.group td { background: #faf8f4; font-weight: 600; color: var(--muted); text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.btable tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
.btable td.auto { color: var(--muted); }
.btable .del { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 2px 6px; }
.btable .del:hover { color: var(--danger); }
.save-state { font-size: 12.5px; color: var(--muted); }

@media print {
  nav.sections, .ed-bar, .doc-head .btn, .empty .btn, .no-print { display: none !important; }
  .doc-card, .swatch, .kpi, .chart-card, .table-wrap { break-inside: avoid; }
  .table-wrap { overflow: visible; }
  .table-wrap table { min-width: 0; }
}
@media (max-width: 980px) {
  nav.sections { padding: 0 8px; top: 0; position: static; }
  .doc-grid { grid-template-columns: 1fr; }
  .ed-row { grid-template-columns: 1fr auto; }
}
