:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --border: #e8e8e8;
  --border-strong: #d9d9d9;
  --text: #333333;
  --text-muted: #666666;
  --text-faint: #999999;
  --accent: #ff7800;
  --accent-soft: #fff5e6;
  --accent-strong: #e56b00;
  --brand: #ff7800;
  --sidebar-bg: #222222;
  --sidebar-text: #cccccc;
  --sidebar-text-active: #ff7800;
  --sidebar-hover: #2c2c2c;
  --danger: #d92d20;
  --danger-soft: #fef3f2;
  --warning: #b54708;
  --warning-soft: #fffaeb;
  --success: #027a48;
  --success-soft: #ecfdf3;
  --info-soft: #fff8f0;
  --table-head: #f5f5f5;
  --radius: 4px;
  --sidebar-width: 220px;
  --topbar-height: 56px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.1);
  --font: "Roboto", "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
}

.icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 0;
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
}

.brand-mark .icon {
  width: 17px;
  height: 17px;
}

.brand-text .brand-sub {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--sidebar-text);
  letter-spacing: 0.2px;
  text-transform: none;
}

.sidebar-nav {
  padding: 4px 0 24px;
  overflow-y: auto;
  flex: 1;
}

.nav-group-label {
  padding: 18px 20px 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #888888;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  margin-bottom: 0;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--sidebar-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-item.is-active {
  background: transparent;
  border-left-color: var(--accent);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title {
  font-size: 13px;
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button:hover {
  background: var(--table-head);
  color: var(--text);
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 28px 32px 48px;
  width: 100%;
  max-width: none;
  min-height: 0;
  overflow-y: auto;
}

.page-title {
  margin: 0 0 4px;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: -0.4px;
}

.page-subtitle {
  margin: 0 0 22px;
  color: var(--text-muted);
}

.app-footer {
  flex-shrink: 0;
  padding: 18px 32px 28px;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.sidebar-scrim {
  display: none;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.card-tinted-blue {
  background: var(--info-soft);
  border-color: #ffd4a8;
}

.card-tinted-green {
  background: var(--success-soft);
  border-color: #a6f4c5;
}

.card-tinted-amber {
  background: var(--warning-soft);
  border-color: #fedf89;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.card-title-blue {
  color: var(--accent-strong);
}

.card-title-green {
  color: var(--success);
}

.card-title-amber {
  color: var(--warning);
}

.card-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 12.5px;
}

.collapsible-card {
  padding-top: 12px;
  padding-bottom: 12px;
}

.collapsible-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  margin-bottom: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.collapsible-card:not(.is-collapsed) .collapsible-toggle {
  margin-bottom: 14px;
}

.collapsible-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 14px;
  min-width: 0;
  flex: 1;
}

.collapsible-chevron {
  flex: 0 0 auto;
  color: var(--accent-strong);
  transition: transform 0.18s ease;
}

.collapsible-card:not(.is-collapsed) .collapsible-chevron {
  transform: rotate(180deg);
}

.collapsible-body {
  display: block;
}

.collapsible-card.is-collapsed .collapsible-body {
  display: none;
}

/* ---------- Forms ---------- */

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
}

.input,
.select {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(255, 120, 0, 0.22);
  border-color: var(--accent);
}

.input:disabled,
.select:disabled {
  background: var(--table-head);
  color: var(--text-faint);
  cursor: not-allowed;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row .input {
  flex: 1;
}

.field-hint {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.radio-row {
  display: flex;
  gap: 18px;
  align-items: center;
}

.radio-option,
.checkbox-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.date-range {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-range .input {
  flex: 1;
}

.date-range-separator {
  color: var(--text-faint);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-secondary {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.btn-secondary:hover:not(:disabled) {
  background: #ffe8cc;
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--table-head);
  color: var(--text);
}

.btn-sm {
  padding: 6px 11px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- Chips / filters ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: #475467;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.chip:hover {
  background: var(--table-head);
}

.chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

/* ---------- Lists ---------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.list-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.list-item-title {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 700;
}

.list-item-meta {
  color: var(--text-muted);
  font-size: 12.5px;
}

.meta-separator {
  margin: 0 7px;
  color: var(--text-faint);
}

.firmware-detail {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.firmware-name {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 600;
  word-break: break-all;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  color: var(--text-muted);
  font-size: 12.5px;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.version-list {
  margin-top: 10px;
  border-top: 1px solid var(--border);
}

.version-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.version-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.version-info {
  min-width: 0;
}

.version-info .firmware-name {
  margin-bottom: 6px;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-amber {
  background: var(--warning-soft);
  border: 1px solid #fedf89;
  color: var(--warning);
}

.badge-muted {
  background: #f2f4f7;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.badge-ok {
  background: var(--success-soft);
  border: 1px solid #a6f4c5;
  color: var(--success);
}

/* ---------- Tables ---------- */

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table th {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--table-head);
  text-transform: none;
  letter-spacing: 0;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.table-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  white-space: nowrap;
}

/* ---------- Password results ---------- */

.password-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.password-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.password-date {
  color: var(--text-muted);
  font-size: 12.5px;
}

.password-value {
  font-family: "Cascadia Mono", Consolas, "SF Mono", Menlo, monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.6px;
}

/* Password generator — card fills page height */
.content:has(#view-password:not([hidden])) {
  padding-bottom: 28px;
}

#view-password {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
}

.pw-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  margin-bottom: 0;
  padding: 20px;
  min-height: 0;
}

.pw-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 0 0 auto;
}

.pw-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: end;
}

