/* PIA — dark theme of the real PI app ("Luna"), sampled from its screenshot, with the mockups' layout
   (SPEC §11.7; references in data/private/mockups/). One design system: tokens → shell → components → pages. */

/* --- tokens ------------------------------------------------------------------------------------- */
:root {
  /* PI palette */
  --sidebar: #2b2d34;
  --bg: #31333b;
  --bg-2: #2f3038;
  --panel: #3b3d45;
  --panel-2: #42444d;       /* hover / raised */
  --inset: #33353d;         /* inputs, answer bubbles */
  --border: #494c59;
  --hairline: #444652;
  --text: #e8e8ea;
  --text-2: #c4c6cc;
  --muted: #b0b3bb;          /* 5.2 : 1 on --panel, 4.6 on --panel-2, 6.0 on --bg (WCAG AA for small text) */
  --accent: #ebab44;
  --accent-ink: #1b1d22;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --blue: #7cb8f0;
  --blue-soft: color-mix(in srgb, var(--blue) 14%, transparent);
  --red: #f08c8c;
  --red-soft: color-mix(in srgb, var(--red) 14%, transparent);
  --ok: #5cc28c;
  --ok-soft: color-mix(in srgb, var(--ok) 14%, transparent);
  --warn: #f6a821;
  --err: #e5534b;
  --topbar-ink: #23262d;
  --topbar-bg: #fff;
  --accent-fg: var(--accent);   /* accent as text; darker in the light theme for contrast */
  --side-text: #a9acb3;
  --side-hover: var(--panel);
  --btn-hover: #484a54;
  --placeholder: #7b7e86;
  color-scheme: dark;

  /* shape and rhythm */
  --r-sm: 6px;
  --r: 10px;
  --r-pill: 999px;
  --pad: 24px;              /* panel inner padding */
  --gap: 20px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.12);
  --shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.35);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --t: 140ms var(--ease);
}

/* Light theme: the system setting, unless the toggle (data-theme on <html>) says otherwise. Same names, other values. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --sidebar: #ffffff;
    --bg: #f3f4f6;
    --bg-2: #eceef2;
    --panel: #ffffff;
    --panel-2: #f2f3f6;
    --inset: #f7f8fa;
    --border: #d4d7de;
    --hairline: #e6e8ec;
    --text: #1d2027;
    --text-2: #3e434d;
    --muted: #6b707a;
    --accent-fg: #a5670a;
    --blue: #2f6db0;
    --red: #c23b32;
    --ok: #23894f;
    --warn: #c98207;
    --err: #c8362d;
    --side-text: #4a4f59;
    --side-hover: var(--panel-2);
    --btn-hover: #e8eaee;
    --placeholder: #9a9ea6;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.05);
    --shadow-pop: 0 10px 30px rgba(16, 24, 40, 0.14);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
    --sidebar: #ffffff;
    --bg: #f3f4f6;
    --bg-2: #eceef2;
    --panel: #ffffff;
    --panel-2: #f2f3f6;
    --inset: #f7f8fa;
    --border: #d4d7de;
    --hairline: #e6e8ec;
    --text: #1d2027;
    --text-2: #3e434d;
    --muted: #6b707a;
    --accent-fg: #a5670a;
    --blue: #2f6db0;
    --red: #c23b32;
    --ok: #23894f;
    --warn: #c98207;
    --err: #c8362d;
    --side-text: #4a4f59;
    --side-hover: var(--panel-2);
    --btn-hover: #e8eaee;
    --placeholder: #9a9ea6;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.05);
    --shadow-pop: 0 10px 30px rgba(16, 24, 40, 0.14);
}

/* --- base --------------------------------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text);
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%) fixed var(--bg);
  font-family: Roboto, system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
a { color: var(--accent-fg); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--text-2); }
::selection { background: color-mix(in srgb, var(--accent) 40%, transparent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
svg.i { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* --- shell -------------------------------------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex-shrink: 0; background: var(--sidebar); padding: 20px 0; border-right: 1px solid var(--hairline); position: sticky; top: 0;
  height: 100vh; overflow-y: auto; }
.sidebar .brand { display: flex; align-items: flex-start; gap: 8px; padding: 0 16px 28px 14px; text-decoration: none; }
.sidebar .brand img { width: 150px; height: auto; }
.sidebar ul { list-style: none; margin: 0; padding: 0 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar ul a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--r-sm);
  color: var(--side-text); text-decoration: none; font-size: 16px; transition: background var(--t), color var(--t); }
.sidebar ul a:hover { background: var(--side-hover); color: var(--text); }
.sidebar ul a.active { background: var(--accent); color: var(--accent-ink); font-weight: 500; }
.count { display: inline-grid; place-items: center; margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: var(--r-pill); background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; box-shadow: 0 0 0 2px var(--sidebar); }
.count[hidden] { display: none; }
.sidebar ul a.active .count { box-shadow: 0 0 0 2px var(--accent); }
.mobile-menu .count { margin-left: 8px; box-shadow: none; vertical-align: 1px; }
.sidebar a.brand:hover { background: transparent; }  /* the logo is not a menu item: no hover highlight */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 32px; background: var(--topbar-bg); color: var(--topbar-ink);
  min-height: 52px; box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08); position: sticky; top: 0; z-index: 20; }
.topbar a { color: var(--topbar-ink); }
.topbar-user { font-weight: 500; font-size: 13px; }
/* the bell: current system notices in one place instead of banners on top of the pages */
.topbar-bell { margin-left: auto; font-size: 13px; }
.topbar-bell summary { position: relative; padding: 8px; border-radius: 999px; }
.topbar-bell summary svg { width: 22px; height: 22px; }
.bell-count { position: absolute; top: 0; right: 0; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #1d1d1f; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.user-switch .bell-menu { width: min(440px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto; padding: 8px; color: #1d1d1f; }
.bell-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: var(--r-sm); line-height: 1.45;
  font-weight: 400; text-transform: none; overflow-wrap: anywhere; }
