/* Bleu SmartDER — Design System */

:root {
  /* Brand */
  --navy-900: #0d2840;
  --navy-800: #133b5c;
  --navy-700: #1b5c8e;       /* primary */
  --navy-600: #2a7bab;
  --navy-500: #3a96c4;
  --teal-400: #6cb6d4;
  --teal-100: #d9ecf3;
  --teal-50:  #eef6fa;

  --green-700: #3f8a52;
  --green-600: #5baa6f;      /* accent */
  --green-500: #7ec588;
  --green-100: #dff0d8;

  --amber-600: #c98a2a;
  --amber-500: #e0a850;
  --amber-100: #fbeccd;

  --red-600:  #c0392b;
  --red-500:  #e0533f;
  --red-100:  #fadddb;

  /* Neutrals — cool tinted */
  --ink-900: #0d2840;
  --ink-700: #2a3f55;
  --ink-500: #5a6c7f;
  --ink-400: #7d8da0;
  --ink-300: #a4b1c0;
  --ink-200: #d4dce4;
  --ink-100: #e7ecf1;
  --ink-50:  #f1f4f8;
  --surface: #f5f8fb;
  --surface-2: #ffffff;
  --line: #e2e8ef;
  --line-soft: #edf1f5;

  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(13,40,64,0.05), 0 1px 3px rgba(13,40,64,0.04);
  --shadow-md: 0 4px 16px rgba(13,40,64,0.06), 0 1px 3px rgba(13,40,64,0.04);
  --shadow-lg: 0 20px 48px rgba(13,40,64,0.18), 0 4px 12px rgba(13,40,64,0.08);

  --font-sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11";
  background: var(--surface);
  color: var(--ink-900);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ============ Layout ============ */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  min-height: 100vh;
}
.app[data-collapsed="true"] {
  grid-template-columns: 72px 1fr;
}
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
}
.main-body {
  flex: 1;
  padding: 24px 32px 40px;
  overflow-x: hidden;
}

/* ============ Topbar ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 32px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumbs {
  flex: 1;
  color: var(--ink-500);
  font-size: 13px;
  font-weight: 500;
}
.topbar .crumbs strong { color: var(--ink-900); font-weight: 600; }
.topbar .search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 12px;
  width: 320px;
  color: var(--ink-500);
  font-size: 13px;
}
.topbar .search input {
  border: 0; background: transparent; outline: none;
  font: inherit; color: inherit; flex: 1; padding: 0;
}
.topbar .topbtn {
  height: 36px; min-width: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius);
  color: var(--ink-700);
  cursor: pointer;
  position: relative;
}
.topbar .topbtn .dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--red-500); border: 2px solid #fff; }

.role-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.role-pill button {
  border: 0; background: transparent; padding: 5px 12px; border-radius: 999px;
  font: inherit; color: var(--ink-500); cursor: pointer;
}
.role-pill button[data-on="true"] {
  background: var(--navy-700);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.userchip {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 4px 12px 4px 4px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  cursor: pointer;
}
.userchip .av {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy-700), var(--green-600));
  color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.userchip .who { font-size: 12.5px; font-weight: 600; }
.userchip .role { font-size: 11px; color: var(--ink-500); }

/* ============ Sidebar ============ */
.sidebar {
  background: linear-gradient(180deg, #fff 0%, #fbfcfd 100%);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.sidebar .brand .mark {
  width: 36px; height: 36px; border-radius: 9px;
  background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
  border: 1px solid var(--line);
}
.sidebar .brand .mark img { width: 30px; height: 30px; object-fit: contain; }
.sidebar .brand .name { font-weight: 800; font-size: 15.5px; letter-spacing: -0.01em; }
.sidebar .brand .name span { color: var(--navy-700); }
.sidebar .brand .sub { font-size: 11px; color: var(--ink-500); font-weight: 500; }

.sidebar .nav {
  padding: 14px 12px;
  flex: 1;
  overflow-y: auto;
}
.sidebar .nav-section {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-400);
  padding: 16px 10px 6px;
  font-weight: 700;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-700);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
}
.sidebar .nav-item:hover { background: var(--surface); color: var(--ink-900); }
.sidebar .nav-item[data-on="true"] {
  background: var(--teal-50);
  color: var(--navy-700);
  font-weight: 600;
}
.sidebar .nav-item[data-on="true"]::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  background: var(--navy-700); border-radius: 2px;
}
.sidebar .nav-item .badge {
  margin-left: auto;
  background: var(--red-500);
  color: #fff;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  min-width: 18px;
  text-align: center;
}
.sidebar .nav-item .badge.calm { background: var(--ink-100); color: var(--ink-700); }
.sidebar .nav-sub { padding-left: 28px; }
.sidebar .nav-foot {
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
  color: var(--ink-500);
  display: flex; align-items: center; justify-content: space-between;
}
.sidebar .nav-foot .status-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--green-600);
  box-shadow: 0 0 0 3px rgba(91,170,111,0.18);
  margin-right: 6px; display: inline-block; vertical-align: middle;
}

