/* ==========================================================================
   Joripo console design system
   --------------------------------------------------------------------------
   Single source of truth for the signed-in console (everything that extends
   base.html). The public marketing site keeps its own chrome in
   templates/public/base.html and is not styled from here.

   Structure
     1. Palette            in tokens.css (light and dark); nothing here names a colour
     2. Legacy aliases     older templates use --accent, --line, --panel ...
     3. Scale tokens       radius, space, type, elevation, motion
     4. Base + controls    body, links, inputs, buttons, focus
     5. Shell              app bar, workflow tabs, mobile menu, container
     6. Box                the white surface every area of a page sits in
     7. Toolbars + cards   tool buttons, item cards, card actions, panels
     8. Design workbench   [+] bars, add grid, nested boxes, upload, switch
     9. Feedback           modals, callouts, notices, inline errors, busy
    10. Data               tiles, tables, pills, bars, empty states
    11. Data Exporter      the new-tab export page
    12. Form designer      in tester.css (the Edit and Test views' own window)
    13. Responsive         992 / 768 / 480 px
   ========================================================================== */

/* ---- 1. palette --------------------------------------------------------- */
/* Joripo's brand palette (brand sheet; decision D10, Joripo 2.0), in a light
   and a dark theme, is static/css/tokens.css: every page shell loads it
   before this file. The roles this file reads -- --color-primary,
   --color-text, --color-surface ... -- are defined there; nothing below
   names a colour (tests/test_design_tokens.py). */

/* ---- 2. legacy aliases (older templates read these) --------------------- */
:root {
  --brand: var(--color-brand); --brand-tint: var(--color-secondary-tint);
  --accent: var(--color-primary); --accent-dark: var(--color-primary-hover);
  --accent-tint: var(--color-primary-tint);
  --accent-btn: var(--color-primary); --accent-btn-dark: var(--color-primary-hover);
  --bg: var(--color-surface); --page: var(--color-background);
  --panel: var(--color-surface-muted); --band: var(--color-surface-muted);
  --card: var(--color-surface); --shell: var(--color-shell);
  --ink: var(--color-text); --ink-2: var(--color-text-secondary); --muted: var(--color-text-muted);
  --line: var(--color-border); --line-2: var(--color-border-strong);
  --good: var(--color-success); --good-bg: var(--color-success-bg);
  --warning: var(--color-warning); --warning-bg: var(--color-warning-bg);
  --critical: var(--color-danger); --critical-bg: var(--color-danger-bg);
  --info: var(--color-info); --info-bg: var(--color-info-bg);
  --strip: var(--color-strip-form);
}

/* ---- 3. scale ----------------------------------------------------------- */
:root {
  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-pill: 999px;
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px;
  --fs-15: 15px; --fs-16: 16px; --fs-18: 18px; --fs-20: 20px; --fs-22: 22px;
  --font-body: var(--font-ui, system-ui, sans-serif);   /* Inter + Noto Sans Bengali (fonts.css) */
  --font-mono: Consolas, Menlo, monospace;
  --control-h: 36px; --control-h-sm: 30px; --control-h-lg: 44px;
  --container: 1170px;
  --ring: 0 0 0 3px var(--color-primary-tint-2);
  --focus: 2px solid var(--color-primary);
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* ---- 4. base + controls ------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
/* a word too long for its line (a form title or ID with no spaces) breaks
   rather than running off the page */
body { font: 16px/1.42857 var(--font-body); background: var(--color-background);
       color: var(--color-text); min-width: 0; overflow-wrap: break-word; }
a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-hover); text-decoration: underline; }
h1 { font-size: 22px; font-weight: 500; margin: 0 0 4px; overflow-wrap: anywhere; }   /* may shrink in a row of buttons */
.sub { color: var(--color-text-muted); font-size: 13px; margin-bottom: 18px; }
.muted { color: var(--color-text-muted); }
.mono { font-family: var(--font-mono); font-size: 13px; color: var(--color-text-secondary); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; }

/* icons: inline SVG from icons.py. Solid glyphs cut their detail lines out in
   --ic-knock, which each surface sets to its own background. */
.ic { display: inline-block; vertical-align: -0.16em; flex: 0 0 auto; --ic-knock: var(--color-surface); }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=url], input[type=search], input[type=date], select, textarea {
  font: inherit; font-size: 14px; min-height: var(--control-h); padding: 6px 12px;
  border: 1px solid var(--color-control-border); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text); max-width: 100%;
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075); transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 80px; }
input[type=file] { font: inherit; font-size: 14px; max-width: 100%; }
/* the file field's own button: drawn like the console's buttons in both themes, not the browser's grey */
input[type=file]::file-selector-button { font: inherit; font-weight: 600; min-height: var(--control-h); padding: 0 12px;
  margin-right: 10px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md);
  background: var(--color-surface); color: var(--color-text); cursor: pointer; }
input[type=file]::file-selector-button:hover { background: var(--color-hover); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary);
  box-shadow: inset 0 1px 1px rgba(0,0,0,.075), var(--ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--color-input-disabled); color: var(--color-text-muted); cursor: not-allowed; }
::placeholder { color: var(--color-text-muted); }
input[type=checkbox], input[type=radio] { accent-color: var(--color-primary); width: 16px; height: 16px; vertical-align: -3px; }

a:focus-visible, button:focus-visible, [role=button]:focus-visible, summary:focus-visible,
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible {
  outline: var(--focus); outline-offset: 2px; }

/* buttons: Bootstrap 3 / AdminLTE as SurveyCTO draws them */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--control-h); padding: 6px 12px; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm); background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: 14px; font-weight: 500; line-height: 20px; cursor: pointer;
  text-decoration: none; white-space: nowrap; user-select: none;
  transition: background .12s, border-color .12s, color .12s; }
.btn:hover { background: var(--color-hover); color: var(--color-text); text-decoration: none; }
.btn .ic { width: 14px; height: 14px; --ic-knock: var(--color-surface); }
.btn.primary { background: var(--color-primary); border-color: var(--color-primary-border);
  color: var(--color-text-on-primary); box-shadow: inset 0 -1px 0 rgba(0,0,0,.09); }
.btn.primary .ic { --ic-knock: var(--color-primary); }
.btn.primary:hover { background: var(--color-primary-hover); color: var(--color-text-on-primary); }
.btn.primary:hover .ic { --ic-knock: var(--color-primary-hover); }
.btn.primary:active { background: var(--color-primary-active); }
/* legacy "add" buttons (admin.html) read as primary */
.btn.add { background: var(--color-primary); border-color: var(--color-primary-border); color: var(--color-text-on-primary); }
.btn.add .ic { --ic-knock: var(--color-primary); }
.btn.add:hover { background: var(--color-primary-hover); color: var(--color-text-on-primary); }
.btn.success { background: var(--color-secondary); border-color: var(--color-secondary-hover); color: var(--on-success); }
.btn.success:hover { background: var(--color-secondary-hover); color: var(--on-success); }
.btn.success .ic { --ic-knock: var(--color-secondary); }
/* SurveyCTO's red Cancel (btn-cancel), wider as its btn-control buttons are */
.btn.cancel { background: var(--color-danger-solid); border-color: var(--color-danger-hover); color: var(--color-text-on-danger); }
.btn.cancel:hover { background: var(--color-danger-hover); color: var(--color-text-on-danger); }
.btn.cancel .ic { --ic-knock: var(--color-danger-solid); }
.btn.danger { border-color: var(--color-danger-border); color: var(--color-danger); }
.btn.danger:hover { background: var(--color-danger-bg); color: var(--color-danger); }
.btn.danger-solid { background: var(--color-danger-solid); border-color: var(--color-danger-hover); color: var(--color-text-on-danger); }
.btn.danger-solid:hover { background: var(--color-danger-hover); color: var(--color-text-on-danger); }
.btn.danger-solid .ic { --ic-knock: var(--color-danger-solid); }
.btn.ghost { background: none; border-color: transparent; color: var(--color-primary); }
.btn.ghost:hover { background: var(--color-primary-tint); }
.btn.sm { min-height: var(--control-h-sm); padding: 5px 10px; font-size: 12px; line-height: 1.5; }
/* a small button in a row of fields (Filter, Clear, Find) is as tall as the fields */
form > :is(input, select, label) ~ .btn.sm { min-height: var(--control-h); }
.btn.lg { min-height: var(--control-h-lg); padding: 10px 16px; font-size: 18px; }
.btn.block { width: 100%; }
.btn:disabled, .btn[aria-disabled="true"], .btn.disabled { opacity: .65; cursor: not-allowed; }
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--color-primary-tint-2); border-top-color: var(--color-text-on-primary); animation: jr-spin .7s linear infinite; }
.btn:not(.primary):not(.success):not(.cancel).is-loading::after { border-color: var(--color-border); border-top-color: var(--color-primary); }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: none;
  border-radius: var(--radius-sm); background: none; color: var(--color-text-faint); cursor: pointer; padding: 0; }