.bell-item + .bell-item { border-top: 1px solid #ececf0; }
.bell-item svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 2px; color: #b26a00; }
.bell-item.bell-info svg { color: #5a5d66; }
.bell-item a { text-decoration: underline; }
/* the page's name sits in the top bar, like the header of an app; the page itself starts with its content */
.topbar-title { font-size: 20px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mobile-menu, .mobile-brand { display: none; }
.content { flex: 1; padding: 32px 36px 48px; min-width: 0; max-width: 1560px; width: 100%; }

/* user menu (demo switch until login exists) */
.user-switch { position: relative; }
.user-switch summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 4px 8px 4px 4px; border-radius: var(--r-pill); transition: background var(--t); letter-spacing: 0.4px;
  text-transform: uppercase; }
.user-switch summary:hover { background: #f1f1f3; }
.user-switch summary::-webkit-details-marker { display: none; }
.avatar { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 700; letter-spacing: 0; }
.user-switch .caret { width: 14px; height: 14px; color: #6b707a; }
.user-switch .menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 30; min-width: 220px; padding: 6px;
  background: #fff; border-radius: var(--r); box-shadow: var(--shadow-pop); border: 1px solid #e6e6ea; text-transform: none; }
.user-switch .menu-note { padding: 8px 10px 6px; font-size: 12px; color: #6b707a; font-weight: 400; }
.user-switch .menu a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--topbar-ink); text-decoration: none; font-weight: 400; }
.user-switch .menu a:hover { background: #f3f3f5; }
.user-switch .menu a.current { font-weight: 500; }
.user-switch .menu a .avatar { width: 26px; height: 26px; font-size: 12px; }
.user-switch .menu a .role { margin-left: auto; font-size: 12px; color: #6b707a; }

/* --- text helpers ------------------------------------------------------------------------------ */
.muted { color: var(--muted); }
.small { font-size: 13px; }
.error { color: var(--err); }
/* PI mirror freshness: a quiet line on every page, amber when stale; a banner for admins on the Dashboard */
.pi-asof { color: var(--muted); font-size: 12px; text-align: right; margin: -4px 0 8px; }
.pi-asof.stale { color: var(--accent-fg); font-weight: 500; }
.banner-warn { background: var(--accent-soft); color: var(--accent-fg); border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.payments form.override, form.override { display: grid; gap: 6px; margin-bottom: 6px; }
form.override input[name="duplicate_reason"] { min-width: 14em; }
.accent, .tone-accent { color: var(--accent-fg); }
.tone-blue { color: var(--blue); }
.tone-red { color: var(--red); }
.tone-ok { color: var(--ok); }
.tone-plain { color: var(--text); }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mobile-only { display: none; }

/* --- page headers ------------------------------------------------------------------------------- */
.page-header { display: flex; align-items: baseline; gap: 16px; margin-bottom: 26px; flex-wrap: wrap; }
.page-header h1 { margin: 0; font-size: 26px; }
/* PI's page header: outlined shield icon, title, grey subtitle, divider */
.pi-header { display: flex; align-items: center; gap: 20px; padding: 0 0 22px 4px; margin-bottom: 26px;
  border-bottom: 1px solid var(--hairline); }
.pi-header svg { width: 40px; height: 47px; flex-shrink: 0; color: var(--accent-fg); }
.pi-header svg.header-icon { width: 40px; height: 40px; stroke-width: 1.5; }  /* the section's menu icon, larger */
.pi-header h1 { margin: 0; font-size: 28px; }
.pi-header .subtitle { color: var(--muted); margin-top: 0; }
.pi-header .actions { margin-left: auto; }
.section-title { font-size: 13px; font-weight: 500; margin: 32px 0 12px; color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.6px; }

/* --- panels ------------------------------------------------------------------------------------- */
.panel { background: var(--panel); border-radius: var(--r); padding: 20px var(--pad); margin-bottom: var(--gap);
  box-shadow: var(--shadow); }
.panel h2 { margin: 0 0 10px; font-size: 17px; }
.notice { display: flex; gap: 10px; align-items: flex-start; border-radius: var(--r-sm); padding: 10px 12px; margin: 8px 0;
  background: color-mix(in srgb, var(--warn) 11%, transparent); color: var(--text);
  box-shadow: inset 3px 0 0 var(--warn); }

/* block = panel with a title bar and rows (Dashboard, E-maily) */
.block { padding: 0; overflow: hidden; }
.block-title { display: flex; align-items: center; gap: 10px; margin: 0; padding: 16px var(--pad); font-size: 16px;
  border-bottom: 1px solid var(--hairline); }
.block-title .i { color: var(--muted); }
.block-title .badge { font-weight: 500; }
.block-title .more { margin-left: auto; font-size: 13px; font-weight: 400; color: var(--muted); text-decoration: none; }
.block-title .more:hover { color: var(--accent-fg); }
.block-row { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; padding: 18px var(--pad); }
.block-row > .btn { flex-shrink: 0; }
.block .line { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px var(--pad);
  border-bottom: 1px solid var(--hairline); transition: background var(--t); }
.block .line:last-child { border-bottom: 0; }
.block .line > .btn { align-self: center; flex-shrink: 0; }
.block a.line { color: inherit; text-decoration: none; }
.block a.line:hover { background: var(--panel-2); }
.block > p, .block > .muted.small { padding: 14px var(--pad); margin: 0; }
.block > .btn { margin: 16px var(--pad) 20px; }
.block-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px var(--pad);
  border-top: 1px solid var(--hairline); }
.block .line + .block-foot { border-top: 0; }
.line-main { min-width: 0; flex: 1; }
.line-who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.line-who strong { color: var(--text); font-weight: 500; }
.line-subject { margin: 3px 0 2px; font-weight: 500; }
.line-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--gap); align-items: start; margin-bottom: var(--gap); }
.two-col > .panel { margin-bottom: 0; }

/* empty state */
.empty { display: flex; align-items: center; gap: 10px; padding: 18px var(--pad); color: var(--muted); }
.empty .i { color: var(--ok); }
.panel:not(.block) > .empty { padding: 4px 0; }

/* --- buttons ------------------------------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap; font: inherit;
  font-size: 14px; font-weight: 500; line-height: 1; cursor: pointer; border-radius: var(--r-sm); padding: 0 16px;
  height: 38px; border: 1px solid var(--border); background: var(--panel-2); color: var(--text); text-decoration: none;
  transition: background var(--t), border-color var(--t), color var(--t), transform var(--t), box-shadow var(--t); }
.btn:hover { border-color: var(--muted); background: var(--btn-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[disabled] { opacity: 0.4; cursor: default; transform: none; }
.btn-primary { background: var(--accent); border-color: var(--accent-fg); color: var(--accent-ink); }
.btn-primary:hover { background: #f1b65a; border-color: #f1b65a; box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn-outline { background: transparent; border-color: color-mix(in srgb, var(--accent) 70%, transparent); color: var(--accent-fg); }
.btn-outline:hover { background: var(--accent-soft); border-color: var(--accent-fg); }
.btn-light { background: transparent; border-color: var(--border); color: var(--text); }
.btn-light:hover { background: var(--panel-2); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--panel-2); border-color: transparent; color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn .i { width: 16px; height: 16px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions .btn { margin: 0; }

/* --- badges and pills --------------------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: var(--r-pill);
  font-size: 12px; line-height: 18px; background: var(--panel-2); color: var(--text-2); white-space: nowrap; }
.block-title .badge { background: var(--accent); color: var(--accent-ink); }
.badge.tag { background: var(--blue-soft); color: var(--blue); font-variant-numeric: tabular-nums; }
.badge.tag.new { background: var(--accent-soft); color: var(--accent-fg); }
.badge::before { content: none; }
.badge-proposed, .badge-approved, .badge-executed, .badge-failed, .badge-rejected, .badge-expired { padding-left: 8px; }
.badge-proposed::before, .badge-approved::before, .badge-executed::before, .badge-failed::before,
.badge-rejected::before, .badge-expired::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-proposed { background: var(--blue-soft); color: var(--blue); }
.badge-approved { background: var(--accent-soft); color: var(--accent-fg); }
.badge-executed { background: var(--ok-soft); color: var(--ok); }
.badge-failed { background: var(--red-soft); color: var(--red); }
.badge-rejected, .badge-expired { background: var(--panel-2); color: var(--muted); }
.badge-warn { background: var(--accent-soft); color: var(--accent-fg); }
.badge-level-1 { background: var(--panel-2); color: var(--text-2); }
.badge-level-2 { background: var(--accent-soft); color: var(--accent-fg); }
.badge-level-3 { background: var(--red-soft); color: var(--red); }
.pill { display: inline-flex; align-items: baseline; flex-wrap: wrap; gap: 0 6px; padding: 3px 10px; border-radius: 14px;
  font-size: 13px; font-weight: 500; max-width: 100%; }
.pill .muted { font-weight: 400; }
.pill .n { font-variant-numeric: tabular-nums; }
.pill.tone-blue { background: var(--blue-soft); }
.pill.tone-accent { background: var(--accent-soft); }
.pill.tone-red { background: var(--red-soft); }
.pill.tone-ok { background: var(--ok-soft); }
.pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* customer initials */
.initials { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  font-size: 13px; font-weight: 700; color: #fff; letter-spacing: 0.3px; }
.initials.h0 { background: #5b7bb4; } .initials.h1 { background: #4f9a86; } .initials.h2 { background: #a76a9c; }
.initials.h3 { background: #b9784a; } .initials.h4 { background: #6c71b8; } .initials.h5 { background: #4c8fae; }
.with-initials { display: flex; align-items: center; gap: 14px; min-width: 0; flex: 1; }

/* --- forms -------------------------------------------------------------------------------------- */
input, select, textarea { font: inherit; }
.field, form.assign select, form.assign input, form.draft input, form.draft textarea, .ask-form input {
  font-size: 14px; background: var(--inset); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 8px 10px; max-width: 100%; transition: border-color var(--t), box-shadow var(--t); }
form.assign select:focus, form.assign input:focus, form.draft input:focus, form.draft textarea:focus, .ask-form input:focus {
  outline: none; border-color: var(--accent-fg); box-shadow: 0 0 0 3px var(--accent-soft); }
::placeholder { color: var(--placeholder); }
label.small.muted { display: block; margin-top: 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }

/* --- dashboard ---------------------------------------------------------------------------------- */
.dash-header { justify-content: space-between; align-items: flex-end; margin-bottom: 28px; }
.dash-header h1 { font-size: 32px; margin: 0 0 6px; }
.dash-header .muted { font-size: 14px; }
.switch { display: inline-flex; gap: 2px; padding: 3px; background: var(--sidebar); border-radius: var(--r-sm);
  border: 1px solid var(--hairline); }
.switch a { padding: 8px 16px; border-radius: 4px; color: var(--muted); text-decoration: none; font-size: 14px;
  font-weight: 500; transition: background var(--t), color var(--t); }
.switch a:hover { color: var(--text); }
.switch a.active { color: var(--text); background: var(--panel-2); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }

.counters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); margin-bottom: 36px; }
.counters .panel { margin-bottom: 0; }
a.counter { position: relative; color: inherit; text-decoration: none; display: block; padding: 20px 22px 18px;
  transition: transform var(--t), box-shadow var(--t), background var(--t); overflow: hidden; }
a.counter::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: currentColor; opacity: 0;
  transition: opacity var(--t); }
a.counter:hover { transform: translateY(-2px); background: var(--panel-2); box-shadow: var(--shadow-pop); }
.counter-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: 14px; }
.counter-label .i { color: var(--muted); }
.counter-value { font-size: 40px; font-weight: 700; line-height: 1.1; margin: 10px 0 6px; font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em; }
.counter-value.tone-accent { color: var(--accent-fg); }
.counter-value.zero { color: var(--muted); font-weight: 500; }
.counter-note { color: var(--muted); font-size: 13px; }
.counter-note .tone-ok { display: inline-flex; align-items: center; gap: 4px; }
.counter-note .i { width: 14px; height: 14px; vertical-align: -2px; }

.today-title { display: flex; align-items: baseline; gap: 12px; font-size: 20px; margin: 0 0 16px; }
.today-title .muted { font-size: 14px; font-weight: 400; }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
.dash-main { container-type: inline-size; min-width: 0; }
/* the agenda adapts to its own width (window size alone does not tell, the Ask column takes 380 px) */
@container (max-width: 820px) {
  .two-col { grid-template-columns: 1fr; }
}
@container (max-width: 620px) {
  .block .line { flex-wrap: wrap; }
  .block .line > .with-initials { flex-basis: 100%; }
  .block .line > .btn { margin-left: 52px; }
  .block-row { flex-direction: column; align-items: flex-start; }
}

/* payments summary */
.pay-summary { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.pay-summary .lead { font-size: 15px; }
.pay-summary .lead strong { font-weight: 500; }

/* --- Ask panel (mockup '1 · Dashboard', right column) ------------------------------------------- */
.ask-panel { padding: 0; position: sticky; top: 76px; display: flex; flex-direction: column;
  max-height: calc((100vh - 100px) / var(--text-zoom)); overflow: hidden; }
.ask-head { display: flex; gap: 12px; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--hairline); }
.ask-head h3 { margin: 0 0 2px; font-size: 16px; }
.ask-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: var(--accent-soft); color: var(--accent-fg); }
.ask-mark .i { width: 20px; height: 20px; }
.ask-log { padding: 18px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; min-height: 160px;
  scroll-behavior: smooth; }
.ask-intro { display: flex; flex-direction: column; gap: 10px; }
.ask-intro p { margin: 0 0 2px; color: var(--muted); font-size: 13px; }
.suggestion { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; font: inherit; font-size: 14px;
  color: var(--text-2); background: var(--inset); border: 1px solid var(--hairline); border-radius: var(--r-sm);
  padding: 10px 12px; cursor: pointer; transition: border-color var(--t), color var(--t), background var(--t); }
.suggestion:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--text); background: var(--panel-2); }
.suggestion .i { width: 16px; height: 16px; color: var(--muted); }
.ask-q { align-self: flex-end; max-width: 88%; background: var(--accent); color: var(--accent-ink); font-weight: 500;
  border-radius: 14px 14px 4px 14px; padding: 9px 14px; white-space: pre-line; overflow-wrap: anywhere; }
