/* ════════════════════════════════════════════════════════════════════
   HELIX 2.0 — DESIGN SYSTEM
   Dark energy-dashboard theme. All colors/spacing flow from the
   variables below — change the brand in one place.
   ════════════════════════════════════════════════════════════════════ */

:root {
  /* surfaces */
  --bg:        #070d18;
  --bg-2:      #0a1322;
  --panel:     rgba(15, 27, 48, .72);
  --panel-sol: #0e1a2e;
  --border:    rgba(148, 163, 184, .14);
  --border-hi: rgba(45, 212, 191, .45);

  /* text */
  --text:      #e7eef8;
  --muted:     #8ea2bd;
  --faint:     #5b6e8a;

  /* brand */
  --accent:    #2dd4bf;   /* electric teal  */
  --accent-2:  #a3e635;   /* energy lime    */
  --accent-3:  #60a5fa;   /* signal blue    */
  --orange:    #fb923c;
  --violet:    #a78bfa;
  --red:       #f87171;
  --amber:     #fbbf24;

  --grad-brand: linear-gradient(135deg, #2dd4bf 0%, #a3e635 100%);
  --glow:       0 0 24px rgba(45, 212, 191, .25);

  --radius:    16px;
  --radius-sm: 10px;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body:    'Inter', sans-serif;
}

* { box-sizing: border-box; }

/* ════════════════════════════════════════════════════════════════
   RTL / ARABIC SUPPORT
   ════════════════════════════════════════════════════════════════ */
html[dir="rtl"] body,
html[lang="ar"] body {
  font-family: 'Cairo', 'Tajawal', var(--font-body);
  line-height: 1.75;                 /* Arabic needs more vertical room */
}
html[dir="rtl"] .brand-name,
html[lang="ar"] .brand-company,
html[lang="ar"] h1, html[lang="ar"] h2, html[lang="ar"] h3, html[lang="ar"] h4 {
  font-family: 'Cairo', 'Tajawal', var(--font-display);
}
/* the KPI accent bar and card left-border flip to the start edge */
html[dir="rtl"] .kpi::after { left: auto; right: 0; }
html[dir="rtl"] .kpi { }
/* AI panels / fab flip to the left side in RTL */
html[dir="rtl"] .ai-fab   { right: auto; left: 26px; }
html[dir="rtl"] .ai-panel { right: auto; left: 26px; }
html[dir="rtl"] .ai-msg.user { align-self: flex-start; border-bottom-right-radius: 14px; border-bottom-left-radius: 4px; }
html[dir="rtl"] .ai-msg.bot  { align-self: flex-end;   border-bottom-left-radius: 14px; border-bottom-right-radius: 4px; }
/* login split screen: keep hero on the start side */
html[dir="rtl"] .login-side { border-left: none; border-right: 1px solid var(--border); }
/* tables read right-to-left */
html[dir="rtl"] table.data thead th,
html[dir="rtl"] table.data tbody td { text-align: right; }
html[dir="rtl"] table.data.compact tbody td:first-child,
html[dir="rtl"] table.data.compact tbody td:nth-child(2) { text-align: right; }
/* numbers stay LTR even inside RTL text so kWh/dates read correctly */
html[dir="rtl"] .k-value,
html[dir="rtl"] .num,
html[dir="rtl"] .s-value,
html[dir="rtl"] .ch-data-val { direction: ltr; unicode-bidi: embed; }
html[dir="rtl"] .s-value, html[dir="rtl"] .ch-data-val { display: inline-block; }
/* language switch pill */
.lang-switch {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  font: 700 13px var(--font-body);
  color: var(--accent);
  background: rgba(45, 212, 191, .08);
  border: 1px solid rgba(45, 212, 191, .35);
  border-radius: 999px;
  cursor: pointer;
  transition: .18s;
}
.lang-switch:hover { background: rgba(45, 212, 191, .18); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ambient background glow */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(45, 212, 191, .10), transparent 60%),
    radial-gradient(700px 420px at -10% 110%, rgba(96, 165, 250, .08), transparent 60%),
    var(--bg);
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: none; filter: brightness(1.15); }
img { max-width: 100%; }