.icon-btn:hover { color: var(--color-text-secondary); }
.icon-btn .ic { width: 16px; height: 16px; }
@keyframes jr-spin { to { transform: rotate(360deg); } }

/* ---- 5. shell ----------------------------------------------------------- */
/* SurveyCTO's header: #F4F4F4, a 50px row (logo, utilities) and a 44px tab
   strip whose active tab takes the page colour. */
.appbar { position: sticky; top: 0; z-index: 40; background: var(--color-shell); }
/* a link to #somewhere lands below the sticky header and tabs, not under them */
:root:has(.appbar) { scroll-padding-top: 104px; }
.appbar-inner, .tabs, main.container { max-width: var(--container); margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: 0; height: 50px; padding: 0 15px; }
.logo-img { display: block; flex: none; object-fit: contain; }
.wordmark { display: flex; align-items: center; gap: 9px; height: 50px; padding: 0 10px; text-decoration: none; min-width: 0; }
.wordmark:hover { text-decoration: none; }
.logo { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--color-brand);
  color: var(--color-text-on-primary); display: grid; place-items: center; font-weight: 800; font-size: 18px; flex: 0 0 auto; }
.wordmark b { color: var(--color-primary); font-size: 20px; font-weight: 700; display: block; line-height: 1.1; }
.wordmark span { display: block; color: var(--color-text-muted); font-size: 11px; line-height: 1.2; }
.topbar .spacer { flex: 1; min-width: 0; }
.ws-name { font-size: 14px; color: var(--color-text-muted); max-width: 260px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; padding: 0 12px; }
select.project-switch { font-size: 14px; color: var(--color-primary); min-height: 32px;
  padding: 4px 8px; max-width: 260px; margin: 0 8px; }
/* header utilities: icon cells, and the email ▾ menu; an open one turns blue */
.hdr-ico { display: grid; place-items: center; width: 61px; height: 50px; color: var(--color-primary); text-decoration: none; }
.hdr-ico:hover { background: var(--color-hover); color: var(--color-primary); text-decoration: none; }
.hdr-ico:hover .ic { --ic-knock: var(--color-hover); }
.hdr-ico .ic { width: 20px; height: 20px; }
.hdr-switch { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; margin-right: 8px;
  border: 1px solid var(--color-primary); border-radius: 15px; color: var(--color-primary); font-size: 13px;
  font-weight: 600; text-decoration: none; white-space: nowrap; }
.hdr-switch:hover { background: var(--color-primary); color: var(--color-text-on-primary); text-decoration: none; }
.hdr-switch .ic { width: 16px; height: 16px; }
.hdr-switch:hover .ic { --ic-knock: var(--color-primary); }
/* An error page's Sign out (base.html): a form's button drawn as the switch. */
button.hdr-switch { background: none; font-family: inherit; cursor: pointer; }
/* The Legacy console is obsolete: a band under its header says so on every
   page, with the way back to Joripo 2.0 (templates/base.html). */
.legacy-banner { background: var(--color-warning-bg); border-bottom: 1px solid var(--color-warning-border);
  color: var(--color-text); font-size: 14px; }
.legacy-banner-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; max-width: var(--container);
  margin: 0 auto; padding: 8px 20px; }
.legacy-banner-inner > span { flex: 1 1 240px; min-width: 0; }
.legacy-banner .ic { width: 16px; height: 16px; color: var(--color-warning); --ic-knock: var(--color-warning-bg); }
.legacy-banner-go { display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border-radius: 16px;
  background: var(--color-primary); color: var(--color-text-on-primary); font-weight: 600; white-space: nowrap;
  text-decoration: none; }
.legacy-banner-go:hover { background: var(--color-primary-hover); color: var(--color-text-on-primary); text-decoration: none; }
/* An error's technical detail, folded away (templates/partials/technical.html). */
details.tech-details { margin-top: 6px; }
/* a finding's technical details, name beside value (partials/finding.html);
   on a phone the value goes under its name */
.tech-facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 10px; margin: 4px 0 0; }
.tech-facts dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 480px) { .tech-facts { grid-template-columns: minmax(0, 1fr); } .tech-facts dd { margin-bottom: 4px; } }
details.tech-details summary { cursor: pointer; font-size: 12.5px; color: var(--color-text-muted); }
/* a finding's "Technical details" (partials/finding.html): a thumb's height on a phone */
@media (max-width: 760px) { details.tech > summary { display: flex; align-items: center; min-height: 40px; } }
.userbox { color: var(--color-primary); font-size: 14px; display: flex; align-items: center; height: 50px; }
.userbox details { position: relative; height: 50px; }
.userbox summary { cursor: pointer; list-style: none; color: var(--color-primary); display: inline-flex;
  align-items: center; gap: 7px; height: 50px; padding: 0 15px; }
.userbox summary:hover { background: var(--color-hover); }
.userbox details[open] > summary { background: var(--color-primary); color: var(--color-text-on-primary); }
.userbox details[open] > summary .ic { --ic-knock: var(--color-primary); }
.userbox summary::-webkit-details-marker { display: none; }
.menu { position: absolute; right: 0; top: 100%; z-index: 60; background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); box-shadow: var(--shadow-menu);
  min-width: 230px; padding: 5px 0; }
.menu a, .menu button { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; text-align: left;
  padding: 8px 20px; font: inherit; font-size: 14px; color: var(--color-text); background: none;
  border: none; cursor: pointer; text-decoration: none; }
.menu a:hover, .menu button:hover, .menu a:focus-visible, .menu button:focus-visible {
  background: var(--color-surface-sunken); text-decoration: none; outline: none; }
.menu .menu-label { padding: 8px 20px 4px; font-size: 12px; font-weight: 700; color: var(--color-text-muted);
  text-transform: uppercase; letter-spacing: .04em; }
.menu hr { border: none; border-top: 1px solid var(--color-divider); margin: 9px 0; }
.userbox .who { padding: 8px 20px 10px; border-bottom: 1px solid var(--color-divider);
  font-size: 12px; color: var(--color-text-muted); line-height: 1.45; }
.userbox .who b { color: var(--color-text); font-size: 13px; display: block; font-weight: 600; word-break: break-all; }
/* System / Light / Dark, in the user menu and the phone menu
   (templates/partials/theme_picker.html) */
.theme-pick { padding: 8px 20px 10px; }
.theme-pick-label { display: block; margin: 0 0 6px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--color-text-muted); }
.theme-pick-opts { display: flex; gap: 4px; }
.theme-pick button, .menu .theme-pick button, .mobile-nav .theme-pick button {
  flex: 1 1 0; display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; width: auto; min-width: 0; min-height: 44px; padding: 4px 6px; border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text-secondary);
  font: inherit; font-size: 12px; cursor: pointer; }
.theme-pick button:hover, .menu .theme-pick button:hover { background: var(--color-hover); }
.theme-pick button[aria-checked="true"], .menu .theme-pick button[aria-checked="true"] {
  border-color: var(--color-primary); background: var(--color-primary-tint); color: var(--color-primary); font-weight: 700; }
.theme-pick button .ic { --ic-knock: var(--color-surface); }
.nav-toggle { display: none; }

/* workflow tabs: Bootstrap nav-tabs; only the active tab has a caret */
.tabs { display: flex; align-items: flex-end; gap: 0; padding: 0 15px 0 35px; height: 44px; }
.tab-item { position: relative; display: flex; align-items: center; height: 44px; margin-right: 2px;
  border: 1px solid transparent; border-bottom: none; border-radius: 4px 4px 0 0; }