.ask-a { align-self: stretch; background: var(--inset); border: 1px solid var(--hairline); border-radius: 14px 14px 14px 4px;
  padding: 12px 14px; overflow-wrap: anywhere; }
.ask-a.refused, .ask-a.failed { box-shadow: inset 3px 0 0 var(--accent); }
.ask-text { line-height: 1.55; font-size: 14px; }
.ask-text p { margin: 0 0 8px; }
.ask-text ul { margin: 0 0 8px; padding-left: 18px; }
.ask-text li + li { margin-top: 4px; }
.ask-text li::marker { color: var(--accent-fg); }
.ask-text > :last-child { margin-bottom: 0; }
.ask-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 10px; }
.ask-trace { margin-top: 10px; }
.ask-trace summary { cursor: pointer; color: var(--muted); }
.ask-trace summary:hover { color: var(--text-2); }
.ask-trace ul { margin-top: 6px; }
.ask-trace code { font-size: 12px; word-break: break-word; }
.ask-form { display: flex; gap: 8px; padding: 14px 16px; border-top: 1px solid var(--hairline); background: var(--panel); }
.ask-form input { flex: 1; min-width: 0; height: 40px; padding: 0 12px; font-size: 14px; }
.ask-form .btn { height: 40px; }
.ask-busy { padding: 0 20px; }
.typing { display: inline-flex; gap: 5px; align-items: center; padding: 12px 14px; border-radius: 14px 14px 14px 4px;
  background: var(--inset); border: 1px solid var(--hairline); margin: 0 20px 14px; width: fit-content; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
.typing em { font-style: normal; font-size: 13px; color: var(--muted); margin-left: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }
.htmx-indicator { display: none; }
.htmx-request.htmx-indicator, .htmx-request .htmx-indicator { display: inline-flex; }

/* --- tables (Párovanie platieb, Audit) --------------------------------------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; color: var(--muted); }
.legend .pill { margin-right: 4px; }
/* Platby: the legend is the filter */
.legend button.filter { font: inherit; color: inherit; border: 1px solid transparent; cursor: pointer; }
.legend button.filter:not([class*="tone-"]) { background: var(--panel-2); }
.legend button.filter:hover { border-color: var(--border); }
.legend button.filter[aria-pressed="true"] { border-color: currentColor; font-weight: 600; }
.legend button.filter .n { font-weight: 400; opacity: .75; }
#payments-table tbody.pay-group[data-collapsed] tr:not(.group-row) { display: none; }
#payments-table .group-row th { padding: 0; background: var(--panel-2); text-align: left; text-transform: none; letter-spacing: 0; }
#payments-table .group-title { width: 100%; border: 0; background: none; color: var(--text); font: inherit; font-size: 15px;
  font-weight: 500; letter-spacing: -0.01em; cursor: pointer; text-align: left; padding: 10px var(--pad); }
