/* Johtokeskus. Token values copied from the agenttikeskus / MAIA-hub set (UI7): Work Sans, KN blue,
   light and dark. Dark follows the system unless the user picked a theme (data-theme on <html>). */

@font-face {
  font-family: "Work Sans"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/work-sans-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Work Sans"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url("/static/fonts/work-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #f7f6f3; --surface: #ffffff; --surface-2: #f1efea; --surface-3: #e9e6df;
  --border: #e6e2db; --border-strong: #cfc9bf;
  --text: #161f30; --text-2: #5b6473; --text-3: #666b74; --inverse: #ffffff;
  --primary: #0f6cbf; --primary-hover: #0b5aa1; --primary-soft: #e8f1fa; --primary-soft-2: #d3e5f6;
  --danger: #c23a3a; --danger-soft: #fbe9e9; --warn: #996010; --warn-soft: #fff3d6; --ok: #297946; --ok-soft: #e4f4e9;
  --rail-bg: #161f30; --rail-fg: #e9edf3; --rail-fg-2: #a7b2c3; --rail-hover: rgba(255,255,255,.08);
  --rail-mono: rgba(255,255,255,.08); --rail-on: #5aa6ea; --rail-on-fg: #0e1420;
  --ms-bg: #ffffff; --ms-fg: #5e5e5e; --ms-border: #8c8c8c;
  --dev-bg: #fff3d6; --dev-fg: #4d3200; --dev-border: #e6c47a;
  /* Report heat fill: one blue ramp, darker = more (dataviz sequential). Ink is the text on each step. */
  --heat-1: #86b6ef; --heat-2: #3987e5; --heat-3: #1c5cab; --heat-4: #0d366b;
  --heat-ink-1: #161f30; --heat-ink-2: #161f30; --heat-ink-3: #ffffff; --heat-ink-4: #ffffff;
  --shadow-1: 0 1px 2px rgba(22,31,48,.06), 0 1px 1px rgba(22,31,48,.04);
  --shadow-2: 0 8px 24px rgba(22,31,48,.10), 0 2px 6px rgba(22,31,48,.06);
  --ring: 0 0 0 3px rgba(15,108,191,.30);
  --font: "Work Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r-s: 6px; --r-m: 10px; --r-l: 16px;
  --rail-w: 64px; --rail-w-wide: 264px; --toolnav-w: 236px;
  /* Motion tokens (02-ui.md, Motion). Every duration and easing in this file uses one of these. */
  --ease: cubic-bezier(.2,.7,.2,1);        /* enter, move */
  --ease-exit: cubic-bezier(.4,0,1,1);     /* leave */
  --dur-structure: .32s;                   /* rail, tool sidebar: the shell changing shape */
  --dur-exit: .24s;                        /* a panel leaving */
  --dur-drawer: .22s;                      /* phone drawer */
  --dur-fade-out: .14s;                    /* old page content */
  --dur-fade-in: .22s;                     /* new page content, after --dur-fade-delay */
  --dur-fade-delay: .06s;
  --dur-spin: .8s;                         /* one turn of a waiting spinner (UI18) */
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e1420; --surface: #161f30; --surface-2: #1b2637; --surface-3: #22304a;
  --border: #26324a; --border-strong: #3a4a66;
  --text: #e9edf3; --text-2: #a7b2c3; --text-3: #8f9aad; --inverse: #0e1420;
  --primary: #5aa6ea; --primary-hover: #7ab8f0; --primary-soft: #16304a; --primary-soft-2: #1d3f61;
  --danger: #f08484; --danger-soft: #3a1f22; --warn: #e6b45a; --warn-soft: #3a2e14; --ok: #6fcf8f; --ok-soft: #1a3325;
  --rail-bg: #0a0f19;
  --ms-bg: #2f2f2f; --ms-fg: #ffffff; --ms-border: #2f2f2f;
  --dev-bg: #3a2e14; --dev-fg: #ffe9a8; --dev-border: #6a5220;
  --heat-1: #184f95; --heat-2: #256abf; --heat-3: #5598e7; --heat-4: #b7d3f6;
  --heat-ink-1: #e9edf3; --heat-ink-2: #ffffff; --heat-ink-3: #0e1420; --heat-ink-4: #0e1420;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35); --shadow-2: 0 10px 30px rgba(0,0,0,.45);
  --ring: 0 0 0 3px rgba(90,166,234,.40);
  color-scheme: dark;
} }
:root[data-theme="dark"] {
  --bg: #0e1420; --surface: #161f30; --surface-2: #1b2637; --surface-3: #22304a;
  --border: #26324a; --border-strong: #3a4a66;
  --text: #e9edf3; --text-2: #a7b2c3; --text-3: #8f9aad; --inverse: #0e1420;
  --primary: #5aa6ea; --primary-hover: #7ab8f0; --primary-soft: #16304a; --primary-soft-2: #1d3f61;
  --danger: #f08484; --danger-soft: #3a1f22; --warn: #e6b45a; --warn-soft: #3a2e14; --ok: #6fcf8f; --ok-soft: #1a3325;
  --rail-bg: #0a0f19;
  --ms-bg: #2f2f2f; --ms-fg: #ffffff; --ms-border: #2f2f2f;
  --dev-bg: #3a2e14; --dev-fg: #ffe9a8; --dev-border: #6a5220;
  --heat-1: #184f95; --heat-2: #256abf; --heat-3: #5598e7; --heat-4: #b7d3f6;
  --heat-ink-1: #e9edf3; --heat-ink-2: #ffffff; --heat-ink-3: #0e1420; --heat-ink-4: #0e1420;
  --shadow-1: 0 1px 2px rgba(0,0,0,.35); --shadow-2: 0 10px 30px rgba(0,0,0,.45);
  --ring: 0 0 0 3px rgba(90,166,234,.40);
  color-scheme: dark;
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.55; }
h1, h2, h3 { margin: 0; line-height: 1.2; text-wrap: balance; }
p { margin: 0; }
a { color: var(--primary); }
code { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-s); }
/* `hidden` must win over any component's display (e.g. a closed .panel). */
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* Shell */
.app { display: grid; grid-template-columns: auto minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.nav { display: flex; position: sticky; top: 0; height: 100vh; height: 100dvh; z-index: 20; }
.main { min-width: 0; }
.mbar, .scrim { display: none; }

/* Rail */
/* view-transition-name (Motion) makes the rail and the tool sidebar stacking contexts, so the user menu
   and hover labels can only rise above the sidebar if the rail itself is above it. */
.rail { position: relative; z-index: 2; }
.toolnav { position: relative; z-index: 1; }
.rail { width: var(--rail-w); background: var(--rail-bg); color: var(--rail-fg); display: flex; flex-direction: column; gap: 4px; padding: 12px 10px; }
.rail--wide { width: var(--rail-w-wide); }
.rail-brand, .rail-link { display: flex; align-items: center; gap: 12px; padding: 6px; border-radius: var(--r-m); color: var(--rail-fg-2); text-decoration: none; position: relative; min-height: 48px; }
.rail-brand { margin-bottom: 8px; color: var(--rail-fg); }
.rail-link:hover { background: var(--rail-hover); color: var(--rail-fg); }
.rail-link.is-on { color: var(--rail-fg); }
.rail-link.is-on .mono { background: var(--rail-on); color: var(--rail-on-fg); }
.rail--wide .rail-link.is-on { background: var(--rail-hover); }
.mono { flex: none; width: 36px; height: 36px; border-radius: var(--r-m); display: grid; place-items: center; background: var(--rail-mono); font-weight: 700; font-size: 13px; letter-spacing: .02em; }
.mono--brand { background: var(--rail-fg); color: var(--rail-bg); }
.mono--avatar { border-radius: 50%; background: #5aa6ea; color: #0e1420; font-size: 12px; }
.rail-text { display: none; min-width: 0; }
.rail--wide .rail-text { display: flex; flex-direction: column; line-height: 1.25; }
.rail-text > span { font-weight: 600; color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-text small { font-size: 12px; color: var(--rail-fg-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-brand .rail-text > span { font-size: 16px; font-weight: 700; }
.rail-grow { flex: 1; }
/* Collapsed rail: the name appears beside the icon on hover and keyboard focus. */
.rail:not(.rail--wide) [data-label]:hover::after,
.rail:not(.rail--wide) [data-label]:focus-visible::after {
  content: attr(data-label); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%);
  background: var(--rail-bg); color: var(--rail-fg); padding: 5px 10px; border-radius: var(--r-s); font-size: 13px; font-weight: 600;
  white-space: nowrap; box-shadow: var(--shadow-2); pointer-events: none; z-index: 40;
}

/* User menu */
.usermenu { position: relative; }
.usermenu summary { list-style: none; cursor: pointer; }
.usermenu summary::-webkit-details-marker { display: none; }
.usermenu[open] summary::after { display: none; }
.usermenu-pop { position: absolute; left: calc(100% + 10px); bottom: 0; width: 272px; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-2); padding: 16px; display: grid; gap: 12px; z-index: 40; }
.usermenu-who { display: grid; }
.usermenu-who span { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.usermenu-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); margin-bottom: -6px; }
.seg { display: flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; }
.seg button { flex: 1; font: inherit; font-size: 13px; font-weight: 500; border: 0; background: transparent; color: var(--text-2); padding: 5px 8px; border-radius: 999px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--inverse); }

/* Tool sidebar */
.toolnav { width: var(--toolnav-w); background: var(--surface-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; padding: 20px 8px 16px; overflow-y: auto; }
.toolnav-name { font-size: 17px; font-weight: 700; padding: 6px 8px 8px; }
/* A sub-tool's name sits centred over its pages, with a line under it; the pages hang from the column's left edge. */
.toolnav-group { font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--text-3); padding: 14px 8px 7px; margin-bottom: 4px; text-align: center; border-bottom: 1px solid var(--border-strong); }
/* A sub-tool's heading that follows another sub-tool's pages gets room above it, so each sub-tool reads as its
   own block. */
.toolnav-link + .toolnav-group { margin-top: 12px; }
.toolnav-link { display: block; padding: 6px 8px; border-radius: var(--r-s); color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 14px; }
.toolnav-link:hover { background: var(--surface-3); color: var(--text); }
.toolnav-link.is-on { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.toolnav-icon { flex: none; margin-right: 8px; vertical-align: -3px; }
.toolnav-admin { margin-top: auto; padding-top: 6px; display: flex; flex-direction: column; gap: 2px; }

/* Page anatomy (UI3) */
.page { max-width: 1120px; padding: 28px 40px 72px; display: grid; gap: 20px; align-content: start; }
/* Takaisin (UI24): an arrow before the breadcrumb; dimmed when there is nowhere to go back to. */
.crumbs { display: flex; align-items: center; gap: 8px; }
.crumbs-back { flex: none; display: grid; place-items: center; width: 28px; height: 28px; margin-left: -6px; border: 0; border-radius: var(--r-s); background: transparent; color: var(--text-2); cursor: pointer; }
.crumbs-back:hover { background: var(--surface-2); color: var(--text); }
.crumbs-back:disabled { opacity: .4; cursor: default; background: transparent; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; font-size: 13px; color: var(--text-3); }
.crumbs li + li::before { content: "›"; margin-right: 6px; }
.crumbs a { color: var(--text-2); text-decoration: none; }
.crumbs a:hover { color: var(--primary); text-decoration: underline; }
.crumbs [aria-current] { color: var(--text); font-weight: 500; }
.ph { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.ph h1 { font-size: 27px; font-weight: 650; letter-spacing: -.01em; }
.ph-sub { color: var(--text-2); margin-top: 4px; }

/* Controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; justify-self: start; padding: 8px 14px; border-radius: var(--r-s); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn--pri { background: var(--primary); border-color: var(--primary); color: var(--inverse); }
.btn--pri:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--quiet { width: 100%; }
.chip { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.chip--warn { background: var(--warn-soft); color: var(--warn); }
.chip--ok { background: var(--ok-soft); color: var(--ok); }
.chip--danger { background: var(--danger-soft); color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.btn--sm { padding: 5px 10px; font-size: 13px; }
.btn--ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }
.btn--danger { color: var(--danger); margin-left: auto; }
.btn--danger:hover { color: var(--danger); background: var(--danger-soft); }
.link-quiet { font-size: 13px; color: var(--text-2); }
.spacer { flex: 1; }

/* Home */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-1); padding: 18px 20px 20px; display: grid; gap: 8px; align-content: start; }
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; }
.card-src { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.card-title { font-size: 17px; font-weight: 600; }
.card-text { color: var(--text-2); }
.card .btn { margin-top: 6px; }

/* Empty and error states */
.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r-l); padding: 32px; display: grid; gap: 6px; }
.empty h2 { font-size: 17px; font-weight: 600; }
.empty p { color: var(--text-2); max-width: 60ch; }
.err { max-width: 540px; display: grid; gap: 12px; padding-top: 6vh; }
.err h1 { font-size: 27px; font-weight: 650; }
.err p { color: var(--text-2); }
.err-code { font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.err .btn { margin-top: 6px; }

/* Signed-out pages: login and the 500 page */
.solo { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px 96px; }
.solo .page { padding: 0; }
.login { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-2); padding: 36px; display: grid; gap: 16px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.login-brand .mono { background: var(--rail-bg); color: var(--rail-fg); }
.login h1 { font-size: 26px; font-weight: 650; margin-top: 8px; }
.login > p { color: var(--text-2); }
.login form { margin-top: 4px; }
.btn--ms { width: 100%; padding: 11px 14px; background: var(--ms-bg); color: var(--ms-fg); border-color: var(--ms-border); font-family: "Segoe UI", var(--font); font-size: 15px; }
.btn--ms:hover { background: var(--ms-bg); filter: brightness(.97); }
.login-foot { font-size: 13px; color: var(--text-3); }
.notice { padding: 10px 14px; border-radius: var(--r-m); font-size: 14px; }
.notice--info { background: var(--primary-soft); color: var(--text); }
.notice--error { background: var(--danger-soft); color: var(--danger); font-weight: 500; }

/* Detail pattern: profile header, sections, entries */
.ph--split { justify-content: space-between; align-items: flex-start; }
.ph-chips { margin-top: 10px; }
.notice--warn { background: var(--warn-soft); color: var(--text); }
.notice--ok { background: var(--ok-soft); color: var(--text); }
.sections { display: grid; gap: 18px; }
.sect { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); padding: 18px 20px; display: grid; gap: 12px; }
.sect-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.sect-head h2 { font-size: 17px; font-weight: 650; }
.sect-tag { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.sect-empty { color: var(--text-3); }
.entry { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; }
.entry--card { border-top: 1px solid var(--border); padding-top: 12px; }
.sect-head + [data-page-item] > .entry--card, [data-page-first] > .entry--card { border-top: 0; padding-top: 0; }
.entry-main { min-width: 0; display: grid; gap: 4px; }
.entry-title { font-size: 15px; font-weight: 600; }
.entry-note { font-size: 13px; color: var(--text-3); }
.entry-side { display: grid; gap: 8px; justify-items: end; flex: none; }
.entry-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 14px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.kv dd.kv-long { grid-column: 1 / -1; color: var(--text-2); margin-bottom: 4px; }
/* The section's own add action sits in a footer row with the same divider as between entries, so it
   never reads as part of the last entry (e.g. right after that entry's "Lisää liite"). */
.sect-foot { border-top: 1px solid var(--border); padding-top: 12px; }

/* Koulutukset */
.chip--plain { }
.block { display: grid; gap: 10px; }
.block-h { font-size: 13px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.tlist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 380px), 1fr)); gap: 12px; }
.titem { display: grid; gap: 8px; height: 100%; padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); color: var(--text); text-decoration: none; box-shadow: var(--shadow-1); }
.titem:hover { border-color: var(--border-strong); }
.titem-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.titem-title { font-weight: 650; font-size: 16px; }
.titem-meta { font-size: 14px; color: var(--text-2); }
.titem--cancelled { background: var(--surface-2); border-style: dashed; border-color: var(--danger); box-shadow: none; }
.titem--cancelled .titem-title { color: var(--text-2); text-decoration: line-through; }
.titem--cancelled .titem-meta, .titem--cancelled .chip:not(.chip--danger) { opacity: .6; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.sect-h { font-size: 17px; font-weight: 650; }
.prose { color: var(--text); max-width: 68ch; white-space: pre-line; }
.muted { color: var(--text-2); font-size: 14px; }
.action-box { position: sticky; top: 16px; }
.action-stack { display: grid; gap: 10px; }
.action-stack .btn { justify-self: stretch; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }
/* The line is an inset shadow, not a border: a tab's underline then sits on it without a negative
   margin, which would overflow by 1px and show a vertical scrollbar. */
.objtabs { display: flex; gap: 4px; box-shadow: inset 0 -1px var(--border); overflow-x: auto; overflow-y: hidden; }
.objtab { padding: 9px 14px; color: var(--text-2); text-decoration: none; font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; }
.objtab:hover { color: var(--text); }
.objtab.is-on { color: var(--primary); border-bottom-color: var(--primary); }
.objtab-count { font-size: 12px; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 7px; margin-left: 4px; }
.card-tbl { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
.tbl th, .tbl td { text-align: left; padding: 11px 16px; border-top: 1px solid var(--border); vertical-align: top; }
.tbl thead th { border-top: 0; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-link { font-weight: 600; text-decoration: none; }
.cell-sub { display: block; font-size: 13px; color: var(--text-3); }
.plist { display: grid; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr) 260px; gap: 8px 16px; align-items: center; padding: 10px 0; }
.prow + .prow { border-top: 1px solid var(--border); }
.prow-who { display: grid; }
.prow-who a { font-weight: 600; text-decoration: none; }
.prow-state { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.prow-note { font-size: 13px; color: var(--ok); font-weight: 500; }
.form-page { max-width: 880px; }

/* Builder pattern (Hallinta) */
.builder { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.builder-list { display: grid; gap: 10px; position: sticky; top: 16px; }
.builder-main { display: grid; gap: 16px; min-width: 0; }
.blist, .flist { list-style: none; margin: 0; padding: 0; }
.blist { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); overflow: hidden; }
.brow { display: flex; align-items: center; gap: 4px; padding-right: 6px; }
.brow + .brow { border-top: 1px solid var(--border); }
.brow.is-on { background: var(--primary-soft); }
.brow-main { flex: 1; min-width: 0; display: grid; gap: 2px; padding: 10px 12px; color: var(--text); text-decoration: none; }
.brow-name { font-weight: 600; }
.brow.is-on .brow-name { color: var(--primary); }
.brow-sub, .frow-sub { font-size: 13px; color: var(--text-3); }
.is-archived .brow-name, .is-archived .frow-name { color: var(--text-3); text-decoration: line-through; }
.move { display: inline-flex; gap: 2px; flex: none; }
.move-btn { width: 30px; height: 30px; border: 1px solid transparent; border-radius: var(--r-s); background: transparent; color: var(--text-2); font: inherit; font-size: 15px; cursor: pointer; }
.move-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.move-btn:disabled { opacity: .3; cursor: default; }
.flist { display: grid; }
.flist > li + li { border-top: 1px solid var(--border); }
.frow { display: flex; align-items: center; gap: 8px; padding: 10px 0; }
.frow-main { flex: 1; min-width: 0; display: grid; gap: 4px; }
.frow-name { font-weight: 600; }
.flist > li > .entry--form { margin: 10px 0; }
.opts { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; }
.opts legend { font-size: 14px; font-weight: 600; margin-bottom: 6px; padding: 0; }
.opts .check { align-items: flex-start; }
.opts .check input { margin-top: 3px; }
.preview { border: 0; margin: 0; padding: 0; min-width: 0; }
.preview :disabled { cursor: default; }
.inline-add { display: flex; gap: 8px; align-items: center; }
.inline-add input[type="text"] { flex: 1; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-s); padding: 6px 10px; }

/* Attachments */
.files { display: grid; gap: 6px; margin-top: 6px; }
.file-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.file { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 10px; font-size: 14px; min-width: 0; }
.file a { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; text-decoration: none; }
.file a:hover .file-name { text-decoration: underline; }
.file-name { overflow-wrap: anywhere; }
.file-kind { font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--text-2); background: var(--surface-3); border-radius: 4px; padding: 0 5px; }
.file-meta, .file-hint { font-size: 13px; color: var(--text-3); }
.file-add { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.file-add label { cursor: pointer; }
.file-add label:focus-within { box-shadow: var(--ring); }
.file-busy { display: none; font-size: 13px; color: var(--text-2); }
.file-add.htmx-request .file-busy { display: inline; }
.file-add.htmx-request .file-hint { display: none; }
.panel-label { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.queue-what .file-list { margin-top: 4px; }

/* Form pattern */
.entry--form { display: grid; gap: 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-m); padding: 16px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 14px 18px; }
.field { display: grid; gap: 5px; align-content: start; min-width: 0; }
.field--long_text, .field--multi_choice { grid-column: 1 / -1; }
.field label, .field legend { font-size: 14px; font-weight: 600; color: var(--text); padding: 0; }
.field fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
.field input[type="text"], .field input[type="search"], .field input[type="number"], .field input[type="date"], .field select, .field textarea,
.fgroup input[type="number"], .field input[type="datetime-local"], .tender-file-form select, .case-status, .severa-map select {
  font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-s); padding: 7px 10px; width: 100%; min-width: 0;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, .fgroup input:focus-visible { border-color: var(--primary); }
.field--error input, .field--error select, .field--error textarea { border-color: var(--danger); }
.field-help { font-size: 13px; color: var(--text-3); }
.field-err { font-size: 13px; color: var(--danger); font-weight: 500; }
.req { color: var(--danger); }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; flex: none; }
.form-error { color: var(--danger); font-weight: 600; }
.form-note { font-size: 14px; color: var(--text); background: var(--warn-soft); padding: 8px 12px; border-radius: var(--r-s); }
.form-actions { display: flex; gap: 8px; }

/* List pattern: search */
.page--wide { max-width: 1280px; }
.search { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 24px; align-items: start; }
.filters { display: grid; gap: 4px; position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 2px 4px 16px 2px; }
/* The scrollbar's space is always reserved, so opening a filter group that makes the column scroll does
   not narrow it. The thin thumb shows only while the pointer or focus is in the column. */
.filters { scrollbar-gutter: stable; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.filters:hover, .filters:focus-within { scrollbar-color: var(--border-strong) transparent; }
.filters > .field { margin-bottom: 8px; }
.check--box { padding: 8px 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 4px; align-items: flex-start; }
.fgroup { border-bottom: 1px solid var(--border); }
.fgroup summary { cursor: pointer; padding: 10px 2px; font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; list-style: none; }
.fgroup summary::-webkit-details-marker { display: none; }
.fgroup summary::after { content: "+"; margin-left: auto; color: var(--text-3); font-weight: 500; }
.fgroup[open] summary::after { content: "–"; }
.fgroup-count { font-size: 12px; background: var(--primary); color: var(--inverse); border-radius: 999px; padding: 0 7px; }
.fgroup .checks { flex-direction: column; gap: 7px; padding: 0 2px 12px; }
.fgroup input[type="number"] { margin: 0 0 12px; max-width: 120px; }
.check-count { margin-left: auto; font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.fgroup .check { width: 100%; }
.results { display: grid; gap: 12px; align-content: start; min-width: 0; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-height: 32px; }
.results-count { font-size: 14px; color: var(--text-2); }
.results-count b { color: var(--text); font-variant-numeric: tabular-nums; }
.chip--filter { text-decoration: none; background: var(--primary-soft); color: var(--primary); }
.chip--filter:hover { background: var(--primary-soft-2); }
.result-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); overflow: hidden; }
.result-list li + li { border-top: 1px solid var(--border); }
.result { display: grid; gap: 6px; padding: 12px 16px; color: var(--text); text-decoration: none; }
.result:hover { background: var(--surface-2); }
.result[aria-current="true"] { background: var(--primary-soft); }
.result-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.result-name { font-weight: 600; }
.result-meta, .result-stale { font-size: 13px; color: var(--text-2); }
.result-stale { color: var(--warn); }
.result-matches { display: flex; flex-wrap: wrap; gap: 5px; }

/* Side panel (UI3, UI6): its own URL, slides in from the right */
.panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 30; width: min(480px, 100vw); background: var(--surface); border-left: 1px solid var(--border-strong); box-shadow: var(--shadow-2); overflow-y: auto; padding: 20px 22px 32px; display: grid; gap: 14px; align-content: start; }
.panel-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.panel-head h2 { font-size: 20px; font-weight: 650; }
.panel-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.panel-sub, .panel-text { color: var(--text-2); font-size: 14px; }
.panel-close { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: var(--r-s); font-size: 22px; line-height: 1; color: var(--text-2); text-decoration: none; }
.panel-close:hover { background: var(--surface-2); color: var(--text); }
.panel > .btn { justify-self: start; }
.pv { display: grid; gap: 6px; border-top: 1px solid var(--border); padding-top: 12px; }
.pv h3 { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.pv ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.pv li { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; }
.pv-sub { color: var(--text-2); }
.pv-line { display: block; width: 100%; }
.pv-ok { font-size: 12px; font-weight: 600; color: var(--ok); }
.tbl-wrap { overflow-x: auto; }
.diff { width: 100%; border-collapse: collapse; font-size: 14px; }
.diff th, .diff td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.diff thead th { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); }
.diff tbody th { font-weight: 500; color: var(--text-2); }

