:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-2: #eef3f1;
  --ink: #17211f;
  --muted: #65716d;
  --line: #dbe4e0;
  --primary: #0a7a58;
  --primary-dark: #085e44;
  --green: #0f8f68;
  --green-soft: #dff4ec;
  --blue: #2563eb;
  --amber: #c77900;
  --red: #c43b3b;
  --red-soft: #fde7e7;
  --shadow: 0 18px 46px rgba(20, 35, 31, 0.08);
  /* ── Aliases used in JS templates ── */
  --accent:    #0a7a58;
  --danger:    #c43b3b;
  --success:   #0f8f68;
  --warning:   #c77900;
  --warn:      #c77900;
  --border:    #dbe4e0;
  --surface2:  #eef3f1;
  --bg2:       #f4f6fb;
  --bg-alt:    #f8fafc;
  --text:      #17211f;
  --fg:        #17211f;
  --clr-crit:  #c43b3b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
select,
input {
  font: inherit;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(244, 247, 246, 0.94);
  backdrop-filter: blur(4px);
}

.login-screen.hidden {
  display: none;
}

.login-card {
  width: min(420px, calc(100vw - 28px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 24px;
  display: grid;
  gap: 14px;
}

.login-card h1 {
  font-size: 24px;
}

.login-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 0 12px;
}

.login-card button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  background: #11231f;
  color: white;
  font-weight: 800;
  cursor: pointer;
}

#loginError,
.login-error {
  color: var(--red);
  min-height: 18px;
  font-size: 13px;
}

/* ── Filter select (used as class in integrations log) ──────────────────────── */
.filter-select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--ink);
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #11231f;
  color: #f8fbfa;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #21b486;
  color: #06241a;
  font-weight: 900;
}

.brand strong,
.brand span {
  display: block;
}

.brand span,
.side-status span {
  color: #afc7c0;
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 2px;
}

.nav button {
  border: 0;
  text-align: left;
  color: #dbe9e5;
  background: transparent;
  padding: 8px 12px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 13.5px;
}

.nav button.active,
.nav button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.side-status {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding-top: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(199, 121, 0, 0.18);
}

.dot.online {
  background: #28d190;
  box-shadow: 0 0 0 5px rgba(40, 209, 144, 0.18);
}

.dot.offline {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(196, 59, 59, 0.18);
}

.main {
  min-width: 0;
  padding: 22px 26px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.12;
}

h2 {
  font-size: 16px;
}

.topbar p,
.panel-head span,
.muted {
  color: var(--muted);
}

.top-actions {
  display: flex;
  gap: 10px;
}

select,
.top-actions button,
.text-button,
.user-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 12px;
  cursor: pointer;
}

/* ── Panel form inputs (fallback for forms without explicit inline styles) ───── */
.panel input[type="text"],
.panel input[type="email"],
.panel input[type="password"],
.panel input[type="number"],
.panel textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  outline-offset: 1px;
}

.panel input:focus,
.panel textarea:focus,
.panel select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.top-actions button {
  width: 42px;
  font-size: 20px;
}

.text-button {
  color: var(--green);
  font-weight: 700;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  cursor: default;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  min-height: 96px;
}

.kpi span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 24px;
  line-height: 1;
}

.kpi small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

/* KPI value color states (v10.3) */
.kpi strong.kpi-crit { color: var(--red); }
.kpi strong.kpi-warn { color: var(--amber); }
.kpi strong.kpi-ok   { color: var(--green); }

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 14px;
}

.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(330px, 0.75fr);
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.flow {
  display: grid;
  grid-template-columns: 1fr 70px 1fr 70px 1fr;
  align-items: center;
  margin-bottom: 16px;
}

.flow-node {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 8px;
  min-height: 88px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
}

.flow-node strong {
  color: var(--ink);
  font-size: 20px;
}

.flow-line {
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--blue));
}

canvas {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--surface-2);
}

.bar {
  width: 132px;
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  background: var(--green);
}

.bar.warning span {
  background: var(--amber);
}

.bar.critical span {
  background: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 9px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.badge.online,
.badge.ok {
  background: var(--green-soft);
  color: var(--green);
}

.badge.warning,
.badge.warn {
  background: #fff0d9;
  color: var(--amber);
}

.badge.critical,
.badge.offline,
.badge.crit {
  background: var(--red-soft);
  color: var(--red);
}

/* info/neutral — used for modes, types, mock, dry_run, etc. */
.badge.info,
.badge.mock,
.badge.dry_run,
.badge.disabled {
  background: var(--surface-2);
  color: var(--muted);
}

.site-grid,
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.site-card,
.asset-card,
.alarm-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfdfc;
}

.site-card h3,
.asset-card h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.site-meta,
.asset-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

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