#payments-table .group-title svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
#payments-table .group-title[aria-expanded="false"] svg { transform: rotate(-90deg); }
#payments-table .group-title:hover svg { color: var(--text); }
#payments-table .group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#payments-table tbody[data-pinned] .group-title { color: var(--red); cursor: default; }
#payments-table tbody[data-pinned] .group-row th { background: var(--red-soft); }
.legend button.by-day { font: inherit; color: var(--muted); background: none; border: 1px dashed var(--border); cursor: pointer; }
.legend button.by-day[aria-pressed="true"] { color: var(--text); border-style: solid; }
#payments-table[data-filter="match"] tbody tr[data-kind]:not([data-kind="match"]),
#payments-table[data-filter="partial"] tbody tr[data-kind]:not([data-kind="partial"]),
#payments-table[data-filter="unmatched"] tbody tr[data-kind]:not([data-kind="unmatched"]) { display: none; }
.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; min-width: 820px; }
table.data th, table.data td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--t); }
table.data tbody tr:hover { background: color-mix(in srgb, var(--panel-2) 60%, transparent); }
table.data th { color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.6px;
  background: color-mix(in srgb, var(--sidebar) 35%, transparent); }
table.data th:first-child, table.data td:first-child { padding-left: var(--pad); }
table.data th:last-child, table.data td:last-child { padding-right: var(--pad); }
table.data .num { text-align: right; }
table.data td:first-child { min-width: 210px; }
table.data td.actions { display: table-cell; white-space: nowrap; width: 1%; }
table.data td.actions > div { white-space: normal; min-width: 180px; }
table.data td.actions .btn { margin: 0 6px 6px 0; }
@media (max-width: 1600px) {  /* stack confirm / reject so the invoice column keeps its width */
  table.data td.actions .btn { display: flex; width: 100%; justify-content: flex-start; margin: 0 0 6px; }
}
form.assign select { width: 100%; max-width: 340px; }
table.data tr.state-executed, table.data tr.state-rejected, table.data tr.state-expired { opacity: 0.55; }
table.data.compact { min-width: 0; margin: 10px 0 4px; border: 1px solid var(--hairline); border-radius: var(--r-sm);
  border-collapse: separate; border-spacing: 0; overflow: hidden; }