/* ── scrollbars ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e2c44; border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: #2a3d5e; }

/* ════════════════════════════════════════════════════════════════
   TOP NAVIGATION
   ════════════════════════════════════════════════════════════════ */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: rgba(7, 13, 24, .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topnav .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topnav .brand img { height: 38px; width: auto; }
.brand-logo { height: 44px !important; width: auto; }
.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .5px;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-company {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .2px;
  line-height: 1.2;
}
.brand-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topnav .nav-right { display: flex; align-items: center; gap: 14px; }
.nav-user { font-size: 13px; color: var(--muted); white-space: nowrap; }
.nav-user b { color: var(--text); font-weight: 600; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  background: rgba(148, 163, 184, .10);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  transition: .18s;
}
.btn:hover { border-color: var(--border-hi); background: rgba(45, 212, 191, .10); }
.btn-primary {
  background: var(--grad-brand);
  border: none;
  color: #04110d;
}
.btn-primary:hover { box-shadow: var(--glow); filter: brightness(1.06); }
.btn svg { flex: none; }

/* ════════════════════════════════════════════════════════════════
   LOGIN PAGE
   ════════════════════════════════════════════════════════════════ */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
}
.login-hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 48px 56px;
  background:
    radial-gradient(800px 600px at 20% 15%, rgba(45, 212, 191, .16), transparent 55%),
    radial-gradient(700px 500px at 90% 90%, rgba(163, 230, 53, .10), transparent 55%),
    linear-gradient(160deg, #0a1626 0%, #070d18 100%);
}
.login-hero .grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,.05) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(70% 70% at 50% 40%, #000 30%, transparent 100%);
  -webkit-mask-image: radial-gradient(70% 70% at 50% 40%, #000 30%, transparent 100%);
}
.login-hero .hero-brand { display: flex; align-items: center; gap: 14px; z-index: 1; }
.login-hero .hero-brand img { height: 46px; }
.hero-copy { z-index: 1; max-width: 520px; }
.hero-copy h1 {
  font-size: clamp(30px, 3.6vw, 46px);
  line-height: 1.12;
  letter-spacing: -.5px;
  margin-bottom: 18px;
}
.hero-copy h1 .grad {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero-copy p { color: var(--muted); font-size: 16px; max-width: 440px; }
.hero-stats { display: flex; gap: 34px; z-index: 1; flex-wrap: wrap; }
.hero-stat .n {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--accent);
}
.hero-stat .l { font-size: 12.5px; color: var(--muted); letter-spacing: .4px; text-transform: uppercase; }

/* animated energy wave */
.hero-wave { position: absolute; bottom: -8px; left: 0; right: 0; opacity: .8; z-index: 0; }
.hero-wave path { animation: waveShift 9s ease-in-out infinite alternate; }
@keyframes waveShift { from { transform: translateX(0); } to { transform: translateX(-60px); } }

.login-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: var(--bg-2);
  border-left: 1px solid var(--border);
}
.login-card { width: 100%; max-width: 400px; }
.login-card h2 { font-size: 26px; margin-bottom: 6px; }
.login-card .sub { color: var(--muted); font-size: 14px; margin: 0 0 30px; }

.field { margin-bottom: 18px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}
.field input {
  width: 100%;
  padding: 13px 16px;
  font: 500 15px var(--font-body);
  color: var(--text);
  background: rgba(148, 163, 184, .07);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: .18s;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, .15);
  background: rgba(45, 212, 191, .05);
}
.login-btn {
  width: 100%;
  padding: 14px;
  margin-top: 6px;
  font: 700 15px var(--font-display);
  letter-spacing: .4px;
  color: #04110d;
  background: var(--grad-brand);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: .18s;
}
.login-btn:hover { box-shadow: var(--glow); filter: brightness(1.06); }
.login-msg {
  margin: 0 0 18px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}
