/* Softico Archive theme (T10c)
   Soft graphite dark palette + light tokens.
   html[data-theme=light|dark] switches the set. Preference "system" is
   resolved to light|dark before first paint (see document-start). */

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/static/fonts/figtree-latin-400-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/static/fonts/figtree-latin-600-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/static/fonts/figtree-latin-700-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url("/static/fonts/figtree-latin-800-normal.woff2") format("woff2");
}

:root,
html[data-theme="light"] {
  --bg: #eef1f5;
  --brand-gap: 0.6rem;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --text: #0f1c2e;
  --heading: var(--text);
  --muted: #5b6675;
  --primary: #0f1c2e;
  --on-primary: #ffffff;
  --accent: #3a8fd9;
  --accent-hover: var(--accent);
  --border: #dde3ea;
  --border-strong: #9ba6b4;
  --on-accent: var(--on-primary);
  --row-hover: #f4f7fa;
  --row-selected: #e8eef5;
  --link: #3a8fd9;
  --danger-bg: #fef2f2;
  --danger-text: #991b1b;
  --danger-border: #fecaca;
  --warn-bg: #fff8e6;
  --warn-text: #8a5a00;
  --warn-border: #f0d39b;
  --ok-text: #166534;
  --shadow: 0 10px 25px -5px rgba(15, 28, 46, 0.08), 0 8px 10px -6px rgba(15, 28, 46, 0.06);
  --focus-ring: 0 0 0 3px var(--accent);
  --logo-chip: transparent;
  --header-fg: var(--primary);
  --nav-fg: var(--primary);
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #141517;
  --surface: #1c1d21;
  --surface-2: #24252a;
  --text: #eef0f3;
  --heading: var(--text);
  --muted: #a3a8b2;
  --primary: #5aa7e6;
  --on-primary: #0e1116;
  --accent: #5aa7e6;
  --accent-hover: var(--accent);
  --border: #30323a;
  --border-strong: #5f6471;
  --on-accent: var(--on-primary);
  --row-hover: #25272d;
  --row-selected: #1d2a37;
  --link: #7cb8f0;
  --danger-bg: #3b1d1d;
  --danger-text: #fecaca;
  --danger-border: #7f1d1d;
  --warn-bg: #2e2611;
  --warn-text: #f5cf7a;
  --warn-border: #6b5313;
  --ok-text: #86efac;
  --shadow: none;
  --focus-ring: 0 0 0 3px var(--accent);
  --logo-chip: #ffffff;
  --header-fg: var(--text);
  --nav-fg: var(--muted);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Figtree", system-ui, sans-serif;
  font-weight: 400;
  font-size: 1rem;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-weight: 700;
  color: var(--heading);
  letter-spacing: -0.03em;
  line-height: 1.15;
}

/* 800 only for large page headings (>=24px) */
h1.page-title,
.page-heading {
  font-weight: 800;
  font-size: 1.5rem;
}

a {
  color: var(--accent);
}
html[data-theme="dark"] a {
  color: var(--link);
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: var(--focus-ring);
}

/* Header - surface, not the old dark-blue bar */
.app-header {
  background: var(--surface);
  color: var(--header-fg);
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* gap between header logo and app name (A4) */
.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--brand-gap, 0.6rem);
  text-decoration: none;
  flex-shrink: 0;
}

.brand img {
  height: 32px;
  width: auto;
  max-height: 32px;
}

html[data-theme="dark"] .brand img.logo-on-chip {
  background: var(--logo-chip);
  border-radius: 10px;
  padding: 4px 8px;
}

.logo-dark { display: none; }
html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: block; }

.entity-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.entity-nav a {
  color: var(--nav-fg);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
}

.entity-nav a:hover {
  background: var(--surface-2);
}

.entity-nav a.is-active {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

/* Soft graphite nav: muted inactive, surface-2 active pill (dark only) */
html[data-theme="dark"] .entity-nav a {
  color: var(--muted);
  background: transparent;
}
html[data-theme="dark"] .entity-nav a:hover {
  color: var(--text);
  background: transparent;
}
html[data-theme="dark"] .entity-nav a.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.app-header .spacer { flex: 1; }

.user-menu {
  position: relative;
}

.user-menu > summary {
  list-style: none;
  cursor: pointer;
  font-weight: 600;
  color: var(--header-fg);
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.user-menu > summary::-webkit-details-marker { display: none; }

.user-menu[open] > summary {
  background: var(--surface-2);
}

html[data-theme="dark"] .user-menu > summary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}
html[data-theme="dark"] .user-menu[open] > summary {
  background: var(--surface-2);
}

.user-menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  min-width: 12rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  z-index: 30;
}

.user-menu-panel a,
.user-menu-panel button {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  color: var(--text);
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.85rem;
  font: inherit;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
}

.user-menu-panel a:hover,
.user-menu-panel button:hover {
  background: var(--row-hover);
}

.user-menu-panel form { margin: 0; }

/* Unified button system (T10e) — filled variants; .btn-save after .btn so it wins */
.btn,
button.btn,
a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  box-sizing: border-box;
  height: 36px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  width: fit-content;
  color: var(--text);
  background: transparent;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, opacity 0.12s ease;
}

.btn:disabled,
button.btn:disabled,
a.btn.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary,
.btn.btn-primary,
button.btn-primary,
.login-card button[type="submit"],
.profile-card button[type="submit"] {
  background: var(--primary);
  color: var(--on-primary);
  border-color: var(--primary);
}
.btn-primary:hover:not(:disabled),
.btn.btn-primary:hover:not(:disabled),
button.btn-primary:hover:not(:disabled),
.login-card button[type="submit"]:hover,
.profile-card button[type="submit"]:hover {
  background: var(--primary);
  color: var(--on-primary);
  filter: brightness(1.05);
}

/* Secondary filled (light default) */
.btn-secondary,
.btn.btn-secondary,
button.btn-secondary,
a.btn-secondary {
  background: #ffffff;
  border: 1px solid #c9d1db;
  color: #0f1c2e;
}
.btn-secondary:hover:not(:disabled),
.btn.btn-secondary:hover:not(:disabled),
button.btn-secondary:hover:not(:disabled),
a.btn-secondary:hover:not(.is-disabled),
.btn-secondary:focus-visible:not(:disabled),
.btn.btn-secondary:focus-visible:not(:disabled) {
  background: #eef1f5;
  border-color: #c9d1db;
  color: #0f1c2e;
  filter: none;
}
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn.btn-secondary,
html[data-theme="dark"] button.btn-secondary,
html[data-theme="dark"] a.btn-secondary {
  background: #2a2c33;
  border: 1px solid #464955;
  color: #eef0f3;
}
html[data-theme="dark"] .btn-secondary:hover:not(:disabled),
html[data-theme="dark"] .btn.btn-secondary:hover:not(:disabled),
html[data-theme="dark"] button.btn-secondary:hover:not(:disabled),
html[data-theme="dark"] a.btn-secondary:hover:not(.is-disabled),
html[data-theme="dark"] .btn-secondary:focus-visible:not(:disabled),
html[data-theme="dark"] .btn.btn-secondary:focus-visible:not(:disabled) {
  background: #33363e;
  border-color: #464955;
  color: #eef0f3;
  filter: none;
}

/* Danger filled when enabled (light default) */
.btn-danger,
.btn.btn-danger,
button.btn-danger {
  background: #fdecec;
  border: 1px solid #d9534f;
  color: #b3261e;
}
.btn-danger:hover:not(:disabled),
.btn.btn-danger:hover:not(:disabled),
button.btn-danger:hover:not(:disabled),
.btn-danger:focus-visible:not(:disabled),
.btn.btn-danger:focus-visible:not(:disabled) {
  background: #d9534f;
  color: #ffffff;
  border-color: #d9534f;
  filter: none;
}
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn.btn-danger,
html[data-theme="dark"] button.btn-danger {
  background: #3a2324;
  border: 1px solid #d9534f;
  color: #ff8a85;
}
html[data-theme="dark"] .btn-danger:hover:not(:disabled),
html[data-theme="dark"] .btn.btn-danger:hover:not(:disabled),
html[data-theme="dark"] button.btn-danger:hover:not(:disabled),
html[data-theme="dark"] .btn-danger:focus-visible:not(:disabled),
html[data-theme="dark"] .btn.btn-danger:focus-visible:not(:disabled) {
  background: #d9534f;
  color: #ffffff;
  border-color: #d9534f;
  filter: none;
}
.btn-danger:disabled,
.btn.btn-danger:disabled,
button.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Save — AFTER .btn / primary / secondary; compound selectors beat button.btn */
.btn-save,
.btn.btn-save,
button.btn-save,
a.btn-save {
  background: #2f9e62;
  color: #ffffff;
  border-color: #2f9e62;
}
.btn-save:hover:not(:disabled),
.btn.btn-save:hover:not(:disabled),
button.btn-save:hover:not(:disabled),
.btn-save:focus-visible:not(:disabled),
.btn.btn-save:focus-visible:not(:disabled) {
  background: #278553;
  border-color: #278553;
  color: #ffffff;
  filter: none;
}

/* Icon buttons match secondary fill */
.btn-icon,
.btn.btn-icon,
button.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  background: #ffffff;
  border: 1px solid #c9d1db;
  color: #0f1c2e;
}
.btn-icon:hover:not(:disabled),
.btn.btn-icon:hover:not(:disabled),
button.btn-icon:hover:not(:disabled) {
  background: #eef1f5;
  border-color: #c9d1db;
  color: #0f1c2e;
  filter: none;
}
html[data-theme="dark"] .btn-icon,
html[data-theme="dark"] .btn.btn-icon,
html[data-theme="dark"] button.btn-icon {
  background: #2a2c33;
  border: 1px solid #464955;
  color: #eef0f3;
}
html[data-theme="dark"] .btn-icon:hover:not(:disabled),
html[data-theme="dark"] .btn.btn-icon:hover:not(:disabled),
html[data-theme="dark"] button.btn-icon:hover:not(:disabled) {
  background: #33363e;
  border-color: #464955;
  color: #eef0f3;
  filter: none;
}

.btn-sm,
.btn.btn-sm,
.btn-small,
.btn.btn-small {
  height: 30px;
  padding: 0 12px;
  font-size: 13px;
}
.btn-icon.btn-sm,
.btn-icon.btn-small,
.btn.btn-icon.btn-sm,
.btn.btn-icon.btn-small {
  width: 32px;
  height: 32px;
  padding: 0;
  font-size: 13px;
}

/* Cards */
.card,
.page-card,
.login-card,
.profile-card,
.table-wrap,
.search-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.page-card {
  max-width: 720px;
  margin: 2rem auto;
  padding: 1.5rem 1.75rem;
}