.pw-row:has(.pw-field-date.hidden) {
  grid-template-columns: auto;
}

.pw-row .field {
  margin-bottom: 0;
}

.pw-row-action {
  grid-template-columns: 1fr auto;
}

.pw-generate {
  min-height: 40px;
  align-self: end;
  white-space: nowrap;
}

.pw-results {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  min-height: 0;
}

.pw-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex: 0 0 auto;
}

#view-password .password-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.pw-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  height: 100%;
  padding: 14px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  background: #f8fafc;
  border-radius: 8px;
}

#view-password .page-subtitle {
  margin-bottom: 14px;
}

#view-password[hidden] {
  display: none !important;
}

#view-password .alert {
  flex: 0 0 auto;
}

/* ---------- States ---------- */

.state {
  padding: 44px 20px;
  text-align: center;
  color: var(--text-muted);
}

.state .icon {
  width: 30px;
  height: 30px;
  margin-bottom: 8px;
  color: var(--text-faint);
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 10px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.spinner-inline {
  width: 15px;
  height: 15px;
  border-width: 2px;
  margin: 0;
  display: inline-block;
  vertical-align: -2px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}

.alert-danger {
  background: var(--danger-soft);
  border-color: #fecdca;
  color: #912018;
}

.alert-content {
  flex: 1;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
}

.pagination-info {
  color: var(--text-muted);
  font-size: 13px;
}

.info-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 18px;
}

.info-grid dt {
  color: var(--text-muted);
  font-size: 13px;
}

.info-grid dd {
  margin: 0;
  font-weight: 600;
  word-break: break-all;
}

.hidden {
  display: none !important;
}

/* Icon sprite: taken out of flow so it never affects layout. */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.stack-sm {
  margin-top: 8px;
}

.mb-md {
  margin-bottom: 14px;
}

/* ---------- Modal ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 24, 40, 0.5);
}

.modal-panel {
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #eaecf0;
  overflow: hidden;
  margin: 12px 0 8px;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.15s ease;
}

.download-filename {
  font-weight: 600;
  word-break: break-all;
}

/* ---------- Toasts ---------- */

.toast-stack {
  position: fixed;
  /* Clear of the top bar so notifications never cover the log out button. */
  top: calc(var(--topbar-height) + 12px);
  right: 16px;
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow-md);
}

.toast-success {
  border-left-color: var(--success);
}

.toast-error {
  border-left-color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

/* ---------- Login page ---------- */

/* Firmware iSolar login — matches the original Electron login card. */
.isolar-login-wrap {
  display: flex;
  justify-content: center;
  padding: 12px 0 28px;
}

.isolar-login-card {
  width: 100%;
  max-width: 450px;
  background: var(--surface);
  border-radius: 12px;
  padding: 40px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.isolar-login-header {
  text-align: center;
  margin-bottom: 28px;
}

.isolar-login-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
}

.isolar-login-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.isolar-login-card .field {
  margin-bottom: 18px;
}

.isolar-login-card .input,
.isolar-login-card .select {
  padding: 12px 16px;
}

.isolar-login-card .btn-block {
  margin-top: 4px;
  padding: 12px 24px;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #fff5e6 0%, #ffffff 48%, #f5f5f5 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px;
  box-shadow: var(--shadow-md);
}

.login-header {
  text-align: center;
  margin-bottom: 22px;
}

.login-header .brand-mark {
  width: 42px;
  height: 42px;
  margin: 0 auto 12px;
  border-radius: 12px;
}

.login-header .brand-mark .icon {
  width: 24px;
  height: 24px;
}

.login-title {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 700;
}

.login-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 13px;
}