.tab-item:hover { background: var(--color-hover); }
.tab { display: inline-flex; align-items: center; gap: 5px; height: 100%; padding: 10px 25px 10px 15px;
  font-size: 16px; color: var(--color-primary); white-space: nowrap; text-decoration: none; }
.tab:hover { text-decoration: none; }
.tab .n { font-weight: 400; color: inherit; font-variant-numeric: tabular-nums; }
.tab .ic { width: 16px; height: 16px; --ic-knock: var(--color-shell); }
.tab-item:hover .tab .ic { --ic-knock: var(--color-hover); }
.tab-item.active { background: var(--color-background); border-color: var(--color-divider); }
.tab-item.active .tab { color: var(--color-text-secondary); padding-right: 0; }
.tab-item.active .tab .ic { --ic-knock: var(--color-background); }
.tab-caret { display: inline-grid; place-items: center; width: 25px; height: 24px; margin-right: 0;
  border: none; border-radius: var(--radius-sm); background: none; cursor: pointer;
  color: var(--color-text-secondary); padding: 0; }
.tab-caret .ic { width: 12px; height: 12px; }
.tab-item.active .tab-caret:hover, .tab-caret[aria-expanded="true"] { background: var(--color-primary-tint); color: var(--color-primary); }
.tab-item .menu { left: 0; right: auto; top: 100%; }
.tab-crumb { margin-left: auto; align-self: flex-end; display: none; max-width: 340px; height: 38px;
  padding: 8px 15px; font-size: 16px; color: var(--color-text); background: var(--color-background);
  border-top: 2px solid var(--color-primary); border-radius: 3px 3px 0 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab-crumb.help { border-top-color: var(--color-secondary); }
.tab-crumb.on { display: block; }
.m-section { display: none; }
.mobile-nav { display: none; }

main.container { padding: 26px 15px 40px; }
main.container.wide { max-width: none; }

/* footer: SurveyCTO's grey band */
.site-foot { background: var(--color-footer); color: var(--color-text-secondary); padding: 20px 15px; margin-top: 20px; }
.site-foot-inner { max-width: var(--container); margin: 0 auto; padding: 5px 15px 20px; display: flex;
  flex-wrap: wrap; justify-content: space-between; gap: 10px 30px; }
.site-foot h4 { margin: 10px 0 0; font-size: 18px; font-weight: 700; line-height: 1.1; color: var(--color-text); }
.site-foot p { margin: 10px 0 0; }

/* legacy page sections (hfc, settings, submissions ...) read as boxes */
section { background: var(--color-surface); border: none; border-top: 2px solid var(--color-primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-box); padding: 10px;
  margin: 15px 0; overflow-x: auto; }
section > h2 { font-size: 20px; font-weight: 400; color: var(--color-text); margin: 0 0 12px;
  text-transform: none; letter-spacing: 0; line-height: 1.1; }
h2 .live { color: var(--color-success); font-weight: 400; font-size: 12.5px; }

/* ---- 6. box ------------------------------------------------------------- */
/* AdminLTE's .box as SurveyCTO uses it: white, 3px radius, a 2px coloured top
   edge (green help, blue work), 15px apart, 20px inside the container. */
.box { background: var(--color-surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-box);
  border-top: 2px solid var(--color-primary); margin: 15px 20px; overflow: visible; padding: 0;
  scroll-margin-top: 120px; }
.box.help { border-top-color: var(--color-secondary); }
.box-head { display: flex; align-items: flex-start; gap: 6px; padding: 10px; min-height: 56px; }
.box-title { flex: 1; min-width: 0; margin: 0; font-size: 20px; font-weight: 400; line-height: 1.1;
  color: var(--color-text); text-transform: none; letter-spacing: 0; overflow-wrap: anywhere; }
.box.help .box-title { color: var(--color-secondary-ink); }
.box-head .box-ctl { width: 50px; height: 36px; margin: -2px 0; color: var(--color-text-faint); }
.box-head .box-ctl .ic { width: 18px; height: 18px; }
.box-help { display: none; margin: 0; padding: 10px 15px; background: var(--color-success-bg);
  border-top: 1px solid var(--color-success-border); border-bottom: 1px solid var(--color-success-border);
  font-size: 16px; color: var(--color-text); }
.box-help.open { display: block; }
.box-toolbar, .subtoolbar { display: flex; align-items: flex-start; flex-wrap: wrap; gap: 0;
  background: var(--color-surface-muted); padding: 10px; }
.box-toolbar .spacer, .subtoolbar .spacer { flex: 1; }
.box-toolbar .ic, .subtoolbar .ic { --ic-knock: var(--color-surface-muted); }
.box-toolbar.sub { background: var(--color-surface-muted); border-top: 1px solid var(--color-divider); }
.box-toolbar .btn.more { margin: 3px 10px 0; gap: 4px; }
.toolbar-note { align-self: center; font-size: 13px; color: var(--color-text-muted); padding: 0 6px; }
/* a setting in the toolbar (Field team > New phones): wraps, and its select
   shrinks to the line rather than running out of the box on a phone */
form.toolbar-note { flex-wrap: wrap; min-width: 0; }
.toolbar-note select { min-width: 0; max-width: 100%; }
.box-body { padding: 10px; }
.box-body.no-padding { padding: 0; }
.box-body > :last-child { margin-bottom: 0; }
.help-body p { margin: 0 0 10px; max-width: 900px; }
.box-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 10px; }
.box-foot.split { justify-content: space-between; }
.box-foot.start { justify-content: flex-start; }
.box.collapsed > :not(.box-head) { display: none !important; }
.box .box-ctl .ic { transition: transform .15s; }
.box.collapsed .box-ctl.collapse .ic { transform: rotate(180deg); }
.box-subhead { margin: 0 0 10px; font-size: 18px; font-weight: 500; }
.help-grid { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px 24px; align-items: start; }
.help-grid p { margin: 0; max-width: 820px; line-height: 1.6; color: var(--color-text-secondary); }

