/* Portal: a working tool. Same palette as the website, denser and calmer. */
body { font-size: 1rem; line-height: 1.6; }
.pad { padding: 24px; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 28px; display: grid; gap: 12px; }
.login-card h1 { font-family: var(--font-head); color: var(--ink); margin: 0; font-size: 1.6rem; }
.login-card p { margin: 0; }
.linkish { background: none; border: 0; color: var(--ink); text-decoration: underline; cursor: pointer; font: inherit; justify-self: start; padding: 4px 0; }

/* Shell */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--ink); color: #fff; }
:root[data-theme="dark"] .topbar { background: #0a101d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .topbar { background: #0a101d; } }
.topbar .brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-family: var(--font-head); font-weight: 700; font-size: 1.15rem; margin-right: auto; }
.topbar .who { display: flex; align-items: center; gap: 12px; font-size: .9rem; }
.topbar .who .roles { opacity: .75; }
.topbar .btn-quiet { color: #fff; border-color: rgba(255,255,255,.5); min-height: 38px; padding: 6px 12px; }
.topbar .btn-quiet:hover { background: rgba(255,255,255,.1); color: #fff; }
.topbar .menu { display: none; }

.layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 58px); }
.side { border-right: 1px solid var(--line); background: var(--surface); padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.side a { text-decoration: none; padding: 9px 12px; border-radius: var(--radius-s); color: var(--text); border-left: 3px solid transparent; }
.side a:hover { background: var(--paper); }
.side a[aria-current] { background: var(--paper); border-left-color: var(--marigold); font-weight: 600; color: var(--ink); }
.content { padding: 24px clamp(16px, 3vw, 40px) 64px; outline: none; }
.view { max-width: 1100px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; inset: 58px 0 auto 0; z-index: 9; border-bottom: 1px solid var(--line); max-height: calc(100vh - 58px); overflow: auto; }
  .side.open { display: flex; }
  .topbar .menu { display: inline-flex; }
  .topbar .who span { display: none; }
}