.login-footer {
  margin: 18px 0 0;
  text-align: center;
  color: var(--text-faint);
  font-size: 12px;
}

.login-remember-row {
  margin-bottom: 18px;
}

.login-card .input {
  min-height: 44px;
  font-size: 16px;
}

.login-card .btn-block {
  min-height: 46px;
  font-size: 15px;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    left: 0;
    width: min(280px, 86vw);
    flex: none;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(16, 24, 40, 0.45);
    border: 0;
  }

  .topbar {
    padding: 0 12px 0 10px;
    gap: 8px;
  }

  .topbar-title {
    font-size: 12px;
  }

  .content {
    padding: 18px 14px 32px;
  }

  .input,
  .select,
  .btn {
    font-size: 16px;
  }

  .input,
  .select {
    min-height: 44px;
  }

  .page-title {
    font-size: 22px;
  }

  .page-subtitle {
    font-size: 13px;
    margin-bottom: 16px;
  }

  .card {
    padding: 16px;
  }

  .input-row {
    flex-wrap: wrap;
  }

  .input-row .input {
    flex: 1 1 100%;
  }

  .input-row .btn {
    flex: 1 1 auto;
  }

  .list-item-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .list-item-head .btn {
    width: 100%;
  }

  .password-row {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }

  .password-row .btn {
    width: auto;
    flex: 0 0 auto;
  }

  .pw-row,
  .pw-row-action {
    grid-template-columns: 1fr;
  }

  .pw-generate {
    width: 100%;
  }

  .version-row {
    flex-direction: column;
    gap: 10px;
  }

  .version-row .btn {
    width: 100%;
  }

  .table-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .table-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .data-table th:nth-child(3),
  .data-table td:nth-child(3),
  .data-table th:nth-child(4),
  .data-table td:nth-child(4) {
    display: none;
  }

  .modal {
    padding: 12px;
    align-items: flex-end;
  }

  .modal-panel {
    max-width: none;
    border-radius: 14px 14px 10px 10px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    max-width: none;
  }

  .app-footer {
    padding: 14px 16px 22px;
    font-size: 11px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .info-grid {
    grid-template-columns: 1fr;
    gap: 2px 0;
  }

  .info-grid dd {
    margin-bottom: 10px;
  }

  .isolar-login-card {
    padding: 28px 20px;
    border-radius: 12px;
  }

  .isolar-login-title {
    font-size: 20px;
  }

  .chip-row {
    gap: 6px;
  }

  .chip {
    font-size: 12px;
    padding: 6px 10px;
  }
}

@media (max-width: 480px) {
  .login-page {
    padding: 12px;
    align-items: stretch;
    place-items: stretch;
  }

  .login-card {
    max-width: none;
    margin: auto 0;
    padding: 22px 18px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
  }

  .login-title {
    font-size: 19px;
  }

  .login-subtitle {
    font-size: 12.5px;
  }

  .topbar #btn-logout {
    padding: 8px 10px;
  }

  .pagination {
    flex-wrap: wrap;
  }
}

@media (min-width: 901px) {
  .topbar-menu-button {
    display: none;
  }
}

/* ---------- Fault recording / History data (SG Fault Viewer) ---------- */

.alert-warning {
  background: var(--warning-soft);
  border-color: #fedf89;
  color: var(--warning);
}

/* One compact row: open file, a couple of selects, status, export buttons. */
.fv-openbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  padding: 9px 12px;
}