/* Run pattern (UI4, partials/run.html) */
/* A native <progress>: the browser draws the fill from value/max, so no inline width (CSP style-src 'self'). */
.meter { appearance: none; display: inline-block; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--surface-3); overflow: hidden; vertical-align: middle; }
.meter::-webkit-progress-bar { background: var(--surface-3); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.run-progress { display: grid; gap: 6px; min-width: 200px; font-size: 14px; color: var(--text-2); }
.run-progress-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.run-mini { display: inline-flex; align-items: center; gap: 10px; font-variant-numeric: tabular-nums; }
.run-mini .meter { width: 80px; }
/* Perehdytys list on a phone (UI14): no sideways scrolling; the day moves under the name. */
.run-day-sub { display: none; }
@media (max-width: 720px) {
  .tbl--runs { min-width: 0; }
  .tbl--runs th, .tbl--runs td { padding: 10px 8px; }
  .tbl--runs .col-day { display: none; }
  .tbl--runs .run-day-sub { display: block; }
  .tbl--runs .run-mini { gap: 6px; }
  .tbl--runs .run-mini .meter { width: 36px; }
}
.run-groups { display: grid; gap: 16px; }
.run-group { gap: 4px; }
.rstep { display: grid; grid-template-columns: minmax(0, 1fr) 120px minmax(0, 1.3fr); gap: 8px 16px; align-items: center; padding: 10px 0; }
.rstep + .rstep { border-top: 1px solid var(--border); }
.rstep-main { display: grid; gap: 2px; min-width: 0; }
.rstep-name { font-weight: 600; }
.rstep.is-closed .rstep-name { font-weight: 500; color: var(--text-2); }
.rstep-sub { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
.rstep-state { display: flex; flex-wrap: wrap; gap: 4px; }
.rstep-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; align-items: center; }
.rstep-actions form { display: contents; }
/* Tarkista's answer (M9): the account's details under the step, label and value pairs that wrap. */
.rstep-acct { grid-column: 1 / -1; }
/* A step's optional note: a small text that opens the field under the buttons (no JavaScript: <details>). */
.note > summary { list-style: none; cursor: pointer; font-size: 13px; color: var(--text-2); padding: 4px 6px; border-radius: var(--r-s); text-decoration: underline dotted; text-underline-offset: 3px; }
.note > summary::-webkit-details-marker { display: none; }
.note > summary:hover { color: var(--text); background: var(--surface-2); }
.note > summary:focus-visible { box-shadow: var(--ring); outline: none; }
.note[open] { order: 1; flex: 1 1 100%; }
.note[open] > summary { display: inline-block; margin-bottom: 4px; }
.rstep-form .note input[type="text"] { display: block; width: 100%; }
.rstep.is-asking .rstep-actions { grid-column: 1 / -1; justify-content: flex-start; }
.rstep-form input[type="email"] { flex: 0 1 380px; }
.acct { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 16px; margin: 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-m); background: var(--surface-2); font-size: 13px; }
.acct dt { color: var(--text-3); }
.acct dd { margin: 0; overflow-wrap: anywhere; }
.rstep-form input[type="text"], .rstep-form input[type="email"] { flex: 1 1 160px; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-s); padding: 5px 9px; }
/* ▶ Käynnistä: an automatic step acts on real accounts and groups, so it is red, unlike everyday buttons.
   --danger with --inverse text: 5.3:1 light, 7.3:1 dark. */
