/* --- Design tokens: dark --- */
html[data-theme="dark"] {
  --bg-deep: #070a0f;
  --bg: #0e131b;
  --bg-elevated: #141b26;
  --surface: #1a222e;
  --surface-hover: #222b3a;
  --border: #2f3d52;
  --border-subtle: #252f3f;
  --text: #eef2f7;
  --text-secondary: #9fb0c8;
  --muted: #7d8fa3;
  --accent: #4d9fff;
  --accent-hover: #6eb0ff;
  --accent-muted: rgba(77, 159, 255, 0.14);
  --accent-2: #9b7dff;
  --danger: #f07178;
  --danger-muted: rgba(240, 113, 120, 0.15);
  --success: #5fd4a4;
  --success-muted: rgba(95, 212, 164, 0.14);
  --warning-muted: rgba(77, 159, 255, 0.12);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 30px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 0 1px rgba(77, 159, 255, 0.12);
  --input-bg: #0d1219;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

/* --- Design tokens: light --- */
html[data-theme="light"] {
  --bg-deep: #e8ecf2;
  --bg: #f0f3f8;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-hover: #f5f7fb;
  --border: #d8dee8;
  --border-subtle: #e8ecf2;
  --text: #141a22;
  --text-secondary: #3d4a5c;
  --muted: #5c6b7e;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-muted: rgba(37, 99, 235, 0.1);
  --accent-2: #7c3aed;
  --danger: #dc2626;
  --danger-muted: rgba(220, 38, 38, 0.1);
  --success: #059669;
  --success-muted: rgba(5, 150, 105, 0.12);
  --warning-muted: rgba(37, 99, 235, 0.08);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 40px rgba(15, 23, 42, 0.1);
  --shadow-glow: 0 0 0 1px rgba(37, 99, 235, 0.08);
  --input-bg: #f8fafc;
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  line-height: 1.55;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 100% -20%, var(--accent-muted), transparent 50%),
    radial-gradient(ellipse 80% 50% at -10% 100%, rgba(155, 125, 255, 0.08), transparent 45%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 35%, var(--bg) 100%);
  transition: background-color 0.25s ease, color 0.2s ease;
}

html[data-theme="light"] body {
  background-image:
    radial-gradient(ellipse 100% 70% at 100% 0%, var(--accent-muted), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(124, 58, 237, 0.06), transparent 50%),
    linear-gradient(180deg, #f5f7fb 0%, var(--bg) 40%, var(--bg) 100%);
}

a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

/* --- Header --- */
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem clamp(1.25rem, 2.5vw, 2.5rem);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo:hover {
  color: var(--text);
}

.logo-mark {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  box-shadow: var(--shadow-glow);
}

.logo-img {
  display: block;
  width: 2.25rem;
  height: 2.25rem;
  max-width: 12rem;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.admin-branding-preview-wrap {
  margin: 0.5rem 0 0.75rem;
}

.admin-branding-preview-wrap--favicon {
  max-width: 3rem;
}

.admin-branding-preview {
  max-height: 3rem;
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--surface);
}

.admin-branding-preview--favicon {
  max-height: 2rem;
  image-rendering: crisp-edges;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.org-switch-form {
  display: inline-flex;
  align-items: center;
}

.org-switch-select {
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  max-width: 12rem;
}

.org-switch-current {
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.nav-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.15s;
}

.nav-pill:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--surface-hover);
  transform: translateY(-1px);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.25rem 0.6rem 0.25rem 0.25rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  max-width: 220px;
}

.user-chip-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  flex-shrink: 0;
}