.card-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.import-grid {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.file-box {
  display: grid;
  gap: 6px;
  min-width: 280px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.file-box input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 40px;
  padding: 8px 10px;
  background: var(--surface);
}

.import-status {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfdfc;
  color: var(--muted);
  margin-bottom: 12px;
  font-size: 13px;
}

.alarm-list {
  display: grid;
  gap: 10px;
}

.alarm-list.compact {
  max-height: 392px;
  overflow: auto;
}

.alarm-item {
  display: grid;
  gap: 8px;
}

.alarm-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.alarm-actions {
  display: flex;
  justify-content: flex-end;
}

.ack-button {
  border: 0;
  border-radius: 8px;
  background: #11231f;
  color: white;
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    padding: 14px;
    gap: 14px;
  }

  .nav {
    display: flex;
    overflow-x: auto;
  }

  .side-status {
    display: none;
  }

  .layout-two,
  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .main {
    padding: 14px;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

  .flow {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .flow-line {
    width: 3px;
    height: 28px;
    justify-self: center;
  }
}

/* ── Nav group labels ───────────────────────────────────────────────────────── */
.nav-group-label {
  color: #7aada0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 10px 12px 3px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.nav-group-label:first-child {
  border-top: none;
  margin-top: 0;
}

/* ── Login branding ─────────────────────────────────────────────────────────── */
.login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 4px;
}

.login-brand .brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--primary);
  color: #ffffff;
  font-size: 17px;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.login-brand-text strong {
  display: block;
  font-size: 18px;
  color: var(--ink);
}

.login-sub {
  color: var(--muted);
  font-size: 12px;
}

.login-card button:hover {
  background: var(--primary);
}

/* ── Tab bar (Connect view) ─────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--line);
  margin-bottom: 20px;
}

.tab-btn {
  border: 0;
  background: transparent;
  padding: 10px 18px;
  color: var(--muted);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  border-radius: 4px 4px 0 0;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ── Connector grid ─────────────────────────────────────────────────────────── */
.connector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}

.connector-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: var(--surface);
  display: grid;
  gap: 10px;
}

.connector-card h3 {
  margin: 0;
  font-size: 15px;
}

.connector-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.connector-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

/* ── BMS form ───────────────────────────────────────────────────────────────── */
.bms-form {
  display: grid;
  gap: 18px;
  max-width: 820px;
}

.bms-form fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 18px 18px;
  margin: 0;
}

.bms-form legend {
  padding: 0 6px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.form-row label {
  display: grid;
  gap: 5px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.form-row input,
.form-row select {
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 36px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.form-row input:focus,
.form-row select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

.form-row-opts {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
}

.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}

.toggle-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── BMS action row ─────────────────────────────────────────────────────────── */
.bms-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn-primary {
  border: 0;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 18px;
  background: var(--primary);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 0 18px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-danger {
  border: 1px solid #fca5a5;
  border-radius: 8px;
  min-height: 38px;
  padding: 0 18px;
  background: var(--red-soft);
  color: var(--red);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: #fde0e0;
}

/* ── BMS status chip ────────────────────────────────────────────────────────── */
.bms-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--line);
}

.bms-status-chip.ok {
  background: var(--green-soft);
  color: var(--green);
  border-color: #a7f0d4;
}

.bms-status-chip.err {
  background: var(--red-soft);
  color: var(--red);
  border-color: #f5b6b6;
}

.bms-status-chip.warn {
  background: #fff0d9;
  color: var(--amber);
  border-color: #fcd99a;
}

/* ── BMS test result ────────────────────────────────────────────────────────── */
.bms-test-result {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface-2);
  white-space: pre-wrap;
}

.bms-test-result.ok {
  border-color: #a7f0d4;
  background: var(--green-soft);
  color: #065f46;
  display: block;
}

.bms-test-result.err {
  border-color: #f5b6b6;
  background: var(--red-soft);
  color: var(--red);
  display: block;
}

/* ── Panel head standalone (no panel wrapper) ───────────────────────────────── */
.panel-head.standalone {
  margin-bottom: 16px;
}

/* ── EnPI table highlight ───────────────────────────────────────────────────── */
.enpi-good td { color: var(--green); }
.enpi-warn td { color: var(--amber); }
.enpi-bad  td { color: var(--red); }

/* ── Notes list ─────────────────────────────────────────────────────────────── */
.note-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfdfc;
  font-size: 14px;
  display: grid;
  gap: 4px;
}

.note-item .note-meta {
  color: var(--muted);
  font-size: 12px;
}

/* ── Maintenance cards ───────────────────────────────────────────────────────── */
.maintenance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.maintenance-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--surface);
}

.maintenance-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

/* ── Summary KPI mini-cards (used in requests, demo, command, SLA views) ─────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 16px;
  min-width: 120px;
}

/* Large value number inside a mini-card */
.kpi-value,
.kpi-val {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ink);
}

