/* PLC Admin – Entral look without a component library. Tokens first, then layout, components and pages. */

:root {
  --teal-900: #00514d;
  --teal-800: #00726c;
  --teal-700: #0e7c75;
  --teal-600: #095c57;
  --teal-100: #e3f4f2;
  --teal-50: #f3faf9;
  --teal-border: #bfe3de;

  --ink: #1f2328;
  --ink-2: #3a424c;
  --muted: #5b6470;
  --faint: #9aa3ad;
  --line: #e4e7eb;
  --line-soft: #eef0f2;
  --field: #d5dae0;
  --ground: #f6f7f9;
  --ground-2: #f9fafb;
  --ground-3: #f1f3f5;
  --surface: #ffffff;

  --success-bg: #e6f4ea;
  --success: #1e7b34;
  --danger-bg: #fdecec;
  --danger: #b3261e;
  --warning-bg: #fff1cc;
  --warning: #7a4b00;
  --warning-border: #f2d27a;
  --rental-bg: #fff0dc;
  --rental: #8a4600;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-dialog: 0 24px 60px rgba(16, 24, 40, 0.3);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

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

html, body { margin: 0; }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.2; }
h1:focus { outline: none; } /* FocusOnNavigate moves focus to the heading for screen readers */
fieldset { margin: 0; padding: 0; border: 0; min-width: 0; } /* Groups fields to disable them together */
h2 { font-size: 18px; font-weight: 600; }
a { color: var(--teal-700); }
a:hover { color: var(--teal-600); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--teal-700); outline-offset: 2px; }

/* ---------- Utilities ---------- */
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.center { text-align: center; }
.grow { flex-grow: 1; }
.fit { width: fit-content; }
.w-140 { width: 140px; flex-shrink: 0; }
.w-240 { width: 240px; flex-shrink: 0; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.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;
}
.stack-2, .stack-4, .stack-6, .stack-8, .stack-10, .stack-14, .stack-16, .stack-18, .stack-20 { display: flex; flex-direction: column; }
.stack-2 { gap: 2px; } .stack-4 { gap: 4px; } .stack-6 { gap: 6px; } .stack-8 { gap: 8px; } .stack-10 { gap: 10px; }
.stack-14 { gap: 14px; } .stack-16 { gap: 16px; } .stack-18 { gap: 18px; } .stack-20 { gap: 20px; }
.row-10, .row-14, .row-16 { display: flex; align-items: center; flex-wrap: wrap; }
.row-10 { gap: 10px; } .row-14 { gap: 14px; } .row-16 { gap: 16px; align-items: flex-start; }
.icon { flex-shrink: 0; }

/* ---------- Brand ---------- */
.wordmark { font-size: 30px; font-weight: 300; letter-spacing: -0.5px; line-height: 1; color: var(--ink); }
.wordmark-md { font-size: 26px; }
.wordmark-lg { font-size: 44px; letter-spacing: -1px; }
.chip {
  font-size: 11px; font-weight: 600; letter-spacing: 0.4px; color: var(--teal-800);
  background: var(--teal-100); padding: 4px 8px; border-radius: 999px; white-space: nowrap;
}