.btn--start { background: var(--danger); border-color: var(--danger); color: var(--inverse); gap: 6px; }
.btn--start:hover { background: var(--danger); filter: brightness(.92); }
.chip--auto { background: var(--primary-soft); color: var(--primary); vertical-align: 1px; }
.start-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 16px; align-items: start; }
.plain-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 14px; }
.item-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.item-add input[type="text"], .item-add select { flex: 1 1 180px; min-width: 0; font: inherit; font-size: 14px; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-s); padding: 6px 10px; }
.item-add select { flex: 0 1 auto; }
.item-edit { display: grid; gap: 10px; }

.picks { display: grid; gap: 4px; border: 0; margin: 0; padding: 0; min-width: 0; }
.pick { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: var(--r-s); cursor: pointer; font-size: 14px; }
.pick:hover { background: var(--surface-2); }
.pick input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; flex: none; }
.events { list-style: none; margin: 0; padding: 0; display: grid; }
.event { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 4px 14px; padding: 8px 0; font-size: 14px; }
.event + .event { border-top: 1px solid var(--border); }
.event-when { color: var(--text-3); font-variant-numeric: tabular-nums; }
.event-sub { display: block; color: var(--text-2); font-size: 13px; }
.danger-zone { border: 1px solid var(--border); border-radius: var(--r-l); padding: 12px 18px; background: var(--surface); }
.danger-zone summary { cursor: pointer; font-weight: 600; color: var(--danger); font-size: 14px; }
.danger-zone form { margin-top: 10px; flex-wrap: wrap; display: flex; gap: 8px; align-items: center; }
.danger-zone .btn--danger { margin-left: 0; }
.danger-zone form p { flex-basis: 100%; }
.danger-zone input[type="text"] { flex: 1 1 240px; }
.nowrap { white-space: nowrap; }

