/* Plusiņš. A quiet working tool in the manner of the Cloudflare dashboard: a top bar across the
   whole width, a sidebar on the page background, a page header as a band with a rule under it,
   content in a centred column. Neutral greys, near-black text, one bright accent for the main action.
   On a phone: a top bar with the section name and tabs at the bottom. */

/* Inter (variable, weights 400 to 600) cut down to Latin with Latvian letters, WOFF2 without hinting;
   other scripts fall back to the system font. Made with fontTools, see README. */
@font-face { font-family: 'Inter'; src: url('/fonts/Inter.woff2') format('woff2'); font-weight: 400 600; font-display: swap; unicode-range: U+0000-00FF, U+0100-017F, U+0218-021B, U+2010-2027, U+2030-203A, U+20AC, U+2116, U+2122, U+2190-2193, U+2212; }

/* ---------- accent presets: values for both themes, the theme below picks its pair ---------- */
:root {
  --a-l: #0a5ce6; --a-l-hover: #0849b8; --a-l-soft: #eef3fe; --a-l-on: #ffffff;
  --a-d: #5b9bff; --a-d-hover: #82b3ff; --a-d-soft: rgba(91, 155, 255, .14); --a-d-on: #04122e;
}
[data-accent="green"] {
  --a-l: #047857; --a-l-hover: #065f46; --a-l-soft: #ecfdf5; --a-l-on: #ffffff;
  --a-d: #10b981; --a-d-hover: #34d399; --a-d-soft: rgba(16, 185, 129, .12); --a-d-on: #052e1c;
}
[data-accent="teal"] {
  --a-l: #0f766e; --a-l-hover: #115e59; --a-l-soft: #f0fdfa; --a-l-on: #ffffff;
  --a-d: #2dd4bf; --a-d-hover: #5eead4; --a-d-soft: rgba(45, 212, 191, .12); --a-d-on: #042f2c;
}
[data-accent="violet"] {
  --a-l: #6d28d9; --a-l-hover: #5b21b6; --a-l-soft: #f5f3ff; --a-l-on: #ffffff;
  --a-d: #a78bfa; --a-d-hover: #c4b5fd; --a-d-soft: rgba(167, 139, 250, .14); --a-d-on: #1e1038;
}
[data-accent="fuchsia"] {
  --a-l: #a21caf; --a-l-hover: #86198f; --a-l-soft: #fdf4ff; --a-l-on: #ffffff;
  --a-d: #e879f9; --a-d-hover: #f0abfc; --a-d-soft: rgba(232, 121, 249, .13); --a-d-on: #3b0a40;
}
[data-accent="indigo"] {
  --a-l: #4338ca; --a-l-hover: #3730a3; --a-l-soft: #eef2ff; --a-l-on: #ffffff;
  --a-d: #818cf8; --a-d-hover: #a5b4fc; --a-d-soft: rgba(129, 140, 248, .13); --a-d-on: #0d0b33;
}
[data-accent="ocean"] {
  --a-l: #0369a1; --a-l-hover: #075985; --a-l-soft: #f0f9ff; --a-l-on: #ffffff;
  --a-d: #38bdf8; --a-d-hover: #7dd3fc; --a-d-soft: rgba(56, 189, 248, .13); --a-d-on: #04263b;
}
[data-accent="olive"] {
  --a-l: #4d7c0f; --a-l-hover: #3f6212; --a-l-soft: #f7fee7; --a-l-on: #ffffff;
  --a-d: #a3e635; --a-d-hover: #bef264; --a-d-soft: rgba(163, 230, 53, .12); --a-d-on: #1a2e05;
}
[data-accent="pink"] {
  --a-l: #be185d; --a-l-hover: #9d174d; --a-l-soft: #fdf2f8; --a-l-on: #ffffff;
  --a-d: #f472b6; --a-d-hover: #f9a8d4; --a-d-soft: rgba(244, 114, 182, .13); --a-d-on: #3b0a24;
}
[data-accent="orange"] {
  --a-l: #c2410c; --a-l-hover: #9a3412; --a-l-soft: #fff7ed; --a-l-on: #ffffff;
  --a-d: #fb923c; --a-d-hover: #fdba74; --a-d-soft: rgba(251, 146, 60, .13); --a-d-on: #2a1204;
}
[data-accent="slate"] {
  --a-l: #333333; --a-l-hover: #1c1c1c; --a-l-soft: #f2f2f2; --a-l-on: #ffffff;
  --a-d: #d4d4d4; --a-d-hover: #ececec; --a-d-soft: rgba(212, 212, 212, .12); --a-d-on: #121212;
}

/* ---------- light theme: plain greys without a blue tint ---------- */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f2f2f2;
  --border: #e5e5e5;
  --border-strong: #d4d4d4;
  --text: #1c1c1c;
  --text-2: #595959;
  --text-3: #6b6b6b;
  --accent: var(--a-l);
  --accent-hover: var(--a-l-hover);
  --accent-soft: var(--a-l-soft);
  --on-accent: var(--a-l-on);
  --danger: #c81e1e;
  --danger-soft: #fef2f2;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --success: #15803d;
  --info: #1d4ed8;
  --info-soft: #eef4ff;
  --neutral: #8c8c8c;
  --on-danger: #ffffff;
  --shadow-md: 0 4px 12px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .12);
  --backdrop: rgba(0, 0, 0, .4);
  color-scheme: light;

  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --r: 6px;
  --r-modal: 10px;
  --side-w: 230px;
  --bar-h: 50px;
  --tabs-h: 60px;
  --col: 1064px;
  --ctl-h: 44px;          /* buttons and fields: 44px on a phone, 34px on a computer */
  --ctl-fs: 16px;         /* 16px in fields on a phone, otherwise iOS zooms in on focus */
  /* motion: a strong ease-out for anything that appears or answers, an iOS-like curve for what slides in */
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: 150ms var(--ease-out);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121212; --surface: #1a1a1a; --surface-2: #242424;
    --border: #2b2b2b; --border-strong: #3a3a3a;
    --text: #ececec; --text-2: #a6a6a6; --text-3: #8c8c8c;
    --accent: var(--a-d); --accent-hover: var(--a-d-hover); --accent-soft: var(--a-d-soft); --on-accent: var(--a-d-on);
    --danger: #f87171; --danger-soft: rgba(248, 113, 113, .12);
    --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
    --success: #4ade80; --neutral: #737373; --on-danger: #2a0606;
    --info: #8ab4ff; --info-soft: rgba(91, 155, 255, .12);
    --shadow-md: 0 0 0 1px var(--border); --shadow-lg: 0 0 0 1px var(--border);
    --backdrop: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121212; --surface: #1a1a1a; --surface-2: #242424;
  --border: #2b2b2b; --border-strong: #3a3a3a;
  --text: #ececec; --text-2: #a6a6a6; --text-3: #8c8c8c;
  --accent: var(--a-d); --accent-hover: var(--a-d-hover); --accent-soft: var(--a-d-soft); --on-accent: var(--a-d-on);
  --danger: #f87171; --danger-soft: rgba(248, 113, 113, .12);
  --warning: #fbbf24; --warning-soft: rgba(251, 191, 36, .12);
  --success: #4ade80; --neutral: #737373; --on-danger: #2a0606;
  --info: #8ab4ff; --info-soft: rgba(91, 155, 255, .12);
  --shadow-md: 0 0 0 1px var(--border); --shadow-lg: 0 0 0 1px var(--border);
  --backdrop: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
@media (min-width: 768px) {
  :root { --ctl-h: 34px; --ctl-fs: 14px; }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* hidden means hidden, also for elements whose class sets display (.btn) */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--bar-h) + 16px); background: var(--bg); -webkit-tap-highlight-color: transparent;
  scrollbar-color: var(--border-strong) transparent; }
/* the parts the browser draws carry the palette too: selection, the caret */
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--text); }
input, textarea { caret-color: var(--accent); }
body {
  margin: 0; min-height: 100vh; min-height: 100svh; background: var(--bg); color: var(--text);
  font: 400 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}