.user-chip-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.theme-toggle:hover {
  background: var(--surface-hover);
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.theme-icon {
  display: none;
}

html[data-theme="dark"] .theme-toggle .theme-icon-sun {
  display: block;
}

html[data-theme="light"] .theme-toggle .theme-icon-moon {
  display: block;
}

/* --- Layout --- */
.container {
  width: 100%;
  max-width: none;
  margin: 0 auto;
  padding: 2rem clamp(1.25rem, 2.5vw, 2.5rem) 3.5rem;
  box-sizing: border-box;
}

.page-title {
  margin-bottom: 0.25rem;
}

.page-title h1 {
  margin: 0 0 0.35rem;
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.page-title .export-actions {
  margin: 0.75rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.85rem;
  box-shadow: var(--shadow-md);
}

.card-narrow {
  max-width: 440px;
  margin: 2rem auto;
}

.auth-card {
  position: relative;
  overflow: hidden;
}

.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: var(--radius) var(--radius) 0 0;
}

.card h1 {
  margin-top: 0;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.detail-list {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.detail-list > div {
  margin: 0;
}

.detail-list dt {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--muted);
  margin: 0 0 0.25rem;
}

.detail-list dd {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
}

/* --- Forms --- */
.stack {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  margin-top: 1.25rem;
}

.stack label,
.form-admin label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.stack label span,
.form-admin label span {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
}

input,
select,
textarea {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover,
select:hover {
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-muted);
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1.25rem;
  transition: background 0.15s, color 0.15s, transform 0.12s, box-shadow 0.15s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 70%, var(--accent-2)) 100%);
  color: #fff;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--accent) 35%, transparent);
}

.btn-primary:hover {
  filter: brightness(1.06);
  box-shadow: 0 4px 18px color-mix(in srgb, var(--accent) 45%, transparent);
}

.btn-outline {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface-hover);
  color: var(--text);
  border-color: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text);
  background: var(--surface-hover);
  border-color: var(--border-subtle);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger-text {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
}

.btn-danger-text:hover {
  color: var(--text);
  background: var(--danger-muted);
}

.danger-zone {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--border));
  background: var(--danger-muted);
}

.danger-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
}

.danger-check {
  align-items: flex-start;
}

.admin-danger-link {
  margin-top: 1.5rem;
}

.admin-danger-link a {
  font-size: 0.875rem;
}

.btn-danger:hover {
  filter: brightness(1.08);
}

.btn-sm,
.btn-small {
  padding: 0.42rem 0.8rem;
  font-size: 0.8125rem;
}

.admin-machine-actions-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  flex-wrap: wrap;
  vertical-align: middle;
}

.btn-icon-table {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.45rem;
  line-height: 0;
}

.btn-icon-table svg {
  width: 1.1rem;
  height: 1.1rem;
}

.inline-form {
  display: inline;
}

/* --- Links as secondary actions --- */
.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-subtle);
}

.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--accent);
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.btn-text:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* --- Flashes --- */
.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.flash {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  margin: 0.75rem 0 0;
}

.trace-output {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
  font-weight: 400;
  line-height: 1.45;
}

.flash-error {
  background: var(--danger-muted);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent);
  color: var(--danger);
}

html[data-theme="light"] .flash-error {
  color: #b91c1c;
}

.flash-info {
  background: var(--warning-muted);
  border: 1px solid color-mix(in srgb, var(--accent) 28%, transparent);
  color: var(--accent-hover);
}

html[data-theme="dark"] .flash-info {
  color: var(--accent-hover);
}

.flash-success {
  background: var(--success-muted);
  border: 1px solid color-mix(in srgb, var(--success) 35%, transparent);
  color: var(--success);
}

html[data-theme="light"] .flash-success {
  color: #047857;
}