.login-msg.error { background: rgba(248, 113, 113, .10); border: 1px solid rgba(248, 113, 113, .35); color: #fca5a5; }
.login-msg.ok    { background: rgba(45, 212, 191, .10);  border: 1px solid rgba(45, 212, 191, .35);  color: #7df3e1; }
.login-foot { margin-top: 26px; font-size: 12.5px; color: var(--faint); text-align: center; }

@media (max-width: 880px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-hero { min-height: 38vh; padding: 32px 26px; }
  .hero-stats { display: none; }
}

/* ════════════════════════════════════════════════════════════════
   PAGE SCAFFOLD
   ════════════════════════════════════════════════════════════════ */
.page { max-width: 1380px; margin: 0 auto; padding: 28px 28px 80px; }
.page-title-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin: 8px 0 24px;
}
.page-title-row h1 { font-size: clamp(24px, 3vw, 34px); letter-spacing: -.4px; }
.page-title-row .crumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.page-title-row .crumb a { color: var(--muted); }
.page-title-row .crumb a:hover { color: var(--accent); }

/* ════════════════════════════════════════════════════════════════
   KPI STRIP
   ════════════════════════════════════════════════════════════════ */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 30px;
}
.kpi {
  position: relative;
  padding: 20px 22px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
  overflow: hidden;
}
.kpi::after {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--grad-brand);
  opacity: .85;
}
.kpi .k-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi .k-value {
  font-family: var(--font-display);
  font-size: clamp(24px, 2.4vw, 32px);
  font-weight: 700;
  margin-top: 6px;
  color: var(--text);
}
.kpi .k-value .unit { font-size: 14px; color: var(--muted); font-weight: 500; margin-left: 5px; }
.kpi.glow .k-value { color: var(--accent); text-shadow: 0 0 26px rgba(45,212,191,.35); }
.kpi .k-sub { font-size: 12px; color: var(--faint); margin-top: 4px; }

/* ════════════════════════════════════════════════════════════════
   SITE CARDS (portfolio grid)
   ════════════════════════════════════════════════════════════════ */
.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 22px;
}
.site-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(10px);
  transition: transform .22s, border-color .22s, box-shadow .22s;
}
.site-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hi);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .45), var(--glow);
}
.site-card .card-img {
  position: relative;
  height: 175px;
  overflow: hidden;
}
.site-card .card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s;
  display: block;
}
.site-card:hover .card-img img { transform: scale(1.05); }
.site-card .card-img::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 35%, rgba(7, 13, 24, .92) 100%);
}
.card-img .card-title {
  position: absolute;
  left: 18px; right: 18px; bottom: 12px;
  z-index: 1;
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 700;
  text-shadow: 0 2px 10px rgba(0,0,0,.6);
}
.card-img .pill {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 1;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .4px;
  color: #04110d;
  background: var(--grad-brand);
  border-radius: 999px;
}
.site-card .card-body { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 0; flex: 1; }
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 7px 0;
  border-bottom: 1px dashed rgba(148, 163, 184, .12);
  font-size: 13.5px;
}
.stat-row:last-of-type { border-bottom: none; }
.stat-row .s-label { color: var(--muted); }
.stat-row .s-value { font-family: var(--font-display); font-weight: 600; color: var(--text); }
.stat-row .s-value.pos { color: var(--accent-2); }
.card-cta {
  margin-top: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(45, 212, 191, .08);
  border: 1px solid rgba(45, 212, 191, .25);
  border-radius: var(--radius-sm);
  transition: .18s;
}
.site-card:hover .card-cta { background: rgba(45, 212, 191, .16); }

/* ════════════════════════════════════════════════════════════════
   TABS
   ════════════════════════════════════════════════════════════════ */