/* ============ Page header ============ */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 24px; margin-bottom: 22px;
}
.page-head .title { font-size: 24px; font-weight: 700; letter-spacing: -0.015em; }
.page-head .subtitle { color: var(--ink-500); font-size: 13.5px; margin-top: 4px; }
.page-head .actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ============ Cards ============ */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-hd {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-hd .ttl { font-size: 14px; font-weight: 600; }
.card-hd .sub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.tight { padding: 12px 20px; }

/* ============ KPI Cards ============ */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.kpi-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.kpi .label {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
}
.kpi .value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 600;
  color: var(--ink-900);
  margin-top: 8px;
  letter-spacing: -0.01em;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi .value .unit { font-size: 12px; color: var(--ink-400); font-weight: 500; font-family: var(--font-sans); }
.kpi .foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 12px; color: var(--ink-500); }
.kpi .trend { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.kpi .trend.up { color: var(--green-700); }
.kpi .trend.down { color: var(--red-600); }
.kpi .icon {
  position: absolute; top: 16px; right: 16px;
  width: 36px; height: 36px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--teal-50); color: var(--navy-700);
}
.kpi.green .icon { background: var(--green-100); color: var(--green-700); }
.kpi.amber .icon { background: var(--amber-100); color: var(--amber-600); }
.kpi.red .icon { background: var(--red-100); color: var(--red-600); }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px;
  padding: 0 14px;
  font: inherit; font-weight: 600; font-size: 13px;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink-700);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); border-color: var(--ink-200); }
.btn.primary {
  background: var(--navy-700);
  border-color: var(--navy-700);
  color: #fff;
}
.btn.primary:hover { background: var(--navy-800); border-color: var(--navy-800); }
.btn.accent {
  background: var(--green-600);
  border-color: var(--green-600);
  color: #fff;
}
.btn.accent:hover { background: var(--green-700); border-color: var(--green-700); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface); }
.btn.danger { color: var(--red-600); border-color: var(--red-100); }
.btn.danger:hover { background: var(--red-100); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; }

/* ============ Badges ============ */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--ink-100);
  color: var(--ink-700);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.green { background: var(--green-100); color: var(--green-700); }
.badge.amber { background: var(--amber-100); color: var(--amber-600); }
.badge.red { background: var(--red-100); color: var(--red-600); }
.badge.blue { background: var(--teal-50); color: var(--navy-700); }
.badge.outline { background: transparent; border: 1px solid var(--line); }

/* ============ Tabs ============ */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-500);
  border: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: var(--ink-900); }
.tab[data-on="true"] {
  color: var(--navy-700);
  border-bottom-color: var(--navy-700);
  font-weight: 600;
}
.tab .count {
  background: var(--ink-100);
  color: var(--ink-700);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
}
.tab[data-on="true"] .count { background: var(--teal-50); color: var(--navy-700); }