/* --- Menu tiles --- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.1rem;
  margin-top: 1.75rem;
}

.menu-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.5rem 1.5rem 1.5rem 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.menu-tile::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  opacity: 0;
  transition: opacity 0.2s;
}

.menu-tile:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  text-decoration: none;
  color: var(--text);
}

.menu-tile:hover::before {
  opacity: 1;
}

.menu-tile-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: var(--radius-sm);
  background: var(--accent-muted);
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.menu-tile-icon svg {
  width: 1.35rem;
  height: 1.35rem;
}

.menu-tile-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.menu-tile-desc {
  font-size: 0.875rem;
  color: var(--muted);
  font-weight: 500;
}

/* --- Category tiles --- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}

.tile-media {
  display: block;
  margin-bottom: 0.65rem;
}

.tile-img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  object-position: center;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.type-img-tooltip {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  max-width: 420px;
}

.type-img-tooltip img {
  display: block;
  width: 100%;
  max-width: 400px;
  max-height: 240px;
  object-fit: contain;
  object-position: center;
  border-radius: 10px;
}

.choice-userinput-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface-2);
  margin-bottom: 0.5rem;
}

.seg-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.seg-toggle-btn {
  padding: 0.45rem 0.7rem;
  font-size: 0.95rem;
  line-height: 1.1;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  color: var(--text);
}

.choice-userinput-toggle .seg-toggle-btn + .seg-toggle-input + .seg-toggle-btn,
.choice-userinput-toggle .seg-toggle-btn + .seg-toggle-btn {
  border-left: 1px solid var(--border);
}

.seg-toggle-input:checked + .seg-toggle-btn {
  background: var(--surface);
  font-weight: 600;
}

.choice-userinput-help {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

.tile {
  padding: 1.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 108px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}

a.tile.tile-link {
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

a.tile.tile-link:hover .tile-title {
  color: var(--accent);
}

.tile:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  box-shadow: var(--shadow-md);
}

.tile-title {
  font-weight: 700;
}

.tile-meta {
  font-size: 0.75rem;
  color: var(--muted);
  font-family: ui-monospace, monospace;
}

.back-link {
  margin-top: 2rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.back-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.back-link a:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
  background: var(--surface-hover);
  text-decoration: none;
}

/* --- Tables --- */
.table-wrap {
  margin-top: 1.25rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

.table-wrap .data-table {
  margin-top: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr {
  transition: background 0.12s;
}

.data-table tbody tr:hover {
  background: var(--surface-hover);
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
}

.card-emails {
  min-width: 0;
}

.table-wrap.emails-table-wrap {
  overflow-x: auto;
  overflow-y: visible;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.emails-table {
  width: 100%;
  table-layout: fixed;
}

.emails-table th,
.emails-table td {
  vertical-align: top;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.emails-table .col-from,
.emails-table .col-subject,
.emails-table .col-category,
.emails-table .col-feedback {
  max-width: 0;
}

.emails-table col.col-time {
  width: 9%;
}

.emails-table col.col-from {
  width: 14%;
}

.emails-table col.col-subject {
  width: 30%;
}

.emails-table col.col-category {
  width: 13%;
}

.emails-table col.col-mode {
  width: 7%;
}

.emails-table col.col-sent {
  width: 7%;
}

.emails-table col.col-feedback {
  width: 12%;
}

.emails-table col.col-actions {
  width: 8%;
}

.emails-table .col-time {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.email-from-address {
  display: block;
  margin-bottom: 0.15rem;
}

.email-ignore-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  margin-top: 0.35rem;
}

.email-ignore-actions .btn {
  justify-content: center;
  width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  padding-inline: 0.45rem;
}

.email-ignore-actions .badge {
  display: block;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
}

.emails-table .col-category .badge {
  display: inline-block;
  max-width: 100%;
  white-space: normal;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.emails-table .col-mode,
.emails-table .col-sent,
.emails-table .col-actions {
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
}

.email-feedback-cell {
  min-width: 0;
  white-space: normal;
}

.email-feedback-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.email-feedback-actions .btn {
  justify-content: center;
  width: 100%;
  white-space: normal;
  text-align: center;
  line-height: 1.25;
  padding-inline: 0.45rem;
}

.emails-table .col-actions .actions {
  flex-wrap: nowrap;
}

@media (max-width: 960px) {
  .emails-table {
    min-width: 52rem;
  }
}

.email-feedback-expand td {
  padding-top: 0;
  background: color-mix(in srgb, var(--surface) 94%, var(--border-subtle));
}

.email-feedback-form {
  max-width: 100%;
  margin-top: 0;
}

.email-feedback-form textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.email-feedback-form .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Sticky první sloupce v tabulkách strojů / přidělení parametrů (admin) */
#machines-param-table th.machines-table-sticky-1,
#machines-param-table th.machines-table-sticky-2,
#machines-param-table th.machines-table-sticky-3,
#param-assignment-table th.machines-table-sticky-1,
#param-assignment-table th.machines-table-sticky-2,
#param-assignment-table th.machines-table-sticky-3 {
  position: sticky;
  z-index: 2;
  background: color-mix(in srgb, var(--surface) 92%, var(--border));
  box-shadow: 1px 0 0 var(--border-subtle);
}

#machines-param-table th.machines-table-sticky-1,
#param-assignment-table th.machines-table-sticky-1 {
  left: 0;
  min-width: 8rem;
}

#machines-param-table th.machines-table-sticky-2,
#param-assignment-table th.machines-table-sticky-2 {
  left: 8rem;
  min-width: 6rem;
}

#machines-param-table th.machines-table-sticky-3,
#param-assignment-table th.machines-table-sticky-3 {
  left: 14rem;
  min-width: 10rem;
}

#machines-param-table td.machines-table-sticky-1,
#machines-param-table td.machines-table-sticky-2,
#machines-param-table td.machines-table-sticky-3,
#param-assignment-table td.machines-table-sticky-1,
#param-assignment-table td.machines-table-sticky-2,
#param-assignment-table td.machines-table-sticky-3 {
  position: sticky;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border-subtle);
}