/* ---------- App shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 20px 12px; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; justify-content: space-between; padding: 0 10px 24px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-section {
  font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase;
  color: var(--muted); padding: 16px 10px 8px;
}
.nav-section:first-child { padding-top: 8px; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: var(--radius);
  color: var(--ink-2); font-size: 14px; font-weight: 500; text-decoration: none;
}
.nav-link:hover { background: var(--ground-3); color: var(--ink); }
.nav-link.active { background: var(--teal-100); color: var(--teal-800); font-weight: 600; }
.sidebar-footer {
  margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 12px 10px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.sidebar-footer-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.sidebar-footer-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-footer b { color: var(--ink-2); font-weight: 600; }

.main { flex-grow: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  height: 64px; flex-shrink: 0; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 0 32px;
  position: sticky; top: 0; z-index: 10;
}
.env-pill {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--warning);
  background: var(--warning-bg); border: 1px solid var(--warning-border); padding: 5px 10px; border-radius: 999px;
}
.env-pill .dot { width: 7px; height: 7px; border-radius: 999px; background: #c98a00; }
.live-pill {
  display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 5px 10px;
  border-radius: 999px; border: 1px solid var(--line); text-decoration: none; white-space: nowrap;
}
.live-pill .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.live-pill b { font-weight: 600; }
.live-ok, .live-ok:hover { color: var(--success); background: var(--success-bg); border-color: #bfe3c8; }
.live-down, .live-down:hover { color: var(--danger); background: var(--danger-bg); border-color: #f6c7c3; }
.live-unknown, .live-unknown:hover { color: var(--muted); background: var(--ground-3); }

.user-menu { position: relative; }
.user-menu summary {
  list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 10px 6px 6px; background: var(--surface);
}
.user-menu summary::-webkit-details-marker { display: none; }
.avatar {
  width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--teal-700); color: #fff;
  font-size: 12px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}
.user-menu .menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12); padding: 6px;
}
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; text-align: left;
}
.menu-item:hover { background: var(--ground-3); }

.content { flex-grow: 1; padding: 32px 40px; display: flex; flex-direction: column; gap: 24px; min-width: 0; }

.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.page-header-center { align-items: center; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: -8px; }
.breadcrumb a { text-decoration: none; font-weight: 500; }
.breadcrumb span:last-child { color: var(--ink); font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--radius); border: 1px solid transparent; font-size: 14px; font-weight: 600;
  text-decoration: none; white-space: nowrap; transition: background-color 0.12s, border-color 0.12s;
}
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 18px; }
.btn-xl { height: 56px; border-radius: var(--radius-lg); font-size: 16px; }
.btn-block, .btn-xl { width: 100%; }
.btn-primary { background: var(--teal-700); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--teal-600); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--field); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { background: var(--ground-2); color: var(--ink); }
.btn-outline { background: var(--surface); border-color: var(--teal-700); color: var(--teal-700); }
.btn-outline:hover:not(:disabled) { background: var(--teal-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #8f1d17; }
.btn-text-danger { background: transparent; color: var(--danger); padding: 0 12px; }
.btn-text-danger:hover { background: var(--danger-bg); }
.btn-link { background: transparent; color: var(--teal-900); text-decoration: underline; padding: 0 8px; }
.btn:disabled { opacity: 0.55; }

.btn-icon {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
}
.btn-icon:hover { background: var(--ground-3); color: var(--ink); }
.btn-icon-accent { border: 1px solid var(--teal-border); background: var(--teal-100); color: var(--teal-700); }
.btn-icon-accent:hover { background: #d3ede9; color: var(--teal-800); }

.btn-return {
  height: 26px; display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border: 1px solid #f2c27a;
  border-radius: var(--radius-sm); background: #fff7ea; color: var(--warning); font-size: 12px; font-weight: 600;
}
.btn-return:hover { background: #ffefd2; }

.link-icon { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 500; text-decoration: none; }

/* ---------- Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 600; }
.field-error { font-size: 12px; font-weight: 500; color: var(--danger); }
.hint { font-size: 12px; color: var(--muted); }
.input {
  width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--field); border-radius: var(--radius);
  background: var(--surface); font-size: 14px; min-width: 0;
}
.input:focus { outline: none; border-color: var(--teal-700); box-shadow: 0 0 0 1px var(--teal-700); }
.input-sm { height: 34px; padding: 0 10px; font-size: 13px; }
.input-lg { height: 44px; padding: 0 14px; }
.input.invalid, .input[aria-invalid="true"], .input.invalid:focus {
  border-color: var(--danger); background: #fff8f7; box-shadow: none;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input { padding-right: 28px; }

.checkbox { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.checkbox input, .cell-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal-700); cursor: pointer; }
.checkbox-boxed { height: 40px; padding: 0 12px; border: 1px solid var(--field); border-radius: var(--radius); background: var(--surface); white-space: nowrap; }

.search { position: relative; display: flex; align-items: center; width: 360px; max-width: 100%; }
.search .icon { position: absolute; left: 12px; color: var(--muted); pointer-events: none; }
.search .input { padding-left: 40px; }

.segmented { display: inline-flex; background: var(--ground-3); border-radius: var(--radius); padding: 3px; gap: 2px; width: fit-content; }
.segmented button {
  height: 34px; padding: 0 14px; border: 0; border-radius: var(--radius-sm); background: transparent;
  font-size: 13px; font-weight: 500; color: var(--muted);
}
.segmented button.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.08); }
.segmented-lg button { height: 38px; padding: 0 18px; font-size: 14px; }

.toggle {
  position: relative; width: 40px; height: 24px; flex-shrink: 0; border: 0; border-radius: 999px;
  background: var(--field); padding: 0; transition: background-color 0.15s;
}
.toggle-knob {
  position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 999px; background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15); transition: left 0.15s;
}
.toggle.on { background: var(--teal-700); }
.toggle.on .toggle-knob { left: 19px; }
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px;
}
.toggle-row-plain { border: 0; border-top: 1px solid var(--line-soft); border-radius: 0; padding: 12px 0 0; }
.toggle-row-title { font-size: 14px; font-weight: 600; }

/* Searchable select */
.select { position: relative; min-width: 0; }
.select-button {
  width: 100%; height: 40px; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 12px; border: 1px solid var(--field); border-radius: var(--radius); background: var(--surface); font-size: 14px;
}
.select-value { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.select-backdrop { position: fixed; inset: 0; z-index: 30; }
.select-panel {
  position: absolute; z-index: 31; top: calc(100% + 4px); left: 0; right: 0; min-width: 240px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14); overflow: hidden;
}
.select-panel.up { top: auto; bottom: calc(100% + 4px); }
.select-search { padding: 8px; border-bottom: 1px solid var(--line-soft); }
.select-list { list-style: none; margin: 0; padding: 4px; max-height: min(260px, 40vh); overflow-y: auto; }
.select-list button {
  width: 100%; text-align: left; padding: 9px 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
}
.select-list button:hover { background: var(--ground-3); }
.select-list button.active { background: var(--teal-100); color: var(--teal-800); font-weight: 600; }
.select-empty { padding: 10px; color: var(--muted); }