/* nested box inside a grey well (wizards, upload, create dataset) */
.well { background: var(--color-surface-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 10px 20px; margin: 10px 0; }
.well > .box { margin: 0; box-shadow: var(--shadow-box); }

/* ---- 7. toolbar buttons + item cards ----------------------------------- */
/* Icon over label: 14px glyph, 11px/500 caption; the open one in the primary colour. */
.tool { display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 5px; width: 65px; min-height: 39px; padding: 6px 0 0; border: none; background: none;
  border-radius: 0; color: var(--color-text-secondary); font: inherit; font-size: 11px; font-weight: 500;
  line-height: 1.1; text-align: center; cursor: pointer; text-decoration: none; position: relative; }
.tool .ic { width: 14px; height: 14px; }
.tool:hover { color: var(--color-primary); text-decoration: none; }
.tool[aria-expanded="true"], .tool.on { color: var(--color-primary); }
.tool:disabled, .tool[aria-disabled="true"] { opacity: .45; cursor: not-allowed; color: var(--color-text-secondary); }

.item-list { display: flex; flex-direction: column; }
.box-body.item-list { padding: 0; }
/* SurveyCTO's item card: a 30px stripe, a grey header with the title and the
   actions, a white meta row; cards are separated only by [+] bars. */
.item-row { display: flex; border: 1px solid var(--color-border); border-right: none; border-radius: 0;
  background: var(--color-surface); overflow: hidden; margin-bottom: 0;
  transition: outline-color .15s, opacity .2s; }
.item-row + .item-row { margin-top: 20px; }
.item-row.is-active { outline: 1px solid var(--color-primary); outline-offset: -1px; }
.item-strip { width: 30px; flex: 0 0 30px; background: var(--color-strip-form); display: flex;
  align-items: flex-start; justify-content: center; padding-top: 14px; color: var(--color-text-on-primary); }
.item-strip .ic { width: 14px; height: 14px; color: var(--color-text-on-primary); --ic-knock: var(--color-strip-form); }
.dataset-strip { background: var(--color-strip-dataset); }
.dataset-strip .ic { --ic-knock: var(--color-strip-dataset); }
.device-strip { background: var(--color-strip-device); }
.device-strip .ic { --ic-knock: var(--color-strip-device); }
.form-strip { background: var(--color-strip-form); }
.item-body { flex: 1; min-width: 0; }
.item-head { display: flex; align-items: flex-start; gap: 10px; padding: 5px 5px 5px 10px;
  background: var(--color-surface-muted); min-height: 46px; border-bottom: 1px solid var(--color-border); }
.item-head .ic { --ic-knock: var(--color-surface-muted); }
.item-title { font-size: 18px; font-weight: 500; line-height: 1.42857; color: var(--color-text); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-title.sm { font-size: 16px; }
.item-meta { background: var(--color-surface); padding: 10px; font-size: 16px;
  overflow-wrap: anywhere; transition: background .2s; }
.item-meta b { font-weight: 700; }
.item-meta .note { font-size: 14px; color: var(--color-text-muted); margin-top: 4px; }
.item-meta .access .ic { width: 14px; height: 14px; vertical-align: -1px; }
.item-meta.flash { animation: jr-flash 1.2s ease-out; }
@keyframes jr-flash { from { background: var(--color-success-bg); } }
.item-row.match .item-meta { background: var(--color-success-bg); }
.acts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0; }
.acts form { display: contents; }
.act { display: inline-flex; flex-direction: column; align-items: center; justify-content: flex-start;
  gap: 2px; width: 60px; min-height: 35px; padding: 6px 0 0; border: none; background: none;
  border-radius: 0; color: var(--color-text-secondary); font: inherit; font-size: 11px; font-weight: 500;
  line-height: 1.1; text-align: center; cursor: pointer; text-decoration: none; }
.act .ic { width: 14px; height: 14px; }
.act:hover { color: var(--color-primary); text-decoration: none; }
.act[aria-expanded="true"] { color: var(--color-primary); }
.act:disabled, .act[aria-disabled="true"] { opacity: .45; cursor: not-allowed; color: var(--color-text-secondary); }
.act.danger:hover { color: var(--color-danger); }

/* card panels: SurveyCTO's collapse panel, outlined in blue inside the card */
.panel { background: var(--color-surface); border: 1px solid var(--color-primary); margin: 5px 10px 10px; padding: 10px 20px; }
.panel.strip { background: var(--color-surface-sub); border: none; margin: 0; display: flex; flex-wrap: wrap;
  justify-content: flex-end; gap: 0; padding: 10px 5px; border-bottom: 1px solid var(--color-border); }
.panel.strip .ic { --ic-knock: var(--color-surface-sub); }
.panel h3 { margin: 20px 0 10px; font-size: 24px; font-weight: 500; line-height: 1.1; color: var(--color-text); }
.panel > p:first-of-type { margin-top: 0; }
.panel-lead { margin: 0 0 16px; color: var(--color-text); font-size: 16px; max-width: 900px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; align-items: center;
  margin-top: 10px; padding: 0 0 5px; }
.panel-actions .btn, .box-foot .btn { padding: 6px 30px; }
.panel-actions.start { justify-content: flex-start; }
.panel-actions .grow { flex: 1 1 220px; }
.fieldrow { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.fieldrow > label { flex: 1 1 200px; min-width: 0; }
.fieldrow label, label.inline { font-size: 14px; color: var(--color-text); font-weight: 700; }
.fieldrow input, .fieldrow select { width: 100%; margin-top: 4px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 400; color: var(--color-text); }
label.inline input[type=checkbox] { margin: 0; }
.hint, .panel .hint { font-size: 12px; color: var(--color-text-muted); display: block; margin-top: 4px; }

/* settings rows: title and description on the left, a switch on the right */
.option-row { display: flex; align-items: flex-start; gap: 20px; margin: 30px 0 20px; }
.option-label { flex: 1; min-width: 0; }
.option-title { font-weight: 700; line-height: 20px; }
.option-subtitle { font-size: 15.2px; line-height: 1.42857; color: var(--color-text-secondary); }

/* fields (label over control, hint, inline error) */
.field { margin: 0 0 15px; }
.field-label { display: block; font-weight: 700; font-size: 16px; margin-bottom: 5px; color: var(--color-text); }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field select, .field textarea { width: 100%; }
.field-hint { font-size: 12px; color: var(--color-text-muted); margin-top: 5px; }
.field-error { display: none; }
.field.has-error .field-label, .field.has-error .field-hint { color: var(--color-danger-solid); }
.field.has-error input, .field.has-error select { border-color: var(--color-danger-solid);
  border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.field.has-error .field-error { display: block; background: var(--color-danger-solid); color: var(--color-text-on-danger);
  font-size: 14px; font-style: italic; padding: 5px 10px; }
.inset { background: var(--color-surface-sunken); border: 1px solid var(--color-divider);
  border-radius: var(--radius-sm); padding: 14px 14px 2px; margin-bottom: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.opt-group { border: none; margin: 0 0 16px; padding: 0; }
.opt-group legend { font-weight: 700; font-size: 16px; margin-bottom: 8px; padding: 0; }
.opt-group label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 32px; font-size: 16px; }
/* a phone: the option reads as a sentence, its radio, words and field in one flow,
   rather than the radio left alone on a line above them */
@media (max-width: 600px) { .opt-group label { display: block; } .opt-group label > input { vertical-align: middle; } }

/* folders (groups) */
.folder { border: 1px solid var(--color-border); border-radius: 0; margin: 10px 0; background: var(--color-surface); }
.folder-head { display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 10px; min-height: 46px;
  background: var(--color-surface-muted); border-bottom: 1px solid var(--color-border); font-size: 18px; }
.folder-head .ic { --ic-knock: var(--color-surface-muted); }
.folder-caret { display: inline-grid; place-items: center; width: 28px; height: 28px; border: none; background: none;
  border-radius: var(--radius-sm); cursor: pointer; color: var(--color-text-muted); font: inherit; }
.folder-caret:hover { background: var(--color-surface); }
.folder-name { font-weight: 500; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.folder-body { padding: 0 10px 10px; }
.folder.root { border: none; margin: 0; background: none; }
.folder.root > .folder-body { padding: 0; }
.dataset-row { margin-left: 30px; }
.item-row + .dataset-row { margin-top: 20px; }

/* Download › Form files: SurveyCTO's version panel */
.panel.ff-host { padding: 10px 20px; }
.ff-panel { margin: 0 0 20px; background: var(--color-surface); border: 1px solid var(--color-divider); border-radius: 4px; }
.ff-head { padding: 10px 15px; background: var(--color-surface-sunken); border-bottom: 1px solid var(--color-divider);
  border-radius: 3px 3px 0 0; }
.ff-body { padding: 15px; }
.ff-list { display: flex; flex-direction: column; }
.ff-list.ff-sub { margin-top: 10px; }
.ff-item { display: flex; align-items: flex-start; gap: 0; margin: 0 0 -1px; padding: 5px 15px 5px 0;
  color: var(--color-text-secondary); background: var(--color-surface); text-decoration: none; }
a.ff-item:hover { background: var(--color-surface-sunken); color: var(--color-text-secondary); text-decoration: none; }
p.ff-item { margin: 0; padding-left: 0; }
.ff-item.is-missing { color: var(--color-text-muted); }
.ff-icon { flex: 0 0 48px; padding: 3px 0 0 10px; }
.ff-icon .ic { width: 15px; height: 15px; }
.ff-object { flex: 1 1 50%; min-width: 0; overflow-wrap: anywhere; }
.ff-actor { flex: 1 1 50%; min-width: 0; padding-left: 20px; font-size: .95em; font-style: italic; color: var(--color-text-muted); }
.ff-foot { display: flex; justify-content: flex-end; }
.ff-foot .btn { padding: 6px 30px; margin: 0 0 5px 6px; }
.ff-loading, .ff-empty { margin: 10px 0; color: var(--color-text-muted); }
.ff-embed { margin: 10px 0; }
.del-ack { margin: 5px 0 10px; }
.share-panel p { margin: 0 0 10px; }
.share-panel p:last-child { margin-bottom: 0; }

/* a card action that posts (Deactivate): the form is not a box of its own */
.acts > form { display: contents; }
.item-row.is-inactive .item-body { opacity: .55; }
/* an Edit panel's sections (Configure > Your users > Edit) */
.edit-block { padding: 0 0 14px; }
.edit-block + .edit-block { padding-top: 14px; border-top: 1px solid var(--color-border); }
.edit-block h4 { margin: 0 0 6px; font-size: 16px; font-weight: 700; }
.edit-block p { margin: 0 0 8px; }
.edit-inline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.edit-inline .field-label { margin: 0; }
.edit-inline select { width: auto; min-width: 160px; }
/* Configure > Server settings > Storage: usage against the plan */
.usage-list { max-width: 560px; }
.usage-row { margin: 0 0 14px; }
.usage-head { display: flex; justify-content: space-between; gap: 12px; margin: 0 0 4px; font-size: 14px;
  font-variant-numeric: tabular-nums; }
.usage-bar { display: block; width: 100%; height: 10px; border: 0; border-radius: 5px; background: var(--color-track);
  overflow: hidden; appearance: none; }
.usage-bar::-webkit-progress-bar { background: var(--color-track); border-radius: 5px; }
.usage-bar::-webkit-progress-value { background: var(--color-success); border-radius: 5px; }
.usage-bar::-moz-progress-bar { background: var(--color-success); border-radius: 5px; }
.usage-bar.is-high::-webkit-progress-value { background: var(--color-danger-solid); }
.usage-bar.is-high::-moz-progress-bar { background: var(--color-danger-solid); }
.plain-list { margin: 0 0 14px; padding-left: 20px; }
/* Master Admin > Organisations: an organisation's use against its plan */
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 10px 0 4px; max-width: 560px; }
.meter .mlabel { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 4px; font-size: 11.5px;
  color: var(--color-text-secondary); font-variant-numeric: tabular-nums; }
.meter .track { height: 7px; border-radius: 6px; background: var(--color-track); overflow: hidden; }
.meter .fill { height: 100%; background: var(--color-primary); border-radius: 6px; }
.meter .fill.warn { background: var(--color-warning-solid); }
.meter .fill.over { background: var(--color-danger-solid); }
.meter .inf { color: var(--color-text-muted); font-size: 11px; }
@media (max-width: 640px) { .meters { grid-template-columns: minmax(0, 1fr); } }
.opt-group .num-inline { display: inline-block; width: 80px; height: 30px; margin: 0 4px; padding: 4px 8px; }
.edit-inline .lookup-key { flex: 1 1 260px; width: auto; font-family: var(--font-mono); }

/* ---- 8. design workbench ----------------------------------------------- */
/* the [+] bar: a 32 x 16 light-blue button in a 20px row */
.add-marker { display: flex; align-items: center; justify-content: center; width: 32px; height: 16px;
  padding: 0; margin: 2px 0; border: 0; border-radius: 0; background: var(--color-primary-tint-2); color: var(--color-primary);
  font: inherit; cursor: pointer; user-select: none; }
.add-marker .ic { width: 11px; height: 11px; stroke-width: 3; }
.add-marker:hover, .add-marker[aria-expanded="true"] { background: var(--color-add); color: var(--color-text-on-primary); }
.add-hint-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 20px; }
.add-hint { font-size: 13px; font-style: italic; color: var(--color-primary); }

/* the add row: four buttons in one centred line, two blues, and a ✖ */
.add-panel { position: relative; background: var(--color-surface); padding: 30px 10px 15px; margin: 0; }
.add-close { position: absolute; top: 4px; right: 8px; display: grid; place-items: center; width: 24px; height: 24px;
  padding: 0; border: none; background: none; color: var(--color-text-faint); cursor: pointer; }
.add-close:hover { color: var(--color-text); }
.add-close .ic { width: 14px; height: 14px; stroke-width: 3; }
.add-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.add-tile { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 6px 30px; border-radius: var(--radius-sm); border: 0; background: var(--color-add); color: var(--color-text-on-primary);
  font: inherit; font-size: 16px; font-weight: 400; line-height: 1.42857; text-align: center; cursor: pointer;
  text-decoration: none; box-shadow: 0 1px 2px rgba(40,60,70,.2); transition: background .12s; }
.add-tile .ic { width: 16px; height: 16px; --ic-knock: var(--color-add); }
.add-tile:hover { background: var(--color-add-hover); color: var(--color-text-on-primary); text-decoration: none; }
.add-tile:hover .ic { --ic-knock: var(--color-add-hover); }
.add-tile.adv { background: var(--color-add-adv); }
.add-tile.adv .ic { --ic-knock: var(--color-add-adv); }
.add-tile.adv:hover { background: var(--color-add-adv-hover); }
.add-tile.adv:hover .ic { --ic-knock: var(--color-add-adv-hover); }
.add-tile[aria-expanded="true"] { background: var(--color-add-active); box-shadow: inset 0 2px 4px rgba(0,0,0,.2); }
.add-tile[aria-expanded="true"] .ic { --ic-knock: var(--color-add-active); }
.add-tile.adv[aria-expanded="true"] { background: var(--color-add-adv-active); }
.add-tile.adv[aria-expanded="true"] .ic { --ic-knock: var(--color-add-adv-active); }

/* callout: "Is this what you want?" */
.callout { position: relative; background: var(--color-warning-bg); border: 1px solid var(--color-warning-border);
  border-radius: var(--radius-sm); padding: 10px 40px 10px 15px; margin: 0 0 15px; font-size: 16px; color: var(--color-text); }
.callout b:first-child { color: var(--color-warning); }
.callout .icon-btn { position: absolute; top: 3px; right: 3px; }
.callout a { color: var(--color-warning); text-decoration: underline; }

/* upload drop zone + file rows */
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  min-height: 185px; padding: 20px 15px; margin: 0 0 12px; text-align: center; border: 2px dashed var(--color-control-border);
  border-radius: 0; background: var(--color-surface); transition: border-color .12s, background .12s; }
.dropzone.over { border-color: var(--color-primary); background: var(--color-primary-tint); }
.dropzone.is-hidden { display: none; }
.dz-icon { display: grid; place-items: center; color: var(--color-text-faint); }
.dz-icon .ic { width: 28px; height: 28px; --ic-knock: var(--color-surface); }
.dz-title { font-weight: 400; font-size: 16px; color: var(--color-text-muted); }
.dz-hint { font-size: 14px; color: var(--color-text-muted); max-width: 440px; }
.dz-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 4px; }
.dz-actions .btn { min-height: var(--control-h-sm); padding: 5px 10px; font-size: 12px; }
.dropzone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-rows { display: flex; flex-direction: column; gap: 8px; margin: 0 0 12px; }
.file-rows:empty { display: none; }
.file-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 10px;
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface-sunken); }
.file-row .ic { color: var(--color-primary); width: 18px; height: 18px; --ic-knock: var(--color-surface-sunken); }
.file-row .fname { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fsize { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; }
.file-row .icon-btn { color: var(--color-danger-solid); }
.file-row .icon-btn:hover { color: var(--color-danger); }

/* SurveyCTO's toggle: a 60 x 24 pill with the state written in it —
   YES/NO in upload panels (.switch), ON/OFF in settings lists (.onoff). */
.switch-row { display: flex; align-items: center; gap: 12px; min-height: 40px; margin: 4px 0; cursor: pointer; width: fit-content; max-width: 100%; }
.switch-input, .onoff input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch, .onoff-track { position: relative; display: inline-block; flex: 0 0 auto; width: 60px; height: 24px;
  border-radius: 12px; background: var(--color-switch-track); transition: background .18s var(--ease); }
.switch::before, .onoff-track::before { content: ""; position: absolute; left: 2px; top: 2px; width: 20px; height: 20px;
  border-radius: 10px; background: var(--color-switch-knob); transition: left .18s var(--ease), background .18s; }
.switch::after, .onoff-track::after { content: "NO"; position: absolute; left: 27px; top: 2px; line-height: 20px;
  font-size: 14px; font-weight: 400; color: var(--color-text-secondary); }
.onoff-track::after { content: "OFF"; left: 25px; }
.switch-input:checked + .switch, .onoff input:checked + .onoff-track { background: var(--color-switch-on); }
.switch-input:checked + .switch::before, .onoff input:checked + .onoff-track::before { left: 38px; background: var(--color-primary); }
.switch-input:checked + .switch::after { content: "YES"; left: 6px; color: var(--color-switch-on-ink); }
.onoff input:checked + .onoff-track::after { content: "ON"; left: 9px; color: var(--color-switch-on-ink); }
.switch-input:focus-visible + .switch, .onoff input:focus-visible + .onoff-track { outline: var(--focus); outline-offset: 2px; }
.switch-input:disabled + .switch { opacity: .5; }
.onoff { display: inline-flex; margin: 5px 0 0 20px; cursor: pointer; }
.box-head .box-switch { margin: 4px 4px 0 0; }
.onoff input:disabled + .onoff-track { opacity: .6; cursor: not-allowed; }
/* Web data collection turned off: the forms stay listed, dimmed. */
.box.is-off .item-list { opacity: .55; }
.web-off-note { margin: 10px; }
.switch-label { font-weight: 700; font-size: 16px; }
.switch-label small { display: block; font-weight: 400; color: var(--color-text-muted); font-size: 12px; }
.reveal { display: grid; grid-template-rows: 0fr; opacity: 0; transition: grid-template-rows .24s var(--ease), opacity .2s; }
.reveal > .reveal-inner { overflow: hidden; min-height: 0; visibility: hidden; transition: visibility 0s .24s; }
.reveal.open { grid-template-rows: 1fr; opacity: 1; }
.reveal.open > .reveal-inner { visibility: visible; transition: visibility 0s; }
.reveal-pad { padding: 8px 0 8px 72px; }
.pick-list { border: 1px solid var(--color-divider); border-radius: var(--radius-md); max-height: 220px; overflow: auto; background: var(--color-surface); }
.pick-list label { display: flex; align-items: center; gap: 10px; padding: 10px 15px; border-bottom: 1px solid var(--color-divider); font-size: 16px; cursor: pointer; }
.pick-list label:last-child { border-bottom: none; }
.pick-list label:hover { background: var(--color-surface-sunken); }
.pick-empty { padding: 12px; font-size: 14px; color: var(--color-text-muted); }

/* find-in-list (Search) */
.findbar { display: none; align-items: center; gap: 6px; padding: 10px; background: var(--color-surface-muted);
  border-top: 1px solid var(--color-divider); flex-wrap: wrap; }
.findbar.open { display: flex; }
.findbar .find-input { position: relative; flex: 1 1 260px; min-width: 0; }
.findbar .find-input .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--color-text-muted); width: 14px; height: 14px; }
.findbar input { width: 100%; padding-left: 32px; }
.find-status { font-size: 14px; color: var(--color-primary); min-width: 130px; }
.find-status.none { color: var(--color-danger-solid); }