.kpi-label {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* When a badge class is applied to .kpi-val, only change color — no pill */
.kpi-val.badge-crit  { color: var(--red);   background: none; padding: 0; border-radius: 0; font-size: 22px; display: block; }
.kpi-val.badge-warn  { color: var(--amber); background: none; padding: 0; border-radius: 0; font-size: 22px; display: block; }
.kpi-val.badge-ok    { color: var(--green); background: none; padding: 0; border-radius: 0; font-size: 22px; display: block; }
.kpi-val.badge-info  { color: var(--muted); background: none; padding: 0; border-radius: 0; font-size: 22px; display: block; }

/* ── Asset card label/value (used in tariff summary cards) ──────────────────── */
.ac-label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ac-val {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
}

/* ── Badge semantic variants (hyphen form — used in JS rendering) ───────────── */
.badge-crit  { background: var(--red-soft);   color: var(--red);   font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-warn  { background: #fff0d9;            color: var(--amber); font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-ok    { background: var(--green-soft);  color: var(--green); font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-info  { background: var(--surface-2);   color: var(--muted); font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }

/* Severity levels: high / medium / low */
.badge-high  { background: #fff0d9;            color: var(--amber);       font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-med   { background: #e8edf5;            color: #3b5998;            font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-low   { background: var(--green-soft);  color: var(--green);       font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }

/* Visibility badges */
.badge-vis-internal { background: var(--surface-2); color: var(--muted);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-vis-client   { background: #fffbe6;          color: #7a5a00;       font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }
.badge-vis-both     { background: var(--green-soft); color: var(--green); font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 12px; display: inline-block; }

/* ── Info banners ───────────────────────────────────────────────────────────── */
.info-banner {
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid transparent;
}
.info-banner--safe {
  background: var(--green-soft, #e6f9ee);
  color: var(--green, #1e8c4e);
  border-color: var(--green, #1e8c4e);
}
.info-banner--warn {
  background: #fff0d9;
  color: var(--amber, #b07d00);
  border-color: var(--amber, #b07d00);
}

/* ── Filter row utility ─────────────────────────────────────────────────────── */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 10px 0 2px;
}

.filter-row select,
.filter-row input[type="month"],
.filter-row input[type="text"] {
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 8px;
  font-size: 13px;
  background: var(--surface);
  color: var(--ink);
}

.filter-row input[type="month"] {
  min-width: 130px;
}

.filter-row .btn-secondary,
.filter-row .btn-primary {
  min-height: 32px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

/* ── Badge lifecycle states ─────────────────────────────────────────────────── */
.badge-draft     { background: var(--surface-2);  color: var(--muted);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-shadow    { background: #e8edf5;            color: #3b5998;       font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-ready     { background: #fff0d9;            color: var(--amber);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-active    { background: var(--green-soft);  color: var(--green);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-suspended { background: #fff0d9;            color: var(--amber);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-retired   { background: var(--red-soft);    color: var(--red);    font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }

/* ── Badge severity aliases (v10.2) — complementan los dot-notation y hyphen ya existentes */
.badge-normal    { background: var(--green-soft);  color: var(--green);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }
.badge-no-match,
.badge-unknown   { background: var(--surface-2);   color: var(--muted);  font-weight: 700; border-radius: 999px; padding: 2px 9px; font-size: 11px; display: inline-block; }

/* ── Risk badges (v10.3) — filled inverted, para simulate-active risk level ── */
.badge-risk-low    { background: var(--green);  color: #fff; font-weight: 700; border-radius: 12px; padding: 3px 12px; font-size: .8rem; display: inline-block; }
.badge-risk-medium { background: var(--amber);  color: #fff; font-weight: 700; border-radius: 12px; padding: 3px 12px; font-size: .8rem; display: inline-block; }
.badge-risk-high   { background: var(--red);    color: #fff; font-weight: 700; border-radius: 12px; padding: 3px 12px; font-size: .8rem; display: inline-block; }
.badge-risk-data   { background: var(--muted);  color: #fff; font-weight: 700; border-radius: 12px; padding: 3px 12px; font-size: .8rem; display: inline-block; }

/* ── Card actions (report cards, panel button groups) ───────────────────────── */
.card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.card-actions .btn-primary,
.card-actions .btn-secondary {
  height: 32px;
  font-size: 13px;
  padding: 0 12px;
}

/* ── Empty cell ─────────────────────────────────────────────────────────────── */
.empty-cell {
  text-align: center;
  color: var(--muted);
  padding: 24px 10px;
  font-size: 13px;
}

/* ── View mode group (label + toggle) ───────────────────────────────────────── */
.view-mode-group {
  display: flex;
  align-items: center;
  gap: 7px;
}

.vm-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  user-select: none;
}

.view-mode-toggle {
  display: flex;
  border: 1.5px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  gap: 0;
  box-shadow: 0 1px 3px rgba(10,122,88,0.06);
}

.vm-btn {
  background: var(--surface);
  color: var(--muted);
  border: none;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  letter-spacing: 0.01em;
}

.vm-btn:first-child { border-right: 1px solid var(--line); }

.vm-btn.active {
  background: var(--primary);
  color: #fff;
}

.vm-btn#vmClient.active {
  background: #b07d00;
  color: #fff;
}

.vm-btn:hover:not(.active) {
  background: var(--surface-2);
  color: var(--ink);
}

/* ── View mode banner (always visible, switches variant by JS) ───────────────── */
.view-mode-banner {
  padding: 7px 24px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  border-bottom: 1.5px solid transparent;
  transition: background 0.2s, color 0.2s;
}

.view-mode-banner--eprom {
  background: var(--green-soft);
  color: var(--green);
  border-color: #b6dfd0;
}

.view-mode-banner--client {
  background: #fffbe6;
  color: #7a5a00;
  border-color: #f0d060;
}

/* ── Botón Informe Cliente (topbar) ──────────────────────────────────────────── */
.btn-client-report {
  background: #b07d00;
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 5px 13px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-client-report:hover { background: #8a6000; }
.btn-client-report.hidden { display: none; }

/* ── Panel Informe Cliente ───────────────────────────────────────────────────── */
.client-report-panel {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: #f8f9f7;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.client-report-panel.hidden { display: none; }

.cr-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  background: #fff;
  border-bottom: 1.5px solid var(--line);
  flex-shrink: 0;
}
.cr-toolbar-left { display: flex; align-items: baseline; gap: 12px; }
.cr-toolbar-left strong { font-size: 15px; color: var(--ink); }
.cr-disclaimer { font-size: 11.5px; color: var(--muted); font-style: italic; }
.cr-toolbar-right { display: flex; gap: 8px; }

.cr-body {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
}

/* ── Informe — elementos de contenido ────────────────────────────────────────── */
.cr-header { text-align: center; margin-bottom: 32px; border-bottom: 2px solid var(--primary); padding-bottom: 20px; }
.cr-header h1 { font-size: 22px; color: var(--primary); margin: 0 0 4px; }
.cr-header .cr-meta { font-size: 12px; color: var(--muted); }

.cr-section { margin-bottom: 28px; }
.cr-section h2 { font-size: 14px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--primary); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 0 0 14px; }

.cr-kpi-row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.cr-kpi { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 18px; min-width: 130px; text-align: center; }
.cr-kpi .val { font-size: 24px; font-weight: 700; color: var(--ink); }
.cr-kpi .val.ok { color: var(--green); }
.cr-kpi .val.warn { color: var(--amber); }
.cr-kpi .val.crit { color: var(--red); }
.cr-kpi .lbl { font-size: 11px; color: var(--muted); margin-top: 2px; }

.cr-table-wrap { overflow-x: auto; }
.cr-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cr-table th { background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); }
.cr-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cr-table tr:last-child td { border-bottom: none; }

.cr-recs { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.cr-rec { display: flex; align-items: baseline; gap: 10px; padding: 10px 14px; border-radius: 8px; font-size: 13px; }
.cr-rec--ok   { background: var(--green-soft); color: var(--green); }
.cr-rec--warn { background: #fff0d9; color: var(--amber); }
.cr-rec--crit { background: var(--red-soft); color: var(--red); }
.cr-rec-icon  { font-size: 15px; flex-shrink: 0; }

/* ── Print ───────────────────────────────────────────────────────────────────── */
@media print {
  body > *:not(#clientReportPanel) { display: none !important; }
  .client-report-panel { position: static !important; overflow: visible !important; background: #fff !important; }
  .no-print { display: none !important; }
  .cr-body { padding: 0 !important; max-width: 100% !important; overflow: visible !important; }
  .cr-kpi { border: 1px solid #ccc !important; break-inside: avoid; }
  .cr-section { break-inside: avoid; }
  .cr-table { page-break-inside: auto; }
  .cr-table tr { page-break-inside: avoid; }
}

/* ── Toast notification ──────────────────────────────────────────────────────── */
.app-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 9999;
  box-shadow: 0 4px 16px rgba(0,0,0,0.14);
}

.app-toast--show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.app-toast--eprom {
  background: var(--primary);
  color: #fff;
}

.app-toast--client {
  background: #b07d00;
  color: #fff;
}

.app-toast--info {
  background: var(--ink);
  color: #fff;
}

/* ── Responsive adjustments ─────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .connector-grid {
    grid-template-columns: 1fr;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .bms-actions {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 640px) {
  .tab-btn {
    padding: 8px 12px;
    font-size: 13px;
  }

  .bms-form fieldset {
    padding: 12px;
  }
}