/* Reports (Raportit) */
.rform { display: flex; flex-wrap: wrap; align-items: end; gap: 12px 20px; }
.rform .field-row { flex: 1 1 100%; }
/* Two fields on one line when there is room (first name and surname); stacked on a phone. */
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); gap: 12px; }
/* A joining run's account link: the search, its results and the button apart from each other. */
.link-form { display: grid; gap: 12px; }
/* Tarkistuslista while empty: the starting checklist across the whole builder. */
.builder-start { grid-column: 1 / -1; display: grid; gap: 10px; justify-items: start; }
.link-form > .btn { justify-self: start; }
.rform .field { min-width: min(100%, 240px); }
.rform .check { padding-bottom: 9px; }
.report { display: grid; gap: 14px; }
.report-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.report-head .btn { margin-left: auto; }
.heatmap th[scope="row"] { font-weight: 500; white-space: nowrap; }
/* The item column stays in place while the regions scroll sideways (phones, many regions). */
.heatmap tr > :first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.heatmap td, .heatmap th { padding: 4px 6px; vertical-align: middle; }
.heatmap th:first-child, .heatmap td:first-child { padding-left: 16px; }
.heatmap th:last-child, .heatmap td:last-child { padding-right: 16px; }
.heatmap thead th { padding-top: 12px; padding-bottom: 10px; }
.heatmap .heat-col { min-width: 64px; max-width: 104px; white-space: normal; text-transform: none; letter-spacing: 0; font-size: 13px; text-align: center; }
.heatmap tfoot th, .heatmap tfoot td { color: var(--text-2); font-size: 13px; padding-top: 10px; padding-bottom: 10px; }
.heat { display: inline-grid; place-items: center; min-width: 40px; height: 30px; padding: 0 8px; border-radius: 4px; font-variant-numeric: tabular-nums; font-weight: 600; text-decoration: none; background: var(--heat-bg, transparent); color: var(--heat-ink, var(--text-3)); }
.heat--0 { font-weight: 400; }
.heat--1 { --heat-bg: var(--heat-1); --heat-ink: var(--heat-ink-1); }
.heat--2 { --heat-bg: var(--heat-2); --heat-ink: var(--heat-ink-2); }
.heat--3 { --heat-bg: var(--heat-3); --heat-ink: var(--heat-ink-3); }
.heat--4 { --heat-bg: var(--heat-4); --heat-ink: var(--heat-ink-4); }
a.heat:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.heat-total .heat { color: var(--text); }
.heat-legend { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-2); }
.heat-legend .heat { min-width: 22px; height: 14px; padding: 0; }
.heat-legend span:first-child { margin-right: 4px; }
.heat-legend span:last-child { margin-left: 4px; }
.gaps { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); }
.gap { display: grid; gap: 8px; padding: 14px 18px; border-top: 1px solid var(--border); }
.gap:first-child { border-top: 0; }
.gap-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.gap-title { font-weight: 650; }
.gap-train { font-size: 14px; }
.chip--link { text-decoration: none; }
.chip--link:hover { text-decoration: underline; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); padding: 14px 18px; display: grid; gap: 2px; }
.stat-label { font-size: 13px; color: var(--text-2); }
.stat-value { font-size: 30px; font-weight: 650; line-height: 1.2; }
.diff tr.is-changed td { background: var(--warn-soft); font-weight: 600; }
.diff tr.is-changed td:nth-child(2) { text-decoration: line-through; font-weight: 400; color: var(--text-2); }

/* Verification queue */
.queue { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-l); }
.queue-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) 120px 230px; gap: 8px 18px; align-items: center; padding: 12px 16px; }
.queue-row + .queue-row { border-top: 1px solid var(--border); }
.queue-row.is-done { opacity: .7; }
.queue-who, .queue-what { display: grid; min-width: 0; }
.queue-who a { font-weight: 600; text-decoration: none; }
.queue-title { font-weight: 500; }
.queue-sub { font-size: 13px; color: var(--text-3); }
.queue-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* Mock bar */
.devbar { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 60; background: var(--dev-bg); color: var(--dev-fg); border: 1px solid var(--dev-border); border-radius: var(--r-m); box-shadow: var(--shadow-2); font-size: 13px; max-width: min(360px, calc(100vw - 32px)); }
.devbar summary { cursor: pointer; padding: 6px 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; }
.devbar-body { padding: 0 12px 12px; display: grid; gap: 8px; }
.devbar form { display: flex; align-items: center; gap: 8px; }
.devbar select { font: inherit; padding: 4px 6px; border-radius: var(--r-s); border: 1px solid var(--dev-border); background: var(--surface); color: var(--text); }
.devbar-links { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.devbar a { color: inherit; }
.devbar code { overflow-wrap: anywhere; }

/* Motion: spec in plan/02-ui.md, "Motion". Home ⇄ tool. A boosted link replaces the whole body, so the rail is a new element each time and a
   CSS transition has nothing to start from. View Transitions (htmx `transition:true` on <body>) let
   the browser pair old and new by name: the rail shrinks to the left on top and uncovers the tool
   sidebar sliding out from under it; going home reverses it. Without support the swap is instant. */
.rail { view-transition-name: jk-rail; }
.toolnav { view-transition-name: jk-toolnav; }
.main { view-transition-name: jk-main; }
::view-transition-group(*) { animation-duration: var(--dur-structure); animation-timing-function: var(--ease); }
::view-transition-group(jk-rail) { z-index: 3; overflow: clip; }
::view-transition-group(jk-toolnav) { z-index: 2; }
::view-transition-group(jk-main) { overflow: clip; }
/* Draw snapshots at their real size, anchored top-left and clipped by the moving box, so labels
   are cut off by the rail's edge instead of being squeezed. */
::view-transition-old(jk-rail), ::view-transition-new(jk-rail),
::view-transition-old(jk-main), ::view-transition-new(jk-main) {
  height: 100%; object-fit: none; object-position: left top;
}
/* The rail does not cross-fade: both snapshots stay opaque, the new one on top. Whichever is wider
   shows past the other and is cut by the moving edge, so the rail reads as one panel closing or
   opening. The icon column is the same in both. */
::view-transition-old(jk-rail), ::view-transition-new(jk-rail) { animation: none; opacity: 1; }
/* Side panel: enters from its own edge (the right), above everything but the mock bar. */
.panel { view-transition-name: jk-panel; }
::view-transition-group(jk-panel) { z-index: 4; }
::view-transition-new(jk-panel):only-child { animation: jk-panel-in var(--dur-structure) var(--ease) both; }
::view-transition-old(jk-panel):only-child { animation: jk-panel-out var(--dur-exit) var(--ease-exit) both; }
@keyframes jk-panel-in { from { transform: translateX(100%); } }
@keyframes jk-panel-out { to { transform: translateX(100%); } }
/* Mock bar: not part of the choreography. */
.devbar { view-transition-name: jk-devbar; }
::view-transition-group(jk-devbar), ::view-transition-new(jk-devbar) { animation: none; }
::view-transition-old(jk-devbar) { display: none; }
::view-transition-new(jk-toolnav):only-child { animation: jk-toolnav-in var(--dur-structure) var(--ease) both; }
::view-transition-old(jk-toolnav):only-child { animation: jk-toolnav-out var(--dur-exit) var(--ease-exit) both; }
@keyframes jk-toolnav-in { from { transform: translateX(-48px); opacity: 0; } }
@keyframes jk-toolnav-out { to { transform: translateX(-48px); opacity: 0; } }
::view-transition-old(jk-main) { animation: jk-fade-out var(--dur-fade-out) linear both; }
::view-transition-new(jk-main) { animation: jk-fade-in var(--dur-fade-in) linear var(--dur-fade-delay) both; }
@keyframes jk-fade-out { to { opacity: 0; } }
@keyframes jk-fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none !important; }
}
@media (prefers-reduced-motion: no-preference) {
  .nav { transition: transform var(--dur-drawer) var(--ease); }
  /* The save bar (UI34) rises when the first change is made: display none → block restarts the animation. */
  .savebar.is-dirty { animation: jk-rise var(--dur-structure) var(--ease) both; }
}
@keyframes jk-rise { from { transform: translateY(16px); opacity: 0; } }

/* Phone and narrow tablet: rail and tool sidebar fold into one drawer behind the menu button. */
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .mbar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 15; height: 52px; padding: 0 max(8px, env(safe-area-inset-right, 0px)) 0 max(8px, env(safe-area-inset-left, 0px)); background: var(--rail-bg); color: var(--rail-fg); }
  .mbar-btn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-s); background: transparent; color: inherit; cursor: pointer; }
  .mbar-title { font-weight: 700; }
  .nav { position: fixed; inset: 0 auto 0 0; transform: translateX(-105%); z-index: 50; max-width: calc(100vw - 48px); }
  body[data-nav-open] .nav { transform: none; }
  body[data-nav-open] .scrim { display: block; position: fixed; inset: 0; z-index: 45; background: rgba(10,15,25,.45); }
  .toolnav { width: min(var(--toolnav-w), calc(100vw - 48px - var(--rail-w))); }
  .usermenu-pop { left: 0; bottom: calc(100% + 8px); width: min(272px, calc(100vw - 64px)); }
  .search { grid-template-columns: minmax(0, 1fr); }
  .filters { position: static; max-height: none; scrollbar-gutter: auto; }
  .entry { flex-direction: column; }
  .entry-side { justify-items: start; }
  .builder { grid-template-columns: minmax(0, 1fr); }
  .builder-list { position: static; }
  .frow { flex-wrap: wrap; }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
  .action-box { position: static; }
  .prow { grid-template-columns: minmax(0, 1fr); }
  .queue-row { grid-template-columns: minmax(0, 1fr) auto; }
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv dd { margin-bottom: 6px; }
  .queue-what { grid-column: 1 / -1; grid-row: 2; }
  .queue-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .heatmap th[scope="row"] { white-space: normal; min-width: 132px; }
  .rstep { grid-template-columns: minmax(0, 1fr) auto; }
  .rstep-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .event { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .heatmap tr > :first-child { box-shadow: inset -1px 0 var(--border); }
  .page { padding: 20px max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px)); }
  .login { padding: 28px 22px; }
}

/* htmx's indicator rules, which htmx would otherwise inject as an inline <style> (CSP, M1-Q2). No fade: UI10. */
.htmx-indicator { opacity: 0; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Ylläpito → Roolit → a person: one row per role, its button at the end (yllapito/rooli-henkilo.html). */
.role-rows { display: grid; }
.role-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; margin: 0; }
.role-row + .role-row { border-top: 1px solid var(--border); }
.role-row-main { flex: 1; min-width: 0; }