.page-card.narrow { max-width: 560px; }

/* Record detail: use more horizontal space than generic page-card (720px) */
.page-card.record-detail {
  max-width: min(1120px, 96vw);
  width: 100%;
  padding: 1.15rem 1.35rem 1.35rem;
  margin: 1.25rem auto;
}

.page-card h1,
.profile-card h1,
.login-card h1,
.search-panel h2,
.results-meta h1 {
  margin-top: 0;
  font-size: 1.4rem;
  font-weight: 700;
}

.search-panel h2 {
  font-size: 1.05rem;
}

.results-meta h1 {
  font-size: 1.35rem;
}

.meta, .sub, .count, .note, .pager-info, .empty {
  color: var(--muted);
}

.note {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 1rem 1.1rem;
  color: var(--text);
}

a.back {
  display: inline-block;
  margin-top: 1.25rem;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

a.back:hover { text-decoration: underline; }

dl.session {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1rem;
}

dl.session dt { font-weight: 600; color: var(--muted); }
dl.session dd { margin: 0; }

/* Login (L1) - follows the light/dark theme (anonymous visitors: prefers-color-scheme).
   Calm, slowly moving brand-blue gradient + large blurred shapes, CSS only.
   The card is opaque, so text contrast does not depend on the background. */
.login-body {
  --login-bg-1: #e6f0fb;
  --login-bg-2: #cfe2f6;
  --login-bg-3: #f2f6fb;
  --login-shape-1: rgba(58, 143, 217, 0.42);
  --login-shape-2: rgba(23, 70, 135, 0.20);
  --login-shape-3: rgba(125, 190, 240, 0.38);
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-x: hidden;
  background-color: var(--login-bg-2);
  background-image: linear-gradient(135deg, var(--login-bg-1) 0%, var(--login-bg-2) 50%, var(--login-bg-3) 100%);
  background-size: 200% 200%;
  animation: login-gradient 45s ease-in-out infinite alternate;
}

html[data-theme="dark"] .login-body {
  --login-bg-1: #0b1524;
  --login-bg-2: #0f2238;
  --login-bg-3: #131518;
  --login-shape-1: rgba(90, 167, 230, 0.26);
  --login-shape-2: rgba(28, 88, 170, 0.30);
  --login-shape-3: rgba(58, 143, 217, 0.16);
}

.login-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.login-bg span {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  will-change: transform;
  animation: login-drift 60s ease-in-out infinite alternate;
}

.login-bg span:nth-child(1) {
  width: 60vmax;
  height: 60vmax;
  top: -22vmax;
  left: -16vmax;
  background: radial-gradient(circle, var(--login-shape-1) 0%, transparent 70%);
}

.login-bg span:nth-child(2) {
  width: 55vmax;
  height: 55vmax;
  right: -18vmax;
  bottom: -24vmax;
  background: radial-gradient(circle, var(--login-shape-2) 0%, transparent 70%);
  animation-duration: 75s;
  animation-direction: alternate-reverse;
}

.login-bg span:nth-child(3) {
  width: 36vmax;
  height: 36vmax;
  top: 38%;
  left: 58%;
  background: radial-gradient(circle, var(--login-shape-3) 0%, transparent 70%);
  animation-duration: 90s;
}

@keyframes login-gradient {
  0% { background-position: 0% 40%; }
  100% { background-position: 100% 60%; }
}

@keyframes login-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(4vmax, 3vmax, 0) scale(1.08); }
  100% { transform: translate3d(-3vmax, 5vmax, 0) scale(0.95); }
}

@media (prefers-reduced-motion: reduce) {
  .login-body,
  .login-bg span {
    animation: none;
  }
}

.login-card,
.login-card.card {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.75rem 1.5rem;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 32px rgba(15, 28, 46, 0.14);
}

html[data-theme="dark"] .login-card,
html[data-theme="dark"] .login-card.card {
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.login-card .logo,
.login-card .logo-light,
.login-card .logo-dark,
.login-card .logo-on-chip {
  max-height: 48px;
  height: 48px;
  width: auto;
  margin: 0 auto 1.25rem;
}

/* Dark card: THEME_LOGO_DARK if set (global .logo-light/.logo-dark rules),
   otherwise the light logo on a white chip so it stays readable. */
html[data-theme="dark"] .login-card .logo-on-chip {
  background: var(--logo-chip);
  border-radius: 12px;
  padding: 6px 12px;
}

.login-card h1 {
  text-align: center;
  color: var(--heading);
  font-weight: 700;
}

.login-card .sub {
  text-align: center;
  margin: 0 0 1.5rem;
  color: var(--muted);
}

.login-card label,
.search-panel label,
.profile-card label.field {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0.75rem 0 0.35rem;
  color: var(--heading);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
input[type="number"],
input[type="tel"],
input[type="url"],
input[type="date"],
select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  height: 38px;
  padding: 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}

/* Login inputs/buttons use the theme tokens (same theme as the card). */
.login-card input::placeholder {
  color: var(--muted);
}

.login-card input:focus {
  border-color: var(--accent);
  outline-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent);
}

.login-card button[type="submit"],
.login-card .btn-primary {
  margin-top: 1.25rem;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}

.login-card .login-sso {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  height: auto;
  min-height: 44px;
  padding: 0.7rem;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
  text-decoration: none;
}

.login-card .login-sso svg {
  width: 18px;
  height: 18px;
  flex: none;
}

.login-breakglass {
  margin: 0 0 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
}

.login-lang {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-lang a,
html[data-theme="dark"] .login-lang a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 0.35rem 0.4rem;
  border-radius: 6px;
}

.login-lang a:hover,
html[data-theme="dark"] .login-lang a:hover {
  color: var(--text);
}

.login-lang [aria-current="true"] {
  color: var(--text);
  font-weight: 600;
  padding: 0.35rem 0.4rem;
}

@media (max-width: 480px) {
  .login-body {
    align-items: flex-start;
    padding: 1rem 0.75rem;
  }
  .login-card,
  .login-card.card {
    margin-top: 4vh;
    padding: 1.5rem 1.1rem 1.25rem;
    border-radius: 16px;
  }
  .login-bg span {
    filter: blur(50px);
  }
}

.error {
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
  border-radius: 16px;
  padding: 0.65rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.saved {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0.65rem 0.75rem;
  margin-bottom: 0.75rem;
}

/* Profile */
.profile-card {
  max-width: 520px;
  margin: 2rem auto;
  padding: 1.5rem 1.75rem;
}

.theme-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 1rem 0 1.25rem;
}

.theme-options label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  font-weight: 400;
}

.theme-options input { width: auto; }

/* List */
.layout {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  padding: 1rem 1.25rem 1.5rem;
  min-height: calc(100vh - 64px);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.search-panel {
  width: 300px;
  flex-shrink: 0;
  padding: 1rem 1rem 1.25rem;
  align-self: flex-start;
  position: sticky;
  top: 5rem;
}

.search-panel h2 {
  margin: 0 0 0.85rem;
}

.search-panel input,
.search-panel select {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Date ranges: stack Alkaen / Paattyen vertically */
.date-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
}

.date-row > div {
  min-width: 0;
  width: 100%;
}

.date-row label {
  margin-top: 0.35rem;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--muted);
}