table.data.compact td, table.data.compact th { padding: 8px 12px; }
table.data.compact th:first-child, table.data.compact td:first-child { padding-left: 12px; min-width: 0; }
table.data.compact th:last-child, table.data.compact td:last-child { padding-right: 12px; }
.footnote { max-width: 760px; line-height: 1.6; margin-top: 16px; }
form.assign { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

/* --- cards and draft editor (Upomienky, Ponuky, E-maily) ---------------------------------------- */
.card { padding: 22px var(--pad); max-width: 1080px; }
.card table.data.compact { width: auto; min-width: min(560px, 100%); }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 18px; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 13px; }
.card-meta strong { color: var(--text); font-weight: 500; }
.card.state-executed, .card.state-rejected, .card.state-expired { opacity: 0.7; }
form.draft { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
form.draft input, form.draft textarea { width: 100%; padding: 10px 12px; font-size: 14px; }
form.draft textarea { line-height: 1.6; resize: vertical; min-height: 140px; }
form.draft .actions { margin-top: 12px; }
.fill-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; }
.fill-chip { font: inherit; font-size: 12.5px; cursor: pointer; border-radius: var(--r-pill); padding: 3px 10px;
  border: 1px dashed color-mix(in srgb, var(--accent) 70%, transparent); background: var(--accent-soft); color: var(--accent-fg);
  transition: background var(--t), opacity var(--t); text-align: left; }
.fill-chip:hover { background: color-mix(in srgb, var(--accent) 24%, transparent); }
.fill-chip.done { border-style: solid; border-color: var(--ok); background: var(--ok-soft); color: var(--ok); text-decoration: line-through; opacity: 0.75; }
.draft-foot { margin-top: 6px; }
ul.plain { margin: 0; padding-left: 18px; }
ul.plain li + li { margin-top: 3px; }
details > summary { cursor: pointer; }

/* --- e-mail detail (mockup '2 · E-mail – návrh odpovede') --------------------------------------- */
.back { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--accent-fg); }
.mail-meta { margin-bottom: 6px; }
.mail-subject { margin: 0 0 22px; font-size: 26px; line-height: 1.25; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.link-grid { display: grid; grid-template-columns: 110px 1fr; gap: 10px 14px; margin: 10px 0 14px; }
.link-grid dt { color: var(--muted); }
.link-grid dd { margin: 0; }
pre.translation, .thread-msg pre { white-space: pre-wrap; font-family: inherit; font-size: 13px; line-height: 1.55; margin: 6px 0; }
.thread-all { padding: 12px var(--pad) 18px; border-top: 1px solid var(--hairline); }
.thread-msg { border-top: 1px solid var(--hairline); padding: 10px 0; }
.thread-msg:first-of-type { border-top: 0; }
.thread-msg.out { padding-left: 16px; box-shadow: inset 2px 0 0 var(--accent); }
.summary-list { margin: 0 0 10px; padding-left: 18px; line-height: 1.6; }

.scope-switch { margin: -6px 0 20px; }

/* Shown when an HTMX action did not reach the server or failed (base.html). */
.net-error { margin: 16px 36px 0; padding: 12px 16px; border-radius: var(--r-sm); color: var(--text);
  background: color-mix(in srgb, var(--err) 22%, var(--panel)); box-shadow: inset 3px 0 0 var(--err); }

/* HTMX swaps: new content settles in softly */
.htmx-added { animation: settle 220ms var(--ease); }
@keyframes settle { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* --- responsive (mockup '4 · Dashboard v mobile') ---------------------------------------------- */
@media (max-width: 1440px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr) 330px; gap: 22px; }
}
@media (max-width: 1180px) {
  .dash-grid { grid-template-columns: 1fr; }
  .ask-panel { position: static; max-height: none; }
}
@media (max-width: 900px) {
  .counters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .detail-grid { grid-template-columns: 1fr; }
  .content { padding: 24px 20px 40px; }
}
@media (max-width: 640px) {
  :root { --pad: 16px; }
  .sidebar { display: none; }
  .topbar { background: var(--sidebar); color: var(--text); padding: 12px 16px; box-shadow: none; }
  .topbar a { color: var(--text); }
  .topbar-user { display: none; }
  .topbar-title { display: none; }  /* the brand link next to the logo already names the page */
  .mobile-brand { display: flex; align-items: center; order: 0; text-decoration: none; }
  .mobile-brand img { height: 30px; width: auto; }
  .mobile-brand span { color: var(--text); margin-left: 12px; font-size: 15px; }
  .pi-header { padding-left: 0; gap: 14px; }
  .pi-header svg { width: 30px; height: 36px; }
  .pi-header h1 { font-size: 22px; }
  .mobile-menu { display: block; order: 2; margin-left: 4px; }
  .topbar-bell { order: 1; margin-left: auto; }
  .user-switch .bell-menu { position: fixed; left: 12px; right: 12px; top: 58px; width: auto; }
  .mobile-menu summary { list-style: none; cursor: pointer; font-size: 22px; padding: 2px 6px; }
  .mobile-menu summary::-webkit-details-marker { display: none; }
  .mobile-menu ul { position: absolute; right: 12px; top: 52px; z-index: 30; list-style: none; margin: 0; padding: 6px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--r); min-width: 200px; box-shadow: var(--shadow-pop); }
  .mobile-menu ul a { display: block; padding: 10px 14px; border-radius: var(--r-sm); text-decoration: none; }
  .mobile-menu ul a:hover { background: var(--panel-2); }
  .content { padding: 18px 16px 32px; }
  .desktop-only { display: none; }
  .mobile-only { display: block; }
  .dash-header { margin-bottom: 18px; }
  .dash-grid { gap: 0; }
  .dash-header h1 { font-size: 24px; }
  .switch:not(.scope-switch) { display: none; }
  .counters { grid-template-columns: 1fr; gap: 10px; margin-bottom: 18px; }
  a.counter { display: grid; grid-template-columns: 56px 1fr 16px; grid-template-areas: "value label chevron" "value note chevron";
    align-items: center; padding: 14px 16px; }
  a.counter:hover { transform: none; }
  a.counter::after { content: "›"; grid-area: chevron; color: var(--muted); font-size: 22px; }
  .counter-value { grid-area: value; font-size: 26px; margin: 0; text-align: center; }
  .counter-label { grid-area: label; color: var(--text); }
  .counter-label .i { display: none; }
  .counter-note { grid-area: note; font-size: 12px; }
  .next-item h2 { margin: 6px 0; }
  .page-header { flex-wrap: wrap; }
  .block .line { flex-wrap: wrap; }
  .block .line > .btn { width: 100%; }
  .initials { display: none; }
}