/* ============ Tables ============ */
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tbl thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.tbl tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-700);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl td.num, .tbl th.num { font-family: var(--font-mono); text-align: right; }
.tbl .row-id { color: var(--ink-400); font-family: var(--font-mono); font-size: 12px; }
.tbl .pri { color: var(--ink-900); font-weight: 600; }
.tbl .meta { color: var(--ink-500); font-size: 12px; }

/* ============ Filters bar ============ */
.filters {
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}
.filters .grow { flex: 1; }
.select, .input {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  font: inherit; font-size: 12.5px;
  color: var(--ink-700);
  cursor: pointer;
}
.input { cursor: text; }
.input input { border: 0; outline: none; background: transparent; font: inherit; min-width: 140px; padding: 0; color: inherit; }
.select select {
  appearance: none; border: 0; outline: none; background: transparent; font: inherit; color: inherit;
  padding-right: 14px;
}

/* ============ Avatar / Tenant chip ============ */
.tenant-chip {
  display: inline-flex; align-items: center; gap: 10px;
}
.tenant-chip .av {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--navy-700), var(--teal-400));
  color: #fff; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}
.tenant-chip.alt .av { background: linear-gradient(135deg, var(--green-600), var(--teal-400)); }
.tenant-chip.alt2 .av { background: linear-gradient(135deg, var(--amber-500), var(--navy-700)); }
.tenant-chip .meta .name { font-weight: 600; color: var(--ink-900); }
.tenant-chip .meta .sub { font-size: 12px; color: var(--ink-500); }

/* ============ Device cards (admin) ============ */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.device-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  position: relative;
  transition: border-color 0.15s, box-shadow 0.15s;
  cursor: pointer;
}
.device-card:hover { border-color: var(--navy-500); box-shadow: var(--shadow-md); }
.device-card .head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.device-card .head .name { font-weight: 700; font-size: 15px; }
.device-card .head .type { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.device-card .specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px;
  margin-top: 14px; padding: 12px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}
.device-card .specs .lbl { color: var(--ink-500); }
.device-card .specs .val { font-family: var(--font-mono); font-weight: 500; color: var(--ink-900); text-align: right; }
.device-card .foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--ink-500);
}
.device-card.add {
  border: 2px dashed var(--ink-200);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px;
  min-height: 240px;
  color: var(--ink-500);
}
.device-card.add:hover { border-color: var(--navy-500); color: var(--navy-700); box-shadow: none; background: var(--teal-50); }
.device-card.add .plus {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; border: 1px solid var(--ink-200);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
  color: var(--navy-700);
}

/* ============ Tenant fleet device cards ============ */
.fleet-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 16px;
}
.fleet-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fleet-card:hover { border-color: var(--navy-500); box-shadow: var(--shadow-md); }
.fleet-card .head {
  display: flex; align-items: flex-start; justify-content: space-between;
}
.fleet-card .name { font-size: 16px; font-weight: 700; }
.fleet-card .sub { font-size: 12px; color: var(--ink-500); margin-top: 2px; }
.fleet-card .metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  margin-top: 18px;
}
.fleet-metric .lbl {
  font-size: 11.5px;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.fleet-metric .val {
  font-family: var(--font-mono); font-weight: 600; font-size: 18px;
  margin-top: 4px;
  color: var(--ink-900);
}
.fleet-metric .val .unit { font-family: var(--font-sans); font-size: 11px; color: var(--ink-400); font-weight: 500; }
.bar {
  height: 6px; background: var(--ink-100); border-radius: 999px; overflow: hidden;
  margin-top: 4px;
}
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--green-600), var(--green-500)); border-radius: 999px; }
.bar.warn > span { background: linear-gradient(90deg, var(--amber-500), var(--amber-600)); }
.bar.danger > span { background: linear-gradient(90deg, var(--red-500), var(--red-600)); }
.bar.cool > span { background: linear-gradient(90deg, var(--navy-600), var(--teal-400)); }