.date-row input[type="date"] {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.btn-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.btn-row button,
.btn-row a.btn { flex: 1; }

.results {
  flex: 1;
  min-width: 0;
}

.results-meta {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.results-meta h1 {
  margin: 0;
}

/* S1c: a wide table scrolls inside its own box; the page never scrolls sideways */
.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

table.records {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.records th,
table.records td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

table.records th {
  background: var(--surface-2);
  color: var(--heading);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

html[data-theme="dark"] table.records th {
  color: var(--muted);
  font-weight: 600;
}

html[data-theme="dark"] table.records td.col-subject,
html[data-theme="dark"] table.records td.col-subject a.row-link {
  color: var(--link);
  font-weight: 600;
}

html[data-theme="dark"] table.records tbody tr.is-selected,
html[data-theme="dark"] table.records tbody tr[aria-selected="true"] {
  background: var(--row-selected);
}

table.records th a {
  color: inherit;
  text-decoration: none;
}

table.records th a:hover { text-decoration: underline; }

table.records th .sort-ind { opacity: 0.7; font-size: 0.75rem; }

table.records tbody tr { cursor: pointer; }

table.records tbody tr:hover { background: var(--row-hover); }

table.records td a.row-link {
  color: inherit;
  text-decoration: none;
  display: block;
}

.empty { padding: 2rem; text-align: center; }

.layout-no-access {
  display: flex;
  min-height: calc(100vh - 4rem);
}

.layout-no-access .results {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-no-access {
  padding: 3rem 1.5rem;
  font-size: 1.05rem;
  max-width: 36rem;
  margin: 0 auto;
  text-align: center;
}


.pager {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.9rem;
  flex-wrap: wrap;
}

.pager a,
.pager span.current {
  display: inline-block;
  min-width: 2rem;
  text-align: center;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
  text-decoration: none;
}

.pager a {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--border);
}

.pager a:hover { border-color: var(--accent); background: var(--row-hover); }

.pager span.current {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}

.pager .pager-info { margin-right: 0.75rem; }

@media (max-width: 800px) {
  .layout { flex-direction: column; }
  .search-panel { width: auto; position: static; }
  .app-header { flex-wrap: wrap; }
}
/* Admin area */
.admin-layout {
  display: flex;
  align-items: stretch;
  gap: 1rem;
  padding: 1rem 1.25rem 1.5rem;
  min-height: calc(100vh - 64px);
}

.admin-nav {
  width: 240px;
  flex-shrink: 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  align-self: flex-start;
  position: sticky;
  top: 5rem;
}

.admin-nav-head h2 {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
}

.admin-back {
  display: inline-block;
  font-size: 0.85rem;
  margin-bottom: 0.85rem;
  color: var(--accent);
  text-decoration: none;
}

.admin-back:hover { text-decoration: underline; }

.admin-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.admin-nav li { margin: 0.15rem 0; }

.admin-nav a {
  display: block;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
}

.admin-nav a:hover { background: var(--row-hover); }

.admin-nav a.is-active {
  background: var(--accent);
  color: var(--on-accent);
}

.admin-main {
  flex: 1;
  min-width: 0;
}

.admin-main h1 { margin-top: 0; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.admin-stat {
  padding: 1rem 1.1rem;
}

.admin-stat-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}

.admin-stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--heading);
  margin-top: 0.25rem;
}

.admin-section {
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.admin-section h2 {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--surface-2);
  color: var(--heading);
}
html[data-theme="dark"] .admin-table th {
  color: var(--muted);
  font-weight: 600;
}

.admin-links {
  margin: 0;
  padding-left: 1.2rem;
}

.admin-links a {
  color: var(--accent);
  text-decoration: none;
}

.admin-links a:hover { text-decoration: underline; }

.muted { color: var(--muted); }

@media (max-width: 800px) {
  .admin-layout { flex-direction: column; }
  .admin-nav { width: auto; position: static; }
}

/* Admin templates (TT2) */
.admin-breadcrumb { margin: 0 0 0.5rem; font-size: 0.9rem; }
.admin-breadcrumb a { color: var(--link); }
.admin-flash {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  line-height: 1.35;
  font-size: 0.92rem;
  transition: opacity 0.28s ease;
}
.admin-flash > .admin-flash-body {
  flex: 1;
  min-width: 0;
}
.admin-flash > .admin-flash-body > p {
  margin: 0;
}
.admin-flash > .admin-flash-body > p + p,
.admin-flash > .admin-flash-body > ul {
  margin-top: 0.35rem;
}
.admin-flash-close {
  flex-shrink: 0;
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
}
.admin-flash-close:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.admin-flash.is-hiding {
  opacity: 0;
}
.admin-flash-ok {
  background: color-mix(in srgb, var(--ok, #1a7f37) 12%, transparent);
  border-color: color-mix(in srgb, var(--ok, #1a7f37) 40%, var(--border));
}
.admin-flash-err {
  background: color-mix(in srgb, var(--danger, #c0392b) 12%, transparent);
  border-color: color-mix(in srgb, var(--danger, #c0392b) 40%, var(--border));
}
.admin-temp-password {
  align-items: flex-start;
  padding: 0.65rem 0.75rem;
}
.admin-badge {
  display: inline-block;
  font-size: 0.8rem;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--row-hover);
  border: 1px solid var(--border);
}
.admin-badge-ok {
  background: color-mix(in srgb, var(--ok, #1a7f37) 15%, transparent);
}
.admin-form { display: flex; flex-direction: column; gap: 0.75rem; max-width: 40rem; }
.admin-form-inline { margin-top: 0.5rem; }
.admin-label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.9rem; }
.admin-label textarea,
.admin-label input[type="file"] {
  font: inherit;
}
.admin-label textarea {
  width: 100%;
  min-height: 8rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}

/* Admin template editor (TT3) */
.tpl-editor-section { overflow: visible; }
.tpl-editor-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr);
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 1199.98px) {
  .tpl-editor-layout { grid-template-columns: minmax(0, 1fr); }
}
.tpl-editor-left,
.tpl-editor-right { min-width: 0; }
.tpl-editor-left > h3:first-child,
.tpl-editor-right > h3:first-child { margin-top: 0; }
.tpl-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  align-items: center;
}
.tpl-status { min-height: 1.25rem; margin-bottom: 0.5rem; font-size: 0.9rem; }
.tpl-status-ok { color: var(--ok, #1a7f37); }
.tpl-status-err { color: var(--danger, #c0392b); }
.tpl-rows { display: flex; flex-direction: column; gap: 0.85rem; }
.tpl-row-editor {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  background: var(--surface-2);
}
.tpl-row-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: 0.55rem;
}
.tpl-row-cols {
  display: grid;
  gap: 0.5rem;
}
.tpl-row-col {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 0.4rem;
  min-height: 3.5rem;
  background: var(--surface-2);
}
.tpl-row-col-label { font-size: 0.75rem; margin-bottom: 0.25rem; }
.tpl-col-list, .tpl-pool {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-height: 2rem;
}
.tpl-pool {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem;
  background: var(--surface-2);
}
.tpl-class-chip {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.65rem;
  background: var(--surface-2);
  cursor: grab;
}
.tpl-class-chip-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: baseline;
}
.tpl-class-chip-head strong {
  color: var(--text);
  font-weight: 600;
}
.tpl-class-code {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.tpl-class-meta {
  font-size: 0.8rem;
  margin: 0.2rem 0 0.35rem;
  color: var(--muted);
}
.tpl-class-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  align-items: center;
}

.tpl-place-select, .tpl-col-select, .tpl-prop-select {
  font: inherit;
  font-size: 0.85rem;
  height: 38px;
  padding: 0 0.55rem;
  border-radius: 10px;
  border: 1px solid #c9d1db;
  background: var(--surface-2);
  color: var(--text);
}
html[data-theme="dark"] .tpl-place-select,
html[data-theme="dark"] .tpl-col-select,
html[data-theme="dark"] .tpl-prop-select {
  border-color: #464955;
}
.tpl-sortable-ghost { opacity: 0.45; }
.tpl-preview-card {
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface-2, var(--card-bg));
}
.tpl-preview-title {
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: var(--heading);
}
.tpl-preview-row {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 0.65rem;
}
.tpl-preview-panel {
  min-width: 0;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  background: var(--surface-2);
}
.tpl-preview-panel.is-collapsed {
  opacity: 0.75;
}
.tpl-preview-panel-title { font-weight: 600; font-size: 0.9rem; color: var(--text); overflow-wrap: anywhere; }
.tpl-preview-col { min-width: 0; }
.tpl-preview-empty { font-size: 0.85rem; padding: 0.35rem; }
.tpl-preview-hint { margin-top: 0.5rem; font-size: 0.85rem; }

/* Record card layout (titles from template) — denser, fuller width */
.record-card-layout { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.55rem; }
.record-card-row {
  display: grid;
  gap: 0.5rem;
  width: 100%;
}
.record-card-col { min-width: 0; }
.record-card-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  width: 100%;
}
.record-card-panel-title {
  margin: 0;
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--heading);
  background: var(--surface-2, transparent);
  border-bottom: 1px solid var(--border);
}
.record-card-panel.is-collapsed .record-card-panel-body { display: none; }
.record-card-panel-body { padding: 0.35rem 0.7rem 0.45rem; min-height: 0.5rem; }
.record-card-empty { margin-top: 1rem; }


/* TT4 field editor */
.fld-editor-section { margin-top: 1rem; }
.fld-editor-root { margin-top: 0.75rem; }
.fld-toolbar { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.5rem; }
.fld-status { min-height: 1.25rem; margin-bottom: 0.35rem; }
.fld-rebuild { margin-bottom: 0.75rem; font-size: 0.9rem; }
.fld-unmapped { margin-bottom: 1rem; }
.fld-unmapped-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.fld-unmapped-item {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.35rem 0.5rem; border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2, var(--card-bg));
}
.fld-class-section { margin: 1rem 0 1.25rem; }
.fld-class-section h4 { margin: 0 0 0.4rem; }
.fld-table { width: 100%; margin-bottom: 0.5rem; }
.fld-table th, .fld-table td { vertical-align: middle; }
.fld-input, .fld-select {
  font: inherit;
  font-size: 0.85rem;
  width: 100%;
  max-width: 12rem;
  height: 38px;
  padding: 0 0.55rem;
  border-radius: 10px;
  border: 1px solid #c9d1db;
  background: var(--surface-2);
  color: var(--text);
}
html[data-theme="dark"] .fld-input,
html[data-theme="dark"] .fld-select {
  border-color: #464955;
}
.fld-drag-handle { cursor: grab; color: var(--muted, #888); user-select: none; width: 1.5rem; }
.fld-order-cell { white-space: nowrap; }
.fld-order-cell .btn { margin-left: 0.15rem; }
.card-inner { padding: 0.5rem 0; }


/* Template class create/rename modal (TT3 fix) */
.tpl-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(15, 28, 46, 0.45);
}
html[data-theme="dark"] .tpl-modal-overlay {
  background: rgba(0, 0, 0, 0.55);
}
.tpl-modal {
  width: min(420px, 100%);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem 1rem;
}
.tpl-modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  color: var(--heading);
}
.tpl-modal-body {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}
.tpl-modal-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.tpl-modal-input {
  width: 100%;
  box-sizing: border-box;
  height: 38px;
  padding: 0 0.55rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}
.tpl-modal-input:focus {
  outline: none;
  box-shadow: var(--focus-ring);
  border-color: var(--accent);
}
.tpl-modal-error {
  min-height: 1rem;
  font-size: 0.85rem;
  color: var(--danger-text, #c0392b);
}
.tpl-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 1rem;
}


/* TT5 record card fields */
.record-detail .record-nav {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.record-nav-back {
  justify-self: start;
}
.record-nav-pages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
}
.record-nav-pos {
  margin: 0 0.15rem;
  font-weight: 600;
  color: var(--muted, #5a6b78);
  font-variant-numeric: tabular-nums;
}
.record-nav-prev.is-disabled,
.record-nav-next.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}
.record-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}
.record-card-heading-copy {
  min-width: 0;
}
.record-card-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-shrink: 0;
}
.record-card-title {
  margin: 0;
  word-break: break-word;
}

.record-card-panel-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--surface-2, transparent);
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  border-bottom: 1px solid var(--border);
}
.record-card-panel-toggle .record-card-panel-title {
  border-bottom: 0;
  flex: 1;
  background: transparent;
}
.record-card-panel-chevron::before {
  content: '▾';
  display: inline-block;
  padding-right: 0.75rem;
  color: var(--muted, #5a6b78);
  transition: transform 0.15s ease;
}
.record-card-panel.is-collapsed .record-card-panel-chevron::before {
  transform: rotate(-90deg);
}
.record-field {
  display: grid;
  grid-template-columns: minmax(5.5rem, 11.5rem) minmax(0, 1fr);
  gap: 0.2rem 0.85rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,.06));
  align-items: start;
}
.record-field:last-child { border-bottom: 0; }
.record-field-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--muted, #5a6b78);
  word-break: break-word;
  line-height: 1.35;
  padding-top: 0.1rem;
}
.record-field-value,
.record-field-value-wrap {
  font-size: 0.95rem;
  word-break: break-word;
  min-width: 0;
  width: 100%;
}
.record-field-text {
  white-space: pre-wrap;
  width: 100%;
}
.record-field-value-wrap.is-collapsible:not(.is-expanded) .record-field-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: var(--collapse-lines, 10);
  overflow: hidden;
}
.record-field-value-wrap.is-collapsible:not(.is-expanded) .record-field-line.is-overflow {
  display: none;
}
.record-field-more {
  margin-top: 0.3rem;
  border: 0;
  background: transparent;
  color: var(--secondary, #1F7A8C);
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  font-size: 0.88rem;
}
.record-field-more:hover { text-decoration: underline; }
.record-field-multivalue .record-field-line + .record-field-line {
  margin-top: 0.12rem;
}

/* Field editor: compact number inputs for collapse defaults */
.fld-input-num {
  font: inherit;
  font-size: 0.85rem;
  width: 3.5rem;
  max-width: 4.5rem;
  padding: 0.2rem 0.3rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.record-attachments-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.record-attachments-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border-subtle, rgba(0,0,0,.06));
}
.record-attachment-link {
  color: var(--secondary, #1F7A8C);
  font-weight: 600;
  text-decoration: none;
  overflow-wrap: anywhere;
}
.record-attachment-link:hover,
.record-attachment-link:focus-visible {
  text-decoration: underline;
}
.record-attachment-meta {
  color: var(--muted);
  font-size: 0.85rem;
}
.record-attachment-name {
  color: var(--muted);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.record-attachment-missing {
  color: var(--warning-text, var(--muted));
  border: 1px solid var(--border-strong, var(--border));
  border-radius: 999px;
  padding: 0 0.5rem;
  font-size: 0.8rem;
}
.record-unmapped-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.record-unmapped-table th,
.record-unmapped-table td {
  text-align: left;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.record-unmapped-value {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}
@media (max-width: 720px) {
  .record-detail .record-nav {
    grid-template-columns: 1fr;
    justify-items: start;
  }
  .record-nav-pages {
    justify-self: center;
  }
  .record-nav-spacer {
    display: none;
  }
  .record-card-heading {
    flex-direction: column;
  }
  .record-card-toolbar {
    justify-content: flex-start;
  }
  .record-card-row {
    grid-template-columns: 1fr !important;
  }
  .record-field {
    grid-template-columns: 1fr;
  }
  .page-card.record-detail {
    max-width: 100%;
    margin: 0.75rem auto;
    padding: 0.9rem 0.85rem 1.1rem;
  }
}

/* Field editor: ? help next to setting headers */
.fld-th-with-help {
  white-space: nowrap;
  vertical-align: bottom;
}
.fld-th-with-help .fld-th-label {
  margin-right: 0.25rem;
}
.fld-help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  margin: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2, var(--surface));
  color: var(--muted, #5a6b78);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
}
.fld-help-btn:hover,
.fld-help-btn:focus-visible {
  color: var(--accent, #1F7A8C);
  border-color: var(--accent, #1F7A8C);
  outline: none;
  box-shadow: var(--focus-ring, 0 0 0 2px rgba(31, 122, 140, 0.25));
}
.fld-help-modal {
  width: min(440px, 100%);
}
.fld-help-body {
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--text);
  white-space: pre-wrap;
}


/* Admin config export/import (E1) */
.admin-config-form .form-row {
  margin-bottom: 0.85rem;
}
.admin-config-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.admin-config-paste {
  width: 100%;
  max-width: 48rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85rem;
}
.admin-config-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.admin-config-counts {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}
.admin-config-preview h3 {
  margin-top: 1.25rem;
}

/* T11b: title fields editor + class-code rename modal */
.tpl-title-fields {
  margin: 0 0 1.25rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border, #d0d5dd);
  border-radius: 8px;
  background: var(--surface-2, transparent);
}
.tpl-title-fields h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.tpl-title-selected { display: flex; flex-direction: column; gap: 0.35rem; margin: 0.5rem 0; }
.tpl-title-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e4e7ec);
}
.tpl-title-item-actions { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tpl-title-add-row { margin: 0.35rem 0 0.75rem; }
.tpl-title-add-select { min-width: 14rem; }
.tpl-title-sep-label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
  max-width: 16rem;
}
.tpl-title-sep-input { max-width: 8rem; }
.tpl-modal-hint { margin: 0.25rem 0 0.5rem; font-size: 0.85rem; }
.tpl-modal-warn {
  margin: 0.35rem 0 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  font-size: 0.85rem;
  background: #fff7ed;
  color: #9a3412;
  border: 1px solid #fdba74;
}
html[data-theme="dark"] .tpl-modal-warn {
  background: #431407;
  color: #fed7aa;
  border-color: #9a3412;
}

/* A2 user admin */
.admin-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.admin-users-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.admin-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr));
  gap: 0.35rem 1rem;
}
.admin-check {
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.9rem;
}
.admin-fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0;
}
.admin-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.admin-temp-password-value {
  font-size: 1.1rem;
  user-select: all;
}
.field-error {
  color: #d9534f;
  font-size: 0.85rem;
}