/* Theme toggle: a row in the user menu (and the mobile menu). It names the theme it switches to. */
.theme-toggle { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: inherit; font: inherit; font-weight: 400; text-align: left; cursor: pointer; }
.user-switch .theme-toggle { color: var(--topbar-ink); }
.user-switch .theme-toggle:hover { background: #f3f3f5; }
.mobile-menu .theme-toggle:hover { background: var(--panel-2); }
.theme-toggle .i { width: 18px; height: 18px; margin: 0 4px; }
.menu-sep { height: 1px; margin: 6px 4px; background: #e6e6ea; border: 0; }
.mobile-menu .menu-sep { background: var(--hairline); }
.theme-toggle .to-light { display: contents; }
.theme-toggle .to-dark { display: none; }
:root[data-theme="light"] .theme-toggle .to-light { display: none; }
:root[data-theme="light"] .theme-toggle .to-dark { display: contents; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .theme-toggle .to-light { display: none; }
  :root:not([data-theme="dark"]) .theme-toggle .to-dark { display: contents; }
}

/* E-mail helper beside a draft: side by side when the card is wide, stacked under the editor otherwise */
.assist-wrap { container-type: inline-size; }
.assist-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@container (min-width: 900px) {
  .assist-grid { grid-template-columns: minmax(0, 1fr) clamp(300px, 32%, 400px); }
  .assist { position: sticky; top: 76px; }
}
.assist { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--inset); box-shadow: var(--shadow); }
.assist-head { display: flex; gap: 12px; align-items: center; }
.assist-head h3 { margin: 0 0 2px; font-size: 15px; }
.assist-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.assist-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2); font: inherit; font-size: 13px;
  cursor: pointer; transition: border-color var(--t), background var(--t), color var(--t); }
.assist-chip:hover { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--text); }
.assist-chip.primary { border-color: color-mix(in srgb, var(--accent) 55%, transparent); color: var(--accent-fg); font-weight: 500; }
.assist-chip .i { width: 15px; height: 15px; }
.assist-chip:disabled { opacity: 0.55; cursor: progress; }
.assist-form { display: flex; gap: 8px; }
.assist-form input { flex: 1; min-width: 0; height: 36px; padding: 0 12px; font-size: 14px; }
.assist .typing { align-self: flex-start; }
.assist-out:empty { display: none; }
.assist-result { display: flex; flex-direction: column; gap: 10px; padding: 12px 14px; border-radius: var(--r-sm);
  background: var(--panel); border: 1px solid var(--hairline); animation: settle 0.25s var(--ease); }
.assist-task { display: flex; align-items: center; gap: 6px; }
.assist-task .i { width: 14px; height: 14px; color: var(--accent-fg); }
.assist-notes { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.5; }
.assist-notes li + li { margin-top: 4px; }
.assist-notes li::marker { color: var(--accent-fg); }
.assist-preview { border: 1px solid var(--hairline); border-radius: var(--r-sm); padding: 10px 12px; background: var(--inset); }
.assist-subject { font-weight: 500; margin: 4px 0 6px; }
.assist-preview pre { margin: 0; max-height: 320px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
  font: inherit; font-size: 13.5px; line-height: 1.5; color: var(--text-2); }
.assist-apply { display: flex; gap: 8px; }
form.draft textarea.just-filled { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }

/* Login, password change, account (docs/P2-PLAN.md §4) */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px 24px; }
.auth-card h1 { font-size: 20px; margin: 18px 0 14px; }
.auth-brand { display: flex; align-items: center; gap: 10px; color: var(--muted); text-decoration: none; font-size: 14px; }
.auth-brand img { height: 28px; }
.auth-form { display: grid; gap: 6px; margin: 0 0 14px; }
.auth-form label { font-size: 13px; color: var(--muted); margin-top: 8px; }
.auth-form .field { width: 100%; height: 44px; font-size: 16px; } /* 16 px: no zoom on focus on a phone */
.auth-form .btn { margin-top: 16px; height: 44px; }
.auth-error { background: color-mix(in srgb, var(--err) 12%, transparent); color: var(--err); border-radius: 8px; padding: 10px 12px; font-size: 14px; margin: 0 0 8px; }
.auth-codes { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 6px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; margin: 12px 0; padding: 0; list-style: none; }
.auth-codes li { white-space: nowrap; } /* a code broken over two lines is easy to copy wrong */
.auth-qr { display: block; width: 240px; margin: 8px auto 12px; background: #fff; padding: 8px; border-radius: 8px; }
.auth-qr svg { display: block; width: 100%; height: auto; shape-rendering: crispEdges; }
.auth-secret { text-align: center; }
.auth-secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.banner-ok { background: color-mix(in srgb, var(--ok, #3a9d5d) 14%, transparent); border-radius: 8px; padding: 10px 14px; margin: 0 0 14px; font-size: 14px; }
.card.account { margin-bottom: 14px; }
.card.account h2 { font-size: 16px; margin: 0 0 8px; }
.user-switch .menu .menu-form { margin: 0; }
.user-switch .menu .menu-button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--r-sm); background: transparent; color: var(--topbar-ink); font: inherit; font-weight: 400; cursor: pointer; }
.user-switch .menu .menu-button .i, .user-switch .menu a.menu-item .i { width: 18px; height: 18px; margin: 0 4px; }
.user-switch .menu .menu-button:hover { background: #f3f3f5; }

/* Permissions (docs/P2-PLAN.md §6): a card the role may only read shows no actions; one it may edit but not
   send shows no approval. The server refuses the same requests. */
[data-readonly] button, [data-readonly] form.assign, [data-readonly] form.override, [data-readonly] .assist { display: none !important; }
[data-readonly] textarea, [data-readonly] input { pointer-events: none; opacity: 0.75; }
[data-nosend] button[hx-post$="/approve"] { display: none !important; }
.users-table form { display: inline; }

/* "Posunúť kolegovi" (docs/P2-PLAN.md §7) */
.handed { margin-top: 10px; color: var(--accent-fg); }
details.delegate { margin-top: 10px; }
details.delegate > summary { cursor: pointer; color: var(--muted); }
.delegate-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; }
.delegate-form select.field { width: auto; min-width: 140px; }
.delegate-form input.field { flex: 1 1 200px; }
[data-readonly] details.delegate { display: none; }

/* "Ako písať zákazníkovi" (docs/P2-PLAN.md §8) */
.tone-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.tone-form label { margin: 0 !important; }
.tone-form select.field { width: auto; }
.tone-form input.field { flex: 1 1 220px; }
.panel.tone > *:not(.block-title) { margin-left: var(--pad); margin-right: var(--pad); }
.panel.tone { padding-bottom: 14px; }
.error-page p { margin: 0 0 14px; }

/* Split payments (docs/P4-PLAN.md §3): one line per document with its state */
.allocation-states { list-style: none; margin: 0 0 8px; padding: 0; }
.allocation-states .alloc-written { color: var(--ok); }
.allocation-states .alloc-failed, .allocation-states .alloc-unknown { color: var(--err); }

/* Manual assignment of a payment (docs/P4-PLAN.md §4) */
details.assign-editor { margin: 8px 0; }
details.assign-editor > summary { cursor: pointer; color: var(--muted); }
.allocation-draft { list-style: none; margin: 8px 0; padding: 0; }
.doc-search input[name="q"] { width: 100%; margin: 8px 0; }
.doc-result, form.not-invoice { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0; }
[data-readonly] details.assign-editor { display: none; }

/* Statement upload and list (docs/P4-PLAN.md §5) */
.upload-statement { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0 12px; }
details.statements { margin: 12px 0; }

/* Collapsible side menu: icons only, remembered in the browser (data-nav on <html>, set before first paint) */
.sidebar { display: flex; flex-direction: column; transition: width var(--t); }
.nav-toggle { display: flex; align-items: center; gap: 12px; margin: auto 12px 0; padding: 11px 14px; border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer; }
.nav-toggle:hover { background: var(--side-hover); color: var(--text); }
.nav-toggle .i { transition: transform var(--t); flex-shrink: 0; }
:root[data-nav="collapsed"] .sidebar { width: 74px; }  /* 12 + 14 + a 22 px icon + 14 + 12 */
:root[data-nav="collapsed"] .sidebar .nav-label { display: none; }
:root[data-nav="collapsed"] .sidebar .brand { width: 46px; margin: 0 0 0 14px; padding: 0 0 28px; overflow: hidden; }  /* the gear of the logo, where it was */
/* Collapsing hides the labels and nothing else: an icon keeps its size and its place (same padding, no centring). */
:root[data-nav="collapsed"] .sidebar ul a, :root[data-nav="collapsed"] .nav-toggle { position: relative; }
.sidebar ul a .i, .nav-toggle .i { width: 22px; height: 22px; flex-shrink: 0; }
.sidebar ul a, .nav-toggle { min-height: 46px; }  /* the row is as tall without its label as with it */
/* While the bar's width animates, a label must not wrap onto a second line (that made the icons below jump for
   a frame) and must not push anything: it is clipped by its row instead. */
.sidebar ul a, .nav-toggle { white-space: nowrap; overflow: hidden; }
.sidebar .nav-label { overflow: hidden; text-overflow: clip; min-width: 0; }
.sidebar .brand { overflow: hidden; }
.sidebar .brand img { flex-shrink: 0; }
:root[data-nav="collapsed"] .sidebar ul a .count { position: absolute; top: 2px; right: 2px; margin: 0; min-width: 16px; height: 16px; padding: 0 4px; font-size: 10px; }
:root[data-nav="collapsed"] .nav-toggle .i { transform: rotate(180deg); }

/* --- Files of an e-mail (docs/EU-AI-ATTACHMENTS-PLAN.md §3) --- */
.files-panel { margin: 8px 0; }
.files-list { margin: 4px 0; padding: 0; }
.files-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 2px 0; overflow-wrap: anywhere; }
.files-add > summary { cursor: pointer; color: var(--muted); }
.files-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; }
.files-form .field { flex: 1 1 220px; min-width: 0; }