.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 6px;
  margin-bottom: 26px;
  background: rgba(148, 163, 184, .06);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
}
.tab-btn {
  padding: 9px 20px;
  font: 600 13.5px var(--font-body);
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: .18s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: #04110d;
  background: var(--grad-brand);
  box-shadow: 0 4px 18px rgba(45, 212, 191, .35);
}
.tab-panel { display: none; animation: fadeUp .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ════════════════════════════════════════════════════════════════
   PANELS / CHART GRID
   ════════════════════════════════════════════════════════════════ */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  backdrop-filter: blur(10px);
}
.panel + .panel { margin-top: 22px; }
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.panel-title h3 { font-size: 17px; }
.panel-title .meta { font-size: 12.5px; color: var(--faint); }

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-box {
  position: relative;
  height: 300px;
  min-width: 0;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(10px);
}
.chart-box.tall { height: 400px; }

/* ════════════════════════════════════════════════════════════════
   DATA TABLES
   ════════════════════════════════════════════════════════════════ */
.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.table-toolbar input[type="text"] {
  flex: 1;
  min-width: 180px;
  max-width: 340px;
  padding: 10px 16px;
  font: 500 13.5px var(--font-body);
  color: var(--text);
  background: rgba(148, 163, 184, .07);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
.table-toolbar input[type="text"]:focus { border-color: var(--accent); }

.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table.data {
  width: 100%;
  /* 'separate' is required — border-collapse:collapse breaks
     position:sticky on table headers in Chrome */
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
  white-space: nowrap;
}
/* freeze the whole thead as ONE block — reliable for multi-row headers,
   unlike per-cell sticky which lets the second row slip away */
table.data thead {
  position: sticky;
  top: 0;
  z-index: 5;
}
table.data thead th {
  padding: 12px 14px;
  font: 600 11.5px var(--font-body);
  letter-spacing: .6px;
  text-transform: uppercase;
  text-align: left;
  color: var(--muted);
  background: #101e36;
  border-bottom: 1px solid var(--border);
}
/* two-row grouped headers (history table) — everything fits without scrolling */
table.data thead tr.grp-row th {
  text-align: center;
  vertical-align: middle;
  padding: 8px 10px;
  line-height: 1.25;
}
table.data thead tr.grp-row th.grp {
  color: var(--accent);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
table.data thead tr.sub-row th {
  text-align: center;
  padding: 7px 10px;
  font-size: 10.5px;
  color: var(--faint);
}
table.data.compact { white-space: normal; }
table.data.compact tbody td { text-align: right; padding: 9px 10px; }
table.data.compact tbody td:first-child,
table.data.compact tbody td:nth-child(2) { text-align: left; }
table.data tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
  color: var(--text);
}
table.data tbody tr:hover td { background: rgba(45, 212, 191, .045); }
table.data .num { font-variant-numeric: tabular-nums; }

/* ════════════════════════════════════════════════════════════════
   PLANT LAYOUT (live monitor)
   ════════════════════════════════════════════════════════════════ */
.plant-boundary {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0c1729;
  padding: 18px;
}
.ambient-badge {
  position: absolute;
  top: 14px; right: 14px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  background: rgba(7, 13, 24, .88);
  border: 1px solid var(--border-hi);
  border-radius: 999px;
  backdrop-filter: blur(8px);
}
.ambient-badge .amb-icon { font-size: 17px; }
.ambient-badge .amb-label { display: block; font-size: 10px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.ambient-badge .amb-value { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--amber); }

.plant-image-wrap { position: relative; }
.plant-image-wrap > img {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  /* blend the old white layout PNGs into the dark theme */
  filter: invert(.92) hue-rotate(180deg) saturate(.85);
  opacity: .96;
}
/* new isometric layouts (assets/img2) are dark-native — no inversion */
.plant-image-wrap > img[src*="img2"] {
  filter: none;
  opacity: 1;
}
/* inline SVG layout (enables per-chiller fan animation) */
.plant-image-wrap > svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-sm);
}