/* organize wizard */
.organize-list { max-height: 280px; overflow: auto; border: 1px solid var(--color-divider); border-radius: var(--radius-md); margin: 4px 0 12px; background: var(--color-surface); }
.organize-item { display: flex; align-items: center; gap: 10px; padding: 10px 15px; font-size: 16px; border-bottom: 1px solid var(--color-divider); cursor: pointer; }
.organize-item:last-child { border-bottom: none; }
.organize-item:hover { background: var(--color-surface-sunken); }
.organize-item input { margin: 0; }
.wizard-step[hidden] { display: none; }
.step-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 6px; }

/* ---- 9. feedback ------------------------------------------------------- */
.notice { display: flex; align-items: flex-start; gap: 10px; border: 1px solid var(--color-warning-border);
  background: var(--color-warning-bg); color: var(--color-warning); border-radius: var(--radius-sm);
  padding: 10px 15px; font-size: 16px; margin: 0 20px 15px; }
.notice .ic { width: 18px; height: 18px; margin-top: 2px; --ic-knock: var(--color-warning-bg); }
.notice.ok { border-color: var(--color-success-border); background: var(--color-success-bg); color: var(--color-success); }
.notice.ok .ic { --ic-knock: var(--color-success-bg); }
.notice.err { border-color: var(--color-danger-border); background: var(--color-danger-bg); color: var(--color-danger); }
.notice.err .ic { --ic-knock: var(--color-danger-bg); }
.notice .grow { flex: 1; min-width: 0; }
.alert-ok { background: var(--color-success-bg); border: 1px solid var(--color-success-border); border-radius: var(--radius-sm); padding: 15px; font-size: 16px; }
.alert-ok .ic { --ic-knock: var(--color-success-bg); }