#machines-param-table td.machines-table-sticky-1,
#param-assignment-table td.machines-table-sticky-1 {
  left: 0;
}

#machines-param-table td.machines-table-sticky-2,
#param-assignment-table td.machines-table-sticky-2 {
  left: 8rem;
}

#machines-param-table td.machines-table-sticky-3,
#param-assignment-table td.machines-table-sticky-3 {
  left: 14rem;
}

.data-table tbody tr:hover td.machines-table-sticky-1,
.data-table tbody tr:hover td.machines-table-sticky-2,
.data-table tbody tr:hover td.machines-table-sticky-3 {
  background: var(--surface-hover);
}

.actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  align-items: center;
}

/* --- Admin --- */
.admin-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0.5rem;
  margin: 0 0 1.5rem;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 5.5rem;
  z-index: 40;
}

.admin-nav-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.admin-nav-pill:hover {
  color: var(--accent);
  background: var(--accent-muted);
  text-decoration: none;
}

.admin-nav-pill.is-active {
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}

section.card[id] {
  scroll-margin-top: 10rem;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.1rem;
  margin-top: 1.25rem;
}

.admin-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1.35rem 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.admin-card:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  text-decoration: none;
  color: var(--text);
}

.admin-card h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.admin-card p {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-ok {
  background: var(--success-muted);
  color: var(--success);
}

.badge-off {
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  color: var(--muted);
}

.badge-warn {
  background: var(--warning-muted);
  color: var(--accent-hover);
}

.badge-bad {
  background: var(--danger-muted);
  color: var(--danger);
}

.form-admin {
  max-width: 520px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1rem;
}

.form-admin.form-wide {
  max-width: 100%;
}

/* --- Settings page --- */
.setting-field {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.setting-field-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem 1rem;
}

.setting-field-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
}

.setting-field-key {
  display: inline-block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}

.setting-field-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.setting-field-desc {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
}

.setting-form-actions {
  gap: 0.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.setting-form--readonly input[readonly],
.setting-form--readonly textarea[readonly],
.setting-form--readonly select:disabled {
  opacity: 0.85;
  cursor: not-allowed;
}

.setting-form--readonly .setting-toggle-btn:disabled,
.setting-form--readonly .setting-stepper-btn:disabled,
.setting-form--readonly .setting-list-btn:disabled,
.setting-form--readonly .setting-list-add:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.setting-divider {
  border: none;
  border-bottom: 1px solid var(--border-subtle);
  margin: 0 0 1rem;
}

.setting-stepper {
  display: inline-flex;
  align-items: stretch;
  max-width: 14rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--input-bg);
}

.setting-stepper-input {
  flex: 1 1 auto;
  min-width: 0;
  width: 5.5rem;
  text-align: center;
  border: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: transparent;
  font-variant-numeric: tabular-nums;
}

.setting-stepper-input:focus {
  box-shadow: none;
  outline: none;
  background: var(--surface);
}

.setting-stepper-btn {
  flex: 0 0 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.setting-stepper-btn:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

.setting-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--input-bg);
}

.setting-toggle-btn {
  padding: 0.55rem 1.1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.setting-toggle-btn + .setting-toggle-btn {
  border-left: 1px solid var(--border);
}

.setting-toggle-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.setting-toggle-btn.is-active {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
  color: #fff;
}

.setting-toggle-btn.is-active:hover {
  filter: brightness(1.05);
  color: #fff;
}

.setting-list-editor {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  max-width: 100%;
}

.setting-list-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.setting-list-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.setting-list-input {
  flex: 1 1 auto;
  min-width: 0;
}

.setting-list-btn {
  flex: 0 0 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.setting-list-btn-remove:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 40%, var(--border));
  background: var(--danger-muted);
}