/* ============ Gauges / widgets ============ */
.gauge-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; flex-direction: column; gap: 12px;
}
.gauge-card .hd { display: flex; align-items: center; justify-content: space-between; }
.gauge-card .hd .ttl { font-size: 13px; color: var(--ink-500); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.gauge-card .center {
  display: flex; align-items: center; justify-content: center;
  position: relative;
}

/* ============ Activity feed ============ */
.feed { display: flex; flex-direction: column; }
.feed .item {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.feed .item:last-child { border-bottom: 0; }
.feed .time { font-family: var(--font-mono); color: var(--ink-400); font-size: 12px; }
.feed .dev { color: var(--navy-700); font-weight: 600; font-size: 12.5px; }
.feed .msg { color: var(--ink-700); }
.feed .item.warn .dot { background: var(--amber-600); }
.feed .item.alert .dot { background: var(--red-600); }
.feed .item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--navy-600); margin-top: 6px; }

/* ============ Modals ============ */
.scrim {
  position: fixed; inset: 0;
  background: rgba(13,40,64,0.45);
  z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 24px;
  overflow-y: auto;
}
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 720px;
  overflow: hidden;
}
.modal.lg { max-width: 880px; }
.modal-hd {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-hd .ttl { font-size: 17px; font-weight: 700; }
.modal-hd .sub { font-size: 13px; color: var(--ink-500); margin-top: 2px; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-ft {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  background: var(--surface);
}

/* ============ Form fields ============ */
.form {
  display: grid;
  gap: 18px;
}
.fld { display: flex; flex-direction: column; gap: 6px; }
.fld label { font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.fld .hint { font-size: 11.5px; color: var(--ink-500); }
.fld input[type=text], .fld input[type=number], .fld input[type=date],
.fld select, .fld textarea {
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font: inherit; font-size: 13.5px;
  background: #fff;
  color: var(--ink-900);
  outline: none;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(27,92,142,0.12); }
.fld textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.section-ttl {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: var(--ink-500);
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
  margin-bottom: 6px;
}
.toggle {
  display: inline-flex; align-items: center;
  width: 38px; height: 22px;
  border-radius: 999px;
  background: var(--ink-200);
  padding: 2px;
  cursor: pointer;
}
.toggle > i {
  width: 18px; height: 18px; background: #fff; border-radius: 50%;
  display: block; transition: 0.15s transform;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}
.toggle[data-on="true"] { background: var(--green-600); }
.toggle[data-on="true"] > i { transform: translateX(16px); }

/* ============ Stepper / wizard ============ */
.stepper {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 20px;
}
.step {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-500); font-weight: 600;
}
.step .num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--ink-100); color: var(--ink-500);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px;
}
.step[data-on="true"] { color: var(--navy-700); }
.step[data-on="true"] .num { background: var(--navy-700); color: #fff; }
.step[data-done="true"] .num { background: var(--green-600); color: #fff; }
.step-sep { flex: 1; height: 1px; background: var(--line); }

/* ============ Tag inline ============ */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.kv .k { color: var(--ink-500); font-weight: 500; }
.kv .v { color: var(--ink-900); font-family: var(--font-mono); }

/* ============ Helpers ============ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.grid-3-eq { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-500); }
.mono { font-family: var(--font-mono); }
.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.center { text-align: center; }
.right { text-align: right; }
.b { font-weight: 600; }
.bb { font-weight: 700; }

/* ============ Device view tabs in tenant dash ============ */
.device-tabs {
  display: flex; gap: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px;
  width: fit-content;
  box-shadow: var(--shadow-sm);
}
.device-tabs .dtab {
  padding: 7px 14px;
  border: 0; background: transparent;
  border-radius: 999px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--ink-500); cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.device-tabs .dtab[data-on="true"] {
  background: var(--navy-700); color: #fff;
}
.device-tabs .dtab .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--green-600);
}
.device-tabs .dtab[data-on="true"] .dot { background: #fff; }

/* ============ Invoice line items ============ */
.invoice-line {
  display: grid;
  grid-template-columns: 1.5fr 0.5fr 0.5fr 0.7fr 0.7fr;
  gap: 12px;
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--line-soft);
}
.invoice-line.head {
  background: var(--surface);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-500);
}
.invoice-line.sub { background: var(--surface); font-weight: 700; color: var(--navy-700); padding: 8px 16px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.invoice-line.total { background: var(--navy-700); color: #fff; font-weight: 700; }
.invoice-line .num { font-family: var(--font-mono); text-align: right; }

/* ============ Sparkline / chart container ============ */
.chart-frame {
  position: relative;
  width: 100%;
  height: 240px;
}
.chart-frame.tall { height: 320px; }

/* ============ Toast ============ */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink-900);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 500;
  z-index: 200;
  display: flex; align-items: center; gap: 10px;
}
.toast .ico {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-600); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px;
}