a, button, summary, label, input, select, textarea { touch-action: manipulation; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { line-height: 1.3; font-weight: 600; text-wrap: balance; }
h1 { font-size: 20px; letter-spacing: -.01em; margin: 0 0 16px; }
h2 { font-size: 15px; margin: 32px 0 12px; }
h3 { font-size: 14px; margin: 20px 0 6px; }
p { margin: 12px 0; }
p, li { text-wrap: pretty; }
b, strong { font-weight: 600; }
.muted { color: var(--text-2); }
.small, .meta { font-size: 13px; color: var(--text-2); }
.hint { font-size: 12px; color: var(--text-3); }

.err { color: var(--danger); }
.warn { color: var(--warning); }
.num { font-weight: 500; }
/* digits of equal width where numbers stand in columns or are compared */
.num, .count, .stat b, .table, .cr-date, .bar-label, .meta { font-variant-numeric: tabular-nums; }

.name { overflow-wrap: anywhere; }
.sr-only, .visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.ico { width: 14px; height: 14px; fill: currentColor; flex: none; }
:where(a, button, summary, [tabindex], input[type=checkbox], input[type=radio]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip {
  position: fixed; top: 8px; left: 8px; z-index: 50; padding: 8px 14px; border-radius: var(--r);
  background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-md); transform: translateY(-200%);
}
.skip:focus { transform: none; }
@media (max-width: 767px) { .desk-only { display: none !important; } }
@media (min-width: 768px) { .mobile-only { display: none !important; } }

/* ---------- frame ---------- */
.logo { display: block; flex: none; border-radius: 5px; }
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 8px;
  height: calc(var(--bar-h) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 8px 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; flex: none; color: var(--text); font-size: 14px; font-weight: 600; }
.brand:hover { text-decoration: none; }
.appbar-title { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.has-nav .appbar .brand span { display: none; }
.appbar-actions { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.appbar-user { display: inline-flex; align-items: center; gap: 6px; padding: 0 8px; color: var(--text); font-size: 13px; font-weight: 500; white-space: nowrap; }
.appbar-user .ico { color: var(--text-3); }
.theme-form, .logout-form { margin: 0; }
.home-links { display: flex; gap: 2px; margin-left: 8px; }
@media (max-width: 599px) {
  .appbar:has(.home-links) { flex-wrap: wrap; height: auto; padding-bottom: 4px; }
  .home-links { order: 3; flex-basis: 100%; margin-left: -12px; }
}

.sidebar { display: none; }
.side-search { position: relative; margin: 0 0 12px; }
.side-search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.side-search input[type=search] { height: 32px; padding-left: 30px; font-size: 13px; background-color: var(--surface); }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 31px; padding: 0 8px; border: 0; border-radius: var(--r);
  background: none; color: var(--text); font: 500 13px/1 var(--font); text-align: left; white-space: nowrap; cursor: pointer;
}
.nav-item > span { overflow: hidden; text-overflow: ellipsis; }
.nav-item .ico { color: var(--text-3); }
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.on { background: var(--surface-2); }
.nav-item.on .ico { color: var(--text); }

.side-search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none;
  min-width: 20px; padding: 1px 5px; border: 1px solid var(--border); border-radius: 4px; background: var(--surface-2);
  font: 500 11px var(--font); line-height: 16px; text-align: center; color: var(--text-3);
}
.side-search input[type=search]:focus + kbd, .side-search input[type=search]:not(:placeholder-shown) + kbd { display: none; }
/* a section that folds: «Iestatījumi», «Konts», «Nesen atvērti» */
.nav-sec > summary { list-style: none; cursor: pointer; }
.nav-sec > summary::-webkit-details-marker { display: none; }
.nav-sec > summary > .ico:last-child { margin-left: auto; width: 10px; height: 10px; transform: rotate(-90deg); transition: transform var(--ease); }
.nav-sec[open] > summary > .ico:last-child { transform: none; }
.nav-sec > summary.has-on .ico:first-child { color: var(--text); }
.nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 4px 15px; padding-left: 10px; border-left: 1px solid var(--border); }
.nav-subitem {
  display: flex; align-items: center; min-height: 30px; padding: 4px 8px; border-radius: var(--r);
  color: var(--text); font-size: 13px; font-weight: 500;
}
.nav-subitem:hover { background: var(--surface-2); text-decoration: none; }
.nav-subitem.on { background: var(--surface-2); }
/* recents: the name and under it where it is */
.nav-subitem small { display: block; font-size: 11px; font-weight: 400; color: var(--text-3); line-height: 1.2; }
.nav-subitem > span { display: flex; flex-direction: column; min-width: 0; }
.nav-rule { margin: 14px 8px; border: 0; border-top: 1px solid var(--border); }
/* «Palīdzība» next to a page title, «Jauns» on new things: small framed labels */
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.pill, .tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font-size: 12px; font-weight: 500; white-space: nowrap;
}
.pill:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.tag { height: 20px; padding: 0 6px; border-color: var(--border); background: var(--surface-2); font-size: 12px; }
.tag-new { background: var(--surface); border-color: var(--border-strong); }
.tag-warn { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
/* a notice across the column: a light blue band, a bold first line, buttons on the right */
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 20px; padding: 12px 14px;
  border-radius: var(--r); background: var(--info-soft); color: var(--info);
}
.banner-text { flex: 1 1 260px; min-width: 0; }
.banner-text b { display: block; font-weight: 500; }
.banner-text p { margin: 0; font-size: 13px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.banner .btn { height: 28px; padding: 0 10px; font-size: 13px; }
.banner-warn { background: var(--warning-soft); color: var(--warning); }
/* new bug reports waiting for the admin: a red dot after «Administrācija» and on the tab */
.dot { display: inline-block; flex: none; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--danger); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabs-h) + env(safe-area-inset-bottom)); padding: 0 4px env(safe-area-inset-bottom);
  background: var(--bg); border-top: 1px solid var(--border);
}
.tabs a {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--text-3); font-size: 11px; font-weight: 500; line-height: 1.2;
}
.tabs a:hover { text-decoration: none; }
.tabs a .ico { width: 18px; height: 18px; }
.tabs a.on { color: var(--text); }
.tabs a .dot { position: absolute; top: 10px; left: calc(50% + 8px); margin: 0; }
/* on a phone the keyboard pushes the fixed tabs up over the form (iOS Safari): app.js sets .keyboard-open */
.keyboard-open .tabs { display: none; }

/* content: a centred column; the page header is a band with a rule across the whole width */
/* the side padding grows on wide screens so the content stays a centred column */
.page { padding: 0 16px calc(var(--tabs-h) + env(safe-area-inset-bottom) + 32px); overflow-x: clip; }
body.public .page { padding-bottom: 48px; }
.page-head {
  position: relative; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 20px 0 16px; margin-bottom: 20px;
}
.page-head::after { content: ''; position: absolute; left: -100vw; right: -100vw; bottom: 0; height: 1px; background: var(--border); }
.page-head h1 { margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--text-2); }
.page-head-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: none; }
.page-head > .btn { flex: none; }
/* a page without the band: the title alone */
.page > h1:first-child, .page > .flash + h1 { padding-top: 20px; }

@media (min-width: 768px) {
  .appbar { padding: 0 16px 0 0; }
  .appbar .brand { width: var(--side-w); height: 100%; padding: 0 16px; border-right: 1px solid var(--border); }
  .has-nav .appbar .brand span { display: inline; }
  .appbar-title { display: none; }
  body.public .appbar .brand { border-right: 0; width: auto; padding: 0 24px; }
  .sidebar {
    position: fixed; top: var(--bar-h); bottom: 0; left: 0; z-index: 15; display: block;
    width: var(--side-w); padding: 12px 12px 24px; overflow-y: auto; overscroll-behavior: contain;
    background: var(--bg); border-right: 1px solid var(--border);
  }
  .tabs { display: none; }
  html { scroll-padding-top: calc(var(--bar-h) + 24px); }
  /* padding in % is counted from the body width, so the sidebar is taken off first */
  body.has-nav .page { margin-left: var(--side-w); padding: 0 max(40px, calc((100% - var(--side-w) - var(--col)) / 2)) 64px; }
  body.public .page { padding: 0 max(40px, calc((100% - var(--col)) / 2)) 64px; }
  .page-head { padding: 32px 0 24px; margin-bottom: 24px; }
  .page > h1:first-child, .page > .flash + h1 { padding-top: 32px; }
}