/* Page furniture */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { font-family: var(--font-head); color: var(--ink); font-size: clamp(1.5rem, 3vw, 1.9rem); margin: 0; line-height: 1.25; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.view h2 { font-family: var(--font-head); color: var(--ink); font-size: 1.2rem; margin: 28px 0 10px; }
.view p { max-width: 75ch; }

.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 8px 0 8px; border-top: 2px solid var(--ink); }
.figure { text-decoration: none; padding: 14px 16px 14px 0; border-bottom: 1px solid var(--line); }
.figure dt { color: var(--muted); font-size: .9rem; }
.figure dd { margin: 0; font-family: var(--font-head); font-weight: 700; font-size: 2rem; color: var(--ink); line-height: 1.2; }
.figure.alert dd { color: #b3261e; }
.figure:hover dt { text-decoration: underline; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 24px; border-top: 2px solid var(--ink); margin: 0 0 12px; }
.facts div { padding: 10px 0; border-bottom: 1px solid var(--line); }
.facts dd { margin: 0; font-weight: 600; color: var(--ink); }

.table-wrap table { min-width: 640px; font-size: .95rem; }
td.message { max-width: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
tr.ended td { color: var(--muted); }
.row-actions { white-space: nowrap; }
.row-actions .btn, td .btn-quiet { min-height: 36px; padding: 4px 10px; font-size: .9rem; }
.empty { color: var(--muted); padding: 16px 0; }

.badge { display: inline-block; font-size: .82rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); background: var(--paper); white-space: nowrap; }
.badge.ok { color: var(--leaf); border-color: color-mix(in srgb, var(--leaf) 40%, transparent); background: color-mix(in srgb, var(--leaf) 8%, transparent); }
.badge.warn { color: #8a5a00; border-color: color-mix(in srgb, var(--marigold) 60%, transparent); background: color-mix(in srgb, var(--marigold) 14%, transparent); }
.badge.err { color: #b3261e; border-color: color-mix(in srgb, #b3261e 40%, transparent); background: color-mix(in srgb, #b3261e 7%, transparent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn { color: #f3c25a; } :root:not([data-theme="light"]) .badge.err { color: #ff8a80; } }

.panel { border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); margin: 12px 0; }
.panel > summary { cursor: pointer; padding: 12px 16px; font-weight: 600; color: var(--ink); list-style-position: inside; }
.panel[open] > summary { border-bottom: 1px solid var(--line); }
.panel-body { padding: 16px; }
details.mini summary { cursor: pointer; font-size: .9rem; text-decoration: underline; }

form.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 16px; max-width: none; }
form.grid-form .form-actions, form.grid-form fieldset, form.grid-form .check, form.grid-form > p, form.grid-form > .hint { grid-column: 1 / -1; }
form.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; max-width: none; }
form.inline-form .field { min-width: 180px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px; max-width: none; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }
.form-actions { display: flex; gap: 8px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 14px; display: grid; gap: 6px; }
legend { font-weight: 600; padding: 0 4px; }
.check.small { font-size: .88rem; }
.roles-cell { display: grid; grid-template-columns: repeat(2, minmax(0, max-content)); gap: 0 12px; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 4px 0; border-bottom: 1px solid var(--line); }
ul.warnings { margin: 8px 0; padding: 10px 14px 10px 30px; border-left: 3px solid #b3261e; background: color-mix(in srgb, #b3261e 6%, transparent); }
.block { padding: 8px 0 24px; border-bottom: 1px solid var(--line); }
.quorum { font-weight: 600; }
.quorum.ok { color: var(--leaf); }
.view .note { max-width: 75ch; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 40px); opacity: 0; pointer-events: none; z-index: 50;
  background: var(--ink); color: var(--paper); padding: 12px 18px; border-radius: var(--radius-s); max-width: min(92vw, 560px); transition: transform .2s, opacity .2s; }
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.err { background: #b3261e; color: #fff; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }

/* Finance */
.nav-group { margin: 14px 12px 4px; font-size: .8rem; color: var(--muted); font-weight: 600; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
@media (max-width: 760px) { .two-col { grid-template-columns: minmax(0, 1fr); } }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.over td { background: color-mix(in srgb, #b3261e 5%, transparent); }
.result { font-weight: 700; color: var(--ink); font-size: 1.05rem; }
td input[name^="b_"], td input[name="poisha"] { max-width: 160px; text-align: right; }
.decision { border: 2px solid var(--marigold); border-radius: var(--radius-m); padding: 14px 16px; margin: 16px 0; max-width: 640px; }
.voucher { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 20px 24px; margin: 12px 0 20px; }
.voucher header { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 12px; }
.voucher .doc-title { font-family: var(--font-head); font-weight: 700; color: var(--ink); text-align: right; }
.voucher .signatures { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; margin-top: 48px; }
.voucher .signatures div { border-top: 1px solid var(--text); padding-top: 6px; display: grid; }
@media (max-width: 600px) { .voucher header { grid-template-columns: auto 1fr; } .voucher .doc-title { grid-column: 1 / -1; text-align: left; } }

@media print {
  .topbar, .side, .no-print, .toast, .panel, .filters { display: none !important; }
  .layout { display: block; }
  .content { padding: 0; }
  body { background: #fff; color: #000; }
  .voucher { border: 0; padding: 0; }
  .table-wrap { border: 0; overflow: visible; }
  .table-wrap table { min-width: 0; }
  a { text-decoration: none; color: #000; }
}
.facts .wide { grid-column: 1 / -1; }
.filters input, .filters select { width: auto; max-width: 100%; }

/* Programmes */
form.grid-form .wide, form.grid-form fieldset.sub { grid-column: 1 / -1; }
fieldset.sub { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 12px; margin-bottom: 12px; }
.btn.btn-small { min-height: 34px; padding: 4px 12px; font-size: .9rem; }
.btn.btn-danger { background: #b3261e; border-color: #b3261e; color: #fff; }
details.row-edit > summary { cursor: pointer; font-size: .9rem; text-decoration: underline; white-space: nowrap; }
form.row-form { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; min-width: 260px; max-width: 560px; }
form.row-form select, form.row-form input { width: auto; min-width: 0; flex: 1 1 120px; }
form.row-form input.short { flex: 0 1 80px; }