/* ── frozen page header: site name + KPI metrics stay visible ───── */
.sticky-head {
  position: sticky;
  top: 67px;                     /* just below the sticky topnav */
  z-index: 80;
  background: rgba(7, 13, 24, .90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  margin: 0 -28px 22px;
  padding: 8px 28px 12px;
  border-bottom: 1px solid var(--border);
}
.sticky-head .page-title-row { margin: 0 0 12px; }
.sticky-head .page-title-row h1 { font-size: clamp(20px, 2.4vw, 27px); }
.sticky-head .kpi-strip { margin-bottom: 0; gap: 12px; }
.sticky-head .kpi { padding: 12px 18px; }
.sticky-head .kpi .k-value { font-size: 21px; }
.sticky-head .kpi .k-sub { display: none; }
@media (max-width: 700px) {
  .sticky-head { position: static; margin: 0 -14px 18px; padding: 8px 14px 10px; }
}
.ch-card {
  position: absolute;
  transform: translate(-50%, -108%);
  width: 158px;
  background: rgba(10, 19, 34, .94);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 26px rgba(0,0,0,.5);
  z-index: 4;
  font-size: 12px;
}
.ch-card.ch-running { border-color: rgba(45, 212, 191, .55); box-shadow: 0 8px 26px rgba(0,0,0,.5), 0 0 18px rgba(45,212,191,.18); }
.ch-card.ch-stopped { border-color: rgba(248, 113, 113, .4); }
.ch-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.ch-card-id { font-family: var(--font-display); font-weight: 700; font-size: 12.5px; }
.ch-card-model { font-size: 9.5px; line-height: 1.25; color: var(--muted); margin-bottom: 5px; letter-spacing: .2px; }
.ch-card-role {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(96, 165, 250, .16);
  color: var(--accent-3);
}
.ch-card-status { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; margin-bottom: 7px; }
.ch-running .ch-card-status { color: var(--accent); }
.ch-stopped .ch-card-status { color: var(--red); }
.ch-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.ch-running .ch-dot { animation: pulse 1.6s infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(45, 212, 191, .5); }
  70%  { box-shadow: 0 0 0 7px rgba(45, 212, 191, 0); }
  100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0); }
}
.ch-data-row { display: flex; justify-content: space-between; padding: 2.5px 0; }
.ch-data-lbl { color: var(--muted); }
.ch-data-val { font-weight: 600; font-variant-numeric: tabular-nums; }
.ch-data-val.chw-in  { color: var(--orange); }
.ch-data-val.chw-out { color: var(--accent); }
.ch-data-val.ch-sp   { color: var(--violet); }

@media (max-width: 760px) {
  .ch-card { position: static; transform: none; width: auto; margin-top: 10px; }
  .plant-cards-stack { display: flex; flex-direction: column; }
}

/* ════════════════════════════════════════════════════════════════
   SUMMARY / INFO CARDS
   ════════════════════════════════════════════════════════════════ */
.info-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 22px; margin-bottom: 22px; }
.info-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(10px);
}
.info-card h4 {
  font-size: 13px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.info-card .stat-row { font-size: 14px; }

.amc-banner {
  margin: 22px 0;
  padding: 16px 22px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(45,212,191,.12), rgba(163,230,53,.12));
  border: 1px solid rgba(45, 212, 191, .3);
  color: var(--accent);
}

/* ════════════════════════════════════════════════════════════════
   AI ASSISTANT
   ════════════════════════════════════════════════════════════════ */
.ai-fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  font: 700 14px var(--font-display);
  color: #04110d;
  background: var(--grad-brand);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0,0,0,.5), var(--glow);
  transition: .2s;
}
.ai-fab:hover { transform: translateY(-2px); filter: brightness(1.07); }