.fv-barlabel {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.fv-barinput {
  width: auto;
  min-width: 120px;
  max-width: 220px;
  padding: 5px 9px;
  font-size: 13px;
}

.fv-barcheck {
  font-size: 12.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

.fv-barstatus {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

.fv-spacer {
  flex: 1 1 auto;
}

/* The real input stays clickable but invisible, so the label reads as a button. */
.fv-filebtn {
  position: relative;
  overflow: hidden;
  cursor: pointer;
}

.fv-filebtn input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  font-size: 0;
}


/* ---------- Fault recording: chart + side panel ---------- */

.fv-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  align-items: start;
}

.fv-chartpane {
  min-width: 0;
  padding: 10px 14px 14px;
}

.fv-charthead {
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-bottom: 2px;
}

.fv-charthead .icon-button:disabled {
  opacity: 0.4;
  cursor: default;
}

.fv-chartwrap {
  position: relative;
  height: 460px;
}

.fv-chartwrap canvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.fv-tooltip {
  position: absolute;
  display: none;
  z-index: 5;
  padding: 7px 9px;
  border-radius: 6px;
  background: rgba(16, 24, 40, 0.92);
  color: #fff;
  font-size: 11.5px;
  line-height: 1.45;
  white-space: pre;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.fv-minimap {
  position: relative;
  height: 46px;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--accent-soft);
  overflow: hidden;
}

.fv-minimap canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.fv-mmlabel {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  font-size: 11px;
  color: var(--text-muted);
  pointer-events: none;
}

.fv-mmwin {
  position: absolute;
  top: 0;
  bottom: 0;
  background: rgba(47, 111, 237, 0.16);
  border-left: 1px solid var(--accent);
  border-right: 1px solid var(--accent);
  cursor: grab;
}

.fv-mmhandle {
  position: absolute;
  top: 6px;
  bottom: 6px;
  width: 9px;
  margin-left: -4px;
  border: 1px solid var(--accent);
  border-radius: 3px;
  background: var(--surface);
  cursor: col-resize;
}

.fv-charthint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ---------- Fault recording: side panel ---------- */

.fv-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - var(--topbar-height) - 32px);
  overflow: hidden auto;
}

.fv-export {
  position: relative;
}

.fv-export-btn {
  justify-content: flex-start;
}

.fv-export-caret {
  margin-left: auto;
}