.is-busy { position: relative; }
.is-busy > * { opacity: .5; pointer-events: none; transition: opacity .15s; }
.is-busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 30px; height: 30px; margin: -15px 0 0 -15px;
  border-radius: 50%; border: 3px solid var(--color-primary-tint-2); border-top-color: var(--color-primary); animation: jr-spin .8s linear infinite; }
.is-refreshing { opacity: .1; transition: opacity .2s; pointer-events: none; }

/* modal / dialog: blue header, a large status icon beside the message */
.modal-overlay { position: fixed; inset: 0; z-index: 100; background: var(--color-scrim); display: flex;
  align-items: flex-start; justify-content: center; padding: 30px 10px; overflow-y: auto;
  animation: jr-fade .15s ease-out; }
.modal { background: var(--color-surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-modal);
  width: 100%; max-width: 600px; overflow: hidden; animation: jr-zoom .18s var(--ease); }
.modal.sm { max-width: 520px; }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 15px; background: var(--color-primary); color: var(--color-text-on-primary); }
.modal-head .ic { --ic-knock: var(--color-primary); }
.modal-head h3 { margin: 0; font-size: 18px; font-weight: 500; flex: 1; color: var(--color-text-on-primary); line-height: 1.42857; }
.modal-close { display: inline-grid; place-items: center; width: 30px; height: 30px; border: none; background: none;
  color: var(--color-text-on-primary); opacity: .85; font-size: 22px; line-height: 1; cursor: pointer; border-radius: var(--radius-sm); }
.modal-close:hover { opacity: 1; }
.modal-body { padding: 15px; }
.modal-msg { display: grid; grid-template-columns: 80px minmax(0,1fr); gap: 15px; align-items: start; }
.modal-msg p { margin: 0 0 10px; }
.status-ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; color: var(--color-text-on-danger); }
.status-ico .ic { width: 34px; height: 34px; }
.status-ico.error { background: var(--color-danger-solid); --ic-knock: var(--color-danger-solid); }
.status-ico.warning { background: var(--color-warning-solid); color: var(--color-text-on-warning); --ic-knock: var(--color-warning-solid); }
.status-ico.success { background: var(--color-secondary); color: var(--on-success); --ic-knock: var(--color-secondary); }
.status-ico .ic { --ic-knock: inherit; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; padding: 15px;
  border-top: 1px solid var(--color-divider); background: var(--color-surface); }
.modal-foot .btn { padding: 6px 30px; }
.modal-foot.split { justify-content: space-between; }
@keyframes jr-fade { from { opacity: 0; } }
@keyframes jr-zoom { from { opacity: 0; transform: scale(.96); } }

/* ---- 10. data ---------------------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.box-body > .tiles:last-child { margin-bottom: 0; }
.tile { display: block; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface);
  padding: 14px 16px; min-width: 0; color: inherit; text-decoration: none; transition: border-color .12s, box-shadow .12s; }
a.tile:hover { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); text-decoration: none; color: inherit; }
.tile .num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.tile .label { color: var(--color-text-muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.tile.critical .num { color: var(--color-danger); }

/* position: the box that scrolls holds what is positioned inside it (a
   screen-reader-only label), so nothing in a wide table widens the page */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th { text-align: left; font-weight: 700; color: var(--color-text); padding: 9px 10px; border-bottom: 2px solid var(--color-border); font-size: 13px; white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--color-divider); vertical-align: top; }
tr:hover td { background: var(--color-surface-sunken); }
/* Quality-check settings' "Which question holds what" (hfc_configure.html):
   on a phone each row is a stack -- what it is for, the question picker at
   full width, what it drives -- instead of three columns that squeeze the
   picker to a few letters. */