/* ============ Welcome / login page ============ */
.shell-empty {
  display: grid; place-items: center;
  min-height: 100vh;
}

/* Skinny scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d0dae3; border-radius: 6px; border: 2px solid var(--surface); }
::-webkit-scrollbar-thumb:hover { background: #b9c6d2; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ Demo / disclaimer copy (§3, §15, §16) ============ */
.demo-note {
  font-size: 12px;
  color: var(--ink-500);
  margin: -8px 0 22px;
  padding-left: 2px;
  font-style: italic;
}

.tariff-note {
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--teal-50);
  border-left: 3px solid var(--navy-600);
  border-radius: 6px;
  font-size: 12px;
  color: var(--ink-700);
  line-height: 1.5;
}

.demo-disclaimer {
  margin-top: 24px;
  padding: 14px 18px;
  background: #fff;
  border: 1px dashed var(--ink-200);
  border-radius: var(--radius);
  font-size: 12.5px;
  color: var(--ink-500);
  line-height: 1.6;
}
.demo-disclaimer strong {
  color: var(--ink-900);
  font-weight: 600;
}

/* ============ §4 SmartDER Intelligence panel ============ */
.intel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}
.intel-item {
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
}
.intel-item.span-2 { grid-column: 1 / -1; }
.intel-item .lbl {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
}
.intel-item .val {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink-900);
  margin-top: 6px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.intel-item .val .unit {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--ink-400);
  font-weight: 500;
}
.intel-item .intel-fault {
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--amber-600);
  align-items: center;
  gap: 8px;
}
.intel-disclaimer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-500);
  line-height: 1.5;
}

/* Recommendation companion card */
.rec-card .card-body { padding: 0; }
.rec-body {
  padding: 22px 22px 24px;
  background: linear-gradient(165deg, var(--teal-50), #fff 70%);
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
}
.rec-headline {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.45;
}
.rec-sub {
  font-size: 13px;
  color: var(--ink-500);
  line-height: 1.5;
}
.rec-meta {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 8px;
}

/* ============ §5 Low-bandwidth resilience strip ============ */
.resilience {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 18px 22px;
}
.resilience-hd {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.resilience-ttl {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-900);
}
.resilience-sub {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-500);
  line-height: 1.55;
  max-width: 720px;
}
.resilience-strip {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-700);
  font-weight: 500;
}
.resilience-strip span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.resilience-strip .dot-sep {
  color: var(--ink-300);
  font-weight: 400;
}
.resilience-strip .weak { color: var(--amber-600); }
.resilience-strip .ok   { color: var(--green-700); }

