/*
 * Kibo design system. Change the look here only:
 *   1. Tokens (colours, fonts, sizes)   2. Base elements   3. Components   4. Layout helpers
 *   5. Client form   6. Admin pages     7. Small screens
 * Pages use these classes; the only inline styles are data-driven widths (progress bars).
 */

/* ---------- 1. Tokens ---------- */
:root {
  --brand: #0f6b4f;          /* main colour: header, buttons, progress */
  --brand-ink: #ffffff;      /* text on brand colour */
  --brand-soft: #e3f1ec;     /* light brand background */
  --bg: #f4f6f5;             /* page background */
  --card: #ffffff;
  --ink: #1b2420;            /* main text */
  --muted: #64716b;          /* secondary text */
  --line: #dfe5e2;           /* borders */
  --input-line: #c9d2ce;
  --warn-bg: #fff6e0; --warn-ink: #7a5300;
  --ok-bg: #e6f4ea;   --ok-ink: #1e5631;
  --info-bg: #e3edff; --info-ink: #1d4ed8;
  --purple-bg: #f1e8ff; --purple-ink: #6b21a8;
  --err: #b42318;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --radius-s: 10px;
  --space-1: .25rem; --space-2: .5rem; --space-3: .75rem; --space-4: 1rem; --space-5: 1.25rem; --space-6: 2rem;
  --page-width: 1100px;
  --form-width: 640px;
}

/* ---------- 2. Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); }
a { color: var(--brand); }
h1 { font-size: 1.45rem; line-height: 1.25; margin: 0 0 var(--space-2); }
h2 { font-size: 1.1rem; margin: 0 0 var(--space-3); }
h3 { font-size: 1rem; margin: 0 0 var(--space-2); }
p { margin: 0 0 var(--space-3); }
label { display: block; font-weight: 600; margin-bottom: .35rem; }
input, select, textarea { width: 100%; font: inherit; padding: .7rem .8rem; border: 1px solid var(--input-line); border-radius: var(--radius-s); background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; }
input[type=file] { padding: .5rem; }

/* ---------- 3. Components ---------- */
.topbar { background: var(--brand); color: var(--brand-ink); padding: var(--space-3) var(--space-4); display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.topbar nav { display: flex; gap: var(--space-4); flex-wrap: wrap; }
.topbar a { color: var(--brand-ink); text-decoration: none; opacity: .9; }
.topbar a:hover, .topbar a.on { opacity: 1; text-decoration: underline; }
.brand { font-weight: 700; display: flex; align-items: center; gap: var(--space-2); }
.logo { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--brand-ink); color: var(--brand); font-weight: 800; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--space-5); }
.card + .card, .section + .section { margin-top: var(--space-4); }
.section { margin-bottom: var(--space-5); }

.btn { appearance: none; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: var(--radius-s); padding: .65rem 1.1rem; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: .4rem; }
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.ghost { background: transparent; }
.btn.link { border: 0; background: none; color: var(--brand); padding: .4rem 0; font-weight: 500; }
.btn.small { padding: .35rem .7rem; font-size: .875rem; }
.btn.big { padding: .85rem 1.6rem; font-size: 1.05rem; }
.btn.danger { color: var(--err); }
.btn.block { width: 100%; }

.field { margin-bottom: var(--space-4); }
.hint { color: var(--muted); font-size: .85rem; margin-top: .3rem; }
.error { color: var(--err); font-size: .9rem; margin-top: .3rem; }
.alert { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius-s); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-4); }
.alert.ok { background: var(--ok-bg); color: var(--ok-ink); }
.alert.info { background: var(--info-bg); color: var(--info-ink); }
.alert > * + * { margin-top: var(--space-1); }