.fv-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.fv-menuitem {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.fv-menuitem:hover:not(:disabled) {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.fv-menuitem:disabled {
  color: var(--text-faint);
  cursor: default;
}

.fv-infobox {
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.fv-infotoggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 2px;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  cursor: pointer;
}

.fv-infochevron {
  color: var(--text-faint);
  transform: rotate(180deg);
  transition: transform 0.15s ease;
}

.fv-infobox.is-collapsed .fv-infochevron {
  transform: rotate(0deg);
}

.fv-infobox.is-collapsed .fv-infolist {
  display: none;
}

.fv-infolist {
  margin: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 10px;
  font-size: 12.5px;
  padding: 0 0 8px;
}

.fv-infolist:empty {
  display: none;
}

.fv-infolist dt {
  color: var(--text-muted);
}

.fv-infolist dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.fv-chbar {
  display: flex;
  align-items: center;
  gap: 6px;
}

.fv-chbar .input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 6px 10px;
  font-size: 12.5px;
}

.fv-chbar .btn {
  padding: 5px 8px;
}

.fv-empty {
  padding: 20px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.fv-groups {
  overflow-y: auto;
  margin: 0 -4px;
  padding: 0 4px;
}

.fv-group + .fv-group {
  margin-top: 8px;
}

.fv-ghead {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 2px;
}

.fv-gtoggle,
.fv-gname {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.fv-gtoggle {
  width: 14px;
  color: var(--text-faint);
}

.fv-gname {
  flex: 1;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.fv-gcount {
  font-size: 11px;
  color: var(--text-faint);
}

.fv-group.is-collapsed .fv-gitems {
  display: none;
}

/* Two channels per row, like the iConfig channel picker. */
.fv-gitems {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 6px;
  padding-left: 14px;
}

.fv-chitem {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 4px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 0;
}

.fv-chitem:hover {
  background: var(--bg);
}

.fv-chitem.is-on .fv-chname {
  font-weight: 600;
}

/* A channel the record carries no samples for: nothing to draw, so not pickable. */
.fv-chitem.is-empty {
  opacity: 0.45;
  cursor: default;
}

.fv-swatch {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 2px;
  border: 1px solid var(--border-strong);
}

.fv-chname {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- History data table ---------- */

.fv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin-bottom: 12px;
}

.fv-meta:empty {
  display: none;
}

.fv-metaitem {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 13px;
}

.fv-metaitem em {
  font-style: normal;
  color: var(--text-muted);
}

.fv-metaitem b {
  font-weight: 600;
  word-break: break-word;
}

.fv-tablewrap {
  max-height: 60vh;
  overflow: auto;
}

.fv-table {
  font-size: 12.5px;
  white-space: nowrap;
  /* Separate borders: collapsed ones do not follow sticky cells when scrolling. */
  border-collapse: separate;
  border-spacing: 0;
}

.fv-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
}

/* Keep the first column (the timestamp) in view while scrolling sideways. */
.fv-table th:first-child,
.fv-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  box-shadow: inset -1px 0 0 var(--border);
}

.fv-table th:first-child {
  z-index: 3;
}

.fv-table td:first-child {
  z-index: 1;
}

.fv-table th,
.fv-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

.fv-table tbody tr:last-child td {
  border-bottom: 0;
}

@media (max-width: 1100px) {
  .fv-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .fv-side {
    position: static;
    max-height: none;
  }

  .fv-gitems {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .fv-chartwrap {
    height: 300px;
  }

  .fv-gitems {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .fv-barinput {
    flex: 1 1 120px;
    max-width: none;
  }

  .fv-barstatus {
    flex: 1 1 100%;
    text-align: left;
  }
}

/* ---------- Register / Code lookup ---------- */

.lk-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1 1 260px;
  min-width: 180px;
  max-width: 420px;
}

.lk-search .icon {
  position: absolute;
  left: 9px;
  color: var(--text-faint);
  pointer-events: none;
}

.lk-searchinput {
  width: 100%;
  max-width: none;
  padding-left: 30px;
}

.lk-table td {
  vertical-align: top;
}

/* Addresses and code values read better lined up and monospaced. */
.lk-num {
  font-family: "Cascadia Mono", Consolas, "Roboto Mono", monospace;
  font-size: 12px;
  white-space: nowrap;
}

.lk-sub {
  display: block;
  color: var(--text-muted);
  font-size: 11.5px;
}

/* Enum lists in the spreadsheet are multi-line; keep the breaks but cap the width. */
.lk-block {
  display: block;
  max-width: 420px;
  max-height: 120px;
  overflow-y: auto;
  white-space: pre-line;
  overflow-wrap: anywhere;
  line-height: 1.4;
}

/*
 * Column widths. A table with layout:auto ignores max-width on the cell itself,
 * so the cap goes on a block inside it — otherwise one long parameter name or
 * unit stretches its column and pushes the rest off screen. A handful of rows
 * in the source spreadsheet carry a paragraph-long value in a normally-short
 * field (e.g. the full enum list duplicated into "Unit"); max-height keeps
 * that from blowing up the whole row's height — it scrolls instead.
 */
.lk-w-sm,
.lk-w-md,
.lk-w-lg {
  display: block;
  max-height: 90px;
  overflow-y: auto;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.lk-w-sm {
  max-width: 88px;
}

.lk-w-md {
  max-width: 170px;
}

.lk-w-lg {
  max-width: 300px;
}

.lk-chip {
  display: inline-block;
  margin: 1px 2px 1px 0;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 11px;
  white-space: nowrap;
}

.lk-more {
  display: flex;
  justify-content: center;
  padding-top: 12px;
}

/* Admin editing on the lookup pages */

.modal-panel-wide {
  max-width: 640px;
}

/* A register has a dozen editable fields — keep the dialog on screen. */
.modal-panel-wide .modal-body {
  max-height: 62vh;
  overflow-y: auto;
}

.lk-modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lk-textarea {
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

.lk-actions {
  white-space: nowrap;
  text-align: right;
}

.lk-flag {
  margin-left: 6px;
  vertical-align: middle;
}

.lk-row-edited td,
.lk-row-custom td {
  background: var(--warning-soft);
}

/* Language switch */

.lang-button {
  white-space: nowrap;
}

.lang-button-login {
  position: absolute;
  top: 12px;
  right: 12px;
}

.login-header {
  position: relative;
}

/* Fault finder: tint rows the way the manual colour-codes severity */

.ff-row-stop td {
  background: #fff1ee;
}

.ff-row-fault td {
  background: #fff6ed;
}

.ff-row-alarm td {
  background: #fffbeb;
}

.ff-row-stop.lk-row-edited td,
.ff-row-fault.lk-row-edited td,
.ff-row-alarm.lk-row-edited td,
.lk-row-custom td {
  background: var(--warning-soft);
}