/* ============ Auth shell (sign-in / sign-up) ============ */
.auth-shell {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  font-family: var(--font-sans);
  overflow: auto;
}
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 15% 20%, rgba(91,170,111,0.18) 0%, transparent 40%),
    radial-gradient(circle at 85% 80%, rgba(58,150,196,0.22) 0%, transparent 45%),
    linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  z-index: 0;
}
.auth-loader {
  position: relative; z-index: 1;
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.auth-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 460px;
  background: #fff;
  border-radius: 18px;
  padding: 32px 32px 26px;
  box-shadow: 0 20px 60px -20px rgba(13,40,64,0.45);
  border: 1px solid var(--line);
}
.auth-brand {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 22px;
}
.auth-brand img {
  width: 38px; height: 38px;
  object-fit: contain;
}
.auth-brand-name {
  font-size: 18px; font-weight: 800; letter-spacing: -0.01em;
  color: var(--ink-900);
}
.auth-brand-name span { color: var(--navy-700); }
.auth-brand-sub {
  font-size: 11.5px;
  color: var(--ink-500);
  font-weight: 500;
  margin-top: 1px;
}
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--ink-50);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 22px;
}
.auth-tabs button {
  border: 0; background: transparent;
  padding: 9px 14px;
  font-size: 13px; font-weight: 600;
  color: var(--ink-500);
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.auth-tabs button[data-on="true"] {
  background: #fff;
  color: var(--navy-700);
  box-shadow: 0 1px 3px rgba(13,40,64,0.08);
}
.auth-form {
  display: flex; flex-direction: column; gap: 13px;
  margin-bottom: 18px;
}
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-lbl {
  font-size: 11.5px;
  color: var(--ink-500);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.auth-field input,
.auth-field select {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--ink-900);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-field input:focus,
.auth-field select:focus {
  border-color: var(--navy-500);
  box-shadow: 0 0 0 3px rgba(58,150,196,0.18);
}
.auth-error {
  background: var(--red-100);
  color: var(--red-600);
  font-size: 12.5px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 7px;
  border-left: 3px solid var(--red-500);
}
.auth-submit {
  width: 100%;
  padding: 11px;
  font-size: 14px; font-weight: 600;
  font-family: inherit;
  color: #fff;
  background: var(--navy-700);
  border: 0; border-radius: 9px;
  cursor: pointer;
  transition: all 0.15s;
}
.auth-submit:hover:not(:disabled) {
  background: var(--navy-600);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(27,92,142,0.28);
}
.auth-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.auth-sep {
  display: flex; align-items: center; gap: 12px;
  margin: 18px 0 14px;
  color: var(--ink-400);
  font-size: 11px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.auth-sep::before, .auth-sep::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.auth-demo-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.auth-demo-btn {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  font-family: inherit;
  background: var(--ink-50);
  border: 1px solid transparent;
  border-radius: 9px;
  cursor: pointer;
  text-align: start;
  transition: all 0.15s;
}
.auth-demo-btn:hover:not(:disabled) {
  background: #fff;
  border-color: var(--navy-500);
  box-shadow: 0 2px 8px rgba(13,40,64,0.06);
}
.auth-demo-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.auth-demo-ico {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  border-radius: 7px;
  background: var(--teal-50);
  color: var(--navy-700);
}
.auth-demo-ico.shield { background: var(--green-100); color: var(--green-700); }
.auth-demo-text { display: flex; flex-direction: column; min-width: 0; }
.auth-demo-name {
  font-size: 12.5px; font-weight: 600; color: var(--ink-900);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auth-demo-sub {
  font-size: 10.5px; color: var(--ink-500);
  font-family: var(--font-mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.auth-footnote {
  font-size: 12px;
  color: var(--ink-500);
  text-align: center;
  margin-top: 10px;
  line-height: 1.55;
}
.auth-footnote code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--ink-50);
  color: var(--navy-700);
  padding: 1px 6px;
  border-radius: 4px;
}
.auth-footnote a {
  color: var(--navy-700);
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.auth-footnote a:hover { text-decoration: underline; }
.auth-disclaimer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-400);
  text-align: center;
}
.auth-success {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  padding: 8px 4px 4px;
}
.auth-success-ico {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green-100);
  color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 14px;
}
.auth-success h3 {
  font-size: 17px; font-weight: 700;
  color: var(--ink-900);
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}
.auth-success p {
  font-size: 13.5px;
  color: var(--ink-500);
  line-height: 1.55;
  margin: 0 0 18px;
}

@media (max-width: 520px) {
  .auth-card { padding: 24px 20px; }
  .auth-demo-grid { grid-template-columns: 1fr; }
}