@media (max-width: 600px) {
  table.field-map, table.field-map tbody, table.field-map tr, table.field-map td { display: block; width: auto; }
  table.field-map thead { display: none; }
  table.field-map tr { padding: 10px 0; border-bottom: 1px solid var(--color-divider); }
  table.field-map td { padding: 3px 0; border-bottom: 0; }
  table.field-map tr:hover td { background: none; }
}

.sev { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; }
.sev .ic { width: 12px; height: 12px; }
.sev-info { color: var(--color-info); background: var(--color-info-bg); }
.sev-warning { color: var(--color-warning); background: var(--color-warning-bg); }
.sev-warning .ic { --ic-knock: var(--color-warning-bg); }
.sev-critical { color: var(--color-danger); background: var(--color-danger-bg); }
.pill { display: inline-block; padding: 1px 8px; border-radius: var(--radius-sm); background: var(--color-primary-tint);
  color: var(--color-primary); font-size: 12px; font-weight: 700; }
.badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 700; }
.badge.brand { color: var(--color-secondary-ink); background: var(--color-secondary-tint); }
.bar { background: var(--color-divider); border-radius: 3px; height: 9px; min-width: 140px; }
.bar > div { background: var(--color-primary); border-radius: 3px; height: 9px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.empty { color: var(--color-text-muted); text-align: center; padding: 22px 0; }
.empty-state { text-align: center; padding: 32px 16px; }
.empty-state .empty-ico { color: var(--color-text-muted); margin-bottom: 6px; }
.empty-state .empty-ico .ic { width: 40px; height: 40px; }
.empty-state h3 { margin: 6px 0; font-size: 17px; font-weight: 600; }
.empty-state p { margin: 0 auto 15px; color: var(--color-text-muted); font-size: 16px; max-width: 520px; line-height: 1.42857; }
.empty-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.formfilter { display: none; }
.upload-attach { display: block; margin: 10px 0 6px; font-size: 13px; }

/* workflow step cards (Discover) */
.step-card { display: flex; flex-direction: column; border: 1px solid var(--color-border); border-radius: var(--radius-md);
  background: var(--color-surface); overflow: hidden; min-width: 0; color: inherit; text-decoration: none; transition: border-color .12s, box-shadow .12s; }
.step-card:hover { border-color: var(--color-primary); box-shadow: 0 0 0 1px var(--color-primary); text-decoration: none; color: inherit; }
.step-card .step-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--color-surface-muted); font-weight: 600; font-size: 16px; }
.step-card .step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--color-primary); color: var(--color-text-on-primary); display: grid; place-items: center; font-size: 13px; font-weight: 700; flex: 0 0 auto; }
.step-card .step-body { padding: 12px 14px 14px; font-size: 14px; color: var(--color-text-secondary); flex: 1; }
.step-card .step-go { padding: 0 14px 14px; font-size: 14px; color: var(--color-primary); font-weight: 600; }

/* daily submissions chart (Monitor > Submission statistics) */
.chart-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 0 0 10px; }
.chart-head .spacer { flex: 1; }
.chart-title { margin: 0; font-size: 16px; font-weight: 500; }
.chart-period { width: auto; height: 34px; font-size: 14px; }
.chart-scroll { position: relative; overflow-x: auto; }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-note { margin: 6px 0 0; font-size: 13px; color: var(--color-text-muted); }
.chart-downloads { display: inline-flex; flex-wrap: wrap; gap: 6px; }
/* On the page the chart takes the theme's colours; its SVG attributes (the
   light chart) are what its PNG and SVG keep (partials/daily_chart.html). */
.chart-svg .c-bg { fill: var(--chart-bg); }
.chart-svg .c-grid { stroke: var(--chart-grid); }
.chart-svg .c-axis { stroke: var(--chart-axis); }
.chart-svg .c-label { fill: var(--chart-label); }
.chart-svg .c-legend { fill: var(--chart-legend); }
.chart-svg .c-1 { --c: var(--chart-1); } .chart-svg .c-2 { --c: var(--chart-2); }
.chart-svg .c-3 { --c: var(--chart-3); } .chart-svg .c-4 { --c: var(--chart-4); }
.chart-svg .c-5 { --c: var(--chart-5); } .chart-svg .c-6 { --c: var(--chart-6); }
.chart-svg .c-7 { --c: var(--chart-7); } .chart-svg .c-8 { --c: var(--chart-8); }
.chart-svg .c-9 { --c: var(--chart-9); } .chart-svg .c-10 { --c: var(--chart-10); }
.chart-svg .c-line { stroke: var(--c); }
.chart-svg .c-dot { fill: var(--c); }

/* ---- 11. Data Exporter (new tab) --------------------------------------- */
.xp-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.xp-head h1 { flex: 1 1 260px; min-width: 0; margin: 0; font-size: 22px; overflow-wrap: anywhere; }   /* a line of its own on a phone */
.xp-head .xp-kind { display: block; font-size: 13px; font-weight: 700; color: var(--color-primary); text-transform: uppercase; letter-spacing: .05em; }
.xp-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.xp-stage { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 48px 20px; flex-wrap: wrap; text-align: left; }
.xp-status { min-width: 0; max-width: 420px; }
.xp-status .xp-line { font-size: 17px; color: var(--color-primary); margin: 0 0 4px; }
.xp-status .xp-sub { font-size: 14px; color: var(--color-secondary-ink); font-weight: 600; margin: 0; }
.xp-status .xp-detail { font-size: 13px; color: var(--color-text-muted); margin: 6px 0 0; }
.xp-ring { position: relative; width: 96px; height: 96px; flex: 0 0 auto; }
.xp-ring svg { width: 96px; height: 96px; transform: rotate(-90deg); }
.xp-ring .track { stroke: var(--color-divider); }
.xp-ring .arc { stroke: var(--color-primary); transition: stroke-dashoffset .2s linear; }
.xp-ring.indeterminate svg { animation: jr-spin 1.1s linear infinite; }
.xp-ring .pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 18px; font-weight: 700; color: var(--color-secondary-ink); }
.xp-files { list-style: none; margin: 0; padding: 0; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }
.xp-files li { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 12px 14px; border-bottom: 1px solid var(--color-divider); min-width: 0; }
.xp-files li:last-child { border-bottom: none; }
.xp-files .ic { color: var(--color-primary); width: 20px; height: 20px; }
.xp-files a { font-weight: 600; flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }   /* the size wraps below it, never squeezes it */
.xp-files .fsize { font-size: 12.5px; color: var(--color-text-muted); }
.xp-files-head { background: var(--color-surface-muted); font-weight: 700; font-size: 13.5px; }
.xp-other { display: flex; flex-wrap: wrap; gap: 8px; }
.xp-other .btn { max-width: 100%; white-space: normal; text-align: left; }   /* a long name wraps inside its button */
.xp-error { text-align: center; padding: 36px 16px; }
.xp-error p { max-width: 520px; margin: 0 auto 16px; }

/* ---- 12. form designer ------------------------------------------------ */
/* The Form Designer (Edit and Test views) is styled in tester.css. */

/* ---- 13. responsive ---------------------------------------------------- */
/* SurveyCTO's Bootstrap-3 steps: a 1170 / 970 / 750px container, fluid below
   768px, where the tab strip becomes a menu button and a section label. Type
   does not scale down; titles wrap. */
.userbox .caret { display: inline-block; width: 0; height: 0; margin-left: 2px; border-top: 4px solid;
  border-left: 4px solid transparent; border-right: 4px solid transparent; }