.setting-weekdays-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.setting-weekday {
  position: relative;
  cursor: pointer;
}

.setting-weekday-input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.setting-weekday-label {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 600;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}

.setting-weekday:hover .setting-weekday-label {
  background: var(--surface-hover);
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 30%, var(--border));
}

.setting-weekday-input:checked + .setting-weekday-label {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 65%, var(--accent-2)));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 30%, transparent);
}

.setting-weekday-input:focus-visible + .setting-weekday-label {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.setting-select,
.setting-time-input {
  max-width: 24rem;
}

.form-admin .checkbox-row {
  flex-direction: row;
  align-items: center;
  gap: 0.6rem;
}

.form-admin .checkbox-row input {
  width: auto;
  accent-color: var(--accent);
}

.form-hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
}

.mono {
  font-family: ui-monospace, "Cascadia Code", monospace;
  font-size: 0.85em;
}

.table-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: center;
  margin: 1rem 0 0;
}

.card-section-label {
  margin: 0 0 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.detail-line {
  margin: 0.35rem 0;
}

.mb-flow {
  margin-bottom: 1.25rem;
}

.form-card-pad {
  padding-top: 1.5rem;
}

.small {
  font-size: 0.8125rem;
}

.filter-spec-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(200px, 280px);
  gap: 1.5rem;
  align-items: start;
  margin-top: 1.25rem;
}

@media (max-width: 900px) {
  .filter-spec-layout {
    grid-template-columns: 1fr;
  }
}

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.matching-panel {
  min-width: 0;
  max-width: 100%;
}

.filter-panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.filter-panel-header .filter-panel-title {
  margin: 0;
}

.filter-panel-title,
.matching-panel-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
}

.filter-form .filter-field {
  margin-bottom: 1rem;
  min-width: 0;
}

.filter-label {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 0;
  max-width: 100%;
}

.filter-label input,
.filter-label select,
.filter-label textarea {
  font-weight: 500;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

/* Radiobuttony u vizuálního choice — ne „na celou šířku“ (jinak rozpad řádku a falešné mezery) */
.filter-label .filter-choice-visual-wrap input[type="radio"],
.filter-label .param-choice-visual-card input[type="radio"] {
  width: auto;
  max-width: none;
  flex-shrink: 0;
}

.filter-select {
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--input-bg);
  color: var(--text);
  font: inherit;
}

.filter-range-point {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border-subtle);
}

.filter-point-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.filter-point-input {
  flex: 1 1 8rem;
  min-width: 0;
  max-width: 12rem;
  height: 2.35rem;
  padding: 0.5rem 0.65rem;
  line-height: 1.2;
}

.filter-num-range-block {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px dashed var(--border-subtle);
}

.filter-num-range-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem;
}

.filter-num-range-label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 6rem;
  min-width: 0;
  max-width: 10rem;
}

.filter-num-range-label .filter-point-input {
  flex: 0 0 auto;
}

.admin-param-section {
  margin-top: 1.5rem;
  padding: 1.35rem 1.5rem;
}

.admin-param-section-title {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.form-tight {
  margin-top: 0.75rem;
  padding: 0.85rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.form-tight label {
  margin-bottom: 0.65rem;
}

.inline-details summary {
  cursor: pointer;
  list-style: none;
}

.inline-details summary::-webkit-details-marker {
  display: none;
}

.range-inputs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  width: 100%;
}

.range-inputs input {
  flex: 1 1 5rem;
  min-width: 0;
}

.range-sep {
  color: var(--muted);
}

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

.machine-row-pick {
  cursor: pointer;
  transition: background 0.12s;
}

.machine-row-pick:hover {
  background: var(--surface-hover);
}

.machine-row-pick.is-selected {
  background: var(--accent-muted);
  color: var(--text);
}

.table-radio-col {
  width: 2.25rem;
}

.machine-pick-table--compact th,
.machine-pick-table--compact td {
  padding: 0.55rem 0.65rem;
}

.machine-type-cell {
  word-break: break-word;
}

.matching-table-wrap {
  overflow-x: auto;
}

.machine-pick-table--with-overview .machine-pick-overview-col {
  white-space: nowrap;
  max-width: 11rem;
  vertical-align: middle;
}

.table-radio {
  width: 2rem;
  vertical-align: middle;
}

.pick-dot {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
}

.machine-row-pick.is-selected .pick-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.specify-action {
  margin-top: 1.25rem;
}

.specify-hint {
  margin-top: 0.5rem;
}

.spec-page-layout {
  display: grid;
  grid-template-columns: 1fr minmax(240px, 300px);
  gap: 1.5rem;
  align-items: start;
  margin-top: 1rem;
}

@media (max-width: 960px) {
  .spec-page-layout {
    grid-template-columns: 1fr;
  }
}

.spec-page-main {
  min-width: 0;
}

.spec-page-aside {
  position: sticky;
  top: 5.5rem;
}

.aside-title {
  margin: 0 0 1rem;
  font-size: 1rem;
  font-weight: 700;
}

.detail-list.compact {
  gap: 0.5rem;
}

.detail-list.compact dt {
  font-size: 0.75rem;
}

.detail-list.compact dd {
  font-size: 0.9rem;
}

#opt-eq-live-summary .summary-label {
  flex: 1 1 auto;
}