/* CV import (M6) */
.page--narrow { max-width: 760px; }
.ph-actions { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.busy-note { display: none; font-size: 14px; color: var(--text-2); align-self: center; }
form.is-busy .busy-note { display: inline; }
.read-progress { flex-basis: 100%; }
.progress-lines { list-style: none; margin: 10px 0 4px; padding: 10px 14px; display: grid; gap: 4px; font-size: 14px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-l); max-width: 90ch; }
.progress-lines li:last-child { color: var(--text); font-weight: 600; }
.progress-time { font-size: 13px; color: var(--text-3); margin: 0; }
form.is-busy button[type="submit"] { opacity: .6; pointer-events: none; }
/* CV import review: one row per proposed entry; the fields open under "Muokkaa". */
.import-review { display: grid; gap: 16px; }
.import-group { gap: 4px; }
.import-list { list-style: none; margin: 0; padding: 0; }
.import-entry { position: relative; padding: 10px 0; border-top: 1px solid var(--border); }
.import-entry:first-child { border-top: 0; }
.import-keep { display: flex; align-items: baseline; gap: 10px; padding-right: 90px; cursor: pointer; font-size: 14px; }
.import-keep input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; flex: none; align-self: center; }
.import-keep .chip { flex: none; min-width: 64px; text-align: center; }
.import-sum { min-width: 0; overflow-wrap: anywhere; }
.import-sub { color: var(--text-2); }
.import-entry:has(.import-keep input:not(:checked)) .import-sum { color: var(--text-3); text-decoration: line-through; }
.import-entry:has(.import-keep input:not(:checked)) .import-sub { color: inherit; }
.import-note { margin: 4px 0 0 26px; font-size: 13px; color: var(--text-2); }
/* A row that cannot be saved (Tarkista Severasta: no service yet) is greyed, not crossed out like a declined one. */
.import-entry--off .import-keep { cursor: not-allowed; }
.import-entry--off:has(.import-keep input:not(:checked)) .import-sum { color: var(--text-2); text-decoration: none; }
[data-page-group][hidden], [data-page-item][hidden] { display: none; }
/* A list paged in the browser (UI15): Edellinen, the page numbers, Seuraava. In a profile section it sits above
   the add button. */
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 14px; }
.pager[hidden] { display: none; }
.pager button[aria-current="page"] { background: var(--primary); border-color: var(--primary); color: var(--inverse); }
.pager .pager-info { color: var(--text-2); margin-right: auto; }
.import-edit > summary { position: absolute; top: 10px; right: 0; font-size: 14px; color: var(--primary); cursor: pointer; list-style: none; }
.import-edit > summary::-webkit-details-marker { display: none; }
.import-edit > summary::after { content: " ▸"; }
.import-edit[open] > summary::after { content: " ▾"; }
.import-edit > summary:hover { text-decoration: underline; }
.import-fields { grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 12px 0 4px 26px; padding: 14px; background: var(--surface-2); border-radius: var(--r-m); }
.import-fields .field { grid-column: span 3; }
.import-fields .field--choice { grid-column: span 2; }
.import-fields .field--year, .import-fields .field--number, .import-fields .field--date { grid-column: span 1; min-width: 110px; }
.import-fields .field--long_text, .import-fields .field--multi_choice { grid-column: 1 / -1; }
@media (max-width: 720px) {
  .import-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-left: 0; }
  .import-fields .field, .import-fields .field--choice { grid-column: 1 / -1; }
  .import-fields .field--year, .import-fields .field--number, .import-fields .field--date { grid-column: span 1; }
}
.import-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 0; border-top: 1px solid var(--border); }
.import-foot .form-actions { flex-direction: row-reverse; margin-left: auto; }

/* CV import upload: the file input stretched over a dashed drop area. */
.drop { position: relative; display: grid; justify-items: center; gap: 4px; padding: 28px 16px; border: 1.5px dashed var(--border-strong); border-radius: var(--r-m); background: var(--surface-2); text-align: center; font-size: 14px; color: var(--text-2); }
.drop:hover, .drop:focus-within, .drop.is-over { border-color: var(--primary); background: var(--primary-soft); }
.drop:focus-within { box-shadow: var(--ring); }
.drop strong { color: var(--text); font-weight: 600; }
.drop-pick { color: var(--primary); font-weight: 600; text-decoration: underline; }
.drop-files { color: var(--text); font-weight: 500; overflow-wrap: anywhere; }
.drop input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }

/* Oma profiili: "Tyhjennä profiili" at the bottom and its confirmation modal (J25). */
.profile-foot { display: grid; justify-items: start; gap: 2px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border); }
.profile-empty { color: var(--danger); padding-left: 0; }
.profile-empty:hover { color: var(--danger); background: transparent; text-decoration: underline; }
.dialog { max-width: min(460px, calc(100vw - 32px)); padding: 22px 24px; border: 1px solid var(--border); border-radius: var(--r-l); background: var(--surface); color: var(--text); box-shadow: var(--shadow-2); }
.dialog::backdrop { background: rgba(14,20,32,.45); }
.dialog form { display: grid; gap: 12px; }
.dialog h2 { font-size: 17px; font-weight: 650; }
.dialog p { font-size: 14px; color: var(--text-2); line-height: 1.5; }
.dialog .form-actions { justify-content: flex-end; margin-top: 4px; }