.badge { display: inline-block; padding: .15rem .55rem; border-radius: 99px; font-size: .8rem; font-weight: 600; background: #eceff1; color: #455a64; white-space: nowrap; }
.badge.in_progress { background: var(--warn-bg); color: var(--warn-ink); }
.badge.submitted { background: var(--info-bg); color: var(--info-ink); }
.badge.filed { background: var(--purple-bg); color: var(--purple-ink); }
.badge.done { background: var(--ok-bg); color: var(--ok-ink); }
.badge.expired { background: #fde8e8; color: var(--err); }

details > summary { cursor: pointer; }
details > summary h2 { display: inline; }
details[open] > summary { margin-bottom: var(--space-3); }

.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--line); margin-bottom: var(--space-4); overflow-x: auto; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

.checks { display: grid; gap: var(--space-2); }
.check { display: flex; align-items: center; gap: .6rem; border: 1px solid var(--line); border-radius: var(--radius-s); padding: .75rem .9rem; font-weight: 500; cursor: pointer; margin: 0; }
.check:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip { display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--line); border-radius: 99px; padding: .4rem .8rem; font-weight: 500; font-size: .9rem; cursor: pointer; margin: 0; background: var(--card); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.inline-check { display: inline-flex; align-items: center; gap: var(--space-2); font-weight: 500; margin: 0; }

.copy-row { display: grid; grid-template-columns: 11rem 1fr auto; gap: var(--space-2); align-items: center; padding: .4rem 0; border-top: 1px solid var(--line); font-size: .93rem; }
.copy-row:first-of-type { border-top: 0; }
.copy-row > span { color: var(--muted); }
.copy-row > b { font-weight: 500; overflow-wrap: anywhere; }
.copy { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: .2rem .55rem; font-size: .8rem; cursor: pointer; color: var(--muted); }
.copy:hover { color: var(--brand); border-color: var(--brand); }
.copy.done { color: var(--ok-ink); border-color: var(--ok-ink); }

table.list { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.list th, table.list td { text-align: left; padding: .65rem .8rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfa; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.actions { text-align: right; white-space: nowrap; }
.minibar { width: 80px; height: 6px; background: #e3e8e6; border-radius: 99px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: .4rem; }
.minibar > i { display: block; height: 100%; background: var(--brand); }

.linkbox { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; background: var(--brand-soft); border-radius: var(--radius-s); padding: var(--space-3); }
.linkbox input { flex: 1 1 260px; width: auto; }

.rowform { display: grid; gap: var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: var(--space-3); margin-bottom: .6rem; position: relative; }
.rowform .remove { position: absolute; top: .4rem; right: .5rem; }
.numbered { display: grid; gap: .4rem; counter-reset: item; }
.numbered > .item { display: grid; grid-template-columns: 2.6rem 1fr auto; gap: var(--space-2); align-items: start; counter-increment: item; }
.numbered > .item::before { content: counter(item, upper-roman) "."; font-weight: 700; color: var(--muted); padding-top: .65rem; text-align: right; }
.numbered.lower > .item::before { content: "(" counter(item, lower-roman) ")"; }
.numbered.plain > .item::before { content: counter(item) "."; }
.numbered textarea { min-height: 3.2rem; font-size: .92rem; }
.item-tools { display: flex; flex-direction: column; gap: .2rem; }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(4px); padding: var(--space-3) 0; display: flex; gap: var(--space-3); justify-content: flex-end; align-items: center; border-top: 1px solid var(--line); margin-top: var(--space-4); flex-wrap: wrap; }
.save-state { color: var(--muted); font-size: .85rem; margin-right: auto; }

/* ---------- 4. Layout helpers ---------- */
.page { max-width: var(--page-width); margin: 0 auto; padding: var(--space-5) 16px 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-4); flex-wrap: wrap; margin-bottom: var(--space-4); }
.narrow { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-4); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: var(--space-3); }
.span2 { grid-column: span 2; }
.row { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.row.top { align-items: flex-start; }
.grow { flex: 1 1 auto; }
.align-end { display: flex; align-items: flex-end; }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--space-2); } .mb-4 { margin-bottom: var(--space-4); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.upper { text-transform: uppercase; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- 5. Client form ---------- */
.wizard { max-width: var(--form-width); margin: 0 auto; padding: var(--space-4) 16px 3rem; }
.lang-switch { display: flex; gap: .25rem; }
.lang-switch button { background: transparent; border: 1px solid rgba(255,255,255,.5); color: var(--brand-ink); border-radius: 6px; padding: .15rem .5rem; font: inherit; font-size: .8rem; cursor: pointer; }
.lang-switch button.on { background: var(--brand-ink); color: var(--brand); }
.progress-wrap { margin: var(--space-2) 0 var(--space-4); }
.progress-meta { display: flex; justify-content: space-between; font-size: .85rem; color: var(--muted); font-weight: 600; }
.progress { height: 10px; background: #dbe3df; border-radius: 99px; overflow: hidden; margin: .35rem 0; }
.progress > div { height: 100%; background: var(--brand); border-radius: 99px; transition: width .35s ease; }
.progress-cheer { font-size: .9rem; }
.kicker { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--brand); margin-bottom: .35rem; }
.help { color: var(--muted); margin: 0 0 1.1rem; }
.nav { display: flex; justify-content: space-between; gap: var(--space-3); margin-top: var(--space-5); }
.nav.end { justify-content: flex-end; }
.saved { font-size: .8rem; color: var(--muted); margin-top: .6rem; min-height: 1.2em; }
.needlist { display: grid; gap: var(--space-4); margin: var(--space-4) 0; }
.needlist > div { background: var(--bg); border-radius: var(--radius-s); padding: .9rem 1rem; }
.needlist ul, .needlist ol { margin: .2rem 0 0; padding-left: 1.2rem; }
.needlist li { margin: .15rem 0; }
.review-block { border: 1px solid var(--line); border-radius: var(--radius-s); padding: .8rem 1rem; margin-bottom: .8rem; }
.review-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .4rem; }
.review-head h2 { margin: 0; }
.kv { display: grid; grid-template-columns: 9rem 1fr; gap: var(--space-2); padding: .25rem 0; font-size: .92rem; border-top: 1px dashed var(--line); }
.kv span { color: var(--muted); }
.kv b { font-weight: 500; overflow-wrap: anywhere; }
.center { text-align: center; }
.done { text-align: center; padding: var(--space-6) var(--space-5); }
.bigcheck { width: 64px; height: 64px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 2rem; display: grid; place-items: center; margin: 0 auto var(--space-4); }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- 6. Admin pages ---------- */
.text-editor .text-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--line); }
.text-editor .text-row:first-of-type { border-top: 0; }
.text-editor .text-id { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); font-family: ui-monospace, monospace; }
.text-editor textarea { font-size: .9rem; min-height: 2.6rem; }
.text-editor .changed textarea { border-color: var(--brand); background: var(--brand-soft); }
.sector-list a { display: block; padding: .45rem .6rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.sector-list a.on { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.sector-list a:hover { background: var(--bg); }
.sector-layout { display: grid; grid-template-columns: 260px 1fr; gap: var(--space-4); align-items: start; }
.sector-select { display: none; }

/* ---------- 7. Small screens ---------- */
@media (max-width: 720px) {
  .sector-layout { grid-template-columns: 1fr; }
  .sector-layout .sector-list { display: none; }
  .sector-select { display: block; }
  .text-editor .text-row { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
@media (max-width: 640px) {
  .kv { grid-template-columns: 1fr; gap: 0; }
  .copy-row { grid-template-columns: 1fr auto; }
  .copy-row > span { grid-column: 1 / -1; font-size: .8rem; }
  table.list .hide-sm { display: none; }
  h1 { font-size: 1.25rem; }
}