.spec-section-title {
  margin: 1.75rem 0 1rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.spec-section-title:first-child {
  margin-top: 0;
}

.spec-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 2rem;
}

.optional-eq-table .table-num {
  width: 110px;
}

.oe-qty-display {
  display: inline-block;
  min-width: 2.5rem;
  padding: 0.25rem 0.45rem;
  border-radius: 10px;
  border: 1px dashed var(--border-subtle);
  cursor: pointer;
  user-select: none;
}

.oe-qty-display:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(120, 120, 255, 0.18);
}

.oe-qty-input[hidden] {
  display: none !important;
}

.opt-eq-hover {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.cfg-eq-hover {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.ceg-qty-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.65rem;
}
.req-mark {
  color: var(--danger);
  font-weight: 700;
}

.param-block--invalid .filter-label > span {
  color: var(--danger);
}

.param-block--invalid input,
.param-block--invalid select,
.param-block--invalid textarea {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px rgba(255, 70, 70, 0.15);
}

.param-block--locked .spec-locked-field {
  padding: 0.75rem 0.95rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.param-block--locked .spec-locked-value {
  margin: 0.35rem 0 0;
  font-weight: 600;
  font-size: 1rem;
}

.card-tight {
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
}

.equipment-slot-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
}

.eq-param-panel[hidden] {
  display: none !important;
}

.summary-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 1.5rem;
  margin-top: 1rem;
}

@media (max-width: 800px) {
  .summary-layout {
    grid-template-columns: 1fr;
  }
}

.summary-aside {
  align-self: start;
}

.summary-main h2 {
  margin: 1.5rem 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.summary-main h2:first-child {
  margin-top: 0;
}

.summary-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.summary-list li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border-subtle);
}

.summary-label {
  color: var(--muted);
  font-weight: 500;
}

.summary-value {
  font-weight: 600;
  text-align: right;
}

.eq-constraint-dialog {
  max-width: 28rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.eq-constraint-dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.eq-constraint-dialog #eq-constraint-dialog-msg {
  margin: 0 0 1rem;
  line-height: 1.5;
}

/* --- Ceny ve specifikaci --- */
.spec-price-panel {
  margin-bottom: 1rem;
}

.spec-price-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}

.spec-price-total-amount {
  font-variant-numeric: tabular-nums;
  margin-left: 0.35rem;
}

.spec-price-total--incomplete {
  color: #e67e22;
}

.spec-price-detail-wrap {
  margin-top: 0.75rem;
}

.spec-price-breakdown {
  margin-bottom: 0.75rem;
}

.spec-price-breakdown th,
.spec-price-breakdown td {
  vertical-align: top;
}

.spec-price-missing {
  color: #c0392b;
  font-weight: 600;
}