/* Tarjoukset (M11): the case's files, requirements and facts, each with the quote it came from. */
.quote { margin: 4px 0 0; font-size: 13px; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; }
.quote-text { font-style: italic; overflow-wrap: anywhere; }
.quote-src { color: var(--text-3); }
.tender-files { list-style: none; margin: 0; padding: 0; display: grid; }
.tender-file { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 8px 0; border-top: 1px solid var(--border); font-size: 14px; }
.tender-file:first-child { border-top: 0; }
.tender-file-main { flex: 1 1 280px; min-width: 0; display: grid; gap: 2px; }
.tender-file-main a { text-decoration: none; display: inline-flex; gap: 6px; align-items: baseline; min-width: 0; }
.tender-file-main a:hover .file-name { text-decoration: underline; }
.tender-file-form { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin: 10px 0 8px; }
.tender-file-form .check { padding-bottom: 7px; }
.tender-file-desc { flex: 1 1 320px; }
.tender-file-desc textarea { width: 100%; }
.tender-file-chips { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.file-desc { color: var(--text-2); max-width: 78ch; }
.tender-file { align-items: flex-start; }
.tender-file-edit { flex: 0 1 auto; }
.tender-file-edit[open] { flex: 1 1 100%; }
.tender-file-edit > summary { list-style: none; width: fit-content; cursor: pointer; }
.tender-file-edit > summary::-webkit-details-marker { display: none; }
.tender-upload { display: grid; gap: 10px; }
.tender-read { display: grid; gap: 6px; }
.tender-reqs { list-style: none; margin: 0; padding: 0; display: grid; }
.tender-req { padding: 10px 0; border-top: 1px solid var(--border); }
.tender-req:first-child { border-top: 0; padding-top: 0; }
.tender-req-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; font-size: 14px; }
.tender-req-sub { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.tender-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.tender-col { display: grid; gap: 18px; align-content: start; }
.tender-facts { margin: 0; display: grid; gap: 10px; font-size: 14px; }
.tender-facts dt { color: var(--text-3); font-size: 13px; }
.tender-facts dd { margin: 0; overflow-wrap: anywhere; }
.tender-list { display: grid; gap: 10px; font-size: 14px; }
.tender-filter { margin-bottom: 16px; }
.tender-fact-inputs { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 14px; }
.tender-fields .field--number { min-width: 110px; }
.tender-new > details > summary { list-style: none; display: inline-block; }
.tender-new > details > summary::-webkit-details-marker { display: none; }
.tender-new .import-fields { margin-left: 0; }
.tender-changes { margin-top: 4px; font-size: 13px; color: var(--text-2); }
@media (max-width: 900px) { .tender-grid { grid-template-columns: minmax(0, 1fr); } }
.tender-file-form select, .case-status { width: auto; padding: 5px 8px; }
.severa-map { display: flex; flex-wrap: wrap; gap: 8px; }
.severa-map select { width: auto; max-width: 100%; padding: 5px 8px; }

/* Search (UI16): the filters other than the main ones fold under "Lisää rajauksia". */
.fmore { margin-top: 8px; }
.fmore > summary { cursor: pointer; padding: 10px 2px; font-size: 14px; font-weight: 500; color: var(--primary); display: flex; align-items: center; gap: 8px; list-style: none; }
.fmore > summary::-webkit-details-marker { display: none; }
.fmore > summary::after { content: "▸"; color: var(--text-3); }
.fmore[open] > summary::after { content: "▾"; }
.fmore > summary:hover { text-decoration: underline; }
.fmore > .check--box { margin: 4px 2px 8px; }
.fmain-check { margin: 2px 2px 6px; }

/* Areves · Tuntiseuranta (UI17): a week strip of day tiles and a month calendar. The day is the unit, as in
   Severa; the look is ours. A missing day is marked amber on its left edge, the selected day in blue. */
.ts-views { display: flex; border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px; }
.ts-views a { font-size: 14px; font-weight: 600; color: var(--text-2); padding: 5px 14px; border-radius: 999px; text-decoration: none; }
.ts-views a:hover { color: var(--text); }
.ts-views a[aria-current="page"] { background: var(--primary); color: var(--inverse); }
.ts-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ts-period { display: flex; align-items: baseline; gap: 10px; padding: 0 6px; }
.ts-period strong { font-size: 18px; font-weight: 650; }
.ts-period span { color: var(--text-2); font-size: 14px; }
.ts-week { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: stretch; }
.ts-days { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.ts-day { display: grid; gap: 2px; align-content: start; height: 100%; min-height: 96px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--r-m); color: var(--text); text-decoration: none; box-shadow: var(--shadow-1); }
.ts-day:hover { border-color: var(--border-strong); }
.ts-day-label { font-size: 13px; font-weight: 600; color: var(--text-2); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ts-today { font-size: 11px; font-weight: 650; letter-spacing: .04em; text-transform: uppercase; color: var(--primary); }
.ts-day-hours { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ts-day-note { font-size: 12px; color: var(--text-3); line-height: 1.35; }
.ts-lock { display: inline-block; font-weight: 600; color: var(--text-3); }
.ts-day--missing { border-left-color: var(--warn); }
.ts-day--missing .ts-day-note { color: var(--warn); font-weight: 600; }
.ts-day--off { background: var(--surface-2); box-shadow: none; }
.ts-day--off .ts-day-hours, .ts-day--future .ts-day-hours { color: var(--text-3); }
.ts-day--elsewhere { opacity: .45; }
.ts-day--sel { border-color: var(--primary); background: var(--primary-soft); box-shadow: var(--ring); }
.ts-day--sel.ts-day--missing { border-left-color: var(--warn); }
.ts-sum { display: grid; align-content: center; justify-items: center; min-width: 110px; padding: 10px 16px; border-left: 1px solid var(--border); }
.ts-sum-label { font-size: 13px; color: var(--text-2); }
.ts-sum-value { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ts-sum-of { font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.ts-daytotal { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.ts-entries { list-style: none; margin: 0; padding: 0; display: grid; }
.ts-entry { display: flex; gap: 16px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--border); }
.ts-entry:first-child { border-top: 0; padding-top: 4px; }
.ts-entry-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.ts-entry-project { font-weight: 600; }
.ts-entry-meta { font-size: 13px; color: var(--text-2); }
.ts-entry-desc { font-size: 14px; color: var(--text-2); overflow-wrap: anywhere; }
.ts-entry-hours { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat--warn .stat-value { color: var(--warn); }
.ts-month { display: grid; gap: 8px; }
.ts-month-row { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.ts-month-head span { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 0 4px; }
.ts-month .ts-day { min-height: 84px; }
.ts-main { display: grid; gap: 20px; }
.ts-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ts-card { display: grid; gap: 14px; padding: 16px 18px; border: 1px solid var(--primary-soft-2); border-radius: var(--r-m); background: var(--surface-2); }
.ts-card-head h3 { font-size: 15px; font-weight: 650; }
.ts-card-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 18px; align-items: start; }
.ts-card-pick, .ts-card-side { display: grid; gap: 12px; align-content: start; }
.ts-card-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 12px; }
.ts-card .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.ts-card .field-hint { font-size: 12px; color: var(--text-3); }
.ts-hours input[aria-invalid] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.ts-card .field-hint--error { color: var(--danger); font-weight: 600; font-size: 13px; }
.ts-hours input { max-width: 8em; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.ts-chosen { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-s); }
.ts-picklist { display: grid; gap: 2px; max-height: 320px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-s); padding: 6px; }
.ts-pick-group { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-3); padding: 8px 8px 4px; }
.ts-pick { display: grid; gap: 1px; text-align: left; font: inherit; color: var(--text); background: transparent; border: 0; border-radius: var(--r-s); padding: 7px 10px; cursor: pointer; }
.ts-pick:hover, .ts-pick:focus-visible { background: var(--primary-soft); }
.ts-pick-label { font-weight: 600; font-size: 14px; }
.ts-pick-sub { font-size: 12px; color: var(--text-2); }
.ts-card-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ts-card-foot .btn--danger { margin-left: 0; }
.ts-entry .btn { align-self: flex-start; margin-top: -2px; }
/* UI18: waiting for Severa, and failures. A waiting row is the entry as it will be, marked by a blue edge and
   a spinner; a row being deleted is crossed out. A failure is one box across the day, never a line in a corner. */
.ts-spin { display: inline-block; flex: none; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
@media (prefers-reduced-motion: no-preference) {
  .ts-spin, .ts-page .btn.htmx-request::after, .ts-card.htmx-request .btn--pri::after, .ts-pick.htmx-request::after, .ts-day.is-waiting::after { animation: jk-spin var(--dur-spin) linear infinite; }
}
@keyframes jk-spin { to { transform: rotate(360deg); } }
.ts-entry--waiting { padding-left: 12px; padding-right: 12px; box-shadow: inset 3px 0 var(--primary); background: var(--primary-soft); border-radius: var(--r-s); }
.ts-entry--waiting + .ts-entry, .ts-entry + .ts-entry--waiting { border-top-color: transparent; }
.ts-entry--waiting .ts-entry-main, .ts-entry--waiting .ts-entry-hours { opacity: .75; }
.ts-entry--deleting { box-shadow: inset 3px 0 var(--danger); background: var(--danger-soft); }
.ts-entry--deleting .ts-entry-main, .ts-entry--deleting .ts-entry-hours { text-decoration: line-through; }
.ts-entry-status { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; margin-top: 2px; font-size: 13px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.ts-entry--deleting .ts-entry-status { color: var(--danger); }
.ts-page .btn.htmx-request::after, .ts-card.htmx-request .btn--pri::after, .ts-pick.htmx-request::after, .ts-day.is-waiting::after {
  content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; vertical-align: -1px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%;
}
.ts-pick.htmx-request { background: var(--primary-soft); }
.ts-day.is-waiting { position: relative; }
.ts-day.is-waiting::after { position: absolute; top: 10px; right: 10px; margin: 0; color: var(--primary); }
.ts-page.is-loading .ts-main > .sect, .ts-page.is-loading .ts-month, .ts-page.is-loading .stats { opacity: .5; }
.ts-card select.htmx-request, .ts-card input.htmx-request { border-color: var(--primary); }
.ts-card-pick:has(input.htmx-request) .ts-picklist { opacity: .6; }
.ts-alert { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 12px; align-items: start; padding: 14px 16px; background: var(--danger-soft); border: 1px solid var(--danger); border-left-width: 4px; border-radius: var(--r-m); color: var(--text); }
.ts-alert:focus { outline: none; }
.ts-alert:focus-visible { box-shadow: var(--ring); }
.ts-alert-icon { color: var(--danger); margin-top: 1px; }
.ts-alert-body { display: grid; gap: 4px; min-width: 0; }
.ts-alert-title { font-size: 15px; font-weight: 650; color: var(--danger); }
.ts-alert-body p { font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.ts-alert-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.ts-alert-actions:empty { display: none; }
.ts-card--error { border-color: var(--danger); }
/* Henkilöstön tunnit (UI19): the people on the left, the picked person's month on the right. */
.ts-staff { display: grid; gap: 20px; }
.ts-people { position: relative; max-width: 480px; z-index: 5; }
.ts-people-list { position: absolute; top: calc(100% + 4px); left: 0; right: 0; list-style: none; margin: 0; padding: 4px; display: grid; gap: 1px; max-height: 360px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m); box-shadow: var(--shadow-2, var(--shadow-1)); }
.ts-people [data-filter-empty] { position: absolute; top: calc(100% + 4px); left: 0; right: 0; margin: 0; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-m); }
.ts-person { display: grid; gap: 1px; padding: 7px 10px; border-radius: var(--r-s); color: var(--text); text-decoration: none; }
.ts-person:hover, .ts-person:focus-visible, .ts-person.is-first { background: var(--surface-2); }
.ts-person.is-on { background: var(--primary-soft); box-shadow: inset 3px 0 var(--primary); }
.ts-person-name { font-weight: 600; font-size: 14px; }
.ts-person-office { font-size: 12px; color: var(--text-3); }
.ts-person.htmx-request::after { content: ""; justify-self: end; margin-top: -30px; width: 12px; height: 12px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; color: var(--primary); }
@media (prefers-reduced-motion: no-preference) { .ts-person.htmx-request::after { animation: jk-spin var(--dur-spin) linear infinite; } }
.ts-person-month { display: grid; gap: 16px; min-width: 0; }
.ts-person-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ts-person-head h2 { font-size: 20px; font-weight: 650; }
.ts-page.is-loading .ts-person-month { opacity: .5; }
.ts-day--static:hover { border-color: var(--border); }
@media (max-width: 720px) {
  .ts-card-grid, .ts-card-row { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  .ts-week { grid-template-columns: minmax(0, 1fr); }
  .ts-sum { display: flex; align-items: baseline; gap: 8px; min-width: 0; border-left: 0; border-top: 1px solid var(--border); padding: 8px 0 0; }
  .ts-sum-value { font-size: 18px; }
  .ts-days, .ts-month-row { gap: 4px; }
  .ts-day { min-height: 64px; padding: 6px; border-left-width: 3px; }
  .ts-day-hours { font-size: 15px; }
  .ts-day-note, .ts-today { display: none; }
  .ts-month .ts-day { min-height: 56px; }
  .ts-people { max-width: none; }
}

/* Oma agentti bubble (M17, UI20). The persona colour is a class (no inline styles under the CSP), the same
   six Agenttikeskus colours; no animation (UI10: only navigation animates). */
.agent { --agent-accent: var(--primary); }
.agent--sininen { --agent-accent: #2f6fd6; }
.agent--vihrea { --agent-accent: #2f8a4f; }
.agent--violetti { --agent-accent: #7a52d6; }
.agent--oranssi { --agent-accent: #c8661a; }
.agent--punainen { --agent-accent: #c23a3a; }
.agent--harmaa { --agent-accent: #5f6b7a; }
.agent-fab { position: fixed; right: 20px; bottom: 20px; z-index: 60; width: 56px; height: 56px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--agent-accent, var(--primary)); color: #fff; box-shadow: 0 6px 20px rgba(14,20,32,.22); cursor: pointer; }
.agent-fab:focus-visible { outline: none; box-shadow: var(--ring), 0 6px 20px rgba(14,20,32,.22); }
.agent-panel { position: fixed; right: 20px; bottom: 88px; z-index: 61; width: min(420px, calc(100vw - 32px)); height: min(640px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: 0 16px 48px rgba(14,20,32,.22); overflow: hidden; }
.agent-panel[hidden] { display: none; }
/* The resize handle: the panel is pinned bottom-right, so it grows from its top-left corner. */
.agent-resize { position: absolute; top: 0; left: 0; z-index: 1; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none;
  background: linear-gradient(135deg, var(--border-strong) 0 2px, transparent 2px 5px, var(--border-strong) 5px 7px, transparent 7px); border-top-left-radius: var(--r-l); }
.agent-resize:focus-visible { outline: none; box-shadow: var(--ring); }
html.agent-resizing, html.agent-resizing * { user-select: none; cursor: nwse-resize; }
.agent-body { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.agent-loading { padding: 24px 16px; color: var(--text-2); }
.agent-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 20px; border-bottom: 1px solid var(--border); }
.agent-avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--agent-accent, var(--primary)); color: #fff; flex: none; }
.agent-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-iconbtn { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 0; border-radius: var(--r-s); background: transparent; color: var(--text-2); cursor: pointer; }
.agent-iconbtn:hover { background: var(--surface-2); color: var(--text); }
.agent-iconbtn:focus-visible, .agent-iconbtn:focus-within { outline: none; box-shadow: var(--ring); }
.agent-budget { margin: 0; padding: 8px 14px; font-size: 13px; background: var(--warn-soft); color: var(--text); }
.agent-budget.is-full { background: var(--danger-soft); }
.agent-convo { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.agent-msgs { list-style: none; margin: 0; padding: 14px; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.agent-empty { color: var(--text-2); font-size: 14px; line-height: 1.5; }
.agent-msg { max-width: 92%; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.agent-msg.is-user { align-self: flex-end; background: var(--primary-soft); padding: 8px 12px; border-radius: var(--r-m) var(--r-m) 4px var(--r-m); }
.agent-msg.is-user.is-blocked { background: var(--surface-2); color: var(--text-2); text-decoration: line-through; }
.agent-msg.is-assistant { align-self: flex-start; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; max-width: 100%; }
.agent-spark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--agent-accent, var(--primary)); margin-top: 1px; }
.agent-reply { min-width: 0; }
.agent-msg.is-system { align-self: center; }
.agent-text, .agent-live { white-space: pre-wrap; }
.agent-md > :first-child { margin-top: 0; }
.agent-md > :last-child { margin-bottom: 0; }
.agent-md p, .agent-md ul, .agent-md ol { margin: 0 0 8px; }
.agent-md ul, .agent-md ol { padding-left: 20px; }
.agent-md pre { overflow-x: auto; padding: 8px 10px; background: var(--surface-2); border-radius: var(--r-s); font-size: 13px; }
.agent-md code { font-family: var(--mono); font-size: 13px; }
.agent-md table { border-collapse: collapse; font-size: 13px; display: block; overflow-x: auto; }
.agent-md th, .agent-md td { border: 1px solid var(--border); padding: 4px 8px; text-align: left; }
.agent-md h1, .agent-md h2, .agent-md h3 { font-size: 15px; margin: 10px 0 6px; }
.agent-status, .agent-note { margin: 4px 0 0; font-size: 12px; color: var(--text-3); }
.agent-status:empty { display: none; }
.agent-tool { margin: 0 0 4px; font-size: 12px; color: var(--text-2); }
.agent-tool::before { content: "✓ "; color: var(--ok); }
.agent-tool.is-running::before { content: "… "; color: var(--text-3); }
.agent-tool.is-failed::before { content: "✕ "; color: var(--danger); }
.agent-file { display: inline-flex; gap: 6px; align-items: baseline; margin: 2px 6px 6px 0; padding: 6px 10px; border: 1px solid var(--border-strong); border-radius: var(--r-s); font-size: 13px; color: var(--text); text-decoration: none; background: var(--surface); }
.agent-file span { color: var(--text-3); font-size: 12px; }
.agent-file:hover { border-color: var(--primary); }
.agent-file.is-gone { color: var(--text-3); }
.agent-chip { display: inline-block; margin: 4px 4px 0 0; padding: 2px 8px; border-radius: 999px; background: var(--surface-3); font-size: 12px; }
.agent-chip.is-pending { opacity: .6; }
.agent-alert { margin-top: 8px; font-size: 13px; }
.agent-composer { border-top: 1px solid var(--border); padding: 10px 12px 8px; display: grid; gap: 6px; }
.agent-chips:empty { display: none; }
/* One row: attach, the input that grows with its text, send (or stop while a reply comes). */
.agent-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: end; gap: 6px; padding: 4px 4px 4px 2px; border: 1px solid var(--border-strong); border-radius: 22px; background: var(--surface); }
.agent-row:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.agent-row textarea { display: block; width: 100%; resize: none; min-height: 34px; max-height: 160px; padding: 7px 4px; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 14px; line-height: 20px; overflow-y: auto; }
.agent-row textarea:focus { outline: none; }
.agent-attach { border-radius: 50%; }
.agent-roundbtn { width: 34px; height: 34px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--agent-accent, var(--primary)); color: #fff; cursor: pointer; }
.agent-roundbtn:hover { filter: brightness(1.08); }
.agent-roundbtn:focus-visible { outline: none; box-shadow: var(--ring); }
.agent-roundbtn[hidden] { display: none; }
.agent-stop { background: var(--text); color: var(--surface); }
.agent-warning { margin: 0; padding: 0 6px; font-size: 12px; color: var(--text-3); }
.agent-accept { padding: 14px; overflow-y: auto; display: grid; gap: 8px; font-size: 14px; line-height: 1.5; }
.agent-accept h3 { margin: 8px 0 0; font-size: 15px; }
.agent-accept h4 { margin: 4px 0 0; font-size: 14px; }
.agent-foot { margin: 0; padding: 6px 14px 10px; font-size: 12px; }
.agent-foot a { color: var(--text-2); }
.agent-panel > .agent-body > .agent-alert { margin: 14px; }
@media (max-width: 640px) {
  .agent-panel { inset: 0; width: auto !important; height: auto !important; border-radius: 0; border: 0; }
  .agent-resize { display: none; }
  .agent-fab { right: 16px; bottom: 16px; }
  html.agent-open .agent-fab { display: none; }
}

/* Projektit (M18, UI21): the first form and the stages of one project. */
.pj-page { max-width: 920px; }
.pj-form { display: grid; gap: 16px; }
.pj-form .sect { display: grid; gap: 14px; }
.pj-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.pj-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pj-narrow { max-width: 280px; }
.pj-foot { display: flex; justify-content: flex-end; gap: 8px; }
.pj-wait { display: none; }
.pj-form.htmx-request .pj-wait { display: inline-block; }
.pj-stages { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.pj-stage { display: grid; gap: 10px; }
.pj-stage-n { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 650; }
.pj-fields { margin: 0; display: grid; }
.pj-field { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px; padding: 7px 0; border-top: 1px solid var(--border); }
.pj-field dt { font-size: 14px; color: var(--text-2); }
.pj-field dd { margin: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; font-size: 14px; overflow-wrap: anywhere; }
.pj-need { font-size: 13px; color: var(--warn); font-weight: 500; }
@media (max-width: 720px) {
  .pj-grid, .pj-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .pj-field { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
.pj-search { display: flex; flex-wrap: wrap; gap: 8px; max-width: 640px; min-width: 0; }
#pj-results { min-width: 0; }
.pj-search-opts { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.pj-kinds { display: inline-flex; flex-wrap: wrap; gap: 4px 14px; }
.pj-kind { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.pj-kindtag { font-size: 13px; color: var(--text-2); }
.pj-hitnum { color: var(--text-2); font-variant-numeric: tabular-nums; }
.pj-rows-title { margin: 20px 0 8px; font-size: 15px; font-weight: 650; }
.pj-search input[type="search"] { flex: 1; min-width: 0; padding: 8px 12px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-s); }
.field-help:empty { display: none; }
.pj-form-sect { display: grid; gap: 14px; }
.pj-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.pj-checks { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.pj-checks legend { padding: 0 0 6px; font-size: 14px; font-weight: 600; }
.pj-checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.pj-pick { width: 100%; cursor: pointer; }
.pj-check-all { font-weight: 600; }

/* Toimeksiannot (UI23): the year and "at least" pairs in the filters, the summary line, a row's count line,
   and a coach's own description in the panel. */
/* The legend is floated so the line above it is its own border: a fieldset's border would run through the text. */
.work-nums { border: 0; margin: 0; padding: 0 2px 4px; }
.work-nums legend { float: left; width: 100%; padding: 10px 0 6px; border-top: 1px solid var(--border); font-size: 14px; font-weight: 600; }
.work-pair { clear: both; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.legend-hint { font-weight: 400; color: var(--text-3); }
.work-pair label { font-size: 13px; color: var(--text-2); font-weight: 400; }
.work-pair input { width: 100%; min-width: 0; }
.work-sum { font-size: 14px; color: var(--text-2); }
.work-sum b { color: var(--text); font-variant-numeric: tabular-nums; }
.work-line { font-size: 14px; font-variant-numeric: tabular-nums; }
.pv-desc { flex-basis: 100%; margin: 0; padding-left: 10px; border-left: 2px solid var(--border-strong); color: var(--text-2); white-space: pre-line; }

/* Sopivat valmentajat (UI25): people against a tender's requirements, best first. */
.match-no, .match-cell { flex: none; display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px; border-radius: var(--r-s); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.match-cell.is-met { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.match-cell.is-met.is-unverified { background: transparent; border: 1px dashed currentColor; }
.match-cell.is-met.is-estimate { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.match-severa { color: var(--text-2); }
/* Yhteenveto's counts (UI33): three tiles that look alike, each opening its tab. */
.case-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 16px; margin: 0; }
.case-summary-item { display: flex; flex-direction: column; gap: 2px; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--r-l); background: var(--surface); color: var(--text); text-decoration: none; font-size: 14px; }
.case-summary-item:hover { border-color: var(--border-strong); }
.case-summary-item b { font-size: 28px; font-weight: 650; line-height: 1.1; }
.case-summary-item span { font-size: 13px; color: var(--text-3); }
.case-summary-item .case-summary-label { font-size: 14px; font-weight: 600; color: var(--text); }
/* A case's tab content: its blocks have the page's gap. The reading's block takes no room while it shows nothing. */
#case-body { display: grid; gap: 20px; align-content: start; min-width: 0; }
.ingest:not(:has(.ingest-box:not([hidden]), .notice:not([hidden]))) { display: none; }
.sect--key { border-color: var(--primary); }
.sect-fold > summary { cursor: pointer; list-style: none; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; margin-bottom: 0; }
.sect-fold > summary::-webkit-details-marker { display: none; }
.sect-fold > summary::after { content: "Näytä"; margin-left: auto; font-size: 13px; font-weight: 600; color: var(--primary); }
.sect-fold[open] > summary::after { content: "Piilota"; }
.sect-fold[open] > summary { margin-bottom: 12px; }
.sect-fold-sum { font-size: 13px; color: var(--text-3); }
.sect-fold--plain { margin-top: 16px; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--r-l); background: var(--surface); }
.company-figures { margin-top: 8px; padding: 10px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-l); display: grid; gap: 4px; font-size: 14px; max-width: 100ch; }
.company-figures-h { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.company-figures p { margin: 0; }
.match-links { display: flex; flex-wrap: wrap; gap: 6px; }
.match-cell.is-miss { color: var(--text-3); text-decoration: line-through; }
.match-cell.is-miss.is-must { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.match-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.match { border: 1px solid var(--border); border-radius: var(--r-m); background: var(--surface); }
.match-sum { display: flex; align-items: center; gap: 16px; padding: 12px 16px; cursor: pointer; list-style: none; }
.match-sum::-webkit-details-marker { display: none; }
.match-sum:hover { background: var(--surface-2); }
.match-pct { flex: none; width: 64px; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.match-who { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.match-cells { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; max-width: 45%; }
.match-warn { color: var(--danger); font-weight: 600; }
.match details[open] > .match-sum { border-bottom: 1px solid var(--border); }
.match details > p { margin: 0; padding: 0 16px 14px; }
.match-detail { list-style: none; margin: 0; padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.match-detail li { display: flex; gap: 10px; align-items: flex-start; }
.req-lists { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 720px) {
  .match-sum { flex-wrap: wrap; gap: 8px 12px; }
  .match-cells { max-width: 100%; justify-content: flex-start; width: 100%; }
}

/* Sub-items of a list (J50, UI26): indented under their parent in Listat and in forms; a fold of their own in a
   search filter. */
/* Listat as a tree: a top item's sub-items sit in a block under it, joined to it by a line on the left. */
.ftree { list-style: none; }
.flist--sub { list-style: none; margin: 0 0 0 14px; padding: 0 0 0 18px; border-left: 2px solid var(--border); }
.flist--sub .frow { position: relative; }
.flist--sub .frow::before { content: ""; position: absolute; left: -18px; top: 50%; width: 12px; border-top: 2px solid var(--border); }
.flist--sub .frow-name { font-weight: 500; }
.ftree--parent > .frow .frow-name::after { content: " ▾"; color: var(--text-3); font-weight: 400; }
.check--sub { margin-left: 22px; }
.subchecks { flex-basis: 100%; margin: -2px 0 4px 23px; }
.subchecks > summary { cursor: pointer; font-size: 12px; color: var(--text-3); list-style: none; }
.subchecks > summary::-webkit-details-marker { display: none; }
.subchecks > summary::before { content: "▸ "; }
.subchecks[open] > summary::before { content: "▾ "; }
.subchecks .check { display: flex; margin: 4px 0 0 2px; }
/* The place select in Listat's forms (UI26): styled as the inputs beside it, and never wider than the row. */
.inline-add select { flex: 0 1 240px; min-width: 0; max-width: 240px; font: inherit; font-size: 14px; padding: 7px 8px; border: 1px solid var(--border); border-radius: var(--r-s); background: var(--surface); color: var(--text); }
.frow > form.inline-add { flex-wrap: wrap; row-gap: 8px; }
.ftree--parent > .frow .frow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tarjoukset: a case as tabs (UI33). The header has Tila as a select and a ⋯ menu; Yhteenveto opens with the
   Seuraavaksi box. */
.case-actions { align-items: center; }
.case-status-label { font-size: 13px; font-weight: 600; color: var(--text-2); }
.case-status { font-weight: 600; min-height: 40px; }
.case-menu { position: relative; }
.case-menu > summary { list-style: none; min-width: 40px; min-height: 40px; font-weight: 700; }
.case-menu > summary::-webkit-details-marker { display: none; }
.case-menu-pop { position: absolute; right: 0; top: calc(100% + 6px); width: 300px; max-width: calc(100vw - 32px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--r-l); box-shadow: var(--shadow-2); padding: 8px; display: grid; z-index: 30; }
.case-menu-item { display: grid; gap: 4px; padding: 8px 10px; border-top: 1px solid var(--border); }
.case-menu-item:first-child { border-top: 0; }
a.case-menu-item { color: var(--text); font-weight: 600; text-decoration: none; border-radius: var(--r-s); }
a.case-menu-item:hover { background: var(--surface-2); }
.case-menu-item .profile-empty { justify-self: start; padding-left: 0; }
.next-step { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px 20px; background: var(--primary-soft); border: 1px solid var(--primary-soft-2); border-radius: var(--r-l); }
.next-step-h { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--primary); }
.next-step-text { font-size: 16px; font-weight: 600; }
.sect-link { margin-left: auto; font-size: 14px; font-weight: 600; }
.key-facts { margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px 20px; font-size: 14px; }
.key-facts dt { color: var(--text-3); font-size: 13px; }
.key-facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.case-summary { margin: 0; }
.tab-intro { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.help-fold > summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--primary); width: fit-content; }
.help-fold > p { margin-top: 6px; max-width: 90ch; }
/* A quote folded behind Lähde (UI33); "Lähdettä ei löytynyt" stays beside it. */
.quote-fold { margin-top: 4px; font-size: 13px; }
.quote-fold > summary { display: inline; cursor: pointer; color: var(--primary); font-weight: 600; }
.quote-fold > .quote { margin-top: 4px; }
.company-cards { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.company-card { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; gap: 16px 20px; }
.company-card-req { display: grid; gap: 6px; }
.company-card-text { font-weight: 600; }
.company-card .company-figures { margin-top: 0; }
@media (max-width: 900px) { .company-card { grid-template-columns: minmax(0, 1fr); } }
.staff-req { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; }
.staff-req > div { min-width: 0; }

/* The save bar (UI34): one card at the bottom of the screen over the content, only while something is
   unsaved (app.js adds is-dirty) or a save was refused. Without scripts it is always shown. */
.savebar { display: none; position: sticky; bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 20; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-l); box-shadow: var(--shadow-2); padding: 12px 16px; }
.savebar.is-dirty, .savebar--error { display: block; }
@media (scripting: none) { .savebar { display: block; } }
.savebar--error { border-color: var(--danger); border-left-width: 4px; }
.savebar--error .savebar-text strong { color: var(--danger); }
.savebar-form { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.savebar-text { flex: 1 1 320px; font-size: 14px; color: var(--text-2); }
.savebar-text strong { color: var(--text); }
.savebar-actions { display: flex; gap: 8px; }

/* Tarjoukset (J57, UI36): the reading's box, each file's state, the tab marker and Vahvistettavat muutokset. */
.ingest:empty { display: none; }
.ingest { display: grid; gap: 8px; }
.ingest-box { display: grid; gap: 8px; padding: 14px 20px; background: var(--primary-soft); border: 1px solid var(--primary-soft-2); border-radius: var(--r-l); }
.ingest-box[hidden] { display: none; }
.ingest-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 12px; margin: 0; }
.ingest-head p { margin: 0; overflow-wrap: anywhere; }
.ingest-time { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ingest-line { margin: 0; font-size: 14px; }
.ingest-line a { font-weight: 600; }
.ingest-bar { appearance: none; width: 100%; height: 6px; border: 0; border-radius: 999px; background: var(--primary-soft-2); overflow: hidden; }
.ingest-bar::-webkit-progress-bar { background: var(--primary-soft-2); border-radius: 999px; }
.ingest-bar::-webkit-progress-value { background: var(--primary); border-radius: 999px; }
.ingest-bar::-moz-progress-bar { background: var(--primary); border-radius: 999px; }
.drop-types { font-size: 13px; color: var(--text-2); }
.tender-upload-actions .busy-note { font-size: 14px; }
.tender-file-side { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px 12px; flex: 0 1 auto; }
.tender-file-side:has(.tender-file-edit[open]) { flex: 1 1 100%; justify-content: flex-start; }
.tender-file-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.file-state { font-size: 13px; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.file-state--ok { color: var(--ok); }
.file-state--busy { color: var(--primary-hover); }
.file-state--warn { color: var(--warn); }
.file-state--error { color: var(--danger); }
.file-fail { font-size: 13px; color: var(--danger); }
.objtab-mark { display: inline-block; width: 8px; height: 8px; margin-left: 4px; border-radius: 999px; background: var(--warn); vertical-align: middle; }
.change-card { display: grid; gap: 10px; }
.change-card--conflict { border-color: var(--danger); }
.change-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.change-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 12px; }
.change-col { padding: 10px 14px; background: var(--surface-2); border-radius: var(--r-m); display: grid; gap: 4px; align-content: start; }
.change-col p { margin: 0; }
.change-label { font-size: 13px; color: var(--text-2); }
.change-value { font-weight: 600; overflow-wrap: anywhere; }
.change-why { margin: 0; font-size: 14px; }
.change-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.change-adds { list-style: none; margin: 0; padding: 0; display: grid; }
.change-add { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; padding: 12px 0; border-top: 1px solid var(--border); }
.change-add:first-child { border-top: 0; }
.change-add > div { flex: 1 1 360px; display: grid; gap: 2px; min-width: 0; }

/* Tarjoukset' fixes after the browser test (UI14, UI33 to UI36). */
/* The list on a phone: no sideways scrolling; Tila moves under the name, Muutettu goes; Vaihe and the deadline stay. */
.case-status-sub { display: none; }
@media (max-width: 720px) {
  .tbl--cases { min-width: 0; }
  .tbl--cases th, .tbl--cases td { padding: 10px 8px; }
  .tbl--cases .col-status, .tbl--cases .col-upd { display: none; }
  .tbl--cases .case-status-sub { display: block; margin-top: 4px; }
  .tbl--cases .nowrap { white-space: normal; }
}
/* The tab row wraps onto two rows on a narrow screen instead of scrolling sideways. */
@media (max-width: 720px) {
  .objtabs { flex-wrap: wrap; overflow: visible; row-gap: 0; }
  .objtab { padding: 8px 10px; }
}
/* The ⋯ menu stays inside the screen: on a narrow screen it opens under the header, at its right edge. */
@media (max-width: 720px) {
  .case-head { position: relative; }
  .case-menu, .case-actions { position: static; }
  .case-menu-pop { right: 0; left: auto; top: 100%; }
}
/* "Lähdettä ei löytynyt" in sight before the fold, on its own line. */
.quote-missing { margin-top: 4px; margin-right: 6px; }
/* The file an item without a quote came from, beside the chip. */
.quote-file { font-size: 13px; color: var(--text-3); overflow-wrap: anywhere; }
/* The save bar: Tallenna comes first for the keyboard, and sits on the right. */
.savebar-actions .btn--pri { order: 2; }
/* The leave dialog: three buttons on one row when there is room, stacked full width on a phone. */
#leave-dialog { max-width: min(600px, calc(100vw - 32px)); }
#leave-dialog .form-actions { flex-wrap: wrap; }
#leave-dialog .form-actions .btn { white-space: nowrap; }
@media (max-width: 600px) {
  #leave-dialog .form-actions { flex-direction: column-reverse; align-items: stretch; }
  #leave-dialog .form-actions .btn { width: 100%; justify-content: center; }
}
/* The mock bar steps out of the save bar's way while the bar is shown. */
body:has(.savebar.is-dirty) .devbar, body:has(.savebar--error) .devbar { top: max(16px, env(safe-area-inset-top, 0px)); bottom: auto; }
/* A chip beside a new item's text keeps its own width. */
.change-add > div > .chip { justify-self: start; }
.change-actions .btn--pri { order: 2; }