.userbox summary .ic { --ic-knock: var(--color-shell); }
@media (min-width: 992px) {
  .tab-crumb.on { display: block; }
}
@media (max-width: 1199px) {
  :root { --container: 970px; }
}
@media (max-width: 991px) {
  :root { --container: 750px; }
  .tab-crumb, .tab-crumb.on { display: none; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabs { padding-left: 15px; }
  .tab { padding: 10px 18px 10px 12px; }
  .ws-name { max-width: 160px; }
  /* card actions leave little room here: wrap the title, never clip it */
  .item-title { white-space: normal; overflow-wrap: anywhere; min-width: 140px; }
}
@media (max-width: 767px) {
  .chart-svg { min-width: 640px; }   /* readable text; the chart scrolls in its box */
  :root { --container: none; }
  .appbar { position: sticky; }
  :root:has(.appbar) { scroll-padding-top: 84px; }
  .topbar { height: auto; min-height: 50px; padding: 0 10px 0 5px; flex-wrap: wrap; }
  .wordmark span { display: none; }
  .m-section { display: block; font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--color-text-muted); padding: 0 15px 8px; line-height: 1.35; overflow-wrap: anywhere; }
  .ws-name { max-width: 40vw; }
  select.project-switch { max-width: 44vw; }
  .userbox, .hdr-ico, .hdr-switch { display: none; }
  .nav-toggle { display: inline-grid; place-items: center; width: 44px; height: 40px; margin: 5px 0; border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md); background: transparent; color: var(--color-text-muted); cursor: pointer; padding: 0; }
  .nav-toggle[aria-expanded="true"] { background: var(--color-hover); color: var(--color-text); }
  .nav-toggle .ic { width: 20px; height: 20px; }
  .tabs { display: none; }
  .mobile-nav { display: none; border-top: 1px solid var(--color-divider); padding: 5px 0; background: var(--color-shell); max-height: calc(100vh - 60px); overflow-y: auto; }
  .mobile-nav.open { display: block; }
  .mobile-nav a, .mobile-nav button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; padding: 10px 15px;
    font: inherit; font-size: 16px; color: var(--color-primary); text-decoration: none; background: none; border: none; text-align: left; cursor: pointer; }
  .mobile-nav a .n { display: none; }
  .mobile-nav a.active { background: var(--color-hover); color: var(--color-text); }
  .mobile-nav hr { border: none; border-top: 1px solid var(--color-divider); margin: 5px 0; }
  .mobile-nav .who { padding: 8px 15px; font-size: 14px; color: var(--color-text-muted); overflow-wrap: anywhere; }
  main.container { padding: 20px 15px 40px; }
  .box { margin: 15px 10px; }
  .notice { margin: 0 10px 15px; }
  .box-toolbar, .subtoolbar { padding: 10px 5px; }
  .toolbar-note { flex-basis: 100%; padding: 4px 6px; }
  .help-grid { grid-template-columns: 1fr; }
  .item-head { flex-wrap: wrap; gap: 4px; }
  .item-title { white-space: normal; flex-basis: 100%; }
  .acts { justify-content: flex-start; display: grid; grid-template-columns: repeat(4, 60px); width: 100%; }
  .dataset-row { margin-left: 10px; }
  .panel { margin: 5px 5px 10px; padding: 10px; }
  .panel.strip { justify-content: flex-start; display: grid; grid-template-columns: repeat(auto-fill, 60px); }
  .option-row { flex-direction: column; gap: 6px; margin: 20px 0; }
  .onoff { margin-left: 0; }
  .add-grid { flex-direction: column; align-items: stretch; }
  .add-tile { justify-content: center; }
  .well { padding: 10px; margin: 10px 0; }
  .dropzone { min-height: 170px; padding: 20px 12px; }
  .dz-actions { flex-direction: column; width: 100%; max-width: 180px; }
  .dz-actions .btn { width: 100%; white-space: normal; }
  .reveal-pad { padding-left: 0; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .num { font-size: 22px; }
  .findbar { padding: 10px 5px; }
  .find-status { min-width: 0; flex-basis: 100%; }
  .modal-overlay { padding: 12px; }
  .modal { max-width: none; }
  .modal-msg { grid-template-columns: 52px minmax(0,1fr); gap: 12px; }
  .status-ico { width: 48px; height: 48px; }
  .modal-foot .btn { flex: 1 1 auto; }
  .ff-item { flex-wrap: wrap; }
  .ff-actor { flex-basis: 100%; padding-left: 48px; }
  .site-foot-inner { padding: 0; }
  .xp-stage { padding: 28px 8px; gap: 18px; flex-direction: column; text-align: center; }
  table { font-size: 14px; }
}
@media (max-width: 767px) {
  /* phones: every control at least 40px tall */
  :root { --control-h: 40px; --control-h-sm: 40px; }
  .tool, .act { min-height: 44px; }
  .box-head .box-ctl { height: 40px; }
  .icon-btn, .folder-caret, .add-close { width: 40px; height: 40px; }
  .add-marker { width: 48px; height: 40px; }
  .chart-period, select.project-switch { min-height: 40px; height: auto; }
  .schema-details > summary, details > summary.more { min-height: 40px; display: flex; align-items: center; }
  .pager a, .pager button { min-height: 40px; display: inline-flex; align-items: center; }
}
@media (max-width: 479px) {
  .tool { width: 25%; min-width: 0; }
  .xp-tools .btn { flex: 1 1 auto; }
  /* a label cell sized for a desktop (style="width:230px": Server name,
     Address devices connect to, a health check) would leave its value a
     few letters a line: on a phone the table shares the width by content */
  td[style*="width:"], th[style*="width:"] { width: auto !important; }
}
@media (pointer: coarse) {
  .icon-btn { width: 44px; height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}


/* ---- Design > Attachments: packages and previews ------------------------ */
.att-package { border: 1px solid var(--color-border); border-radius: var(--radius-md);
  margin: 10px 0; background: var(--color-surface); }
.att-package-head { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 10px 12px; flex-wrap: wrap; }
.att-package-head .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.att-gallery-slot { padding: 0 12px 12px; }
.att-gallery-head { display: flex; justify-content: space-between; align-items: center;
  gap: 10px; font-size: 13px; color: var(--color-text-muted); margin: 8px 0; flex-wrap: wrap; }
.att-pager { display: flex; gap: 6px; }
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.att-card { margin: 0; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--color-surface); display: flex; flex-direction: column; }
/* Signatures and drawings are strokes on a transparent background: white behind them in both themes. */
.att-card img { width: 100%; height: 120px; object-fit: contain; background: var(--media-backdrop); display: block; }
.att-card audio, .att-card video { width: 100%; }
.att-card .att-file { display: flex; height: 120px; align-items: center; justify-content: center;
  color: var(--color-text-muted); }
.att-card figcaption { font-size: 11px; padding: 4px 6px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; color: var(--color-text-muted); }

/* ---- schema details: column names folded away ------------------------- */
.schema-details { margin-top: 4px; font-size: 13px; }
.schema-details > summary { cursor: pointer; color: var(--color-text-muted); }
.schema-cols { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; max-height: 180px; overflow: auto; }
.schema-cols .mono { background: var(--color-primary-tint); border-radius: var(--radius-sm); padding: 0 6px; font-size: 12px; }

/* ---- Monitor > Submissions and a form's Data Explorer (DSX-02) -------- */
.explore-filters { margin-bottom: 4px; }
.explore-filters > label { flex: 1 1 150px; }
.explore-actions { display: flex; gap: 8px; align-items: flex-end; }
.explore-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0 8px; font-size: 13px; }
.explore-bar .spacer { flex: 1; }
.explore-sep { width: 1px; align-self: stretch; background: var(--color-border); margin: 0 4px; }
.explore-jump { display: inline-flex; gap: 6px; align-items: center; font-weight: 400; }
.explore-jump select { width: auto; max-width: 22em; }
.explore-table th .col-label { display: block; max-width: 18em; overflow: hidden; text-overflow: ellipsis; }
.explore-table th .col-name { display: block; font-weight: 400; font-size: 11px; }
.explore-table td { white-space: nowrap; max-width: 22em; overflow: hidden; text-overflow: ellipsis; }
.explore-table .file-link { display: inline-flex; align-items: center; gap: 4px; max-width: 14em; }
.explore-table .file-link .file-name { overflow: hidden; text-overflow: ellipsis; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin: 14px 0; font-size: 13px; }

/* ------------------------------------------------------------- print --- */
/* Paper gets the page, not the console around it: no bar, tabs, menus or
   footer, and nothing sticks to the top of every printed sheet. */
@media print {
  .appbar, .mobile-nav, .site-foot, .nav-toggle, .usermenu, .announcements { display: none !important; }
  .box { box-shadow: none; break-inside: avoid; }
}