.spec-price-subtotals {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.spec-price-subrow {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.spec-price-subrow-total {
  margin-top: 0.35rem;
  padding-top: 0.5rem;
  border-top: 1px dashed var(--border);
}

body.spec-prices-hidden .price-display,
body.spec-prices-hidden .spec-price-hint {
  display: none !important;
}

/* Parametr choice — vizuální segmenty (souprava / rozložení) */
.param-choice-visual-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.35rem;
  width: 100%;
}

.param-choice-visual-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.param-choice-visual-card:hover {
  border-color: var(--border-subtle);
}

.param-choice-visual-card:has(.param-choice-visual-radio:checked) {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
}

.param-choice-visual-card-head {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  width: 100%;
}

.param-choice-visual-card-text {
  flex: 1;
  line-height: 1.35;
}

/* Řádek obrázků pod textem; vlevo, bez mezer mezi segmenty (bez flex-grow u img — ten dělal „díry“) */
.param-choice-visual-strip {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: flex-start;
  align-items: flex-end;
  gap: 0;
  margin-top: 0.35rem;
  width: 100%;
  max-width: 100%;
  line-height: 0;
  font-size: 0;
  overflow: hidden;
  --pcv-scale: 1;
}

.param-choice-visual-strip img {
  flex: 0 0 auto;
  height: calc(3.5rem * var(--pcv-scale));
  width: auto;
  max-width: none;
  object-fit: contain;
  object-position: left bottom;
  display: block;
  margin: 0;
  padding: 0;
  border: 0;
}

.param-choice-visual-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-height: 3.5rem;
  padding: 0 0.2rem;
  font-size: 0.75rem;
  line-height: 1.2;
  color: var(--muted);
  margin: 0;
  border: 0;
  white-space: nowrap;
  box-sizing: border-box;
}

.summary-choice-visual {
  margin-top: 0.35rem;
}

.machine-pick-overview-col .param-choice-visual-strip {
  margin-top: 0.35rem;
}

.machine-pick-overview-col .param-choice-visual-strip img {
  height: calc(2.5rem * var(--pcv-scale));
}

/* Filtrační stránka — choice s vizuály */
.filter-choice-visual-wrap {
  width: 100%;
  max-width: 100%;
}

.filter-choice-visual-dropdown {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.filter-choice-visual-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  list-style: none;
}

.filter-choice-visual-summary::-webkit-details-marker {
  display: none;
}

.filter-choice-visual-summary::after {
  content: "▾";
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform 0.15s ease;
}

.filter-choice-visual-dropdown[open] .filter-choice-visual-summary::after {
  transform: rotate(180deg);
}

.filter-choice-visual-summary-label {
  min-width: 0;
  flex: 1;
  font-weight: 600;
  line-height: 1.35;
}

.filter-choice-visual-summary-meta {
  flex: 0 0 auto;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.filter-panel .filter-param-choice-visual.param-choice-visual-options {
  margin-top: 0;
  gap: 0.5rem;
  padding: 0 0.5rem 0.5rem;
  border-top: 1px solid var(--border);
}

.filter-panel .filter-param-choice-visual .param-choice-visual-strip {
  margin-top: 0.3rem;
  justify-content: flex-start;
}

.filter-panel .filter-param-choice-visual .param-choice-visual-strip img {
  height: calc(2.75rem * var(--pcv-scale));
}

.filter-panel .param-choice-visual-card {
  max-width: 100%;
  align-items: flex-start;
}

.filter-panel .param-choice-visual-card-head {
  flex-wrap: nowrap;
  align-items: center;
}

.filter-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(7, 10, 15, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.filter-loading-overlay[hidden] {
  display: none;
}

.filter-loading-card {
  min-width: min(22rem, 100%);
  max-width: 28rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.filter-loading-card p {
  margin: 0;
  font-weight: 600;
}

.filter-loading-spinner {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 30%, var(--border));
  border-top-color: var(--accent);
  animation: filter-loading-spin 0.75s linear infinite;
  flex: 0 0 auto;
}

body.is-filter-loading {
  cursor: progress;
}

body.is-filter-loading .filter-spec-layout {
  pointer-events: none;
}

@keyframes filter-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .site-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    justify-content: space-between;
  }

  .user-chip-name {
    max-width: 120px;
  }
}

.audit-filters {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 0.75rem 1rem;
  align-items: end;
}

@media (max-width: 768px) {
  .audit-filters {
    grid-template-columns: 1fr;
  }
}

.audit-value-cell {
  max-width: 28rem;
  word-break: break-word;
}

.audit-old {
  color: var(--muted);
}

.audit-new {
  color: var(--text);
}

.password-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.password-strength-meter {
  width: 100%;
  height: 0.45rem;
}