/* --- Phone pass (docs/P6-PLAN.md §5): nothing may make the page wider than the screen (checked at 390 px) --- */
@media (max-width: 640px) {
  /* the collapsible sidebar (a later rule sets display: flex) must stay hidden on a phone: the menu is ☰ */
  .sidebar, :root[data-nav="collapsed"] .sidebar { display: none; }
  .layout, .main, .content { max-width: 100vw; }
  /* the file panel (inbox #31, seen at 390 px): fingers need more than a 19 px line or a 32 px button */
  .files-add > summary { padding: 10px 0; min-height: 40px; }
  .files-list li { padding: 4px 0; }
  .files-list li > a { padding: 8px 0; }
  .files-list .btn-sm, .files-form .btn-sm { min-height: 40px; }
  .content > *, .panel, .card, .detail-grid > *, .dash-grid > *, form, fieldset { min-width: 0; max-width: 100%; }
  .detail-grid, .dash-grid, .assist-grid { grid-template-columns: minmax(0, 1fr); }
  /* a table that does not fit scrolls inside its card instead of stretching the page */
  .panel, .card, .table-scroll, details.statements { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  pre, .thread-msg pre, .translation { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
  .card-head, .card-meta, .actions, .line, .mail-meta, .auth-codes { flex-wrap: wrap; }
  .card-head h2, .mail-subject, .line-main, .line-sub, .card-meta span { overflow-wrap: anywhere; min-width: 0; }
  input, select, textarea, .field { max-width: 100%; min-width: 0; }
  .actions .btn, .btn { white-space: normal; }
  img, svg { max-width: 100%; }
  .topbar, .mobile-brand, .pi-header, .pi-header > *, .assist, .assist-grid > *, .assist-head > * { min-width: 0; }
  .mobile-brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pi-header, .block-title, .assist-head, .scope-switch, .switch { flex-wrap: wrap; max-width: 100%; }
  .assist, .assist-grid > * { max-width: 100%; }
  .assist-chip { max-width: 100%; white-space: normal; text-align: left; }
  .delegate-form { max-width: 100%; }
  .delegate-form select.field, .delegate-form input.field, .delegate-form .btn {
    flex: 1 1 100%; width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
  a.counter { grid-template-columns: 56px minmax(0, 1fr) 16px; min-width: 0; }
  .counter-label, .counter-note { min-width: 0; overflow-wrap: anywhere; flex-wrap: wrap; }
  dl.link-grid { grid-template-columns: minmax(0, 1fr); }
  dl.link-grid dd, dl.link-grid dt, .recipients, .recipients strong { min-width: 0; overflow-wrap: anywhere; }
}

/* --- The panel for an iframe on the PI Dashboard (docs/P6-PLAN.md §3): one column from 320 px --- */
.panel-body { margin: 0; padding: 10px 12px 16px; min-width: 0; background: var(--bg); overflow-x: hidden; }
.panel-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.panel-head .btn { margin-left: auto; white-space: nowrap; }
.panel-counters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.panel-counter { display: flex; flex-direction: column; padding: 8px 10px; border-radius: 8px; background: var(--panel, rgba(127, 127, 127, 0.12)); color: inherit; text-decoration: none; min-width: 0; }
.panel-counter strong { font-size: 1.4rem; line-height: 1.2; }
.panel-counter span { font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-items { margin: 0 0 8px; padding: 0; }
.panel-items li { padding: 6px 0; border-top: 1px solid rgba(127, 127, 127, 0.25); overflow-wrap: anywhere; }
.panel-items a { color: inherit; text-decoration: none; }
.panel-items a:hover { text-decoration: underline; }
.panel-ask { margin-top: 12px; }
.panel-ask-row { display: flex; gap: 6px; }
.panel-ask-row .field { flex: 1 1 auto; min-width: 0; }
.panel-login { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#panel-answer { margin-top: 8px; overflow-wrap: anywhere; }
#panel-answer pre, #panel-answer table { max-width: 100%; overflow-x: auto; display: block; }


/* names of attachments on the reply card (read / not read by the model): long names wrap, also on a phone */
.file-name { overflow-wrap: anywhere; font-weight: 500; }

/* 'Potvrdiť všetky spárované', first step: the list to check before anything is confirmed (UX audit C1) */
.bulk-review { border: 1px solid var(--accent); }
.bulk-review h3 { margin: 0 0 10px; }
.bulk-list { list-style: none; padding: 0; margin: 0 0 12px; max-height: 320px; overflow-y: auto; }
.bulk-list li { padding: 6px 0; border-bottom: 1px solid var(--border); }

/* Text size from the user menu (three steps, saved per device): the page content scales, the sidebar does not. */
:root { --text-zoom: 1; }
:root[data-text-size="2"] { --text-zoom: 1.125; }
:root[data-text-size="3"] { --text-zoom: 1.25; }
.main { zoom: var(--text-zoom); }
/* lined up with the other menu items: the small A in the icon column (4 + 18 + 4 px), the slider where their text starts */
.text-size { padding: 8px 10px; }
.text-size-row { display: flex; align-items: center; gap: 10px; }
.text-size-row input[type="range"] { flex: 1; min-width: 0; accent-color: var(--accent); min-height: 28px; margin: 0; }
.text-size .a-small { width: 26px; flex-shrink: 0; text-align: center; font-size: 13px; }
.text-size .a-large { font-size: 19px; line-height: 1; }
.user-switch .text-size { color: var(--topbar-ink); }

/* 'Ostatná prijatá pošta' grouped by day, week and month (inbox #49) */
/* the group headers look like the block titles above ("E-maily s pripravenou odpoveďou") */
.other-mail .group-title { cursor: pointer; list-style: none; user-select: none; font-weight: 500; letter-spacing: -0.01em; }
.other-mail .group-title::-webkit-details-marker { display: none; }
.other-mail .group-title svg { width: 16px; height: 16px; color: var(--muted); transition: transform .15s; }
.other-mail .mail-group:not([open]) > .group-title svg { transform: rotate(-90deg); }
.other-mail .group-title:hover svg { color: var(--text); }
.other-mail .group-title:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.other-mail .more { margin: 12px var(--pad); }

/* AI state on the Dashboard when the model does not answer (inbox #59) */
.warn-text { color: var(--red); font-weight: 600; }