.ai-panel {
  position: fixed;
  right: 26px;
  bottom: 26px;
  z-index: 310;
  width: min(420px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 60px));
  display: none;
  flex-direction: column;
  background: #0b1424;
  border: 1px solid var(--border-hi);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  overflow: hidden;
}
.ai-panel.open { display: flex; }
.ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: linear-gradient(90deg, rgba(45,212,191,.14), rgba(163,230,53,.10));
  border-bottom: 1px solid var(--border);
}
.ai-head .t { font-family: var(--font-display); font-weight: 700; font-size: 15px; display:flex; align-items:center; gap:9px; }
.ai-head .t .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); animation: pulse 1.8s infinite; }
.ai-head .sub { font-size: 11px; color: var(--muted); }
.ai-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; padding: 4px 8px; }
.ai-close:hover { color: var(--text); }

.ai-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 86%; padding: 11px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.ai-msg.user { align-self: flex-end; background: rgba(45, 212, 191, .16); border: 1px solid rgba(45, 212, 191, .3); border-bottom-right-radius: 4px; }
.ai-msg.bot  { align-self: flex-start; background: rgba(148, 163, 184, .09); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.ai-msg.bot.thinking { color: var(--muted); font-style: italic; }
.ai-msg.bot.error { border-color: rgba(248,113,113,.4); color: #fca5a5; }

.ai-suggestions { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  padding: 7px 13px;
  font-size: 12px;
  color: var(--accent);
  background: rgba(45, 212, 191, .07);
  border: 1px solid rgba(45, 212, 191, .25);
  border-radius: 999px;
  cursor: pointer;
  transition: .15s;
}
.ai-chip:hover { background: rgba(45, 212, 191, .16); }

.ai-input-row { display: flex; gap: 10px; padding: 14px; border-top: 1px solid var(--border); background: #0a1322; }
.ai-input-row input {
  flex: 1;
  padding: 12px 16px;
  font: 500 14px var(--font-body);
  color: var(--text);
  background: rgba(148, 163, 184, .08);
  border: 1px solid var(--border);
  border-radius: 999px;
  outline: none;
}
.ai-input-row input:focus { border-color: var(--accent); }
.ai-send {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-brand);
  color: #04110d;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  transition: .15s;
}
.ai-send:hover { filter: brightness(1.08); }
.ai-send:disabled { opacity: .45; cursor: default; }

/* ════════════════════════════════════════════════════════════════
   FOOTER & MISC
   ════════════════════════════════════════════════════════════════ */
.footer {
  margin-top: 50px;
  padding: 26px;
  text-align: center;
  font-size: 12.5px;
  color: var(--faint);
  border-top: 1px solid var(--border);
}
.section-label {
  display: inline-block;
  margin-bottom: 14px;
  padding: 5px 14px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(45, 212, 191, .08);
  border: 1px solid rgba(45, 212, 191, .25);
  border-radius: 999px;
}
.glance-expand { cursor: pointer; color: var(--accent); font-weight: 700; user-select: none; width: 30px; text-align: center; }
tr.hidden-row { display: none; }
tr.hidden-row.shown { display: table-row; }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font: 600 13px var(--font-body);
  color: var(--accent-2);
  background: rgba(163, 230, 53, .08);
  border: 1px solid rgba(163, 230, 53, .3);
  border-radius: 999px;
  cursor: pointer;
  transition: .15s;
}
.export-btn:hover { background: rgba(163, 230, 53, .16); }

@media (max-width: 700px) {
  .page { padding: 18px 14px 70px; }
  .topnav { padding: 12px 14px; }
  .brand-sub { display: none; }
  .chart-box { height: 280px; }
}

/* ════════════════════════════════════════════════════════════════
   PUBLIC HOME PAGE
   ════════════════════════════════════════════════════════════════ */
.pub-hero {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 40px;
  align-items: start;
  padding: 40px 0 30px;
}
.pub-copy h1 {
  font-size: clamp(32px, 4.2vw, 52px);
  line-height: 1.1;
  letter-spacing: -.6px;
  margin: 16px 0 18px;
}
.pub-copy h1 .grad {
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.pub-lead {
  color: var(--muted);
  font-size: 16.5px;
  max-width: 560px;
  margin: 0 0 30px;
}
.pub-lead b { color: var(--text); }
.pub-kpis { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 0; }

/* embedded chat card (reuses .ai-head/.ai-body/.ai-input-row styles) */
.ai-embed {
  display: flex;
  flex-direction: column;
  height: 520px;
  background: #0b1424;
  border: 1px solid var(--border-hi);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45), var(--glow);
}

.pub-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px;
  margin-top: 26px;
}
.pub-features .info-card p { color: var(--muted); font-size: 13.5px; margin: 0; }