/* «Grupas / DT-21» breadcrumbs above the title */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 0 0 4px; font-size: 13px; color: var(--text-2); }
.crumbs a { color: var(--text-2); }
.crumbs a:hover { color: var(--text); }
.crumbs .sep { color: var(--text-3); }
/* breadcrumbs sit on top of the page head band */
.crumbs:has(+ .page-head) { padding-top: 16px; margin-bottom: 0; }
.crumbs + .page-head { padding-top: 4px; }
@media (min-width: 768px) { .crumbs:has(+ .page-head) { padding-top: 24px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; position: relative;
  height: var(--ctl-h); padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--r);
  background: var(--surface); color: var(--text); font: 500 14px/1 var(--font); white-space: nowrap;
  cursor: pointer; text-decoration: none; user-select: none;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease), transform 160ms var(--ease-out);
}
.btn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
/* a press is felt: the button gives a little, and comes back as soon as it is let go */
.btn:active:not(:disabled, [aria-disabled="true"]) { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text); font-weight: 500; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-ghost .ico { color: var(--text-2); }
.btn-danger-outline { color: var(--danger); background: var(--surface); }
.btn-danger-outline:hover { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
/* filled red: only the «yes» button of a confirmation dialog */
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--on-danger); }
.btn-danger:hover { background: var(--danger); filter: brightness(.92); color: var(--on-danger); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-icon { width: var(--ctl-h); padding: 0; flex: none; }
.btn-sm { height: 28px; padding: 0 8px; font-size: 13px; }
.btn.is-loading { color: transparent; cursor: progress; opacity: 1; }
.btn.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid var(--text-2); border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-primary.is-loading::after { border-color: var(--on-accent); border-right-color: transparent; }
.btn-danger.is-loading::after { border-color: var(--on-danger); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-row > form { margin: 0; display: contents; }
/* a form's one submit button takes the full width on a phone; every other button keeps its own width */
@media (max-width: 767px) {
  .stack > .btn-primary:last-child, .stack > button.btn-primary { align-self: stretch; }
}

/* ---------- forms ---------- */
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack + .list, .action + .list, .stack + .stack { margin-top: 16px; }
.stack > .btn { align-self: flex-start; }
/* text inside a form: no paragraph margins on top of the gap; a note belongs to the field above it */
.stack > p { margin: 0; }
.stack > .hint { margin-top: -8px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.label .muted { font-weight: 400; color: var(--text-3); }
legend { padding: 0; margin-bottom: 6px; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
/* clearly lighter than a typed value, so an example never looks filled in */
::placeholder { color: color-mix(in srgb, var(--text-3) 72%, var(--surface)); opacity: 1; }
input[type=text], input[type=search], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; height: var(--ctl-h); padding: 0 10px;
  background-color: var(--surface); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--r);
  font: 400 var(--ctl-fs)/1.25 var(--font);
  transition: border-color var(--ease), box-shadow var(--ease);
}
input[type=search]::-webkit-search-cancel-button { display: none; }
textarea { height: auto; min-height: 96px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
select {
  appearance: none; padding-right: 30px; cursor: pointer; text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%238c8c8c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 14px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
input[aria-invalid="true"], .is-invalid { border-color: var(--danger); }
input[aria-invalid="true"]:focus, .is-invalid:focus { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.field-error { margin: 0; font-size: 13px; color: var(--danger); }

input[type=checkbox], input[type=radio] { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); flex: none; cursor: pointer; }
.fixed { display: flex; align-items: center; height: var(--ctl-h); padding: 0 10px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.checks { display: flex; flex-direction: column; padding: 0 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.checks .check + .check { border-top: 1px solid var(--border); }
.checks.plain .check + .check { border-top: 0; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pair-wide { display: grid; gap: 16px; }
@media (min-width: 768px) { .pair-wide { grid-template-columns: 1fr 1fr; } }
/* a setting as a row: what it is on the left, the control on the right */
.set-row { display: grid; gap: 10px 24px; align-items: center; padding: 16px 0; }
.set-row + .set-row { border-top: 1px solid var(--border); }
.card-head + .set-row { padding-top: 0; }
.set-row:last-child { padding-bottom: 0; }
.set-row-only { padding: 0; }
.set-label b { display: block; font-weight: 500; }
.set-label p { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.set-row > .btn { justify-self: start; }
.set-row form { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
@media (min-width: 768px) { .set-row { grid-template-columns: 240px minmax(0, 1fr); } .set-row > form { justify-self: start; } .set-row-only { grid-template-columns: 1fr auto; } }

form.js .js-hide { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  height: 28px; padding: 0 10px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text-2); font: 400 13px var(--font); cursor: pointer;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background-color var(--ease), border-color var(--ease), color var(--ease);
}
.chip:hover { border-color: var(--border-strong); background: var(--surface-2); color: var(--text); }
.chip .ico { width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px; }
.banner-actions.chips form { margin: 0; }

/* a choice of one: group codes on «Izsniegt», sort order in «Administrācija» */
.tiles { display: flex; flex-wrap: wrap; gap: 6px; }

/* segmented control: theme in «Profils» */
.segmented { display: inline-flex; padding: 2px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.segmented label { position: relative; }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
  display: inline-flex; align-items: center; gap: 6px; height: calc(var(--ctl-h) - 6px); padding: 0 10px;
  border-radius: 4px; color: var(--text-2); font-weight: 500; transition: background-color var(--ease), color var(--ease);
}
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

/* accent colour: one click on a swatch */
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 0; }
.swatch {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%;
  background: var(--sw); color: #fff; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}
.swatch .ico { width: 12px; height: 12px; opacity: 0; }
.swatch[aria-pressed="true"] { outline: 2px solid var(--text); outline-offset: 2px; }
.swatch[aria-pressed="true"] .ico { opacity: 1; }
.swatch[data-c="blue"] { --sw: #0a5ce6; }
.swatch[data-c="green"] { --sw: #047857; }
.swatch[data-c="teal"] { --sw: #0f766e; }
.swatch[data-c="violet"] { --sw: #6d28d9; }
.swatch[data-c="fuchsia"] { --sw: #a21caf; }
.swatch[data-c="slate"] { --sw: #333333; }
.swatch[data-c="indigo"] { --sw: #4338ca; }
.swatch[data-c="ocean"] { --sw: #0369a1; }
.swatch[data-c="olive"] { --sw: #4d7c0f; }
.swatch[data-c="pink"] { --sw: #be185d; }
.swatch[data-c="orange"] { --sw: #c2410c; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .swatch { color: #121212; }
  :root:not([data-theme="light"]) .swatch[data-c="blue"] { --sw: #5b9bff; }
  :root:not([data-theme="light"]) .swatch[data-c="green"] { --sw: #10b981; }
  :root:not([data-theme="light"]) .swatch[data-c="teal"] { --sw: #2dd4bf; }
  :root:not([data-theme="light"]) .swatch[data-c="violet"] { --sw: #a78bfa; }
  :root:not([data-theme="light"]) .swatch[data-c="fuchsia"] { --sw: #e879f9; }
  :root:not([data-theme="light"]) .swatch[data-c="slate"] { --sw: #d4d4d4; }
  :root:not([data-theme="light"]) .swatch[data-c="indigo"] { --sw: #818cf8; }
  :root:not([data-theme="light"]) .swatch[data-c="ocean"] { --sw: #38bdf8; }
  :root:not([data-theme="light"]) .swatch[data-c="olive"] { --sw: #a3e635; }
  :root:not([data-theme="light"]) .swatch[data-c="pink"] { --sw: #f472b6; }
  :root:not([data-theme="light"]) .swatch[data-c="orange"] { --sw: #fb923c; }
}
:root[data-theme="dark"] .swatch { color: #121212; }
:root[data-theme="dark"] .swatch[data-c="blue"] { --sw: #5b9bff; }
:root[data-theme="dark"] .swatch[data-c="green"] { --sw: #10b981; }
:root[data-theme="dark"] .swatch[data-c="teal"] { --sw: #2dd4bf; }
:root[data-theme="dark"] .swatch[data-c="violet"] { --sw: #a78bfa; }
:root[data-theme="dark"] .swatch[data-c="fuchsia"] { --sw: #e879f9; }
:root[data-theme="dark"] .swatch[data-c="slate"] { --sw: #d4d4d4; }
:root[data-theme="dark"] .swatch[data-c="indigo"] { --sw: #818cf8; }
:root[data-theme="dark"] .swatch[data-c="ocean"] { --sw: #38bdf8; }
:root[data-theme="dark"] .swatch[data-c="olive"] { --sw: #a3e635; }
:root[data-theme="dark"] .swatch[data-c="pink"] { --sw: #f472b6; }
:root[data-theme="dark"] .swatch[data-c="orange"] { --sw: #fb923c; }

/* ---------- panels: white, with a border, no shadow ---------- */
.card, .help-page, .empty-state, .chart-sheet, .list{
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.card { padding: 16px; }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -16px -16px 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { margin: 0; font-size: 14px; }
.card > section + section { margin: 16px -16px 0; padding: 16px 16px 0; border-top: 1px solid var(--border); }
.card > section > h3:first-child { margin-top: 0; }
@media (min-width: 768px) {
  .card { padding: 20px; }
  .card-head { margin: -20px -20px 16px; padding: 12px 20px; }
  .card > section + section { margin: 20px -20px 0; padding: 20px 20px 0; }
}

/* ---------- lists and tables ---------- */
.list { display: flex; flex-direction: column; overflow: hidden; }
.list:empty { display: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 10px 14px; color: var(--text); }
.list > .row + .row { border-top: 1px solid var(--border); }
a.row:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.big-row { min-height: 48px; font-weight: 500; }
.row-main { display: flex; flex-direction: column; min-width: 0; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; flex: none; text-align: right; }
.row.archived { color: var(--text-3); }
.count { flex: none; color: var(--text-2); font-size: 13px; white-space: nowrap; }
.check-row { cursor: pointer; justify-content: flex-start; }
.check-row.dup { background: var(--warning-soft); }
.check-row .badge { margin-left: auto; flex: none; }

.select-all { margin-top: 4px; }
/* «Rādīti 4 no 4» under a table */

/* coupon rows: on a computer a table (the number first, as a link), on a phone a block per coupon.
   The number's link stretches over the whole row; the «⋯» menu sits above it. */
.coupon-row {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; column-gap: 8px; row-gap: 2px; align-items: center;
  grid-template-areas: "num status menu" "name name name" "meta meta meta" "date date date"; padding: 10px 8px 12px 16px;
}
.coupon-row.no-student { grid-template-areas: "num status menu" "meta meta meta" "date date date"; }
.coupon-row .cr-num { grid-area: num; font-weight: 500; }
.row-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.row-link::after { content: ''; position: absolute; inset: 0; }
.coupon-row:hover { background: var(--surface-2); }
.coupon-row:hover .row-link { text-decoration-color: currentColor; }
.row-link:focus-visible { outline: none; }
.row-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--r); }
.coupon-row .cr-name { grid-area: name; font-weight: 500; min-width: 0; }
.coupon-row .cr-reward { display: none; }
.coupon-row .cr-meta { grid-area: meta; color: var(--text-2); min-width: 0; }
.coupon-row .cr-reason { display: block; font-size: 13px; color: var(--text-3); }
.coupon-row .cr-status { grid-area: status; justify-self: end; }
.coupon-row .cr-date { grid-area: date; font-size: 13px; color: var(--text-3); }
.coupon-row .cr-menu { grid-area: menu; }
.coupon-row.head { display: none; }
/* a table only where there is room for it (the sidebar takes 230px) */
@media (min-width: 1024px) {
  .coupon-row, .coupon-row.no-student {
    grid-template-columns: 112px minmax(0, 1fr) 72px minmax(0, 1.4fr) 112px 96px 40px;
    grid-template-areas: "num name reward meta status date menu"; column-gap: 0;
    min-height: 44px; padding: 0 0 0 14px;
  }
  .coupon-row.no-student { grid-template-columns: 112px 72px minmax(0, 1fr) 112px 96px 40px; grid-template-areas: "num reward meta status date menu"; }
  .coupon-row > span { padding-right: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .coupon-row .cr-name { font-weight: 400; }
  .coupon-row .cr-reward { display: block; grid-area: reward; }
  .coupon-row .cr-meta > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .coupon-row .cr-status { justify-self: start; }
  .coupon-row .cr-date { color: var(--text-2); font-size: 14px; }
  /* the header row: white, labels with thin rules between the columns */
  .coupon-row.head { display: grid; min-height: 40px; background: var(--surface); border-bottom: 1px solid var(--border); border-radius: var(--r) var(--r) 0 0; }
  .coupon-row.head:hover { background: var(--surface); }
  .coupon-row.head > span { position: relative; display: flex; align-items: center; height: 100%; font-size: 13px; font-weight: 500; color: var(--text-2); }
  .coupon-row.head > span + span:not(:empty) { padding-left: 14px; margin-left: -14px; }
  .coupon-row.head > span + span:not(:empty)::before { content: ''; position: absolute; left: 0; top: 11px; bottom: 11px; width: 1px; background: var(--border); }
  .list > .coupon-row.head + .row { border-top: 0; }
}
.list:has(.menu) { overflow: visible; }
.list > .row:last-child { border-radius: 0 0 var(--r) var(--r); }

/* «⋯» menu */
.menu { position: relative; z-index: 2; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu[open] { z-index: 31; }
.menu[open] > summary { background: var(--surface-2); }
.menu-pop {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 200px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md);
  /* opens out of the «⋯» button it belongs to (top right), quickly; closing is instant */
  transform-origin: top right;
}
.menu[open] .menu-pop { animation: pop-in 150ms var(--ease-out); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
.menu-pop form { margin: 0; }
.menu-pop a, .menu-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 4px;
  background: none; color: var(--text); font: 500 13px var(--font); text-align: left; cursor: pointer; white-space: nowrap;
}
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; }
.menu-pop .ico { color: var(--text-3); }
.menu-pop .danger, .menu-pop .danger .ico { color: var(--danger); }
.menu-pop :is(a, form) + :is(a.danger) { margin-top: 4px; border-top: 1px solid var(--border); border-radius: 0 0 4px 4px; }

/* status tabs over a list: underlined, with a count */
.tabs-line { display: flex; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.tabs-line::-webkit-scrollbar { display: none; }
.tabs-line a {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 36px; padding: 0 8px; margin-bottom: -1px;
  border-bottom: 2px solid transparent; color: var(--text-2); font-weight: 500;
}
.tabs-line a:hover { color: var(--text); text-decoration: none; }
.tabs-line a.on { color: var(--text); border-bottom-color: var(--text); }
.count-tag { min-width: 20px; height: 18px; padding: 0 5px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); font-size: 12px; line-height: 18px; text-align: center; font-variant-numeric: tabular-nums; }
.tabs-line a.on .count-tag { background: var(--text); color: var(--surface); }

/* filters as one joined bar */
.toolbar { display: flex; margin: 0 0 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); overflow: hidden; }
.toolbar > select, .toolbar-field { flex: 1 1 0; min-width: 0; }
.toolbar select { border: 0; border-radius: 0; height: var(--ctl-h); background-color: transparent; }
.toolbar select:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.toolbar > * + * { border-left: 1px solid var(--border); }
.toolbar-field { position: relative; display: flex; align-items: center; }
.toolbar-field > .ico { position: absolute; left: 10px; color: var(--text-3); pointer-events: none; }
.toolbar-field select { padding-left: 30px; }
.toolbar .btn { border: 0; border-left: 1px solid var(--border); border-radius: 0; height: var(--ctl-h); }
@media (max-width: 767px) {
  .toolbar { overflow-x: auto; scrollbar-width: none; }
  .toolbar > select, .toolbar-field { flex: none; width: auto; }
  .toolbar select { width: auto; max-width: 60vw; }
}
.list-count { margin: 0 0 8px; font-size: 13px; color: var(--text-2); }

/* a real table (the «Kopsavilkums» of a group) */
.table{ width: 100%; border-collapse: separate; border-spacing: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; }
.table th, .table td{ height: 44px; padding: 6px 14px; border-bottom: 1px solid var(--border); text-align: left; }
.table thead th{ position: relative; height: 40px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.table thead th + th::before{ content: ''; position: absolute; left: 0; top: 11px; bottom: 11px; width: 1px; background: var(--border); }
.table tbody th{ font-weight: 400; }
.table tbody tr:hover{ background: var(--surface-2); }
.table tbody th a{ color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.table .num{ text-align: right; width: 1%; white-space: nowrap; }

.table tfoot th, .table tfoot td{ border-bottom: 0; font-weight: 600; }
.table tbody:last-child tr:last-child > *{ border-bottom: 0; }

/* ---------- statuses: a coloured dot and plain text ---------- */
.st-active { --st: var(--success); }
.st-redeemed { --st: var(--neutral); }
.st-cancelled { --st: var(--danger); }
.st-expired { --st: var(--warning); }
.badge { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-size: 14px; white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--st, var(--neutral)); flex: none; }

/* ---------- inline messages (form errors, warnings, reminders) ---------- */
.flash { display: flex; align-items: flex-start; gap: 10px; margin: 0 0 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); line-height: 1.45; }
.flash::before {
  content: ''; flex: none; width: 14px; height: 14px; margin-top: 2px; background: var(--fl, var(--success));
  -webkit-mask: var(--fl-icon) center / contain no-repeat; mask: var(--fl-icon) center / contain no-repeat;
}
.flash{ --fl-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM369 209L241 337c-9.4 9.4-24.6 9.4-33.9 0l-64-64c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l47 47L335 175c9.4-9.4 24.6-9.4 33.9 0s9.4 24.6 0 33.9z'/%3E%3C/svg%3E"); }
.flash-error { --fl: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  --fl-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c13.3 0 24 10.7 24 24l0 112c0 13.3-10.7 24-24 24s-24-10.7-24-24l0-112c0-13.3 10.7-24 24-24zM224 352a32 32 0 1 1 64 0 32 32 0 1 1 -64 0z'/%3E%3C/svg%3E"); }

.flash a { margin-left: 4px; }
.page > .flash:first-child { margin-top: 16px; }
.email-notice { flex-wrap: wrap; align-items: center; column-gap: 10px; row-gap: 4px; }
.email-notice > span { flex: 1 1 220px; }
.email-notice form { margin-left: auto; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
body.public .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; width: max-content; max-width: min(420px, 100%);
  padding: 10px 10px 10px 12px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md); pointer-events: auto;
  animation: toast-in 220ms var(--ease-out);
}
.toast > .ico { margin-top: 3px; color: var(--success); }
.toast-error > .ico { color: var(--danger); }
.toast-warn > .ico { color: var(--warning); }
.toast p { margin: 0; flex: 1; min-width: 0; line-height: 1.45; }
.toast-close { display: grid; place-items: center; flex: none; width: 22px; height: 22px; margin: -1px -2px -1px 0; padding: 0; border: 0; border-radius: 4px; background: none; color: var(--text-3); cursor: pointer; }
.toast-close:hover { background: var(--surface-2); color: var(--text); }
.toast-close .ico { width: 11px; height: 11px; }
.toast.auto { animation: toast-in 220ms var(--ease-out), toast-out 180ms var(--ease-out) 4s forwards; }
.toast.out { animation: toast-out 180ms var(--ease-out) forwards; }
/* one that can be undone: 10 seconds, a line at the bottom shows the time left; stops while pointed at or focused */
.toast.long { position: relative; overflow: hidden; animation: toast-in 220ms var(--ease-out), toast-out 180ms var(--ease-out) 10s forwards; }
.toast.long::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--accent); transform-origin: left; animation: toast-time 10s linear forwards; }
.toast.long:is(:hover, :focus-within), .toast.long:is(:hover, :focus-within)::after { animation-play-state: paused; }
.toast-undo { flex: none; margin: -4px 0; }
@keyframes toast-time { to { transform: scaleX(0); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(8px); visibility: hidden; } }
@media (min-width: 768px) { .toasts { left: auto; right: 24px; bottom: 24px; align-items: flex-end; } }

/* ---------- empty state ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 40px 24px; }

.empty-state h2, .empty-state h3 { margin: 12px 0 4px; font-size: 14px; }
.empty-state p { margin: 0; max-width: 380px; color: var(--text-2); }
.empty-state .btn { margin-top: 16px; }

/* a smaller empty state inside a list: an outline icon, no circle */
.empty-small { padding: 32px 24px; }
.empty-small > .ico { width: 28px; height: 28px; color: var(--text-3); }
.empty-small h2 { margin-top: 10px; }
/* the first time: the way to start on the left, an example coupon on the right */
.empty-hero {
  display: grid; gap: 24px; align-items: center; padding: 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
}
.empty-hero h2 { margin: 0 0 6px; font-size: 20px; }
.empty-hero p { margin: 0 0 16px; max-width: 420px; color: var(--text-2); }
.empty-hero img { display: block; width: 100%; max-width: 220px; height: auto; justify-self: center; border-radius: var(--r); border: 1px solid var(--border); }
@media (min-width: 768px) { .empty-hero { grid-template-columns: minmax(0, 1fr) 220px; padding: 32px 40px; } }

/* ---------- loading ---------- */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 4px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0; transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--surface) 55%, transparent), transparent);
  animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- statistics: one strip divided by rules ---------- */

.stat { display: flex; flex-direction: column-reverse; justify-content: flex-end; gap: 4px; padding: 14px 16px; box-shadow: -1px 0 var(--border), 0 -1px var(--border); }
.stat b { font-size: 24px; font-weight: 600; line-height: 1.2; letter-spacing: -.01em; }
.stat span { font-size: 13px; color: var(--text-2); }

/* ---------- dialogs: centred on a computer, a sheet from the bottom on a phone ---------- */
.modal {
  width: min(440px, calc(100% - 32px)); max-height: calc(100% - 64px); padding: 20px;
  border: 1px solid var(--border); border-radius: var(--r-modal); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); overscroll-behavior: contain;
}
.modal::backdrop { background: var(--backdrop); }
.modal[open] { animation: modal-in 200ms var(--ease-out); }
.modal[open]::backdrop { animation: fade 200ms ease-out; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin: 20px 0 0; }
.confirm-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.confirm-text { margin: 6px 0 0; color: var(--text-2); }
.confirm-text:empty { display: none; }
.help-dialog { width: min(560px, calc(100% - 32px)); padding: 0; }
.help-dialog[open] { display: flex; flex-direction: column; }
.help-body { padding: 4px 20px 0; overflow-y: auto; overscroll-behavior: contain; }
.help-dialog .modal-actions { padding: 0 20px 20px; margin-top: 16px; }
@keyframes modal-in { from { opacity: 0; transform: scale(.98); } }
/* a sheet on a phone rises from the bottom edge, the whole of its height */
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 767px) {
  .modal, .help-dialog {
    width: 100%; max-width: 100%; max-height: calc(100% - 48px); margin: auto 0 0;
    border-radius: var(--r-modal) var(--r-modal) 0 0; border-width: 1px 0 0;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
  }
  .help-dialog { padding-bottom: env(safe-area-inset-bottom); }
  .modal[open] { animation: sheet-in 300ms var(--ease-drawer); }
  .modal-actions .btn { flex: 1; }
}

/* ---------- help and text pages ---------- */
.help-page { max-width: 720px; padding: 4px 20px 16px; margin-left: 0; font-size: 16px; line-height: 1.6; }
.help-body h2:first-child, .help-page h2:first-child { margin-top: 16px; }
/* text pages: a heading is 24 above and 8 above its text; paragraphs and lists 12 apart */
.help-body h3, .help-page h3, .doc-sections > h2 { font-size: 14px; margin: 24px 0 8px; }
/* a readable measure for running text (about 70 characters) */
.help-page :is(p, ul, ol) { max-width: 62ch; }
/* links inside running text are underlined, not told apart by colour alone */
:is(.help-page, .help-body) :is(p, li) a { text-decoration: underline; text-underline-offset: 3px; }
.help-body :is(p, ul, ol), .help-page :is(p, ul, ol) { margin: 0 0 12px; }
.help-body ol, .help-body ul, .help-page ol, .help-page ul { padding-left: 20px; }
.help-body li, .help-page li { margin: 4px 0; }
.made { margin: 24px 0 4px; color: var(--text-3); font-size: 13px; }
.heart { width: 13px; height: 13px; vertical-align: -2px; fill: var(--danger); }

/* ---------- transitions between pages ---------- */
@view-transition { navigation: auto; }
/* Safari on iPhone sometimes leaves an image of the new page blank after the transition: no transitions there */
@supports (-webkit-touch-callout: none) { @view-transition { navigation: none; } }
.sidebar { view-transition-name: sidebar; }
.appbar { view-transition-name: appbar; }
.tabs { view-transition-name: tabs; }
::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation-duration: 150ms; animation-timing-function: var(--ease-out); }

/* ---------- reduced motion: no movement, only fading ---------- */
@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) { animation: none; }
  .modal[open], .modal[open]::backdrop { animation: fade 200ms ease-out; }
  .toast { animation: fade 200ms ease-out; }
  .toast.auto { animation: fade 200ms ease-out, toast-fade 200ms ease-out 4s forwards; }
  .toast.long { animation: fade 200ms ease-out, toast-fade 200ms ease-out 10s forwards; }
  .toast.long::after { display: none; }
  .toast.out { animation: toast-fade 200ms ease-out forwards; }
  .skeleton::after { animation: none; }
  .menu[open] .menu-pop { animation: fade 150ms ease-out; }
  .btn:active:not(:disabled) { transform: none; }
  .btn.is-loading::after { animation-duration: 1.6s; }
}
@keyframes toast-fade { to { opacity: 0; visibility: hidden; } }

/* theme button: a moon while the page is light, a sun while it is dark */
.t-ico { display: none; }
.t-ico .ico { display: block; }
.t-to-dark { display: inline-flex; }
:root[data-theme="dark"] .t-to-dark { display: none; }
:root[data-theme="dark"] .t-to-light { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .t-to-dark { display: none; }
  :root:not([data-theme="light"]) .t-to-light { display: inline-flex; }
}

/* ===================================================================================
   Pages
   =================================================================================== */

/* ---------- «Iestatījumi»: the sections are in the sidebar (the burger menu on a phone) ---------- */

.settings-main { min-width: 0; }

/* ---------- «Izsniegt»: quick coupon ---------- */
.quick-wrap { margin-bottom: 24px; }
.quick > summary { list-style: none; width: fit-content; }
.quick > summary::-webkit-details-marker { display: none; }
.quick > summary .when-closed { display: inline-flex; align-items: center; gap: 8px; }
.quick > summary .when-open, .quick[open] > summary .when-closed { display: none; }
.quick[open] > summary .when-open { display: inline; }
/* open: the same place, only quieter («Aizvērt»), so the button does not jump to the other side */
.quick[open] > summary { display: flex; width: fit-content; margin: 0 0 12px; background: transparent; border-color: var(--border); color: var(--text-2); }
.quick[open] > summary:hover { background: var(--surface-2); color: var(--text); }
.quick-grid { display: grid; gap: 16px; }
.quick-fields { padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.quick-preview { margin: 0 auto; width: 100%; max-width: 260px; }
.quick-preview img { display: block; width: 100%; height: auto; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); transition: opacity var(--ease); }
.quick-preview.loading img { opacity: .6; }
.quick-fields .design-hint { margin: 0; }
.quick-submit .btn { width: 100%; }
.reward-new { margin-top: 8px; }
.quick fieldset:not(:has(input[value="new"]:checked)) .reward-new { display: none; }
.design-hint { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }
@media (max-width: 767px) {
  /* on a phone the button sticks to the bottom of the screen while the form scrolls */
  .quick-submit {
    position: sticky; bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom)); z-index: 5;
    margin: 0 -16px; padding: 12px 16px; background: var(--bg); border-top: 1px solid var(--border);
  }
  .keyboard-open .quick-submit { bottom: 0; }
}
@media (min-width: 768px) {
  .quick-fields { padding: 24px; }
  /* the button stays in sight at the bottom of the screen while the form is longer than the screen */
  .quick-submit { position: sticky; bottom: 0; z-index: 5; padding: 12px 0 16px; background: var(--bg); }
}
@media (min-width: 1000px) {
  /* on a computer the preview stands on the right of the fields */
  .quick-grid { grid-template-columns: minmax(0, 640px) 260px; grid-template-areas: "fields preview" "submit preview"; column-gap: 24px; align-items: start; }
  .quick-fields { grid-area: fields; }
  .quick-submit { grid-area: submit; }
  .quick-submit .btn { width: auto; }
  .quick-preview { grid-area: preview; max-width: none; margin: 0; position: sticky; top: 32px; }
}

/* reward choice: radio rows on a card */
.reward-tiles { display: flex; flex-direction: column; padding: 0 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); }
.reward-tile { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 0; cursor: pointer; }
.reward-tile + .reward-tile, .more-rewards { border-top: 1px solid var(--border); }
.more-rewards > summary { display: flex; align-items: center; min-height: 44px; list-style: none; cursor: pointer; color: var(--text-2); font-weight: 500; }
.more-rewards > summary:hover { color: var(--text); }
.more-rewards > summary::-webkit-details-marker { display: none; }
.more-rewards > summary::after { content: ''; width: 6px; height: 6px; margin-left: 10px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.more-rewards[open] > summary::after { transform: translateY(1px) rotate(-135deg); }
.more-rewards > .reward-tile { border-top: 1px solid var(--border); }
.reward-tile .big { flex: none; font-weight: 600; font-size: 16px; min-width: 4.5em; }
.reward-tile .small { color: var(--text-2); font-size: 13px; }

/* ---------- coupon page ---------- */
/* «Anulēt» away from «Izmantot»: under the details, smaller */

/* the life of a coupon: issued, then used or cancelled, and the date it runs out */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 128px; column-gap: 16px; padding: 0 0 14px 20px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ''; position: absolute; left: 2px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--tl, var(--neutral)); }
.timeline li::after { content: ''; position: absolute; left: 5px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline .tl-what { font-weight: 500; }
.timeline .tl-when { color: var(--text-2); text-align: right; font-variant-numeric: tabular-nums; }
.timeline .tl-note { grid-column: 1 / -1; color: var(--text-2); font-size: 13px; }
.timeline li[class*="st-"] { --tl: var(--st); }
.timeline li.later::before { background: none; box-shadow: inset 0 0 0 1.5px var(--neutral); }
.timeline li.later .tl-what { font-weight: 400; color: var(--text-2); }

.action > summary { list-style: none; }
.action > summary::-webkit-details-marker { display: none; }

.coupon-preview { margin: 16px 0 0; }
.coupon-preview img { display: block; width: 100%; max-width: 480px; height: auto; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); }
/* actions in one row: icon and a short word */

/* right after issuing: «Kopīgot» is the main button where the phone can share files, otherwise «QR» */

.send-row:not(:has(> [data-share-png]:not([hidden]))) .act-qr { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
/* a form that opens below the row from a button linking to its #id */
.cancel-form:not(:target) { display: none; }
/* «QR audzēknim»: a large code on white, also in the dark theme, so phones read it */
.share-qr { margin: 16px 0; max-width: 360px; padding: 16px; background: #fff; border: 1px solid var(--border); border-radius: var(--r); }
.share-qr svg { display: block; width: 100%; height: auto; }

/* a page with a narrow column on the right (the coupon, a preview, numbers), like the «Usage» panel */
.with-aside { display: grid; gap: 16px; align-items: start; }
.main-col, .aside-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.main-col > .card + .card, .aside-col > .card + .card { margin-top: 0; }
.aside-col .coupon-preview { margin: 0; }
.aside-col .coupon-preview img { max-width: none; }
.aside-card h2 { margin: 0 0 4px; font-size: 14px; }
.aside-card p { margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.aside-actions { display: flex; flex-direction: column; gap: 8px; }
.aside-actions form { margin: 0; }
.aside-actions .btn { width: 100%; }
/* the coupon page shows the coupon first on a phone; other pages keep the main column first */
@media (max-width: 767px) { .aside-first .aside-col { order: -1; } .aside-col .coupon-preview img { max-width: 320px; margin: 0 auto; } }
@media (min-width: 1000px) { .with-aside { grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; } }
/* label and value rows inside a card */
.details { display: grid; grid-template-columns: max-content minmax(0, 1fr); margin: 0; }
.details dt, .details dd { margin: 0; padding: 9px 0; border-top: 1px solid var(--border); }
.details dt:first-of-type, .details dt:first-of-type + dd { border-top: 0; padding-top: 0; }
.details dt { padding-right: 32px; color: var(--text-2); }
.details dd b { font-weight: 600; margin-right: 4px; }
.text-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 3px; }
.text-link:hover { color: var(--text); text-decoration-color: currentColor; }
/* «Anulēt» on the coupon page: the reason and the button in one row under the card's text */
#anulet { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
#anulet .field { flex: 1 1 260px; }
#anulet:not(:target) { display: none; }
.banner .send-row form { margin: 0; }

/* tabs as a segmented strip under the title (a group's pages) */
.seg-tabs { display: flex; width: fit-content; gap: 2px; margin: 0 0 24px; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); max-width: 100%; overflow-x: auto; }
.seg-tabs a { display: inline-flex; align-items: center; height: 28px; padding: 0 10px; border-radius: 4px; color: var(--text-2); font-weight: 500; white-space: nowrap; }
.seg-tabs a:hover { color: var(--text); text-decoration: none; }
.seg-tabs a.on { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border); }

/* above a list: the count on the left, actions on the right */
.list-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.list-bar .list-count { margin: 0; }
.inline-form { display: grid; gap: 12px; align-items: end; }
@media (min-width: 768px) { .inline-form { grid-template-columns: 1fr 1fr auto; } }
/* a list with a header like a table, a link in the first column */
.row.table-head { min-height: 40px; padding-top: 0; padding-bottom: 0; font-size: 13px; font-weight: 500; color: var(--text-2); }
.link-row { position: relative; }
.link-row:hover { background: var(--surface-2); }
.row-side-inline { display: flex; align-items: center; gap: 12px; flex: none; font-size: 13px; }
.details-sm { margin-bottom: 12px; font-size: 13px; }
.details-sm dt, .details-sm dd { padding: 6px 0; }
.details-sm dt { padding-right: 16px; }
.table tr.zero td { color: var(--text-3); }

/* a panel with a grey title bar and tools on the right («Metrics» in Cloudflare) */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; margin-bottom: 16px; }
.panel-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 0; padding: 8px 8px 8px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 500; color: var(--text-2); }
.panel-tools { display: flex; flex-wrap: wrap; gap: 6px; }
.small-select, .panel-tools select { height: 30px; font-size: 13px; width: auto; max-width: 100%; }
@media (max-width: 767px) { .panel-tools, .panel-tools > * { width: 100%; } .panel-tools select { width: 100%; } }
.panel-tools .toolbar-field select { padding-left: 28px; }
.panel-tools .toolbar-field > .ico { left: 9px; }
.metrics { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics .stat { box-shadow: -1px 0 var(--border), 0 -1px var(--border); }
.stat b small { font-size: 14px; font-weight: 400; color: var(--text-2); }
@media (min-width: 768px) { .metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.split-2 { display: grid; gap: 16px; margin-bottom: 8px; }
.split-2 > .card + .card { margin-top: 0; }
@media (min-width: 768px) { .split-2 { grid-template-columns: 1fr 1fr; } }
.card-label { margin: 0 0 8px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.legend b { color: var(--text); font-weight: 500; margin-right: 10px; }
.legend .key { display: inline-block; width: 8px; height: 8px; margin: 0; border-radius: 50%; }
.key-used, .seg-used { background: var(--accent); }
.key-unused, .seg-unused { background: var(--border-strong); }
.stack-bar { display: flex; height: 28px; border-radius: 4px; overflow: hidden; background: var(--surface-2); }
.stack-bar span { display: block; height: 100%; }
.top-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.top-list li { display: grid; grid-template-columns: minmax(0, 1fr) 40% 2ch; align-items: center; gap: 12px; font-size: 13px; }
.top-list .text-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.bar-track { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.bar-track span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.top-list b { font-weight: 500; text-align: right; font-variant-numeric: tabular-nums; }
.section-title { margin: 32px 0 12px; }
/* in a column with a gap the margins add up: the title keeps 32 above and 12 below */
:is(.main-col, .aside-col) > * { margin-top: 0; margin-bottom: 0; }
:is(.main-col, .aside-col) > .section-title { margin: 16px 0 -4px; }

/* «Drukāt»: the selection bar and the list with check boxes */
.layouts-card { margin-bottom: 16px; }
.select-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin: 0 0 8px; }
.select-bar .check { min-height: 32px; font-weight: 500; }
.select-count { font-size: 13px; color: var(--text-2); margin-right: auto; }
.print-row { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; grid-template-areas: "box num status" "box name name" "box meta meta" "box printed printed"; column-gap: 12px; row-gap: 2px; align-items: center; cursor: pointer; }
.pr-printed { grid-area: printed; display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.pr-printed:empty { display: none; }
.pr-printed .ico { width: 12px; height: 12px; color: var(--text-3); }
.print-row > input { grid-area: box; align-self: start; margin-top: 3px; }
.pr-num { grid-area: num; font-weight: 500; }
.pr-name { grid-area: name; }
.pr-meta { grid-area: meta; color: var(--text-2); }
.pr-status { grid-area: status; justify-self: end; }
.pr-date { display: none; }
.print-row.table-head { display: none; }
.print-row:hover { background: var(--surface-2); }
.print-row:has(input:not(:checked)) { color: var(--text-3); }
.print-row:has(input:not(:checked)) .pr-meta { color: var(--text-3); }
@media (min-width: 1024px) {
  .print-row { grid-template-columns: 16px 112px minmax(0, 1fr) minmax(0, 1.4fr) 112px 96px 112px; grid-template-areas: "box num name meta status date printed"; min-height: 44px; padding-top: 0; padding-bottom: 0; }
  .pr-printed, .pr-printed:empty { display: flex; font-size: 14px; }
  .print-row > input { align-self: center; margin-top: 0; }
  .print-row > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pr-date { display: block; color: var(--text-2); }
  .pr-status { justify-self: start; }
  .print-row.table-head { display: grid; cursor: default; }
  .print-row.table-head:hover { background: none; }
}

/* «Dizains»: cards with the sample, labels and a bar at the bottom */
.designs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 768px) { .designs { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; } }
@media (min-width: 1200px) { .designs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.design-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; cursor: pointer; transition: border-color var(--ease); }
.design-card:hover { border-color: var(--border-strong); }
.design-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.design-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.design-img { display: block; border-bottom: 1px solid var(--border); }
/* a shimmer (skeleton) under the sample until it has loaded: the image covers it, no JS needed */
.design-img.skeleton { border-radius: 0; }
.design-img img { position: relative; z-index: 1; display: block; width: 100%; height: auto; aspect-ratio: 4 / 5; outline: 0; border-radius: 0; }
.design-body { display: flex; align-items: center; gap: 8px; padding: 10px 12px; min-height: 44px; }
.design-name { font-weight: 500; color: var(--text); margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.design-state { display: none; align-items: center; gap: 4px; flex: none; color: var(--accent); font-size: 13px; font-weight: 500; }
.design-state .ico { width: 11px; height: 11px; }
.design-card:has(input:checked) .design-state { display: inline-flex; }
@media (max-width: 420px) { .design-body { padding: 8px 10px; } }

/* cards in a grid (rewards) */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.item-card { display: flex; flex-direction: column; gap: 6px; padding: 14px 16px 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); transition: border-color var(--ease); }
.item-card:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.item-big { font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.item-text { color: var(--text-2); flex: 1; }
.item-foot { display: flex; align-items: center; justify-content: space-between; margin: 8px -16px 0; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 500; }
.item-foot .ico { width: 10px; height: 10px; color: var(--text-3); }
/* a new item: the form opens under the page head from «Pievienot» (#jauns) */
.new-form { margin-bottom: 16px; }
.new-form .card-label { margin: 0; }
.inline-form-1 { grid-template-columns: 1fr auto; }
@media (max-width: 767px) { .inline-form-1 { grid-template-columns: 1fr; } }

/* a form on its own on a page: not wider than it needs */
.form-card { max-width: 640px; }

/* ---------- «Atradi kļūdu?» ---------- */
.row.report { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.report-text { margin: 6px 0 0; white-space: pre-wrap; }
.report-reply { margin: 8px 0 0; padding-left: 12px; border-left: 2px solid var(--accent); }
.report-device { margin: 6px 0 0; overflow-wrap: anywhere; }
.report-form { margin-top: 10px; }

/* ---------- invitation link ---------- */
.invite-link { padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); font-weight: 500; word-break: break-all; }
.copy-btn { position: relative; }
.copy-tip {
  display: block; position: absolute; top: calc(100% + 6px); left: 50%; z-index: 20; transform: translate(-50%, -4px);
  padding: 6px 10px; border-radius: var(--r); background: var(--text); color: var(--surface);
  font-size: 13px; font-weight: 500; white-space: nowrap; pointer-events: none;
  opacity: 0; visibility: hidden; transition: opacity var(--ease), transform var(--ease), visibility var(--ease);
}
.copy-tip.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.copy-tip:empty { display: none; }

/* ---------- journal filters ---------- */

/* ---------- «Pārbaudīt»: everything in the middle, like Cloudflare's account home ---------- */
.hero-check { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 640px; margin: 0 auto; padding: 40px 0 8px; }
.hero-check h1 { font-size: 28px; letter-spacing: -.02em; margin: 0 0 8px; }
.hero-check > p { margin: 0 0 24px; }
.btn-lg { height: 48px; padding: 0 20px; font-size: 16px; }
.btn-lg .ico { width: 18px; height: 18px; }
.big-search { position: relative; display: flex; gap: 6px; width: 100%; padding: 4px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: calc(var(--r) + 2px); box-shadow: 0 0 0 4px var(--surface-2); }
.big-search:focus-within { border-color: var(--accent); }
.big-search > .ico { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-3); pointer-events: none; }
.big-search input[type=text], .big-search input[type=search] { flex: 1; min-width: 0; height: 44px; padding-left: 36px; border: 0; font-size: 16px; }
.big-search input:focus { box-shadow: none; }
.big-search .btn { height: 44px; }
.big-search.small { box-shadow: none; max-width: 640px; }
.big-search.small input { height: 36px; }
.big-search.small .btn { height: 36px; }
.check-results { max-width: 640px; margin: 24px auto 0; }
.check-results .list .row .ico { color: var(--text-3); width: 10px; }
.scan-start { margin: 0 0 20px; }
.fake { margin: 0 0 16px; padding: 14px 16px; background: var(--danger-soft); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); border-radius: var(--r); text-align: left; }
.fake-head { display: flex; align-items: center; gap: 8px; color: var(--danger); font-size: 16px; }
.fake-head .ico { width: 16px; height: 16px; }
.fake p { margin: 6px 0 0; }
.qr-center { max-width: 420px; }
.error-state { margin-top: 48px; padding: 48px 24px; }
.error-state > .ico, .empty-small > .ico { width: 28px; height: 28px; color: var(--text-3); }
.error-state h1 { font-size: 20px; margin: 12px 0 4px; }

/* ---------- QR scanner in «Pārbaudīt» ---------- */

.scan-dialog { padding: 16px; }
.scan-view { position: relative; overflow: hidden; aspect-ratio: 1; border-radius: var(--r); background: #000; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-frame { position: absolute; inset: 18%; border: 2px solid rgba(255, 255, 255, .85); border-radius: var(--r); }
.scan-status { margin: 12px 0; min-height: 1.5em; }
.scan-status.err { color: var(--danger); }

/* ---------- «Administrācija»: number cards with their weeks as small bars ---------- */
.spark-cards { display: grid; gap: 12px; margin-bottom: 16px; }
@media (min-width: 768px) { .spark-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.spark-cards > .card + .card { margin-top: 0; }
.spark-card { display: flex; flex-direction: column; padding: 14px 16px 12px; }
.spark-card .card-label { margin-bottom: 4px; }
.spark-card > b { font-size: 24px; font-weight: 600; line-height: 1.2; font-variant-numeric: tabular-nums; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 56px; margin-top: 12px; border-bottom: 1px solid var(--border); }
.spark span { flex: 1; min-height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; opacity: .85; }
.spark-muted span { background: var(--neutral); }
/* nothing in these weeks: a quiet label in the middle, like «No data» */
.spark:has(.spark-empty) { justify-content: center; align-items: center; border-bottom-style: dashed; }
.spark-empty { padding: 2px 8px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface); color: var(--text-3); font-size: 12px; font-style: normal; }
.spark-warn span { background: var(--warning); }
@media (min-width: 768px) { .metrics-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.table-wrap { overflow-x: auto; }
.cell-sub { display: block; font-size: 12px; color: var(--text-3); font-weight: 400; }
.table th .tag { margin-left: 6px; vertical-align: 1px; }
.btn .tag { margin-left: 2px; }
.report-list { display: flex; flex-direction: column; gap: 12px; }
.report-list > .card + .card { margin-top: 0; }
.report-card .report-form { display: grid; gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (min-width: 768px) { .report-card .report-form { grid-template-columns: 180px 1fr auto; align-items: start; } }
.report-card textarea { min-height: 34px; }

/* ---------- «Administrācija»: charts ---------- */
.chart-sheet{ padding: 16px; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin: 0 0 12px; font-size: 13px; color: var(--text-2); }
.key { display: inline-block; width: 10px; height: 10px; margin-right: -8px; border-radius: 2px; }
.key-issued, .bar-issued { background: var(--accent); }
.key-redeemed, .bar-redeemed { background: var(--border-strong); }

.bars { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 160px; margin-bottom: 8px; }

.bar-week { display: flex; flex-direction: column; min-width: 0; }
.bar-pair { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2px; border-bottom: 1px solid var(--border); }
.bar { width: 40%; max-width: 14px; min-height: 0; border-radius: 2px 2px 0 0; }

.bar-label { margin-top: 4px; font-size: 11px; color: var(--text-3); text-align: center; white-space: nowrap; overflow: hidden; }
.bar-week:nth-child(odd) .bar-label { visibility: hidden; }

@media (min-width: 768px) {
  
  .bar-week:nth-child(odd) .bar-label { visibility: visible; }
}

/* ---------- public home page (like a Cloudflare product page) ---------- */
.home-hero { display: grid; gap: 32px; align-items: center; padding: 32px 0 40px; border-bottom: 1px solid var(--border); }
.home-coupon { display: block; width: 100%; max-width: 280px; height: auto; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--r); }
.home-hero h1 { font-size: 34px; line-height: 1.15; letter-spacing: -.025em; margin: 0 0 16px; font-weight: 600; }
.lead { font-size: 16px; line-height: 1.55; margin: 0 0 24px; color: var(--text-2); max-width: 520px; }
.home-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.home-links-row { display: grid; gap: 16px; padding: 32px 0; }
/* how it works and the questions: plain text sections between rules, the measure kept readable */
.home-section { padding: 40px 0; border-bottom: 1px solid var(--border); }
.home-section h2 { margin: 0 0 20px; font-size: 24px; letter-spacing: -.02em; }
.home-steps { display: grid; gap: 20px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.home-steps li { counter-increment: step; display: grid; align-content: start; grid-template-columns: 32px 1fr; column-gap: 12px; font-size: 16px; line-height: 1.55; color: var(--text-2); max-width: 62ch; }
.home-steps li::before {
  content: counter(step); grid-row: span 2; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 14px;
}
.home-steps b { display: block; margin-bottom: 4px; color: var(--text); font-weight: 600; }
/* questions as rows between rules: the question and a «+» on the right, the answer under it when open */
.faq { border-top: 1px solid var(--border); }
.home-section:has(.faq) { border-bottom: 0; }   /* the last question already closes it with a rule */
.faq-item { border-bottom: 1px solid var(--border); }
.faq-item > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 0; cursor: pointer; list-style: none; }
.faq-item > summary::-webkit-details-marker { display: none; }
.faq-item h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.faq-item > summary:hover h3 { color: var(--accent); }
.faq-sign { flex: none; display: grid; place-items: center; width: 20px; height: 20px; color: var(--accent); }
.faq-sign .ico { width: 16px; height: 16px; grid-area: 1 / 1; }
.faq-sign .ico + .ico, .faq-item[open] .faq-sign .ico:first-child { display: none; }
.faq-item[open] .faq-sign .ico + .ico { display: block; }
.faq-item p { margin: -4px 0 0; padding: 0 36px 20px 0; font-size: 16px; line-height: 1.55; color: var(--text-2); max-width: 70ch; }
.link-card { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); color: var(--text); }
.link-card:hover { border-color: var(--border-strong); text-decoration: none; color: var(--text); }
.link-card b { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 500; }
.link-card b .ico { width: 12px; height: 12px; color: var(--text-3); }
.link-card span { color: var(--text-2); }
@media (min-width: 768px) {
  /* the headline leads the first screen: it grows with the window, and stays on two lines at most */
  .home-hero { grid-template-columns: 260px minmax(0, 1fr); gap: 40px; padding: 56px 0; }
  .home-coupon { max-width: 260px; }
  .home-hero h1 { font-size: clamp(40px, 4.2vw, 60px); line-height: 1.08; text-wrap: balance; }
  .home-links-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
  .home-steps { grid-template-columns: repeat(3, 1fr); gap: 32px; }
}
@media (min-width: 1024px) {
  .home-hero { grid-template-columns: 340px minmax(0, 1fr); gap: 56px; }
  .home-coupon { max-width: 340px; }
}

/* login and registration: one card in the middle */
.auth { max-width: 400px; margin: 32px auto 0; padding: 28px 24px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-modal); }
.auth h1 { margin: 0 0 4px; font-size: 22px; }
.auth-sub { margin: 0 0 20px; color: var(--text-2); }
.auth .stack > .btn-primary { align-self: stretch; }
.auth-foot { margin: 20px 0 0; padding-top: 16px; border-top: 1px solid var(--border); color: var(--text-2); font-size: 13px; }
.auth .banner { margin-bottom: 12px; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row a { font-weight: 400; }
@media (max-width: 767px) { .auth { margin-top: 8px; padding: 20px 16px; } }

/* ---------- printing: selection ---------- */
/* «Drukāt»: how many coupons on a sheet, as small A4 sheets */
.layouts { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.layout-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 0; border-radius: var(--r); cursor: pointer; }
.mini-wrap { display: flex; align-items: center; justify-content: center; height: 54px; }
.mini-sheet {
  display: grid; grid-template-columns: repeat(var(--cols), 1fr); grid-template-rows: repeat(var(--rows), 1fr); gap: 3px;
  width: 38px; height: 52px; padding: 5px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 3px;
  outline: 2px solid transparent; outline-offset: 3px; transition: outline-color var(--ease);
}
.mini-sheet.landscape { width: 52px; height: 38px; }
.mini-sheet i { background: var(--border); border-radius: 1px; }
.layout-n { font-weight: 500; color: var(--text-2); }
.layout-pick:hover .mini-sheet { outline-color: var(--border); }
.layout-pick:has(input:checked) .mini-sheet { outline-color: var(--accent); }
.layout-pick:has(input:checked) .mini-sheet i { background: var(--accent); }
.layout-pick:has(input:checked) .layout-n { color: var(--text); font-weight: 600; }
.layout-pick:has(input:focus-visible) .mini-sheet { outline-color: var(--accent); outline-style: dashed; }
@media (min-width: 768px) {
  .layouts { gap: 12px; }
  .mini-wrap { height: 118px; }
  .mini-sheet { width: 80px; height: 112px; padding: 9px; gap: 6px; border-radius: 4px; }
  .mini-sheet.landscape { width: 112px; height: 80px; }
  .layout-pick { gap: 8px; }
  .layout-n { font-size: 16px; }
  /* students in columns inside one panel, alphabetical from top to bottom (like a phone book):
     newspaper columns instead of a grid, so the order runs down the first column first */
  .list.cols { display: block; column-count: 2; column-gap: 0; column-rule: 1px solid var(--border); }
  .list.cols > .row, .list.cols > .row + .row { break-inside: avoid; border: 0; border-radius: 0; box-shadow: 0 -1px 0 var(--border); }
}
@media (min-width: 1000px) {
  .list.cols { column-count: 3; }
}

/* ---------- printing: A4 sheets (a preview on screen, real millimetres when printed) ---------- */
.print-page { padding: 0 0 40px; }
.print-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.print-bar { flex-wrap: wrap; }
.print-bar .muted { margin-right: auto; }
.print-mark { display: flex; align-items: center; gap: 8px; }
.print-ask { display: none; font-weight: 500; }
/* after the print dialog (print.js): the question and the button stand out */
.printed .print-ask { display: inline; }
.printed .print-mark .btn { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.printed .print-now { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.print-empty { max-width: 640px; margin: 24px auto; padding: 0 16px; }
.sheet {
  width: min(100% - 32px, 794px); aspect-ratio: 210 / 297; margin: 16px auto; padding: 3.333%;
  display: flex; align-items: center; justify-content: center;
  background: #fff; box-shadow: 0 4px 12px rgba(15, 23, 42, .12); container-type: inline-size;
}
.sheet.landscape { width: min(100% - 32px, 1123px); aspect-ratio: 297 / 210; padding: 2.357%; }
/* sizes are fractions of the sheet's working width (cqw), so the preview and the print match */
.sheet-grid { position: relative; display: grid; grid-template-columns: repeat(var(--cols), auto); gap: calc(var(--g) * 1cqw); }
.sheet-grid img { display: block; width: calc(var(--k) * 1cqw); height: auto; }
.cut { position: absolute; display: block; }
.cut-v { width: 0; border-left: 1px dashed #9aa0aa; }
.cut-h { height: 0; border-top: 1px dashed #9aa0aa; }
@media print {
  html, body { background: #fff; }
  .print-page { background: #fff; padding: 0; }
  .print-bar, .print-empty { display: none; }
  .sheet { aspect-ratio: auto; margin: 0; padding: 0; box-shadow: none; break-after: page; }
  .sheet:last-of-type { break-after: auto; }
  .cut-v { border-left: .25mm dashed #888; }
  .cut-h { border-top: .25mm dashed #888; }
}

@media (min-width: 1024px) { .ph-only { display: none; } }
/* on a phone the top bar already names the section */
@media (max-width: 767px) {
  .page-head.is-section h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .page-head.is-section .pill { display: none; }
  .page-head { flex-wrap: wrap; }
}
@media (min-width: 768px) { .coupon-row .cr-name { font-weight: 400; } }

/* a link with «Kopēt» joined to it */
.copy-field { display: flex; }
.copy-field .invite-link { flex: 1; min-width: 0; display: flex; align-items: center; height: var(--ctl-h); padding: 0 10px; border-radius: var(--r) 0 0 var(--r); border-right: 0; font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
.copy-field .btn { border-radius: 0 var(--r) var(--r) 0; }
.share-btn { margin-top: 12px; }
/* text pages without login: a readable column */
.doc-page { max-width: 760px; }
.gap-sm { margin-top: 16px; }

/* ---------- «Sāc darbu»: a guide in steps, in the middle of the page ---------- */
.wizard { max-width: 680px; margin: 0 auto; padding: 40px 0 24px; }
.wizard h1 { margin: 0; text-align: center; font-size: 28px; letter-spacing: -.02em; }
.wizard-sub { margin: 8px 0 24px; text-align: center; color: var(--text-2); }
.steps { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 0; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.steps li { display: flex; align-items: center; color: var(--text-2); }
.steps li + li::before { content: ''; width: 28px; height: 1px; margin: 0 10px; background: var(--border-strong); }
.steps a { display: flex; align-items: center; color: inherit; }
.steps a:hover { color: var(--text); text-decoration: none; }
.step-n {
  display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 8px; border-radius: 50%;
  border: 1px solid var(--border-strong); background: var(--surface); font-size: 12px; font-weight: 600; color: var(--text-2);
}
.step-n .ico { width: 10px; height: 10px; }
.step-now { color: var(--text) !important; font-weight: 500; }
.step-now .step-n { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.step-done .step-n { color: var(--accent); border-color: var(--accent); }
.wizard-rule { margin: 24px 0; border: 0; border-top: 1px solid var(--border); }
.wizard .banner { margin-bottom: 16px; }
.wizard-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.wizard-final { display: grid; gap: 20px; align-items: center; margin: 8px 0 16px; }
.wizard-final img { width: 180px; height: auto; border: 1px solid var(--border); border-radius: var(--r); justify-self: center; }
.wizard-final h2 { margin: 0 0 6px; font-size: 18px; }
.wizard-final p { margin: 0 0 6px; }
@media (min-width: 640px) { .wizard-final { grid-template-columns: 180px 1fr; } }
.wizard-done { grid-template-columns: auto 1fr !important; }
.done-mark { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); }
.done-mark .ico { width: 16px; height: 16px; }

/* phone: the steps show only the numbers, the current one with its name */
@media (max-width: 559px) {
  .steps li:not(.step-now) .step-label { display: none; }
  .steps li + li::before { width: 16px; margin: 0 6px; }
  .wizard { padding-top: 16px; }
  .wizard h1 { font-size: 22px; }
}

/* ---------- the design picker over the issuing form ---------- */
.design-pick {
  display: flex; align-items: center; gap: 10px; min-height: calc(var(--ctl-h) + 8px); padding: 4px 12px 4px 4px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); color: var(--text);
  transition: background-color var(--ease), border-color var(--ease);
}
.design-pick:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.design-thumb { flex: none; width: 24px; height: 30px; border-radius: 3px; border: 1px solid var(--border); object-fit: cover; background: var(--surface-2); }
.design-current { flex: 1; min-width: 0; font-weight: 500; }
.design-change { display: inline-flex; align-items: center; gap: 6px; flex: none; font-size: 13px; font-weight: 500; color: var(--accent); }
.design-change .ico { width: 13px; height: 13px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-head form { margin: -6px -8px -6px 0; }
.modal-sub { margin: 4px 0 16px; color: var(--text-2); font-size: 13px; }
.design-dialog { width: min(960px, calc(100% - 48px)); max-height: calc(100% - 48px); }
.design-dialog[open] { display: flex; flex-direction: column; }
.modal-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; margin: 0 -20px; padding: 2px 20px; }
.design-dialog .designs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.design-dialog .modal-actions { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
@media (min-width: 640px) { .design-dialog .designs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) { .design-dialog .designs { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 767px) { .design-dialog { width: 100%; max-height: 88%; } .modal-scroll { margin: 0 -16px; padding: 2px 16px; } }
.modal:focus { outline: none; }

/* ---------- one look for every drop-down: the select's list and the name suggestions ---------- */
/* where the browser draws the list itself (Safari, Firefox): at least readable in both themes */
select option { background-color: var(--surface); color: var(--text); }
.dropdown-pop, select::picker(select) {
  padding: 4px; border: 1px solid var(--border); border-radius: var(--r);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-md);
}
.dropdown-item, select option {
  display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 10px; border-radius: 4px;
  font: 400 14px/1.3 var(--font); color: var(--text); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dropdown-item:hover, .dropdown-item[aria-selected="true"], select option:hover, select option:focus-visible { background: var(--surface-2); outline: none; }
/* Chrome draws the select's list from CSS (customizable select) */
@supports (appearance: base-select) {
  select, select::picker(select) { appearance: base-select; }
  select { display: flex; align-items: center; }
  select::picker-icon { display: none; }
  /* always under the field, never flipped above it */
  select::picker(select) { margin: 4px 0; min-width: anchor-size(width); max-height: min(320px, 60vh); overflow-y: auto; position-area: block-end span-inline-end; position-try-fallbacks: none; }
  select option::checkmark { order: 1; margin-left: auto; content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  select option:checked { font-weight: 500; }
  select option { background: none; }
  select option:checked:not(:hover) { background: none; }
  select[disabled] { opacity: .5; }
}
/* the name suggestions under a field (instead of the browser's datalist) */
.field, .dropdown-host { position: relative; }
.dropdown-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; max-height: 264px; overflow-y: auto; overscroll-behavior: contain; }
.dropdown-pop[hidden] { display: none; }
.dropdown-item mark { background: none; color: inherit; font-weight: 600; }
/* results under a search field start 16 below it */
.big-search + :is(.list-count, .list, .empty-state, .fake) { margin-top: 16px; }

/* one student's issuing form: the coupon preview on the right, staying in sight while the form scrolls */
.issue-aside .coupon-preview img { max-width: none; transition: opacity var(--ease); }
.issue-aside .coupon-preview.loading img { opacity: .6; }
@media (min-width: 1000px) {
  .issue-layout { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }
  .issue-aside { position: sticky; top: calc(var(--bar-h) + 24px); }
}
@media (max-width: 999px) { .issue-aside .coupon-preview img { max-width: 360px; margin: 0 auto; } }

/* ---------- phone: the menu slides in from the left (burger) ---------- */
.burger, .drawer-head, .drawer-foot, .nav-backdrop { display: none; }
@media (max-width: 767px) {
  .burger { display: inline-flex; margin-left: -6px; }
  .appbar .brand span { display: none; }
  body.public .appbar .brand span { display: inline; }   /* no burger there: the name has room */
  .sidebar {
    display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 45;
    width: min(300px, 86vw); padding: env(safe-area-inset-top) 12px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg); border-right: 1px solid var(--border); overflow-y: auto; overscroll-behavior: contain;
    transform: translateX(-100%); visibility: hidden;
  }
  /* sliding out only after «close» (JS), not when the window gets narrower, e.g. a phone turned upright */
  .nav-closing .sidebar { transition: transform 240ms var(--ease-drawer), visibility 0s 240ms; }
  /* :target is only the no-JS way; with JS the class opens it (a hash changed by script does not reset :target) */
  html:not(.js-on) .sidebar:target, .nav-open .sidebar { transform: none; visibility: visible; transition: transform 300ms var(--ease-drawer); box-shadow: var(--shadow-lg); }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; height: var(--bar-h); margin: 0 -4px 8px 4px; }
  .drawer-head .brand span { display: inline; }
  .drawer-foot { display: flex; flex-direction: column; gap: 2px; margin-top: auto; padding-top: 12px; border-top: 1px solid var(--border); }
  .sidebar nav { margin-bottom: 16px; }
  .nav-item, .nav-subitem { min-height: 40px; }
  .nav-backdrop { position: fixed; inset: 0; z-index: 44; background: var(--backdrop); }
  html:not(.js-on) .sidebar:target ~ .nav-backdrop, .nav-open .nav-backdrop { display: block; }
  .nav-open { overflow: hidden; }
}
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .nav-closing .sidebar, html:not(.js-on) .sidebar:target, .nav-open .sidebar { transition: none; }
}

/* installed app (PWA) turned sideways: keep clear of the notch on the left and right */
@media (max-width: 767px) {
  .appbar { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .page { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .tabs { padding-left: max(4px, env(safe-area-inset-left)); padding-right: max(4px, env(safe-area-inset-right)); }
  .sidebar { padding-left: max(12px, env(safe-area-inset-left)); }
}

/* ---------- «Izsniegt vairākiem» ---------- */
html:not(.js-on) .js-only { display: none !important; }
.list-bar + .list { margin-top: 8px; }
.list-bar .check { min-height: 32px; font-weight: 500; }
.pick-row { justify-content: flex-start; cursor: pointer; }
.pick-row .name { flex: 1; min-width: 0; }
.pick-row:has(input:checked) { background: var(--accent-soft); }
.pick-row:hover { background: var(--surface-2); }
.pick-row:has(input:checked):hover { background: var(--accent-soft); }
/* the bar under the list stays at the bottom of the screen while the list is longer than the screen */
.pick-bar {
  position: sticky; z-index: 5; bottom: 16px; display: flex; align-items: center; gap: 8px; margin-top: 16px;
  padding: 8px 8px 8px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-md);
}
.pick-count { flex: 1; min-width: 0; font-weight: 500; }
@media (max-width: 767px) {
  .pick-bar { bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 8px); padding-left: 12px; }
  .pick-count { font-size: 13px; }
}
/* the ticked students in the form: compact, in columns, untick to leave one out */
.legend-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.legend-row legend { float: left; margin: 0; padding: 0; }
.picked { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 16px; max-height: 248px; overflow-y: auto; padding: 4px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r); }
.picked .check { min-height: 36px; }
.coupon-preview figcaption { margin-top: 8px; font-size: 13px; color: var(--text-2); text-align: center; }

/* ---------- «Jauns mācību gads» ---------- */
.year-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); justify-content: stretch; gap: 10px 12px; align-items: start; padding: 14px; }
.year-group { grid-column: 1 / -1; display: flex; flex-direction: column; min-width: 0; }
.year-group .muted { font-size: 13px; }
.year-act { grid-column: 1 / -1; display: flex; }
.year-act label { flex: 1; }
.year-act span { display: flex; justify-content: center; white-space: nowrap; }
.year-row .field { min-width: 0; gap: 4px; }
.year-row .field-error:empty { display: none; }
.year-note { display: none; margin-top: 2px; font-size: 13px; color: var(--text-2); }
/* only «Pārcelt» needs the new code and name: the fields stay in place (no jumping), but inactive */
.year-row:not(:has(input[value="move"]:checked)) .year-new input { opacity: .45; pointer-events: none; }
.year-row:has(input[value="keep"]:checked) .year-note-keep { display: block; }
.year-row:has(input[value="done"]:checked) .year-note-done { display: block; color: var(--danger); }
.year-row:has(input[value="done"]:checked) .year-group b { color: var(--text-3); text-decoration: line-through; }
.year-list .table-head { display: none; }
.year-foot { display: flex; flex-direction: column; align-items: stretch; gap: 12px; margin-top: 16px; }
.year-foot .hint { margin: 0; max-width: 72ch; }
.year-summary { max-width: 640px; }
.year-changes { display: flex; flex-direction: column; margin: 0 0 20px; padding: 0; list-style: none; }
.year-changes li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.year-changes li:first-child { padding-top: 0; }
.year-changes .ico { width: 12px; height: 12px; color: var(--text-3); }
.year-change-done span { color: var(--danger); }
@media (min-width: 768px) {
  .year-foot { flex-direction: row; align-items: center; justify-content: space-between; }
  .year-act { justify-self: start; width: 320px; }
  .year-row { grid-template-columns: 128px minmax(0, 360px); justify-content: start; }
}
/* a table only when the four columns fit next to the sidebar; narrower it stays a card per group */
@media (min-width: 1180px) {
  /* fixed widths, so the header row lines up with the rows */
  .year-row { grid-template-columns: minmax(150px, 1fr) 216px 128px minmax(180px, 1.4fr); justify-content: stretch; gap: 16px; padding: 10px 14px; align-items: center; }
  .year-group, .year-act { grid-column: auto; }
  .year-act { justify-self: stretch; width: auto; }
  .year-row .ph-label { display: none; }
  .year-list .table-head { display: grid; min-height: 40px; }
}