/* ---------- Cards, stats, tables ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.card-pad { padding: 20px; overflow: visible; }
.card-title { font-size: 16px; font-weight: 600; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.card-toolbar {
  display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.card:has(.select-panel), .card:has(.menu-panel) { overflow: visible; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat-accent { background: var(--teal-800); border-color: var(--teal-800); color: #fff; }
.stat-label { font-size: 13px; font-weight: 600; }
.stat-value { font-size: 32px; font-weight: 600; line-height: 1.15; }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 20px; background: var(--ground-2); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted); white-space: nowrap;
}
.table td { padding: 12px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fbfcfc; }
.table-compact th, .table-compact td { padding: 8px 12px; }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover td { background: var(--ground-2); }
.table-clickable tbody tr.row-selected:hover td { background: var(--teal-50); }
.table-scroll { overflow-x: auto; }
.dialog-body .table-scroll { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius); }
.row-muted td { color: var(--muted); background: #fafbfc; }
.row-selected td, .row-selected:hover td { background: var(--teal-50); }
.row-pending td { background: #fffbef; }
.cell-title { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--muted); }
.cell-check { width: 44px; padding-right: 0 !important; }
.cell-actions { text-align: right; white-space: nowrap; }
.cell-num { text-align: right; font-variant-numeric: tabular-nums; }
.th-sort {
  display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; padding: 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit;
}
.th-sort.active, .th-sort:hover { color: var(--ink); }

.pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 4px 10px;
  border-radius: 999px; white-space: nowrap; vertical-align: middle;
}
.pill .dot { width: 7px; height: 7px; border-radius: 999px; background: currentColor; }
.pill-success { background: var(--success-bg); color: var(--success); }
.pill-danger { background: var(--danger-bg); color: var(--danger); }
.pill-neutral { background: var(--ground-3); color: var(--muted); }
.pill-warning { background: var(--warning-bg); color: var(--warning); }
.pill-rental { background: var(--rental-bg); color: var(--rental); font-size: 11px; padding: 2px 8px; margin-left: 8px; }
.tag, .type-tag { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-sm); background: #eef1f4; color: var(--ink-2); }
.type-tag { font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-var { font-size: 12px; padding: 2px 8px; border-radius: var(--radius-sm); background: var(--ground-3); color: var(--ink-2); white-space: nowrap; }
.chip-var b { font-weight: 600; }
.chip-more { background: var(--teal-100); color: var(--teal-800); font-weight: 600; }
.owner-cell { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.selection-bar {
  display: flex; align-items: center; gap: 12px; padding: 10px 20px; background: var(--teal-100);
  border-bottom: 1px solid var(--teal-border); flex-wrap: wrap;
}
.selection-count { font-weight: 600; color: var(--teal-900); }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--line-soft); }
.pager-buttons { display: flex; gap: 6px; }
.btn-page {
  min-width: 34px; height: 34px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
}
.btn-page.active { background: var(--teal-700); border-color: var(--teal-700); color: #fff; font-weight: 600; }
.btn-page:disabled { color: var(--faint); }

.empty { padding: 32px 20px; text-align: center; color: var(--muted); }
.table.is-loading tbody { opacity: 0.45; transition: opacity 0.15s; }
.loading-text { display: inline-flex; align-items: center; gap: 8px; color: var(--teal-800); font-weight: 600; }
.spinner { width: 14px; height: 14px; border-radius: 999px; border: 2px solid var(--teal-border); border-top-color: var(--teal-700); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* Only shown when loading takes a while, so fast loads do not flash a loading text */
.delayed-loading { animation: fade-in 0.2s ease-out 0.5s both; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.alert { padding: 12px 14px; border-radius: var(--radius); font-size: 14px; border: 1px solid transparent; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #f6c7c3; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #bfe3c8; }
.alert-info { background: #e7f0fb; color: #1d4f91; border-color: #c5d9f2; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }

/* ---------- Dialog ---------- */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(31, 35, 40, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.dialog {
  max-width: 100%; max-height: calc(100vh - 48px); background: var(--surface); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-dialog); display: flex; flex-direction: column;
}
.dialog-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 24px; overflow-y: auto; }
/* An open picker extends past the body, which would otherwise clip it (like .card) */
.dialog-body:has(.select-panel), .dialog-body:has(.menu-panel) { overflow: visible; }
.dialog-footer {
  display: flex; align-items: center; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line);
  background: var(--ground-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

/* ---------- Device detail ---------- */
.detail-grid { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.readonly-value { padding: 2px 0; }

/* ---------- Device settings ---------- */
.settings-head { display: flex; flex-direction: column; gap: 10px; padding: 18px 20px 14px; }
.settings-toolbar { padding-top: 0; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1.6fr) minmax(0, 1.4fr) auto; gap: 16px; align-items: center; padding: 12px 20px; }
.settings-grid-head {
  padding-top: 10px; padding-bottom: 10px; background: var(--ground-2); border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 600; letter-spacing: 0.3px; text-transform: uppercase; color: var(--muted);
}
.settings-group {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px 20px; border: 0; border-bottom: 1px solid var(--line-soft);
  background: #fcfcfd; text-align: left;
}
.settings-group:hover { background: var(--ground-3); }
.rotate-90 { transform: rotate(-90deg); }
.settings-row { border-bottom: 1px solid var(--line-soft); }
.settings-row.row-edited { background: var(--teal-50); }
.settings-key { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.settings-key label { font-size: 13px; font-weight: 500; overflow-wrap: anywhere; }
.settings-value, .settings-status { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: flex-start; }
.settings-value > .mono { overflow-wrap: anywhere; }
.settings-input { width: 100%; max-width: 240px; }
.settings-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.value-change { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.strike { text-decoration: line-through; }
.input-changed { border-color: var(--teal-700); background: var(--teal-50); }

.pill-info { background: #e7f0fb; color: #1d4f91; }
.pill-orange { background: #fff1de; color: #8a4600; }
.pill-unsaved { background: var(--teal-100); color: var(--teal-900); }
.pill-xs { font-size: 11px; padding: 2px 8px; }

.segmented-sm button { height: 32px; padding: 0 14px; }
.segmented button.active-accent { background: var(--teal-700); color: #fff; font-weight: 600; }

.btn-warning-soft { background: #fff7ea; border-color: #f2c27a; color: var(--warning); }
.btn-warning-soft:hover { background: #ffefd2; }
.btn-icon-sm { width: 32px; height: 32px; }

.row-menu { position: relative; }
.menu-panel {
  position: absolute; z-index: 31; right: 0; top: calc(100% + 4px); width: 280px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(16, 24, 40, 0.14); padding: 6px;
}
.menu-option {
  width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 10px; border: 0; border-radius: var(--radius-sm);
  background: transparent; text-align: left; font-size: 14px; font-weight: 500;
}
.menu-option:hover { background: var(--ground-3); }
.menu-divider { height: 1px; background: var(--line-soft); margin: 4px 0; }

.changes-bar {
  position: sticky; bottom: 20px; z-index: 20; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 16px 12px 20px; background: var(--ink); color: #fff; border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(16, 24, 40, 0.25);
}
.changes-dot { width: 8px; height: 8px; border-radius: 999px; background: #3fd0c3; }
.changes-names { font-size: 13px; color: #c4cbd3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 520px; }
.changes-error { font-size: 13px; font-weight: 600; color: #ffb4ab; }
.btn-link-light { background: transparent; color: #fff; text-decoration: underline; }
.btn-bright { background: #3fd0c3; color: #0b2e2b; font-weight: 700; }
.btn-bright:hover:not(:disabled) { background: #62dccf; }

.review-list { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.review-row { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1.6fr) auto; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line-soft); }
.review-row:last-child { border-bottom: 0; }
.review-change { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  /* Add the same photograph as the UE portal here: background-image: url(../img/login.jpg); */
  background: #23313a center / cover no-repeat;
}
.login-card {
  width: 460px; max-width: 100%; background: var(--surface); border-radius: 20px; padding: 36px;
  display: flex; flex-direction: column; gap: 24px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.login-brand { display: flex; align-items: center; justify-content: space-between; }
.login-title { font-size: 26px; }
.login-form {
  background: var(--ground); border: 1px solid var(--line-soft); border-radius: var(--radius-lg); padding: 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-form .validation-message { font-size: 12px; font-weight: 500; color: var(--danger); }
.login-form .input.invalid { border-color: var(--danger); }

.message-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px; text-align: center; }

/* ---------- Public mobile flow ---------- */
.mobile-page { min-height: 100vh; min-height: 100dvh; max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; background: var(--ground); }
.mobile-header {
  height: 60px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.progress { display: flex; gap: 6px; padding: 12px 20px 0; }
.progress span { flex-grow: 1; height: 4px; border-radius: 999px; background: var(--field); }
.progress span.done { background: var(--teal-700); }
.mobile-main { flex-grow: 1; display: flex; flex-direction: column; gap: 20px; padding: 24px 20px 32px; font-size: 15px; }
.mobile-main h1 { font-size: 26px; }
.lead { font-size: 15px; color: var(--muted); line-height: 1.5; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: var(--muted); }
.serial { font-family: var(--mono); font-size: 20px; font-weight: 500; letter-spacing: 0.5px; word-break: break-all; }
.mobile-page .card { border-radius: var(--radius-xl); }
.mobile-center { flex-grow: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; text-align: center; }
.result-icon { width: 88px; height: 88px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.result-icon-success { background: var(--success-bg); color: var(--success); }
.result-icon-danger { background: var(--danger-bg); color: var(--danger); }
.scanner { width: 100%; min-height: 300px; border-radius: var(--radius-xl); overflow: hidden; background: #1b2429; }
.scanner video { display: block; width: 100% !important; }
.manual-entry summary { cursor: pointer; font-weight: 600; color: var(--teal-700); padding: 4px 0; }
.manual-entry form { margin-top: 12px; }
.link-card { display: flex; flex-direction: column; }
.link-part { padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.link-arrow { display: flex; align-items: center; gap: 12px; padding: 0 20px; }
.link-arrow > span:not(.link-arrow-icon) { flex-grow: 1; height: 1px; background: var(--line); }
.link-arrow-icon { width: 36px; height: 36px; border-radius: 999px; background: var(--teal-100); color: var(--teal-700); display: flex; align-items: center; justify-content: center; }

/* ---------- Blazor ---------- */
#blazor-error-ui {
  display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; padding: 12px 20px;
  background: var(--warning-bg); color: var(--warning); border-top: 1px solid var(--warning-border); font-weight: 500;
}
#blazor-error-ui .reload { margin-left: 12px; }
.blazor-error-boundary { padding: 16px; border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); }
.blazor-error-boundary::after { content: "Ett fel inträffade."; }

/* ---------- Live log ---------- */
.monitor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.monitor-card { display: flex; flex-direction: column; }
.monitor-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 16px; padding: 16px 20px 0; }
.monitor-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; padding: 14px 20px 16px; }
.progress { height: 4px; background: var(--ground-3); }
.progress-bar { height: 100%; background: var(--teal-700); transition: width 0.3s; }
.spinner-xs { width: 10px; height: 10px; border-width: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: -8px; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; margin-bottom: -1px;
  color: var(--muted); font-weight: 500; text-decoration: none; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--teal-800); font-weight: 600; border-bottom-color: var(--teal-700); }
.tab-count { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--ground-3); padding: 1px 8px; border-radius: 999px; }
.dot-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.log { font-family: var(--mono); font-size: 12px; line-height: 1.5; max-height: 560px; overflow-y: auto; background: var(--ground-2); }
.log-line { display: flex; gap: 12px; padding: 3px 20px; border-bottom: 1px solid var(--line-soft); }
.log-line:last-child { border-bottom: 0; }
.log-time { color: var(--faint); flex-shrink: 0; }
.log-device { flex-shrink: 0; width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-message { overflow-wrap: anywhere; white-space: pre-wrap; min-width: 0; }
.log-warning { background: #fff8e6; }
.log-warning .log-message { color: var(--warning); }
.log-note { padding: 10px 20px; font-size: 13px; color: var(--muted); background: var(--ground-2); border-bottom: 1px solid var(--line-soft); }
.session { border-bottom: 1px solid var(--line); }
.session:last-child { border-bottom: 0; }
.session summary { display: flex; align-items: center; gap: 10px; padding: 12px 20px; cursor: pointer; list-style: none; }
.session summary::-webkit-details-marker { display: none; }
.session summary:hover { background: var(--ground-2); }
.session-chevron { transform: rotate(-90deg); transition: transform 0.15s; color: var(--muted); }
.session[open] .session-chevron { transform: none; }
.session[open] summary { border-bottom: 1px solid var(--line-soft); }

/* ---------- Narrow screens ---------- */
@media (max-width: 1280px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 0 12px 0 0; gap: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-section, .sidebar-footer { display: none; }
  .topbar { padding: 0 16px; position: static; }
  .content { padding: 20px 16px; }
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .monitor-grid { grid-template-columns: minmax(0, 1fr); }
  .table-wrap-mobile, .card { overflow-x: auto; }
  .search { width: 100%; }
  .w-240 { width: 100%; }
}