/* A2-fix: groups picker */
.admin-groups-picker {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.admin-groups-filter {
  width: 100%;
}
.admin-groups-list {
  max-height: 250px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.admin-groups-count {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.admin-groups-warn {
  color: #d9534f;
  font-size: 0.85rem;
  margin: 0;
}
.admin-password-input.is-disabled,
.admin-password-input:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.admin-badge-no-groups {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}

/* A2-fix3: edit user two-column + status card */
.admin-user-edit-layout {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.admin-user-edit-main {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}
.admin-user-edit-aside {
  min-width: 0;
}
@media (min-width: 1100px) {
  .admin-user-edit-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    align-items: start;
    gap: 1.25rem;
  }
  .admin-user-edit-main {
    grid-column: 1;
    grid-row: 1;
  }
  .admin-user-edit-aside {
    grid-column: 2;
    grid-row: 1;
  }
  .admin-user-status {
    position: sticky;
    top: 16px;
  }
}
.admin-user-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 0.15rem 0 0.75rem;
}
.admin-badge-active {
  background: color-mix(in srgb, var(--ok, #1a7f37) 18%, transparent);
  border-color: color-mix(in srgb, var(--ok, #1a7f37) 45%, var(--border));
  color: var(--ok, #1a7f37);
  font-weight: 600;
}
.admin-badge-disabled {
  background: color-mix(in srgb, var(--danger, #c0392b) 14%, transparent);
  border-color: color-mix(in srgb, var(--danger, #c0392b) 45%, var(--border));
  color: var(--danger, #c0392b);
  font-weight: 600;
}
.admin-badge-warn {
  background: color-mix(in srgb, #d4a017 18%, transparent);
  border-color: color-mix(in srgb, #d4a017 50%, var(--border));
  color: #9a7200;
  font-weight: 600;
}
html[data-theme="dark"] .admin-badge-warn {
  color: #f0c35a;
}
.admin-user-meta {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin: 0 0 0.85rem;
}
.admin-user-meta dt {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 0.15rem;
}
.admin-user-meta dd {
  margin: 0;
  font-size: 0.95rem;
}
.admin-user-status-actions {
  margin-top: 0.15rem;
}
.admin-user-status-hint {
  margin: 0.5rem 0 0;
}
.admin-danger-zone {
  border-color: color-mix(in srgb, #d9534f 45%, var(--border));
}
.admin-danger-zone h2 {
  color: #b3261e;
}
html[data-theme="dark"] .admin-danger-zone h2 {
  color: #ff8a85;
}

/* A3: groups admin */
.admin-groups-access-cell {
  max-width: 28rem;
  word-break: break-word;
}
.admin-groups-access-block {
  margin: 1rem 0;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}
.admin-groups-access-block:first-of-type {
  border-top: none;
  padding-top: 0;
}
.admin-groups-access-block > h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}
.admin-groups-access-values {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 220px;
  overflow-y: auto;
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.admin-groups-visible-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.admin-groups-visible-list > li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.9rem;
}
.admin-groups-summary-sub {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.95rem;
}
.admin-groups-preview-form {
  /* same row layout as .admin-users-filter — left-aligned User + Show */
  margin-bottom: 0.25rem;
  max-width: none;
  flex-direction: row;
}
.admin-entity-perm-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  margin: 0;
  max-width: 40rem;
}
.admin-entity-perm-form .admin-label {
  width: 100%;
}
.admin-entity-perm-form select {
  min-width: 12rem;
  width: 100%;
  max-width: 40rem;
}
.admin-entity-perm-form .admin-actions {
  justify-content: flex-start;
  margin-top: 0;
}
.admin-entity-card > .admin-entity-refresh-status {
  margin-top: 0.75rem;
}
.admin-entity-field-hint {
  max-width: 40rem;
}


/* A3-fix: group permissions + soft-limit value picker */
.admin-groups-perm-block {
  margin: 1rem 0;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, #ddd);
}
.admin-groups-perm-radios {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  margin: 0.5rem 0;
}
.admin-groups-perm-hint { margin: 0.25rem 0 0; }
.admin-groups-value-picker.is-hidden { display: none; }
.admin-groups-value-search {
  width: 100%;
  max-width: 28rem;
  margin: 0.5rem 0;
}
.admin-groups-access-values {
  max-height: 250px;
  overflow: auto;
  border: 1px solid var(--border, #ddd);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-bottom: 0.5rem;
}
.admin-check.is-disabled { opacity: 0.55; }
.admin-groups-preview-form .admin-groups-preview-user {
  flex: 0 1 22rem;
  margin: 0;
  min-width: 12rem;
}
.admin-groups-preview-form select {
  min-width: 14rem;
}
.admin-entity-group-list { margin: 0.5rem 0 0; padding-left: 1.25rem; }
.admin-entity-card { margin-bottom: 1.25rem; }


/* A3-fix3: effective access + overlap + All badge */
.admin-effective-access {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}
.admin-effective-access li + li {
  margin-top: 0.35rem;
}
.admin-overlap-warn {
  margin: 0.65rem 0 0;
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--warn, #b45309) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn, #b45309) 35%, transparent);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
}
.admin-access-parts {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.4;
}
.admin-access-parts li + li {
  margin-top: 0.25rem;
}
.admin-badge-all {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: color-mix(in srgb, var(--primary, #0f1c2e) 14%, transparent);
  color: var(--primary, #0f1c2e);
  border: 1px solid color-mix(in srgb, var(--primary, #0f1c2e) 28%, transparent);
  vertical-align: middle;
}
html[data-theme="dark"] .admin-badge-all {
  background: color-mix(in srgb, var(--primary, #8eb4ff) 18%, transparent);
  color: var(--text);
  border-color: color-mix(in srgb, var(--primary, #8eb4ff) 35%, transparent);
}
.admin-flash-list {
  margin: 0.35rem 0 0;
  padding-left: 1.2rem;
}
.admin-flash-list li {
  margin: 0.15rem 0;
}


/* P2 admin job progress */
.admin-job-progress {
  margin: 0.75rem 0 1rem;
  max-width: 28rem;
}
.admin-job-progress[hidden],
.admin-entity-rebuild-progress[hidden] {
  display: none !important;
}
.admin-job-progress-label {
  font-size: 0.875rem;
  color: var(--color-muted, #5c6b7a);
  margin-bottom: 0.35rem;
}
.admin-job-progress-track {
  height: 0.5rem;
  background: var(--color-border, #d7dee7);
  border-radius: 999px;
  overflow: hidden;
}
.admin-job-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-primary, #0b6bcb);
  border-radius: 999px;
  transition: width 0.25s ease;
}
.admin-job-progress-indeterminate .admin-job-progress-bar {
  width: 40%;
  animation: admin-job-indeterminate 1.2s ease-in-out infinite;
}
@keyframes admin-job-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
.admin-entity-refresh-wrap {
  margin-top: 0.5rem;
}

/* TT6 template editor: tabs, sticky save bar, unsaved-change markers, toast */
.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.tpl-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}
.tpl-tablist a.tpl-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.55rem 0.95rem;
  margin-bottom: -1px;
  border: 1px solid transparent;
  border-bottom: 2px solid transparent;
  border-radius: 10px 10px 0 0;
  color: var(--muted);
  font-weight: 600;
  text-decoration: none;
}
.tpl-tablist a.tpl-tab:hover {
  color: var(--text);
  background: var(--row-hover);
  text-decoration: none;
}
.tpl-tablist a.tpl-tab:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.tpl-tablist a.tpl-tab.is-active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 2px solid var(--accent);
}
html[data-theme="dark"] .tpl-tablist a.tpl-tab {
  color: var(--muted);
}
html[data-theme="dark"] .tpl-tablist a.tpl-tab:hover,
html[data-theme="dark"] .tpl-tablist a.tpl-tab.is-active {
  color: var(--text);
}
.tpl-tab-dot {
  color: var(--accent);
  font-size: 1.2em;
  line-height: 1;
}
.tpl-tab-dot[hidden],
.tpl-tabpanel[hidden],
.tpl-savebar[hidden] {
  display: none !important;
}
.tpl-tab-form {
  margin: 0;
}

/* Sticky save bar: sits at the bottom of the viewport while its tab scrolls */
.tpl-savebar {
  position: sticky;
  bottom: 0;
  z-index: 50;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 0;
  padding: 0.65rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 -6px 18px -8px rgba(15, 28, 46, 0.25);
}
html[data-theme="dark"] .tpl-savebar {
  box-shadow: 0 -6px 18px -6px rgba(0, 0, 0, 0.6);
}
.tpl-savebar-count {
  font-weight: 600;
  color: var(--text);
}
.tpl-savebar-status {
  font-size: 0.9rem;
  color: var(--muted);
}
.tpl-savebar-status.is-error {
  color: var(--danger-text);
}
.tpl-savebar-actions {
  display: inline-flex;
  gap: 0.5rem;
  margin-left: auto;
}

/* Changed rows / inputs (compared to values loaded with the page) */
.tpl-row-editor.is-dirty,
.tpl-class-chip.is-dirty,
.tpl-title-item.is-dirty {
  border-left: 4px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface-2));
}
.fld-table tr.is-dirty > td {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}
.fld-table tr.is-dirty > td:first-child {
  box-shadow: inset 4px 0 0 var(--accent);
}
.fld-input.is-dirty-input,
.fld-select.is-dirty-input,
.tpl-modal-input.is-dirty-input {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 1px var(--accent);
}
input[type="checkbox"].is-dirty-input {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Duplicate list_order warning (save still allowed) */
.fld-input-order {
  max-width: 6rem;
}
.fld-dup-warn,
.fld-noidx-warn {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a5a00;
  background: #fff4d6;
  border: 1px solid #f0c75e;
  white-space: nowrap;
}
html[data-theme="dark"] .fld-dup-warn,
html[data-theme="dark"] .fld-noidx-warn {
  color: #f5d38a;
  background: #3a2f12;
  border-color: #7a5d1c;
}
.fld-table tr.has-dup-order .fld-input-order {
  border-color: #d4a017;
}
.fld-dup-summary {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  border: 1px solid #f0c75e;
  background: #fff8e5;
  color: #6b4700;
  font-size: 0.9rem;
}
.fld-dup-summary ul {
  margin: 0.25rem 0 0;
  padding-left: 1.25rem;
}
html[data-theme="dark"] .fld-dup-summary {
  border-color: #7a5d1c;
  background: #2c2410;
  color: #f5d38a;
}

/* Toast */
.tpl-toast-wrap {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}
.tpl-toast {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 14rem;
  max-width: 26rem;
  padding: 0.65rem 0.9rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--ok, #1a7f37);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 10px 25px -5px rgba(15, 28, 46, 0.25);
  font-size: 0.92rem;
  pointer-events: auto;
  transition: opacity 0.28s ease, transform 0.28s ease;
}
html[data-theme="dark"] .tpl-toast {
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
}
.tpl-toast-err {
  border-left-color: var(--danger-text);
}
.tpl-toast-icon {
  font-weight: 800;
  color: var(--ok, #1a7f37);
}
.tpl-toast-err .tpl-toast-icon {
  color: var(--danger-text);
}
.tpl-toast.is-hiding {
  opacity: 0;
  transform: translateY(6px);
}
.tpl-guard-modal p {
  margin: 0;
}

/* Admin → Platform settings (A4). Tabs + sticky save bar reuse .tpl-* (TT6). */
.settings-page .admin-section {
  max-width: 760px;
}
/* Inside the 2/3 column the column itself limits the width. */
.page-with-aside-main .admin-section {
  max-width: none;
}
.settings-field {
  margin: 0 0 1rem;
}
.settings-field > label,
.settings-radios legend {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 0 0 0.35rem;
  color: var(--heading);
}
.settings-radios {
  border: 0;
  padding: 0;
}
.settings-radio,
.settings-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.25rem 0;
  font-weight: 400;
  cursor: pointer;
}
.settings-radio input,
.settings-check input {
  width: auto;
  height: auto;
}
.settings-help {
  margin: 0.3rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.settings-note {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  color: var(--text);
}
.settings-warning,
.settings-warning-inline {
  color: #8a5a00;
  font-size: 0.875rem;
}
.settings-warning {
  margin: 0.4rem 0 0;
  padding: 0.5rem 0.7rem;
  border: 1px solid #f0d39b;
  background: #fff8e6;
  border-radius: 10px;
}
html[data-theme="dark"] .settings-warning,
html[data-theme="dark"] .settings-warning-inline {
  color: #f5cf7a;
}
html[data-theme="dark"] .settings-warning {
  border-color: #6b5313;
  background: #2e2611;
}
.settings-field-error {
  margin: 0.3rem 0 0;
  color: var(--danger-text);
  font-size: 0.85rem;
}
.settings-page .has-error {
  border-color: var(--danger-text);
}
.settings-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0;
  vertical-align: middle;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}
.settings-inline {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.settings-inline input {
  flex: 1 1 auto;
}
.settings-inline .btn {
  flex: none;
}
.settings-page textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  font: inherit;
  background: var(--surface-2);
  color: var(--text);
}
.settings-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  font-size: 0.8rem !important;
}
.settings-secret-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.4rem;
}
.settings-secret-row[hidden] {
  display: none;
}
.settings-secret-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 0.2rem 0.6rem;
  border-radius: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.settings-md-result {
  margin-top: 0.6rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  overflow-wrap: anywhere;
}
.settings-md-result.is-error {
  color: var(--danger-text);
  border-color: var(--danger-border);
  background: var(--danger-bg);
}
.settings-md-result h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}
.settings-md-dl {
  display: grid;
  grid-template-columns: 11rem 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.6rem;
  font-size: 0.875rem;
}
.settings-md-dl dt {
  color: var(--muted);
  font-weight: 600;
}
.settings-md-dl dd {
  margin: 0;
}
@media (max-width: 640px) {
  .settings-inline {
    flex-direction: column;
    align-items: stretch;
  }
  .settings-md-dl {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------
   Page with a "Good to know" side panel (partials/info-aside.ejs).
   Main content ~2/3, aside ~1/3 on the right; stacks below the content
   under 1000px. Sticky save bars stay outside .page-with-aside so they
   keep spanning the full width.
   ------------------------------------------------------------------ */
.page-with-aside {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(15rem, 1fr);
  gap: 1rem;
  align-items: start;
}
.page-with-aside-main {
  min-width: 0;
}
.page-with-aside-main > .admin-section:last-child {
  margin-bottom: 0;
}
.info-aside {
  position: sticky;
  top: 1rem;
  align-self: start;
  margin: 0;
  padding: 0.9rem 1.1rem 1rem;
  background: var(--surface-2);
  border-left: 4px solid var(--accent);
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text);
}
.info-aside-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--heading);
}
.info-aside-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-family: Georgia, 'Times New Roman', serif;
  font-style: italic;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
}
.info-aside-list {
  margin: 0;
  padding-left: 1.1rem;
}
.info-aside-list li {
  margin: 0 0 0.45rem;
}
.info-aside-list li:last-child {
  margin-bottom: 0;
}
.info-aside-list li::marker {
  color: var(--accent);
}
.info-aside-subtitle {
  margin: 0.9rem 0 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.info-aside-fields {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.85rem;
}
.info-aside-fields li {
  margin: 0 0 0.45rem;
  overflow-wrap: anywhere;
}
.info-aside-fields li:last-child {
  margin-bottom: 0;
}
.info-aside-fields strong {
  color: var(--heading);
}
/* "Good to know" sections with a table: the table keeps a readable width and scrolls sideways */
.info-aside-intro {
  margin: 0 0 0.5rem;
}
.info-aside-table-wrap {
  margin: 0 0 0.75rem;
}
.info-aside-table {
  min-width: 34rem;
  font-size: 0.8rem;
  line-height: 1.35;
}
.info-aside-table th,
.info-aside-table td {
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}
.info-aside-table tbody th {
  background: transparent;
  font-weight: 600;
}
html[data-theme="dark"] .info-aside {
  background: var(--surface-2);
  border-color: var(--border);
  border-left-color: var(--accent);
}
@media (max-width: 999.98px) {
  .page-with-aside {
    grid-template-columns: minmax(0, 1fr);
  }
  .info-aside {
    position: static;
  }
}


/* ---------------------------------------------------------------------------
   F2: SSO – group membership source badges, profile account facts, SAML settings
   --------------------------------------------------------------------------- */
.source-badge {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1.5;
  vertical-align: middle;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.source-badge-sso {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}
.profile-account {
  margin: 0 0 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.profile-account h2 {
  margin: 0 0 0.6rem;
  font-size: 1.05rem;
}
.profile-account-dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.35rem 1rem;
  margin: 0;
}
.profile-account-dl dt {
  color: var(--muted);
  font-size: 0.9rem;
}
.profile-account-dl dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.profile-groups {
  margin: 0;
  padding: 0;
  list-style: none;
}
.profile-groups li + li {
  margin-top: 0.2rem;
}
.profile-sso-note,
.profile-password-link {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}
.admin-check-readonly {
  opacity: 0.85;
}
.admin-sso-info dd code,
.admin-sso-groups code {
  overflow-wrap: anywhere;
}
.admin-sso-groups {
  margin: 0.25rem 0 0;
  padding-left: 1.1rem;
}
.admin-sso-groups li + li {
  margin-top: 0.2rem;
}
.settings-sp-info {
  margin: 0 0 1rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}
.settings-sp-info h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}
.settings-sp-info dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0;
}
.settings-sp-info dt {
  color: var(--muted);
  font-size: 0.85rem;
}
.settings-sp-info dd {
  margin: 0;
  overflow-wrap: anywhere;
}
.settings-mappings {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}
.settings-mappings th,
.settings-mappings td {
  padding: 0.35rem 0.4rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}
.settings-mappings th {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}
.settings-mappings input,
.settings-mappings select {
  width: 100%;
  font: inherit;
}
.settings-mappings td.settings-mapping-actions {
  width: 1%;
  white-space: nowrap;
}
.settings-mappings-empty {
  margin: 0.5rem 0;
}
@media (max-width: 760px) {
  .settings-mappings thead {
    display: none;
  }
  .settings-mappings tr,
  .settings-mappings td {
    display: block;
    width: auto;
  }
  .settings-mappings td.settings-mapping-actions {
    width: auto;
  }
}

/* S1b: search panel suggestions (combobox + listbox) – theme variables only */
.suggest-wrap {
  position: relative;
}
.suggest-wrap.suggest-exact input[role="combobox"] {
  border-color: var(--accent);
  font-weight: 600;
}
.suggest-list {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: 100%;
  margin: 2px 0 0;
  padding: 4px 0;
  list-style: none;
  max-height: min(18rem, 50vh);
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.suggest-list[hidden] {
  display: none;
}
.suggest-option {
  padding: 0.45rem 0.75rem;
  cursor: pointer;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.suggest-option[aria-selected="true"],
.suggest-option:hover {
  background: var(--row-selected);
}
.suggest-option mark {
  background: transparent;
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 2px;
}
@media (max-width: 640px) {
  .suggest-option {
    padding: 0.65rem 0.75rem; /* larger touch targets */
  }
}
/* S1c: pick list - chips wrap inside the field; theme variables only */
.pick-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  width: 100%;
  min-width: 0;
  min-height: 38px;
  box-sizing: border-box;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  cursor: text;
}
.pick-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
}
.search-panel .pick-box input[role="combobox"],
.search-panel .pick-box input[role="combobox"]:focus {
  flex: 1 1 5rem;
  width: auto;
  min-width: 4rem;
  height: 30px;
  padding: 0 4px;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
}
/* S1c: after chips the input only needs a little room, so it stays on the last chip row
   (no extra empty row); it still wraps to a row of its own when that row is full */
.search-panel .pick-box .pick-chip ~ input[role="combobox"] {
  flex: 1 1 3em;
  min-width: 3em;
  height: 26px;
}
.pick-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-width: 0;
  padding: 1px 2px 1px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.875em;
  line-height: 1.3;
}
.pick-chip-text {
  min-width: 0;
  overflow-wrap: anywhere;
}
.pick-chip-x {
  flex-shrink: 0;
  margin: 0;
  padding: 2px 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  line-height: 1;
  cursor: pointer;
}
.pick-chip-x:hover,
.pick-chip-x:focus-visible {
  color: var(--text);
  background: var(--row-selected);
}
.suggest-pick .suggest-option {
  display: flex;
  gap: 0.4rem;
}
.pick-check {
  flex-shrink: 0;
  width: 1em;
  color: var(--accent);
}
.suggest-option.is-picked {
  font-weight: 600;
}
.suggest-option.is-picked .pick-check::before {
  content: "\2713";
}
@media (max-width: 640px) {
  .pick-chip-x {
    padding: 6px 8px; /* larger touch targets */
  }
}
/* Fields tab: suggestion mode notes */
.fld-suggest-cell select {
  max-width: 9rem;
}
.fld-suggest-note {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
  white-space: normal;
  max-width: 14rem;
}
/* ------------------------------------------------------------------
   TT6a: Fields tab layout. Tables scroll inside their own box (never the
   page), sticky header + code column, fixed column widths, compact
   suggestion cell; collapsible "Good to know" panel.
   ------------------------------------------------------------------ */
.fld-table-scroll {
  max-width: 100%;
  /* Horizontal scroll only when the table is really wider; the page scrolls vertically. */
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 0.75rem;
}
.fld-table-scroll > .fld-table {
  width: max-content;
  min-width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
}
.fld-table th,
.fld-table td {
  white-space: nowrap;
  background: var(--surface);
}
.fld-table tr.is-dirty > td,
.fld-table tbody tr:hover > td {
  background: var(--row-selected);
}
/* List settings table: fixed column widths; it only grows past 100% when they don't fit */
.fld-table-scroll > .fld-table.fld-list-table {
  width: 100%;
  table-layout: fixed;
}
/* Header row (no sticky header: inside an overflow-x box it could only stick to that box) */
.fld-table-scroll .fld-table thead th {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.25;
}
/* Code column; sticky (opaque) only while the table actually scrolls sideways */
.fld-table-scroll .fld-table .fld-col-code {
  width: 8rem;
  min-width: 8rem;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fld-table-scroll .fld-table .fld-col-handle {
  width: 2rem;
  min-width: 2rem;
  max-width: 2rem;
}
.fld-table-scroll.is-hscroll .fld-table .fld-col-code,
.fld-table-scroll.is-hscroll .fld-table .fld-col-handle {
  position: sticky;
  left: 0;
  z-index: 2;
}
.fld-table-scroll.is-hscroll .fld-table .fld-col-code {
  box-shadow: 1px 0 0 var(--border);
}
.fld-table-scroll.is-hscroll .fld-table .fld-col-code-after-handle {
  left: 2rem;
}
/* Fixed widths */
.fld-table-scroll .fld-table th,
.fld-table-scroll .fld-table td {
  padding-left: 0.45rem;
  padding-right: 0.45rem;
}
.fld-table .fld-col-cb {
  width: 4.25rem;
  min-width: 4.25rem;
  text-align: center;
}
.fld-table .fld-col-datefilter {
  width: 5.75rem;
  min-width: 5.75rem;
}
.fld-table .fld-col-order {
  width: 8.75rem;
  min-width: 8.75rem;
}
.fld-table .fld-col-sorder {
  width: 6rem;
  min-width: 6rem;
}
.fld-table .fld-col-suggest {
  width: 192px;
  min-width: 192px;
  max-width: 192px;
  white-space: normal;
}
.fld-table td.fld-col-cb input[type="checkbox"] {
  margin: 0;
}
/* Order: number + arrows (+ badge) in one row */
.fld-order-group {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  flex-wrap: nowrap;
}
.fld-order-group {
  position: relative;
}
.fld-order-group .btn {
  margin: 0;
}
/* Duplicate-order badge sits on the number's corner, so it never pushes into the next column */
.fld-order-group .fld-dup-warn.fld-tip {
  position: absolute;
  left: 2.9rem;
  top: -0.45rem;
  width: 1.15rem;
  height: 1.15rem;
  font-size: 0.65rem;
  z-index: 1;
}
.fld-table .fld-input-order {
  width: 3.75rem;
  min-width: 3.75rem;
  max-width: 3.75rem;
  padding: 0 0.4rem;
}
.fld-table .fld-input-order:disabled,
.fld-order-group .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
/* Suggestions: select line + one compact meta line (same height with or without warnings) */
.fld-suggest-line {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 38px;
}
.fld-suggest-cell .fld-suggest-line select {
  width: 9rem;
  max-width: 9rem;
}
.fld-suggest-meta {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  height: 1.5rem;
  margin-top: 0.2rem;
  overflow: visible;
  white-space: nowrap;
}
.fld-suggest-count {
  font-size: 0.72rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 0.15rem;
}
.fld-suggest-own {
  font-size: 0.85rem;
  color: var(--text);
}
/* Icon badges with focusable tooltip */
.fld-tip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 1.4rem;
  height: 1.4rem;
  margin: 0;
  padding: 0;
  border-radius: 999px;
  font-size: 0.75rem;
  line-height: 1;
  cursor: help;
  white-space: nowrap;
}
.fld-tip:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.fld-info-icon {
  font-weight: 700;
  font-style: italic;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.fld-tip[data-tip]:hover::after,
.fld-tip[data-tip]:focus::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 30;
  right: 0;
  top: calc(100% + 0.3rem);
  width: max-content;
  max-width: 16rem;
  padding: 0.4rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 0.75rem;
  font-weight: 400;
  font-style: normal;
  line-height: 1.35;
  white-space: normal;
  text-align: left;
}
/* Collapsible "Good to know" panel */
.aside-toggle-bar {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 0.5rem;
}
.aside-toggle[aria-expanded="true"] {
  background: var(--row-selected);
}
.aside-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 0.75rem;
}
.info-aside-collapsible {
  position: relative;
}
.info-aside-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
}
.info-aside-collapsible .info-aside-title {
  padding-right: 2.25rem;
}
.page-with-aside.aside-collapsible {
  grid-template-columns: minmax(0, 1fr);
}
.page-with-aside.aside-collapsible:not(.is-aside-open) > .info-aside {
  display: none;
}
@media (min-width: 1400px) {
  .page-with-aside.aside-collapsible.is-aside-open {
    grid-template-columns: minmax(0, 1fr) minmax(16rem, 22rem);
  }
  .page-with-aside.aside-collapsible .info-aside-close {
    display: none; /* the toggle closes it; the column never overlaps */
  }
}
@media (max-width: 1399.98px) {
  .page-with-aside.aside-collapsible.is-aside-open > .info-aside {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    width: min(24rem, 92vw);
    max-height: none;
    margin: 0;
    border-radius: 0;
    overflow-y: auto;
    background: var(--surface);
    box-shadow: var(--shadow), -1px 0 0 var(--border);
  }
}

/* ---------------------------------------------------------------------------
   TT6c: template editor - header line, Help button in the tab bar row,
   one "Good to know" drawer over the content, consistent section spacing.
   --------------------------------------------------------------------------- */
.tpl-page-title { margin-bottom: 0.2rem; }
.tpl-last-saved { margin: 0 0 1rem; font-size: 0.85rem; }
.tpl-tabbar {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--border);
}
.tpl-tabbar > .tpl-tablist {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  border-bottom: 0;
}
.tpl-help-toggle {
  flex: none;
  margin: 0 0 0.35rem auto;
}
.tpl-help[hidden] { display: none !important; }
/* Floating panel anchored under the Help button row; top set by JS (--tpl-help-top). */
.tpl-help > .info-aside {
  position: fixed;
  top: var(--tpl-help-top, 1rem);
  right: 1.25rem;
  z-index: 1000;
  width: min(24rem, calc(100vw - 2rem));
  max-height: calc(100vh - var(--tpl-help-top, 1rem) - 1rem);
  margin: 0;
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  overflow-y: auto;
  background: var(--surface);
  box-shadow: var(--shadow);
}
@media (max-width: 599.98px) {
  .tpl-help > .info-aside { right: 1rem; width: calc(100vw - 2rem); }
}
.tpl-tabpanel .admin-section { padding: 1rem 1.15rem; margin: 0 0 1rem; }
.tpl-tabpanel .admin-section > h2 { margin: 0 0 0.75rem; font-size: 1.05rem; }
.tpl-tabpanel .admin-section h3 {
  margin: 1.25rem 0 0.5rem;
  font-size: 0.95rem;
  color: var(--heading);
}
.tpl-tabpanel .admin-section h3:first-child { margin-top: 0; }

/* LIC1: licence status line + admin-only warning banner */
.license-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid var(--warn-border);
  font-size: 0.9rem;
}
.license-banner a { color: inherit; text-decoration: underline; font-weight: 600; }
.license-banner-icon,
.license-status-warn::before {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  border: 1px solid currentColor;
  font-weight: 700;
  font-size: 0.8rem;
  flex: none;
}
.license-status {
  margin: 0 0 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}
.license-status-ok { color: var(--ok-text); }
.license-status-dev { color: var(--muted); }
.license-status-warn {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-border);
}
.license-status-warn::before { content: "!"; }
.license-status a { color: inherit; text-decoration: underline; margin-left: 0.35rem; }

/* SYS1: Admin > System */
.sys-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.sys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
  gap: 0 1rem;
}
.sys-dl {
  display: grid;
  grid-template-columns: minmax(8rem, max-content) 1fr;
  gap: 0.35rem 0.9rem;
  margin: 0;
  font-size: 0.9rem;
}
.sys-dl dt { color: var(--muted); font-weight: 600; }
.sys-dl dd { margin: 0; min-width: 0; }
.sys-break { overflow-wrap: anywhere; word-break: break-all; }
.sys-pkg-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.sys-pkg-head h2 { margin: 0; }
.sys-filter { display: block; margin: 0.75rem 0; }
.sys-filter input { width: 100%; max-width: 360px; }
.sys-pkg-table td:nth-child(2) { white-space: nowrap; }
@media (max-width: 560px) {
  .sys-dl { grid-template-columns: 1fr; }
  .sys-dl dd { margin-bottom: 0.35rem; }
}
.sys-pkg-table-wrap { overflow-x: auto; max-width: 100%; }
.sys-unknown { color: var(--muted); font-style: italic; }

/* T12: attachments list column + system fields box (Fields tab) */
td.col-attachments {
  white-space: nowrap;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.fld-system-fields {
  margin-top: 1rem;
}
.fld-system-fields h4 {
  margin: 0 0 0.25rem;
}

/* ---------- A4: branding (header name, Themes tab, live preview) ---------- */
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--header-fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 16rem;
}
.brand-field-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.brand-field-row input[type="text"] { flex: 1 1 14rem; min-width: 0; }
.brand-field-row .brand-hex { flex: 0 0 7.5rem; width: 7.5rem; }
.brand-color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem 1.5rem;
}
.brand-color-col h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.brand-contrast-warn { margin: 0.35rem 0 0; }
.brand-color-picker {
  inline-size: 2.6rem;
  block-size: 2.3rem;
  padding: 0.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}
.brand-logo-grid,
.brand-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}
.brand-logo-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: var(--surface-2);
  min-width: 0;
}
.brand-logo-box h3 { margin: 0 0 0.5rem; font-size: 1rem; }
.brand-logo-box input[type="file"] { max-width: 100%; }
.brand-logo-thumb {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 4.5rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  border: 1px dashed var(--border-strong);
}
.brand-logo-thumb img { max-height: 3.5rem; max-width: 100%; }
.brand-logo-thumb-light { background: #ffffff; }
.brand-logo-thumb-dark { background: #1c1d21; }
.brand-logo-actions { margin: 0.25rem 0; }
/* CFG1: Import / Export page */
.inline-form { display: inline; }
.admin-config-actions { margin: 1rem 0 0; }
.cfg-env-differs th,
.cfg-env-differs td { font-weight: 600; }
/* TH2: favicon preview: the thumb background shows the light / dark theme */
.brand-favicon-img { inline-size: 2rem; block-size: 2rem; object-fit: contain; }

/* Preview: nested data-theme gets the theme tokens it needs (root tokens apply to html only) */
.brand-preview[data-theme="light"] {
  --bg: #eef1f5;
  --primary: #0f1c2e;
  --accent: #3a8fd9;
  --surface: #ffffff;
  --text: #0f1c2e;
  --muted: #5b6675;
  --border: #dde3ea;
  --on-primary: #ffffff;
  --logo-chip: transparent;
  --header-fg: var(--primary);
  color-scheme: light;
}
.brand-preview[data-theme="dark"] {
  --bg: #141517;
  --surface: #1c1d21;
  --text: #eef0f3;
  --muted: #a3a8b2;
  --border: #30323a;
  --primary: #5aa7e6;
  --accent: #5aa7e6;
  --on-primary: #0e1116;
  --logo-chip: #ffffff;
  --header-fg: var(--text);
  color-scheme: dark;
}
.brand-preview {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  min-width: 0;
}
.brand-preview-label { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); }
.brand-preview-header {
  display: flex;
  align-items: center;
  gap: var(--brand-gap, 0.6rem);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--header-fg);
  min-width: 0;
}
.brand-preview-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-preview-nav { margin-left: auto; color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.brand-preview-logo { display: inline-flex; border-radius: 6px; padding: 2px; }
.brand-preview-logo.is-chip { background: var(--logo-chip); padding: 3px 6px; }
.brand-preview-logo img { max-height: 1.6rem; max-width: 7rem; display: block; }
.brand-preview-login {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0.75rem auto 0;
  max-width: 16rem;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.brand-preview-login .brand-preview-logo img { max-height: 2.4rem; max-width: 10rem; }
.brand-preview-input {
  display: block;
  width: 100%;
  height: 1.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}
.brand-preview-btn {
  display: block;
  width: 100%;
  padding: 0.4rem;
  border-radius: 6px;
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 600;
}
.brand-preview-link { color: var(--accent); font-size: 0.85rem; text-decoration: underline; }

@media (max-width: 760px) {
  .brand-logo-grid,
  .brand-preview-grid { grid-template-columns: minmax(0, 1fr); }
  .brand-name { max-width: 9rem; font-size: 0.95rem; }
}

/* ---------- A5: audit log view ---------- */
.audit-layout {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 1100px) {
  .audit-layout { grid-template-columns: minmax(0, 1fr); }
}
.audit-filters { position: static; }
.audit-actions { border: 0; margin: 0; padding: 0; min-width: 0; }
.audit-actions legend { font-size: 0.9rem; font-weight: 600; margin-bottom: 0.35rem; padding: 0; }
.audit-actions-filter { width: 100%; margin-bottom: 0.35rem; }
.audit-actions-list {
  max-height: 13rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  background: var(--surface);
}
.audit-action-opt { display: flex; gap: 0.4rem; align-items: baseline; font-size: 0.88rem; padding: 0.1rem 0; cursor: pointer; }
.audit-action-opt[hidden] { display: none; }
.search-panel .audit-action-opt input { width: auto; margin: 0; }
.audit-target-row { display: flex; flex-direction: column; gap: 0.35rem; }
.audit-user-wrap { position: relative; }
.audit-results { min-width: 0; }
.audit-table td { vertical-align: top; }
.audit-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.audit-short { max-width: 22rem; overflow-wrap: anywhere; color: var(--muted); }
.audit-action-failed { color: var(--danger-text); font-weight: 600; }
.audit-row-failed td:first-child { box-shadow: inset 3px 0 0 var(--danger-border); }
.audit-detail-row > td { background: var(--surface-2); }
.audit-diff { margin-bottom: 0.75rem; }
.audit-diff td { overflow-wrap: anywhere; }
.audit-old { color: var(--muted); }
.audit-pairs {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 0.25rem 1rem;
  margin: 0;
}
.audit-pairs dt { font-weight: 600; }
.audit-pairs dd { margin: 0; }
.audit-pre {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.85rem;
}

/* SR1: My searches (search panel) */
.ss-menu { margin: 0 0 1rem; padding: 0.5rem 0.75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.ss-menu-summary { cursor: pointer; font-weight: 600; color: var(--heading); }
.ss-group { margin-top: 0.6rem; }
.ss-group-title { margin: 0 0 0.25rem; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.ss-list { list-style: none; margin: 0; padding: 0; }
.ss-item { padding: 0.3rem 0; border-top: 1px solid var(--border); }
.ss-item:first-child { border-top: 0; }
.ss-item.is-active .ss-open { font-weight: 700; }
.ss-open { color: var(--link); text-decoration: none; overflow-wrap: anywhere; }
.ss-open:hover, .ss-open:focus-visible { text-decoration: underline; }
.ss-item-actions { margin-top: 0.25rem; }
.ss-item-actions > summary { list-style: none; display: inline-block; }
.ss-item-actions > summary::-webkit-details-marker { display: none; }
.ss-inline-form { display: flex; gap: 0.4rem; align-items: center; margin-top: 0.4rem; }
.search-panel .ss-inline-form input[type="text"] { flex: 1 1 auto; min-width: 0; margin: 0; }
.ss-save { margin-top: 0.75rem; }
.ss-save > summary { list-style: none; display: inline-block; }
.ss-save > summary::-webkit-details-marker { display: none; }
.ss-save-form { margin-top: 0.6rem; }
.ss-help, .ss-empty { font-size: 0.85rem; margin: 0.35rem 0 0.6rem; }
.ss-flash { margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; border-radius: 8px; font-size: 0.9rem; border: 1px solid var(--border); }
.ss-flash-ok { color: var(--ok-text); }
.ss-flash-err { background: var(--danger-bg); color: var(--danger-text); border-color: var(--danger-border); }
.ss-flash-info { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }
.profile-start-view { margin-top: 1.25rem; }
.profile-start-view-help { font-size: 0.85rem; margin: 0.35rem 0 1rem; }

/* SR1b: search panel - icon tabs, sticky action bar, collapse strip, resize handle, overlay */
.icon { flex-shrink: 0; vertical-align: middle; }
.sp-head { display: flex; align-items: center; gap: 0.35rem; margin: 0 0 0.75rem; border-bottom: 1px solid var(--border); }
.sp-tabs { display: flex; flex: 1 1 auto; gap: 0.15rem; min-width: 0; flex-wrap: wrap; }
.sp-tab {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 0.2rem;
  min-width: 40px; height: 38px; padding: 0 0.55rem; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.sp-tab:hover { color: var(--text); }
.sp-tab[aria-selected="true"] { color: var(--heading); border-bottom-color: var(--accent); }
.sp-tab:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 6px; }
.sp-badge {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.1rem; height: 1.1rem;
  padding: 0 0.28rem; border-radius: 999px; background: var(--accent); color: var(--on-accent);
  font-size: 0.7rem; font-weight: 700; line-height: 1;
}
.sp-badge-muted { background: var(--row-selected); color: var(--text); }
.sp-icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.15rem; flex-shrink: 0;
  width: 32px; height: 32px; padding: 0; border: 1px solid transparent; border-radius: 999px;
  background: transparent; color: var(--text); cursor: pointer; list-style: none;
}
.sp-icon-btn::-webkit-details-marker { display: none; }
.sp-icon-btn:hover { background: var(--row-hover); border-color: var(--border); }
.sp-icon-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sp-icon-btn[hidden] { display: none; }
.search-panel { overflow: auto; max-height: calc(100vh - 6rem); padding-bottom: 0; }
.search-panel .btn-row {
  position: sticky; bottom: 0; z-index: 2; align-items: center; margin-top: 1rem;
  padding: 0.75rem 0 1rem; background: var(--surface); border-top: 1px solid var(--border);
}
.search-panel .btn-row .sp-save-btn { flex: 0 0 36px; width: 36px; padding: 0; }
.sp-js .ss-nojs { display: none; }
.sp-panel[hidden] { display: none; }
/* Collapsed: narrow strip with the expand + filter (badge) buttons */
.search-panel.is-collapsed { width: 52px !important; padding: 0.6rem 0.35rem; overflow: visible; }
.search-panel.is-collapsed [data-sp-body] { display: none; }
.sp-strip { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; }
.sp-strip[hidden] { display: none; }
.sp-strip-filter { position: relative; }
.sp-strip-filter .sp-badge { position: absolute; top: -4px; right: -6px; }
/* Resize handle between the panel and the results */
.sp-resize {
  flex: 0 0 8px; align-self: stretch; margin: 0 -0.5rem; cursor: col-resize; border-radius: 4px; touch-action: none;
}
.sp-resize:hover, .sp-resize:focus-visible { background: var(--row-selected); outline: none; }
.sp-resize[hidden] { display: none; }
.sp-resizing, .sp-resizing * { cursor: col-resize !important; user-select: none; }
.sp-open-filters { margin-right: 0.5rem; }
.sp-open-filters[hidden] { display: none; }
.sp-backdrop { position: fixed; inset: 0; z-index: 899; background: rgba(15, 28, 46, 0.45); }
html[data-theme="dark"] .sp-backdrop { background: rgba(0, 0, 0, 0.55); }
.sp-backdrop[hidden] { display: none; }
@media (max-width: 800px) {
  .search-panel { max-height: none; }
  .sp-js .search-panel {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 900; width: min(360px, 92vw); max-height: none;
    border-radius: 0 16px 16px 0; transform: translateX(-105%); transition: transform 0.2s ease; visibility: hidden;
  }
  .sp-js .search-panel.is-open { transform: none; visibility: visible; }
}
@media (prefers-reduced-motion: reduce) { .sp-js .search-panel { transition: none; } }
/* My searches tab */
.ss-menu { margin: 0; padding: 0; border: 0; background: transparent; }
.ss-toolbar { display: flex; gap: 0.35rem; align-items: center; margin-bottom: 0.6rem; }
.search-panel .ss-toolbar .ss-find { flex: 1 1 auto; width: auto; margin: 0; }
.ss-empty { text-align: center; padding: 0.75rem 0; }
.ss-group { border-top: 1px solid var(--border); padding: 0.35rem 0; }
.ss-group:first-of-type { border-top: 0; }
.ss-group-title { display: flex; align-items: center; gap: 0.3rem; cursor: pointer; list-style: none; padding: 0.3rem 0; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.ss-group-title::-webkit-details-marker { display: none; }
.ss-group-title .icon { transition: transform 0.15s ease; }
.ss-group[open] > .ss-group-title .icon { transform: rotate(90deg); }
.ss-group-count { margin-left: auto; font-weight: 400; }
.ss-item { display: flex; align-items: center; gap: 0.3rem; position: relative; padding: 0.15rem 0 0.15rem 1.3rem; border-top: 0; }
.ss-item .ss-open { flex: 1 1 auto; min-width: 0; }
.ss-start-mark { color: var(--muted); display: inline-flex; }
.ss-item-actions { margin: 0; }
.ss-row-pop {
  position: absolute; right: 0; top: 100%; z-index: 5; min-width: 200px; padding: 0.5rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.ss-row-pop .ss-inline-form { margin: 0.25rem 0 0; }
.ss-row-pop .ss-inline-form:first-child { margin-top: 0; }
.ss-row-pop .ss-inline-form > .btn { width: 100%; justify-content: flex-start; }
.sp-js .ss-rename-form input[type="text"] { display: none; }
.sp-js .ss-rename-form > .btn { width: 100%; justify-content: flex-start; }
.ss-dialog .ss-help { margin: 0; font-size: 0.85rem; }

/* SR1c: row actions popover (fixed, on body), empty state, compact dialog */
.ss-js-hidden { display: none; }
.ss-popover {
  position: fixed; z-index: 1100; min-width: 220px; max-width: calc(100vw - 16px); padding: 0.3rem 0;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow);
}
.ss-menuitem {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; box-sizing: border-box; padding: 0.5rem 0.9rem;
  border: 0; border-radius: 0; background: transparent; color: var(--text); font: inherit; font-size: 0.9rem;
  line-height: 1.2; text-align: left; cursor: pointer; white-space: nowrap;
}
.ss-menuitem:hover, .ss-menuitem:focus-visible { background: var(--row-hover); outline: none; }
.ss-menuitem .icon { color: var(--muted); }
.ss-menuitem-danger, .ss-menuitem-danger .icon { color: var(--danger-text); }
.ss-menuitem-danger:hover, .ss-menuitem-danger:focus-visible { background: var(--danger-bg); }
.ss-menu-sep { height: 1px; margin: 0.3rem 0; background: var(--border); }
.ss-empty { display: flex; flex-direction: column; align-items: center; gap: 0.6rem; }
.ss-empty p { margin: 0; }
.ss-dialog .tpl-modal-body { gap: 0.5rem; }
.ss-dialog .tpl-modal-error { min-height: 0; margin: 0; }
.ss-dialog .tpl-modal-error:empty { display: none; }
.ss-dialog .tpl-modal-actions { margin-top: 0.5rem; }

/* CFG2: Import / Export layout. The "Good to know" panel scrolls inside itself when it is taller than the window
   (it is sticky, so it was cut off before) and long values wrap instead of widening the page. */
.page-with-aside > .info-aside {
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  min-width: 0;
  overflow-wrap: anywhere;
}
.page-with-aside-main code,
.page-with-aside-main .muted,
.page-with-aside-main .admin-flash {
  overflow-wrap: anywhere;
}
.admin-config-form input[type="file"] {
  max-width: 100%;
}

/* CFG3: change list in the import preview / report */
.cfg-diff-row > td { padding-top: 0; }
.cfg-diff > summary { cursor: pointer; font-weight: 600; padding: 0.25rem 0; }
.cfg-diff-list { list-style: none; margin: 0.3rem 0 0.5rem; padding: 0; display: grid; gap: 0.35rem; }
.cfg-diff-item { display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 0.5rem; align-items: start; border-left: 3px solid var(--border-strong); padding-left: 0.5rem; }
.cfg-diff-added { border-left-color: var(--ok-text); }
.cfg-diff-removed { border-left-color: var(--danger-text); }
.cfg-diff-changed { border-left-color: var(--warn-text); }
.cfg-diff-op { font-size: 0.8125rem; font-weight: 600; }
.cfg-diff-added .cfg-diff-op { color: var(--ok-text); }
.cfg-diff-removed .cfg-diff-op { color: var(--danger-text); }
.cfg-diff-changed .cfg-diff-op { color: var(--warn-text); }
.cfg-diff-lines { display: grid; gap: 0.15rem; min-width: 0; }
.cfg-diff-line { overflow-wrap: anywhere; }
.cfg-diff-code { color: var(--muted); font-size: 0.8125rem; background: none; padding: 0; }
.cfg-diff-seglabel { color: var(--muted); }
.cfg-diff-old { color: var(--danger-text); }
.cfg-diff-new { color: var(--ok-text); }
.cfg-diff-secret { color: var(--muted); font-style: italic; }
.cfg-diff-more { padding-left: 0.5rem; }

/* DEMO1: demo mode banner, login account list, job form */
.demo-banner {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-bottom: 1px solid var(--warn-border);
  padding: 0.45rem 1rem;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
}
/* DEMO2b: progress banner while a demo job runs */
.demo-banner.demo-loading {
  background: var(--primary-soft, var(--warn-bg));
}
/* Login page: the body is a centred flex box, so the banner is laid out as a full-width top row and the card
   centres itself in the remaining space (no overlap with the card, no fixed height needed on phones). */
.login-body:has(> .demo-banner) {
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
}
.login-body > .demo-banner {
  position: sticky;
  top: 0;
  z-index: 30;
  margin: -1.5rem -1.5rem 1.5rem;
  border-bottom: 1px solid var(--warn-border);
}
.login-body:has(> .demo-banner) > .login-card {
  margin: auto;
}
.demo-accounts {
  margin: 1rem 0 0;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
}
.demo-accounts h2 { margin: 0 0 0.25rem; font-size: 0.95rem; }
.demo-accounts p { margin: 0 0 0.4rem; }
.demo-accounts ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 0.2rem 0.75rem; }
.demo-account-btn {
  background: none;
  border: 0;
  padding: 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}
.demo-job-form { margin: 0.75rem 0 0; }
.demo-pw-row { margin: 0 0 0.75rem; }
.demo-pw-row input { display: block; width: 100%; max-width: 32rem; box-sizing: border-box; }
/* Import confirmation: password field on its own row, buttons in one row below it */
.admin-confirm-form { display: block; margin: 1rem 0 0; }
.admin-confirm-buttons { display: flex; flex-wrap: wrap; gap: 0.75rem; }
@media (max-width: 600px) {
  .admin-confirm-buttons .btn { flex: 1 1 100%; }
}
.admin-good-list { margin: 0; padding-left: 1.2rem; }
.admin-good-list li { margin: 0 0 0.4rem; }