@media (max-width: 980px) {
  .pub-hero { grid-template-columns: 1fr; }
  .ai-embed { height: 460px; }
}

/* ── sign-in modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 8, 16, .72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }
.modal-card {
  position: relative;
  width: 100%;
  max-width: 410px;
  padding: 34px 36px 28px;
  background: #0d1830;
  border: 1px solid var(--border-hi);
  border-radius: 20px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .65);
  animation: fadeUp .22s ease;
}
.modal-card h2 { font-size: 24px; margin-bottom: 4px; }
.modal-card .sub { color: var(--muted); font-size: 13.5px; margin: 0 0 24px; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 22px;
}

/* ════════════════════════════════════════════════════════════════
   ADMIN — approval banner + user rows
   ════════════════════════════════════════════════════════════════ */
.approve-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 22px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(251,146,60,.14), rgba(163,230,53,.10));
  border: 1px solid rgba(251, 146, 60, .4);
}
.approve-banner .ab-text { display: flex; align-items: center; gap: 12px; font-size: 15px; }
.approve-banner .ab-icon { font-size: 20px; }
.approve-banner b { color: var(--amber); }

.count-pill {
  display: inline-block;
  min-width: 22px;
  padding: 1px 8px;
  margin-left: 8px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  color: #04110d;
  background: var(--grad-brand);
  border-radius: 999px;
  vertical-align: middle;
}

.approve-list { display: flex; flex-direction: column; gap: 14px; }
.approve-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: rgba(148, 163, 184, .05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.approve-row .ar-info { min-width: 220px; flex: 1; }
.ar-name { font-family: var(--font-display); font-weight: 600; font-size: 15.5px; }
.ar-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.ar-meta .ar-date { color: var(--faint); }
.ar-note { margin-top: 6px; font-size: 13px; color: var(--muted); font-style: italic; }
.ar-controls { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; }
.ar-label { display: flex; flex-direction: column; gap: 6px; font-size: 11.5px; font-weight: 600; letter-spacing: .5px; text-transform: uppercase; color: var(--muted); }
.ar-label select, .ar-label input {
  min-width: 240px;
  padding: 10px 14px;
  font: 500 14px var(--font-body);
  color: var(--text);
  background: rgba(148, 163, 184, .08);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
}
.ar-label select:focus, .ar-label input:focus { border-color: var(--accent); }
.ar-label select option { background: #0e1a2e; color: var(--text); }
.ar-buttons { display: flex; gap: 8px; }
@media (max-width: 640px) {
  .ar-controls { width: 100%; }
  .ar-label select, .ar-label input { min-width: 0; width: 100%; }
}

/* ── form grids (Add a user, Add a site) ──────────────────────────────
   .ar-label inputs carry min-width:240px, which suits the inline approve
   row but fights a grid: the input refuses to shrink below 240px, so a
   track sized at 210px overflows and the columns break into a ragged
   stack. Inside .form-grid the field yields to the track instead. */
.form-grid {
  display: grid;
  gap: 14px 16px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  align-items: end;
}
.form-grid .ar-label { width: 100%; }
.form-grid .ar-label input,
.form-grid .ar-label select,
.form-grid .ar-label textarea { min-width: 0; width: 100%; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid .actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
