/* ==========================================================================
   BatteryStatus - a thin layer over Bootstrap 5.

   House style: quiet, flat and dense.

   Near-white ground, white panels with a single hairline border and almost no
   shadow, small radii. Readings are set in a monospaced face with tabular
   figures so columns of numbers line up and a ticking digit does not shift the
   ones beside it.

   Colour is reserved for STATE. Green means healthy, amber means watch it, red
   means act - and nothing else in the interface borrows those hues for
   decoration. Every state is also spelled out in words and carries a shape
   (pill, dot, top-border), so colour is never the only channel.
   ========================================================================== */

:root {
  /* Text scale. 1 everywhere; the content area raises it (see .bs-content),
     so the nav rail and top bar keep their size. */
  --fs: 1;

  /* --- ground and ink --------------------------------------------------- */
  --bs-body-bg:    #f6f7f8;
  --bs-body-color: #1b1f24;
  --surface:       #ffffff;
  --surface-2:     #fbfcfc;      /* panel and table headers */
  --ink-2:         #5b6673;      /* secondary text */
  --muted:         #6b7480;      /* labels, captions - 4.74:1 on white, clears AA */
  --muted-2:       #97a0a9;      /* decorative only: gridlines, disabled glyphs */
  --border:        #e4e7ea;      /* the hairline everything uses */
  --border-2:      #eef0f2;      /* inner dividers, gridlines */

  /* --- state (reserved - never decorative) ------------------------------ */
  --ok:   #1f9254;  --ok-tint:   #e9f5ee;  --ok-ink:   #15693c;
  --warn: #d5942a;  --warn-tint: #fdf4e4;  --warn-ink: #8a5c07;
  --crit: #d64545;  --crit-tint: #fdecec;  --crit-ink: #a32c2c;
  --off:  #9aa3ad;  --off-tint:  #f1f3f5;  --off-ink:  #5b6673;

  /* --- brand (chrome only) ---------------------------------------------- */
  --brand: #2f6fd0;  --brand-tint: #eaf1fc;  --brand-ink: #1d4e99;

  /* --- categorical hues -------------------------------------------------
     A second, independent colour layer. These identify WHICH THING you are
     looking at - which metric, which site - and never what condition it is in.
     Without them a healthy fleet renders almost entirely green, because state
     is the only thing carrying colour. All measured >= 4.5:1 on white. */
  --m-indigo: #4f46e5;  --m-indigo-tint: #eef2ff;  --m-indigo-ink: #4338ca;
  --m-cyan:   #0e7490;  --m-cyan-tint:   #ecfeff;  --m-cyan-ink:   #0e7490;
  --m-violet: #7c3aed;  --m-violet-tint: #f5f3ff;  --m-violet-ink: #6d28d9;
  --m-amber:  #b45309;  --m-amber-tint:  #fffbeb;  --m-amber-ink:  #b45309;
  --m-amber-line: #e08c14;   /* chart strokes only - not text */
  --m-rose:   #e11d48;  --m-rose-tint:   #fff1f2;  --m-rose-ink:   #be123c;
  --m-teal:   #0f766e;  --m-teal-tint:   #f0fdfa;  --m-teal-ink:   #0f766e;

  /* --- navy nav rail ----------------------------------------------------
     Taken from the MegaHostZone reference the user supplied, not re-tuned.
     Every text colour here clears 4.5:1 on the navy. The active pill fill is
     2.44:1 against the navy, so the active item is ALSO marked without
     colour: a heavier label, plus aria-current for screen readers. */
  --side-bg:      #1e2a5a;
  --side-ink:     #eef1fa;   /* labels   12.1:1 */
  --side-icon:    #d3dbef;   /* icons     9.9:1 */
  --side-section: #8e9dd0;   /* headings  5.1:1 */
  --side-line:    rgba(255, 255, 255, .09);
  --side-hover:   rgba(255, 255, 255, .07);
  --side-active:  #2f5fd8;   /* white on it 5.6:1 */
  --side-accent:  #4d8ef7;   /* brand glyph + focus ring */
  --side-badge:   rgba(255, 255, 255, .13);
  --side-badge-ink: #e3e8f7; /* 7.5:1 on the badge */

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", "Courier New", monospace;

  --radius: 9px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(27, 31, 36, .05);
}

/* Bootstrap display utilities carry !important, which beats the plain
   [hidden] rule - so a hidden .d-flex element would still show. */
[hidden] { display: none !important; }

/* Keyboard focus was invisible everywhere. One ring, stated once. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 3px;
}
.bs-side :focus-visible { outline-color: var(--side-accent); }

body {
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: calc(.875rem * var(--fs));
  -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- shell -- */

.bs-shell { display: flex; min-height: 100vh; }

.bs-side {
  width: 252px;
  color: var(--side-ink);
  border-right: 1px solid var(--side-bg);
}

/* Bootstrap forces "background-color: transparent !important" on .offcanvas-lg
   above its breakpoint, so a flat colour set the normal way silently vanishes -
   the rail was see-through and only looked right while it happened to be white
   on a white page. Two classes plus !important is what it takes to win. */
.bs-side.offcanvas-lg { background-color: var(--side-bg) !important; }

/* Below lg the rail is a Bootstrap off-canvas drawer. Bootstrap's own
   ".offcanvas-lg.show { transform: none }" was losing to its
   ".offcanvas-lg.offcanvas-start { transform: translateX(-100%) }" here, which
   left the opened drawer parked off-screen. Stating it explicitly with our own
   (higher) specificity removes the doubt. */
@media (max-width: 991.98px) {
  .bs-side.offcanvas-lg { width: 272px; }
  .bs-side.offcanvas-lg.show,
  .bs-side.offcanvas-lg.showing { transform: none; }
  .bs-side.offcanvas-lg.hiding  { transform: translateX(-100%); }
}

@media (min-width: 992px) {
  .bs-side {
    position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column;
    z-index: 1030;
  }
  .bs-main { margin-left: 252px; }
}

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

/* --- rail: brand ------------------------------------------------------- */

.bs-side-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; padding: 1.05rem 1.1rem .95rem;
  border-bottom: 1px solid var(--side-line);
}

.bs-brand {
  display: inline-flex; align-items: center; gap: .6rem;
  color: #fff; text-decoration: none;
  font-weight: 750; font-size: calc(1.05rem * var(--fs)); letter-spacing: -.02em;
  min-width: 0;
}
.bs-brand:hover { color: #fff; }

/* A plain glyph in the accent blue - no tile behind it, as in the reference. */
.bs-brand-mark { color: var(--side-accent); font-size: calc(1.35rem * var(--fs)); line-height: 1; flex: none; }
.bs-brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- rail: links ------------------------------------------------------- */

.bs-side-nav {
  padding: .7rem .7rem;
  display: flex; flex-direction: column; gap: .22rem;
  overflow-y: auto; flex: 1 1 auto;
}

.bs-side-section {
  font-size: calc(.68rem * var(--fs)); font-weight: 750; letter-spacing: .09em;
  text-transform: uppercase; color: var(--side-section);
  padding: 1.05rem .8rem .35rem;
}

.bs-side-link {
  display: flex; align-items: center; gap: .75rem;
  padding: .62rem .8rem;
  border-radius: 10px;
  color: var(--side-ink); text-decoration: none;
  font-weight: 600; font-size: calc(.92rem * var(--fs));
  transition: background .14s ease, color .14s ease;
}
.bs-side-link .bi {
  font-size: calc(1.12rem * var(--fs)); width: 1.3rem; text-align: center; flex: none;
  color: var(--side-icon); transition: color .14s ease;
}
.bs-side-text { flex: 1 1 auto; min-width: 0; }

.bs-side-link:hover { background: var(--side-hover); color: #fff; }
.bs-side-link:hover .bi { color: #fff; }

/* The current page is a solid filled pill - no side bar, as in the reference. */
.bs-side-link.active {
  background: var(--side-active);
  color: #fff;
  font-weight: 750;
  box-shadow: 0 4px 14px rgba(47, 95, 216, .35);
}
.bs-side-link.active .bi { color: #fff; }

/* Neutral slate count pill, matching the reference. The red, urgent version
   of the same number lives on the bell in the top bar. */
.bs-side-count {
  background: var(--side-badge); color: var(--side-badge-ink);
  font-size: calc(.72rem * var(--fs)); font-weight: 700;
  border-radius: 999px; padding: .12rem .55rem; flex: none;
}
.bs-side-link.active .bs-side-count { background: rgba(255, 255, 255, .22); color: #fff; }

/* --- rail: foot -------------------------------------------------------- */

.bs-side-foot {
  padding: .2rem .7rem 1rem;
  border-top: 1px solid var(--side-line);
  text-align: center;
}
.bs-side-foot .bs-side-section { padding: .85rem 0 .4rem; }

.bs-side-endpoint {
  display: block; margin: 0 .8rem;
  padding: .38rem .5rem;
  text-align: center;
  background: rgba(0, 0, 0, .18);
  border: 1px solid var(--side-line);
  border-radius: 8px;
  color: #d7dff3;
  font-family: var(--mono); font-size: calc(.68rem * var(--fs));
  word-break: break-all;
}

/* --- topbar ------------------------------------------------------------ */

.bs-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: .6rem;
  min-height: 60px;
  padding: .5rem 1.1rem;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.bs-topbar-title {
  font-weight: 650; font-size: calc(.95rem * var(--fs)); color: var(--bs-body-color);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.bs-burger {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--ink-2); border-radius: 10px;
  width: 40px; height: 40px; font-size: calc(1.15rem * var(--fs)); line-height: 1;
  display: inline-grid; place-items: center; flex: none;
}
.bs-burger:hover { background: var(--surface-2); }

.bs-top-actions { margin-left: auto; display: flex; align-items: center; gap: .55rem; }

/* Date and live clock, left side of the top bar. */
.bs-clock {
  align-items: center; gap: .8rem;
  height: 40px; padding: 0 1rem;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: calc(.86rem * var(--fs)); color: var(--bs-body-color); white-space: nowrap;
}
.bs-clock-part { display: inline-flex; align-items: center; gap: .45rem; font-weight: 600; }
.bs-clock-part .bi { color: var(--brand); font-size: calc(.9rem * var(--fs)); }
.bs-clock-part .num { font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.bs-clock-sep { width: 1px; height: 18px; background: var(--border); }

/* Round outlined icon button. */
.bs-top-icon {
  position: relative;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--ink-2); font-size: calc(1.1rem * var(--fs)); text-decoration: none;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.bs-top-icon:hover { background: var(--surface-2); border-color: #d3d9df; color: var(--bs-body-color); }

.bs-top-badge {
  position: absolute; top: -5px; right: -6px;
  min-width: 20px; height: 20px; padding: 0 .32rem;
  border-radius: 999px; background: #d63434; color: #fff;
  font-size: calc(.68rem * var(--fs)); font-weight: 750; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px #fff;
}

/* Pill container - holds the live "updated" stamp. */
.bs-top-pill {
  display: inline-flex; align-items: center; gap: .45rem;
  height: 40px; padding: 0 .95rem;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  font-size: calc(.82rem * var(--fs)); color: var(--ink-2); white-space: nowrap;
}

.live-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--ok); box-shadow: 0 0 0 3px var(--ok-tint);
}
.live-stamp.is-stale { background: var(--warn-tint); border-color: #f0dcae; color: var(--warn-ink); }
.live-stamp.is-stale .live-dot { background: var(--warn); box-shadow: 0 0 0 3px #fbe8c1; }

/* User menu trigger: avatar, name, caret, in one outlined pill. */
.bs-user {
  display: inline-flex; align-items: center; gap: .55rem;
  height: 44px; padding: 0 .75rem 0 .3rem;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  color: var(--bs-body-color); font-weight: 650; font-size: calc(.9rem * var(--fs));
  transition: background .14s ease, border-color .14s ease;
}
.bs-user:hover, .bs-user[aria-expanded="true"] { background: var(--surface-2); border-color: #d3d9df; }

.bs-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: inline-grid; place-items: center;
  background: var(--side-active); color: #fff;
  font-weight: 700; font-size: calc(.92rem * var(--fs)); letter-spacing: 0;
}
.bs-avatar-lg { width: 42px; height: 42px; font-size: calc(1.05rem * var(--fs)); }

.bs-user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-user-caret { font-size: calc(.7rem * var(--fs)); color: var(--ink-2); }

.bs-user-menu {
  min-width: 236px; padding: .4rem;
  border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(27, 31, 36, .14);
  margin-top: .45rem !important;
}
.bs-user-head {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem .6rem .75rem; margin-bottom: .3rem;
  border-bottom: 1px solid var(--border-2);
}
.bs-user-head-name { font-weight: 700; font-size: calc(.92rem * var(--fs)); color: var(--bs-body-color); }
.bs-user-head-role { font-size: calc(.74rem * var(--fs)); color: var(--muted); }

.bs-user-menu .dropdown-item {
  display: flex; align-items: center; gap: .65rem;
  padding: .52rem .6rem; border-radius: 8px;
  font-size: calc(.86rem * var(--fs)); color: var(--bs-body-color);
}
.bs-user-menu .dropdown-item .bi { font-size: calc(1rem * var(--fs)); color: var(--ink-2); width: 1.1rem; text-align: center; }
.bs-user-menu .dropdown-item:hover,
.bs-user-menu .dropdown-item:focus { background: var(--brand-tint); color: var(--brand-ink); }
.bs-user-menu .dropdown-item:hover .bi { color: var(--brand); }
.bs-user-menu .bs-user-out:hover { background: var(--crit-tint); color: var(--crit-ink); }
.bs-user-menu .bs-user-out:hover .bi { color: var(--crit); }
.bs-user-menu .dropdown-divider { margin: .3rem .2rem; border-color: var(--border-2); }

/* Content text is 10% larger than the chrome around it. Every font-size in
   this file is "Xrem * var(--fs)", so this one number scales the whole page
   body - tables, cards, forms and modals included. */
.bs-content {
  --fs: 1.1;
  flex: 1 1 auto; padding: 1.1rem 1.1rem 1.5rem;
  font-size: calc(.875rem * var(--fs));
}

/* The footer sits on the grey page ground, not a white card, so it uses
   --ink-2 (5.45:1 there) - --muted only reaches 4.41:1 on this background. */
.bs-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .4rem 1.25rem;
  margin: 0 1.1rem;
  padding: .8rem 0 1rem;
  border-top: 1px solid var(--border);
  color: var(--ink-2); font-size: calc(.76rem * var(--fs));
}
.bs-foot-group { display: flex; flex-wrap: wrap; align-items: center; gap: .15rem .45rem; }
.bs-foot-sep { opacity: .5; }
/* Both footer links use --brand-ink: 7.52:1 on the grey page ground. */
.bs-foot-link,
.bs-foot-tel {
  color: var(--brand-ink); font-weight: 650; text-decoration: none; white-space: nowrap;
}
.bs-foot-tel {
  display: inline-flex; align-items: center; gap: .3rem;
  font-variant-numeric: tabular-nums;
}
.bs-foot-tel .bi { font-size: calc(.72rem * var(--fs)); }
.bs-foot-link:hover,
.bs-foot-tel:hover { text-decoration: underline; }

/* ----------------------------------------------------------- page head -- */

.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-start;
  justify-content: space-between; gap: .75rem; margin-bottom: .9rem;
}

.page-title {
  font-size: calc(1.25rem * var(--fs)); font-weight: 660; letter-spacing: -.02em;
  color: var(--bs-body-color); line-height: 1.2; margin: 0;
}

.page-sub {
  font-size: calc(.78rem * var(--fs)); color: var(--muted); margin-top: .2rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: .4rem;
}
.page-sub .sep { opacity: .45; }

/* Devices page: total / online / offline / blocked under the title. */
.dev-counts { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin-top: .4rem; }
.dev-count {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: calc(.78rem * var(--fs)); color: var(--ink-2);
  padding: .18rem .6rem; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
}
.dev-count strong { font-weight: 700; color: var(--bs-body-color); }
.dev-count .bi { font-size: calc(.8rem * var(--fs)); color: var(--m-indigo); }
.dev-dot { width: .5rem; height: .5rem; border-radius: 50%; background: var(--off); flex: none; }
.dev-count.c-online  { background: var(--ok-tint);  border-color: #cbe8d7; color: var(--ok-ink); }
.dev-count.c-online strong { color: var(--ok-ink); }
.dev-count.c-online .dev-dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(31, 146, 84, .18); }
.dev-count.c-offline { background: var(--off-tint); border-color: #dfe3e7; color: var(--off-ink); }
.dev-count.c-offline strong { color: var(--off-ink); }
.dev-count.c-blocked { background: #40464e; border-color: #40464e; color: #fff; }
.dev-count.c-blocked strong, .dev-count.c-blocked .bi { color: #fff; }

.fleet-pill {
  display: inline-flex; align-items: center; gap: .35rem;
  font-size: calc(.76rem * var(--fs)); font-weight: 620;
  padding: .3rem .6rem; border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.fleet-pill.p-ok   { background: var(--ok-tint);   color: var(--ok-ink);   border-color: #c8e6d4; }
.fleet-pill.p-warn { background: var(--warn-tint); color: var(--warn-ink); border-color: #f0dcae; }
.fleet-pill.p-crit { background: var(--crit-tint); color: var(--crit-ink); border-color: #f3c9c9; }

/* --------------------------------------------------------------- panel -- */

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}

.panel-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .7rem .9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

.panel-title {
  font-size: calc(.84rem * var(--fs)); font-weight: 650; color: var(--bs-body-color);
  display: flex; align-items: center; gap: .4rem;
}
.panel-title .dim { color: var(--muted); font-weight: 500; }
.panel-body { padding: .85rem .9rem; }
.panel-note { font-family: var(--mono); font-size: calc(.74rem * var(--fs)); color: var(--ink-2); }
.panel-link { font-size: calc(.76rem * var(--fs)); color: var(--brand); text-decoration: none; }
.panel-link:hover { text-decoration: underline; }

/* Names still used by the device / devices / alerts / settings pages. */
.card-flat { background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); box-shadow: var(--shadow); }
.chart-surface { background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chart-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem; padding: .7rem .9rem;
  background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.chart-body { padding: .6rem .4rem .1rem; }

/* The same header strip as .panel-head, for cards whose body is padded with
   Bootstrap's p-3: it bleeds out over that 1rem padding to the card edges. */
.card-flat.p-3 > .card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: .5rem;
  margin: -1rem -1rem 1rem;
  padding: .7rem .9rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}
.chart-title { font-size: calc(.84rem * var(--fs)); font-weight: 650; color: var(--bs-body-color);
               display: flex; align-items: center; gap: .4rem; }
.chart-title .bi { color: var(--muted); }
/* A single device's voltage is a data SERIES, not a verdict, so it takes the
   neutral brand hue - painting it green would read as "healthy" even while the
   bank is in alert. The fleet chart is the opposite case: there, green really
   does mean "the healthy reference line" against amber for the worst bank. */
.series-swatch { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }
.sw-voltage { background: var(--m-indigo); }
.sw-temp    { background: var(--m-amber-line); }

/* ------------------------------------------------------------ KPI tile -- */

.kpi {
  display: flex; align-items: center; gap: .7rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: .75rem .85rem; height: 100%;
  flex-wrap: wrap;
}

/* The caption drops to its own line rather than competing with the value for
   width - without this the device page tiles overlap. */
.kpi-sub {
  flex: 1 0 100%;
  font-size: calc(.72rem * var(--fs)); line-height: 1.3; color: var(--muted);
  margin-top: .3rem;
}

.kpi-icon {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--ok-tint); color: var(--ok);
  font-size: calc(1.05rem * var(--fs)); flex: none;
}
.kpi.k-brand .kpi-icon { background: var(--brand-tint); color: var(--brand); }
.kpi.k-warn  .kpi-icon { background: var(--warn-tint);  color: var(--warn); }
.kpi.k-crit  .kpi-icon { background: var(--crit-tint);  color: var(--crit); }
.kpi.k-off   .kpi-icon { background: var(--off-tint);   color: var(--off); }

/* Metric identity: the tile says which measurement it is, in its own hue. */
.kpi.m-indigo { --m: var(--m-indigo); --mt: var(--m-indigo-tint); }
.kpi.m-cyan   { --m: var(--m-cyan);   --mt: var(--m-cyan-tint); }
.kpi.m-violet { --m: var(--m-violet); --mt: var(--m-violet-tint); }
.kpi.m-amber  { --m: var(--m-amber);  --mt: var(--m-amber-tint); }
.kpi.m-rose   { --m: var(--m-rose);   --mt: var(--m-rose-tint); }
.kpi[class*="m-"] .kpi-icon  { background: var(--mt); color: var(--m); }
.kpi[class*="m-"] .kpi-value { color: var(--m); }
.kpi[class*="m-"] .kpi-unit  { color: var(--m); opacity: .62; }

/* An alerts tile at zero is not an alarm - it stays neutral until it isn't. */
.kpi.is-quiet .kpi-icon  { background: var(--off-tint); color: var(--off); }
.kpi.is-quiet .kpi-value { color: var(--ink-2); }

.kpi-body { min-width: 0; }

.kpi-label {
  font-size: calc(.76rem * var(--fs)); color: var(--ink-2); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Readings are monospaced with tabular figures, so a ticking value does not
   jiggle the digits either side of it. */
.kpi-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: calc(1.5rem * var(--fs)); font-weight: 600; line-height: 1.15;
  letter-spacing: -.03em; color: var(--bs-body-color); margin-top: .05rem;
}
.kpi.is-crit .kpi-value { color: var(--crit); }

.kpi-unit {
  font-family: var(--mono); font-size: calc(.8rem * var(--fs)); font-weight: 500;
  color: var(--muted); margin-left: .1rem;
}

/* ---------------------------------------------------------- bank cards -- */

.bank {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--ok);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: .8rem .85rem .7rem;
  height: 100%;
  display: flex; flex-direction: column;
  text-decoration: none; color: inherit;
  transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
/* The whole card is the link, so there is no small target to hunt for. */
.bank:hover {
  border-color: #ccd3da;
  box-shadow: 0 2px 10px rgba(27, 31, 36, .09);
  transform: translateY(-1px);
}
.bank:hover .bank-name { color: var(--brand); }
.bank.s-warning { border-top-color: var(--warn); }
.bank.s-alert   { border-top-color: var(--crit); }
.bank.s-offline { border-top-color: var(--off); }
.bank.s-blocked { border-top-color: #4b5563; }

/* Offline banks recede - readable, clearly not current. */
.bank.s-offline, .bank.s-blocked { background: var(--surface-2); }
.bank.s-offline .bank-name, .bank.s-blocked .bank-name { color: var(--ink-2); }
.bank.s-offline .reading-value, .bank.s-blocked .reading-value { color: var(--off-ink); }

.bank-head { display: flex; align-items: flex-start; gap: .6rem; margin-bottom: .8rem; }

.bank-mark {
  display: inline-grid; place-items: center;
  width: 42px; height: 42px; border-radius: 9px;
  background: var(--ok-tint); color: var(--ok);
  font-size: calc(1.25rem * var(--fs)); flex: none;
}
.bank.s-warning .bank-mark { background: var(--warn-tint); color: var(--warn); }
.bank.s-alert   .bank-mark { background: var(--crit-tint); color: var(--crit); }
.bank.s-offline .bank-mark,
.bank.s-blocked .bank-mark { background: var(--off-tint);  color: var(--off); }

.bank-id { min-width: 0; flex: 1 1 auto; }

.bank-name {
  display: block; font-weight: 620; font-size: calc(.84rem * var(--fs));
  color: var(--bs-body-color); letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: color .14s ease;
}

/* How stale the reading is. A monitoring card that does not say this is
   quietly lying about how current it looks. */
.bank-age {
  font-size: calc(.68rem * var(--fs)); color: var(--muted); margin-top: .35rem;
  font-family: var(--mono); text-align: right;
}
.bank.s-offline .bank-age, .bank.s-blocked .bank-age { color: var(--crit-ink); font-weight: 600; }

.bank-site {
  font-size: calc(.74rem * var(--fs)); color: var(--muted); margin-top: .18rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Sites get a stable hue so you can pick a location out of the grid without
   reading every label. Identity, not condition. */
.site-chip {
  display: inline-flex; align-items: center; gap: .28rem;
  font-size: calc(.68rem * var(--fs)); font-weight: 620;
  padding: .06rem .38rem; border-radius: 4px;
  background: var(--off-tint); color: var(--off-ink);
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.site-0 { background: var(--m-indigo-tint); color: var(--m-indigo-ink); }
.site-1 { background: var(--m-teal-tint);   color: var(--m-teal-ink); }
.site-2 { background: var(--m-violet-tint); color: var(--m-violet-ink); }
.site-3 { background: var(--m-cyan-tint);   color: var(--m-cyan-ink); }
.site-4 { background: #eef2f7;              color: #3f5069; }
.site-5 { background: #f2f0fb;              color: #524b93; }

/* Battery chemistry on the service register. Categorical hues, never the
   ok/warn/crit state colours: a type is identity, not condition. */
.type-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: calc(.7rem * var(--fs)); font-weight: 640; white-space: nowrap;
  padding: .1rem .45rem; border-radius: 5px; border: 1px solid transparent;
  background: var(--off-tint); color: var(--off-ink);
}
.type-chip .bi { font-size: calc(.78rem * var(--fs)); }
.type-chip.t-lead    { background: var(--m-amber-tint);  color: var(--m-amber-ink);  border-color: #f5dfb0; }
.type-chip.t-lithium { background: var(--m-teal-tint);   color: var(--m-teal-ink);   border-color: #bfe6e0; }
.type-chip.t-nickel  { background: var(--m-violet-tint); color: var(--m-violet-ink); border-color: #ddd3fb; }
.type-chip.t-other   { border-color: var(--border); }
.type-chip + .subtle { margin-top: .2rem; }

.bat-search { max-width: 360px; }

/* Row-leading tile: the family hue from .type-chip, a glyph, and a short
   tag naming the exact chemistry. */
.bat-cell { display: flex; align-items: center; gap: .65rem; min-width: 0; }
.bat-cell-text { min-width: 0; }
.bat-ico {
  flex: none; width: 2.5rem; height: 2.5rem; border-radius: 9px;
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .05rem; border: 1px solid transparent;
  background: var(--off-tint); color: var(--off-ink);
}
.bat-ico .bi { font-size: calc(1.05rem * var(--fs)); line-height: 1; }
.bat-ico-tag { font-size: calc(.54rem * var(--fs)); font-weight: 750; letter-spacing: .02em; line-height: 1; }
.bat-ico.t-lead    { background: var(--m-amber-tint);  color: var(--m-amber-ink);  border-color: #f5dfb0; }
.bat-ico.t-lithium { background: var(--m-teal-tint);   color: var(--m-teal-ink);   border-color: #bfe6e0; }
.bat-ico.t-nickel  { background: var(--m-violet-tint); color: var(--m-violet-ink); border-color: #ddd3fb; }
.bat-ico.t-sensor  { background: var(--m-indigo-tint); color: var(--m-indigo-ink); border-color: #d9defa; }
.bat-ico.t-other,
.bat-ico.t-none    { border-color: var(--border); }
/* Offline and blocked sensors fade, as their cards do on the dashboard. */
.bat-ico.is-faded  { opacity: .45; filter: grayscale(.6); }
.bat-day { font-size: calc(.78rem * var(--fs)); white-space: nowrap; }
.bat-day .subtle { font-family: var(--bs-body-font-family); }
.bat-notes {
  max-width: 240px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.pill {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: calc(.68rem * var(--fs)); font-weight: 650;
  padding: .12rem .42rem; border-radius: 5px;
  border: 1px solid transparent; white-space: nowrap; flex: none;
}
.pill .bi { font-size: calc(.7rem * var(--fs)); }
.pill.p-ok      { background: var(--ok-tint);   color: var(--ok-ink);   border-color: #cbe8d7; }
.pill.p-warning { background: var(--warn-tint); color: var(--warn-ink); border-color: #f0dcae; }
.pill.p-alert   { background: var(--crit-tint); color: var(--crit-ink); border-color: #f3c9c9; }
.pill.p-offline { background: var(--off-tint);  color: var(--off-ink);  border-color: #dfe3e7; }
.pill.p-blocked { background: #40464e;          color: #fff;            border-color: #40464e; }

.bank-readings { display: flex; gap: 1.4rem; margin-bottom: .7rem; }
.reading { min-width: 0; }
.reading-key { font-size: calc(.72rem * var(--fs)); color: var(--muted); margin-bottom: .1rem; }
.reading-value {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: calc(1.35rem * var(--fs)); font-weight: 600; letter-spacing: -.035em;
  color: var(--bs-body-color); line-height: 1.1;
}
.reading-unit { font-size: calc(.74rem * var(--fs)); font-weight: 500; color: var(--muted); margin-left: .15rem; }
.reading.is-hot .reading-value { color: var(--crit); }

.bank-spark { height: 40px; margin: 0 -.1rem .6rem; line-height: 0; }

.bank-foot { margin-top: auto; }
.bank-stats {
  display: flex; justify-content: space-between; gap: .5rem;
  font-size: calc(.72rem * var(--fs)); color: var(--ink-2); margin-bottom: .3rem;
}
.bank-stats .k { color: var(--muted); }
.bank-stats .v { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 600; }

.meter { height: 5px; border-radius: 3px; background: var(--border-2); overflow: hidden; }
/* The meter is state of CHARGE, so it wears the charge hue rather than the
   health green - until the bank is actually in trouble, where state wins. */
.meter-fill {
  height: 100%; border-radius: 3px;
  background: linear-gradient(90deg, var(--m-cyan), var(--m-indigo));
  transition: width .4s ease;
}
.meter-fill.f-warning { background: var(--warn); }
.meter-fill.f-alert   { background: var(--crit); }
.meter-fill.f-offline { background: var(--off); }

/* ---------------------------------------------------------- alert list -- */

.alert-list { display: flex; flex-direction: column; }

.alert-row {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border-2);
  text-decoration: none;
}
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: var(--surface-2); }

.alert-dot {
  width: 7px; height: 7px; border-radius: 50%; flex: none; margin-top: .38rem;
  background: var(--crit);
}
.alert-dot.d-warning { background: var(--warn); }
.alert-dot.d-cleared { background: var(--off); }

.alert-main  { flex: 1 1 auto; min-width: 0; }
.alert-title { font-size: calc(.8rem * var(--fs)); font-weight: 620; color: var(--bs-body-color); }
.alert-meta  { font-size: calc(.72rem * var(--fs)); color: var(--muted); margin-top: .05rem;
               white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.alert-state { font-size: calc(.72rem * var(--fs)); color: var(--muted); white-space: nowrap;
               flex: none; font-family: var(--mono); }
.alert-state.is-active { color: var(--crit); font-weight: 650; }

/* --------------------------------------------------------- fleet chart -- */

.fleet-legend {
  display: flex; flex-wrap: wrap; gap: 1rem;
  padding: .1rem .9rem .8rem;
  font-size: calc(.74rem * var(--fs)); color: var(--ink-2);
}
.fleet-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend-line { width: 18px; height: 0; border-top: 2px solid var(--m-indigo); display: inline-block; }
.legend-line.l-min { border-top-style: dashed; border-top-color: var(--m-amber-line); }

/* ---------------------------------------------------------- stat strip -- */

.stat-strip { display: flex; flex-wrap: wrap; border-top: 1px solid var(--border); background: var(--surface-2); }
.stat-cell { flex: 1 1 25%; min-width: 118px; padding: .5rem .85rem; border-left: 1px solid var(--border); }
.stat-cell:first-child { border-left: 0; }
.stat-key { font-size: calc(.7rem * var(--fs)); color: var(--muted); }
.stat-val { font-family: var(--mono); font-variant-numeric: tabular-nums;
            font-size: calc(1rem * var(--fs)); font-weight: 600; letter-spacing: -.02em; color: var(--bs-body-color); }
.stat-sub { font-size: calc(.7rem * var(--fs)); color: var(--muted); }

/* -------------------------------------------------------------- tables -- */

/* Striped rows: white / very light grey. The header row uses the same pale
   strip as every panel header, and a pale brand tint on hover keeps the row
   under the pointer distinct from its stripe.
   The page's --muted (#6b7480) drops just under 4.5:1 on any visible stripe,
   so tables use a slightly darker grey - 5.0:1 or better on every row colour. */
.table-flat {
  --bs-table-bg: transparent; margin-bottom: 0;
  --muted: #5e6773;
  --row-stripe: #f5f7f9;
  --row-hover:  var(--brand-tint);
  --table-head: var(--surface-2);   /* same strip as .panel-head */
}
.table-flat > :not(caption) > * > * { padding: .55rem .8rem; border-color: var(--border-2); }
.table-flat thead th {
  font-size: calc(.7rem * var(--fs)); font-weight: 650; letter-spacing: .03em; text-transform: uppercase;
  color: var(--muted); background: var(--table-head);
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-flat tbody tr:nth-child(even) { background: var(--row-stripe); }
/* When a search hides rows, keep counting only the visible ones so the stripes
   stay alternate. Browsers without "of S" drop this rule and keep the plain one. */
.table-flat tbody tr:nth-child(odd of :not([hidden]))  { background: transparent; }
.table-flat tbody tr:nth-child(even of :not([hidden])) { background: var(--row-stripe); }
/* Hover paints the cells, not the row: the striping selectors above out-rank
   a plain "tr:hover", so a row-level hover never showed on any row. */
.table-flat > tbody > tr > td { transition: background-color .12s ease; }
.table-flat > tbody > tr:hover > td { background-color: var(--row-hover); }
.table-flat > tbody > tr:hover > td:first-child { box-shadow: inset 3px 0 0 var(--brand); }

/* Clip the header and stripes to the card's rounded corners. */
.card-flat > .table-responsive { border-radius: inherit; }
.panel > .table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.batt-glyph { font-size: calc(.95rem * var(--fs)); vertical-align: -2px; margin-right: .2rem; color: var(--ok); }
.batt-glyph.s-warning { color: var(--warn); }
.batt-glyph.s-alert   { color: var(--crit); }
.batt-glyph.s-offline, .batt-glyph.s-blocked { color: var(--off); }

.device-name { font-weight: 620; font-size: calc(.84rem * var(--fs)); color: var(--bs-body-color);
               text-decoration: none; letter-spacing: -.01em; }
.device-name:hover { color: var(--brand); }

.state-badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: calc(.68rem * var(--fs)); font-weight: 650;
  padding: .12rem .42rem; border-radius: 5px; border: 1px solid transparent;
  white-space: nowrap;
}
.sb-ok      { background: var(--ok-tint);   color: var(--ok-ink);   border-color: #cbe8d7; }
.sb-warning { background: var(--warn-tint); color: var(--warn-ink); border-color: #f0dcae; }
.sb-alert   { background: var(--crit-tint); color: var(--crit-ink); border-color: #f3c9c9; }
.sb-offline { background: var(--off-tint);  color: var(--off-ink);  border-color: #dfe3e7; }
.sb-blocked { background: #40464e;          color: #fff;            border-color: #40464e; }

.health-badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: calc(.7rem * var(--fs)); font-weight: 620;
  padding: .1rem .4rem; border-radius: 5px;
  background: var(--off-tint); color: var(--off-ink); white-space: nowrap;
}
.health-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--off); flex: none; }
.h-excellent { background: var(--ok-tint);   color: var(--ok-ink); }
.h-excellent .health-dot { background: var(--ok); }
.h-good      { background: var(--ok-tint);   color: var(--ok-ink); }
.h-good      .health-dot { background: var(--ok); opacity: .6; }
.h-fair      { background: var(--warn-tint); color: var(--warn-ink); }
.h-fair      .health-dot { background: var(--warn); }
.h-poor      { background: #fdeee4;          color: #8a4415; }
.h-poor      .health-dot { background: #e0813f; }
.h-critical  { background: var(--crit-tint); color: var(--crit-ink); }
.h-critical  .health-dot { background: var(--crit); }

.ribbon-new, .bank-new {
  font-size: calc(.62rem * var(--fs)); font-weight: 700; letter-spacing: .06em;
  color: var(--brand-ink); background: var(--brand-tint);
  border-radius: 4px; padding: .05rem .32rem;
}

/* --------------------------------------------------------------- forms -- */

.form-control, .form-select {
  border-color: var(--border); font-size: calc(.875rem * var(--fs)); border-radius: var(--radius-sm);
}
.form-control:focus, .form-select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 111, 208, .14);
}
.form-label { font-size: calc(.78rem * var(--fs)); font-weight: 600; color: var(--ink-2); margin-bottom: .25rem; }
.form-text  { font-size: calc(.74rem * var(--fs)); color: var(--muted); }
.input-group-text {
  background: var(--surface-2); border-color: var(--border); color: var(--ink-2);
  font-size: calc(.8rem * var(--fs)); font-family: var(--mono);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }

/* ------------------------------------------------------------- buttons -- */

.btn { font-size: calc(.82rem * var(--fs)); border-radius: var(--radius-sm); font-weight: 550; }

.btn-primary {
  --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand);
  --bs-btn-hover-bg: #2760b8; --bs-btn-hover-border-color: #2760b8;
  --bs-btn-active-bg: #22539e;
  font-weight: 600;
}
.btn-outline-secondary {
  --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--border);
  --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--bs-body-color);
  --bs-btn-hover-border-color: #d5dade;
  --bs-btn-active-bg: var(--surface-2); --bs-btn-active-color: var(--bs-body-color);
  --bs-btn-active-border-color: #d5dade;
  font-weight: 550;
}

.range-pills .btn {
  --bs-btn-color: var(--ink-2); --bs-btn-border-color: var(--border);
  --bs-btn-bg: var(--surface);
  --bs-btn-hover-bg: var(--surface-2); --bs-btn-hover-color: var(--bs-body-color);
  --bs-btn-hover-border-color: #d5dade;
  --bs-btn-active-bg: var(--brand); --bs-btn-active-color: #fff;
  --bs-btn-active-border-color: var(--brand);
  font-size: calc(.76rem * var(--fs)); font-weight: 600; font-family: var(--mono);
}

/* ---------------------------------------------------------------- tabs -- */

/* Bootstrap's default tabs, fed the panel's own colours through Bootstrap's
   variables: the active tab is a white folder tab joined to a white panel. */
.nav-tabs {
  --bs-nav-tabs-border-color: var(--border);
  --bs-nav-tabs-border-radius: var(--radius-sm);
  --bs-nav-tabs-link-hover-border-color: var(--border-2) var(--border-2) var(--border);
  --bs-nav-tabs-link-active-color: var(--bs-body-color);
  --bs-nav-tabs-link-active-bg: var(--surface);
  --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--surface);
  --bs-nav-link-color: var(--brand);
  --bs-nav-link-hover-color: var(--brand-ink);
  --bs-nav-link-padding-x: 1rem;
  --bs-nav-link-padding-y: .55rem;
  --bs-nav-link-font-weight: 550;
}
.nav-tabs .nav-link { font-size: calc(.86rem * var(--fs)); }
.nav-tabs .nav-link.active { font-weight: 650; }
.nav-tabs .nav-link:not(.active):hover { background: var(--surface-2); }

/* The panel under the tabs: no top border, the tab strip draws that line. */
.settings-tab-body {
  background: var(--surface);
  border: 1px solid var(--border); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.settings-tab-body .card-flat { box-shadow: none; }

/* -------------------------------------------------------------- alerts -- */

.alert { border-radius: var(--radius); border-width: 1px; font-size: calc(.82rem * var(--fs)); }
.alert-primary { background: var(--brand-tint); border-color: #cfe0f7; color: var(--brand-ink); }
.alert-success { background: var(--ok-tint);    border-color: #cbe8d7; color: var(--ok-ink); }
.alert-danger  { background: var(--crit-tint);  border-color: #f3c9c9; color: var(--crit-ink); }
.alert-warning { background: var(--warn-tint);  border-color: #f0dcae; color: var(--warn-ink); }

.badge.text-bg-danger  { background: var(--crit) !important; }
.badge.text-bg-warning { background: var(--warn) !important; color: #fff !important; }
.badge.text-bg-success { background: var(--ok) !important; }

/* ---------------------------------------------------------------- misc -- */

.subtle   { color: var(--muted); font-size: calc(.76rem * var(--fs)); }

.section-head {
  display: flex; align-items: center; gap: .6rem;
  margin: .2rem 0 .55rem;
}
.section-head .panel-title { white-space: nowrap; }
.section-head .rule { flex: 1 1 auto; height: 1px; background: var(--border); }
.hairline { border-color: var(--border) !important; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state .bi {
  font-size: calc(1.6rem * var(--fs)); display: block; margin: 0 auto .7rem;
  width: 52px; height: 52px; line-height: 52px; border-radius: 12px;
  background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
}

code.endpoint {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: .1rem .35rem;
  color: var(--ink-2); font-family: var(--mono); font-size: calc(.74rem * var(--fs));
}

/* --------------------------------------------------------------- login -- */

/* Split screen: the navy brand panel from the nav rail on the left, the form
   on white on the right. Below lg the brand panel shrinks to a banner. */
.login-page { background: var(--surface); }
.login-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }

.login-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; gap: 2rem;
  padding: 2.2rem 2.8rem;
  color: var(--side-ink);
  background:
    radial-gradient(520px 380px at 12% 8%,  rgba(79, 70, 229, .45), transparent 70%),
    radial-gradient(480px 360px at 95% 92%, rgba(14, 165, 233, .30), transparent 70%),
    var(--side-bg);
}
/* faint dot grid */
.login-brand::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(rgba(255, 255, 255, .08) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 85%);
}
.login-brand > * { position: relative; }

.login-brand-top { display: flex; align-items: center; gap: .65rem; }
.login-logo {
  width: 40px; height: 40px; border-radius: 11px; display: inline-grid; place-items: center;
  background: linear-gradient(135deg, #4d8ef7, #2f5fd8); color: #fff; font-size: 1.2rem;
  box-shadow: 0 6px 18px rgba(47, 95, 216, .45);
}
.login-logo-name { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; color: #fff; }

.login-brand-body { max-width: 460px; }
.login-headline {
  font-size: clamp(1.7rem, 2.6vw, 2.35rem); font-weight: 750; line-height: 1.15;
  letter-spacing: -.03em; color: #fff; margin: 0 0 1.6rem;
}
.login-headline span {
  background: linear-gradient(90deg, #7dd3fc, #a5b4fc);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.login-features { list-style: none; padding: 0; margin: 0; display: grid; gap: .7rem; }
.login-features li { display: flex; align-items: center; gap: .75rem; font-size: .92rem; color: #e3e8f7; }
.lf-ico {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  display: inline-grid; place-items: center; font-size: .95rem;
  border: 1px solid rgba(255, 255, 255, .12);
}
.lf-indigo { background: rgba(129, 140, 248, .18); color: #a5b4fc; }
.lf-teal   { background: rgba(45, 212, 191, .16);  color: #5eead4; }
.lf-amber  { background: rgba(251, 191, 36, .16);  color: #fcd34d; }
.lf-violet { background: rgba(192, 132, 252, .16); color: #d8b4fe; }

.login-art { width: 100%; max-width: 460px; height: auto; display: block; }
.login-art-line { stroke-dasharray: 420; stroke-dashoffset: 420; animation: loginDraw 2.2s .3s ease-out forwards; }
@keyframes loginDraw { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .login-art-line { animation: none; stroke-dashoffset: 0; } }

/* form side */
.login-main {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1.5rem 1rem;
  background:
    radial-gradient(600px 420px at 85% 10%, rgba(47, 111, 208, .10), transparent 70%),
    radial-gradient(520px 380px at 10% 95%, rgba(79, 70, 229, .08), transparent 70%),
    #f2f5fa;
}

/* The form sits on a raised white card with a thin brand bar across the top. */
.login-form-wrap {
  position: relative; width: 100%; max-width: 420px; margin: auto 0;
  background: var(--surface);
  border: 1px solid #e2e8f0; border-radius: 18px;
  padding: 2.3rem 2.1rem 0;
  box-shadow: 0 24px 60px rgba(30, 42, 90, .12), 0 2px 6px rgba(30, 42, 90, .05);
  overflow: hidden;
}
.login-form-wrap::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px;
  background: linear-gradient(90deg, #4f46e5, #2f6fd0 50%, #0ea5e9);
}

.login-head { text-align: center; margin-bottom: 1.7rem; }
.login-mark {
  display: inline-grid; place-items: center;
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, #4d8ef7, #2f5fd8); color: #fff;
  font-size: 1.55rem; margin-bottom: 1rem;
  box-shadow: 0 10px 24px rgba(47, 95, 216, .32), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.login-title { font-size: 1.6rem; font-weight: 720; letter-spacing: -.03em; line-height: 1.2; margin: 0; color: var(--bs-body-color); }
.login-sub { font-size: .92rem; color: var(--muted); margin-top: .35rem; }

.login-main .form-label { font-size: .84rem; font-weight: 600; color: var(--ink-2); margin-bottom: .35rem; }
.login-field { position: relative; margin-bottom: 1.05rem; }
.login-lead {
  position: absolute; left: .9rem; top: 50%; transform: translateY(-50%);
  color: #8a939e; font-size: .95rem; pointer-events: none; transition: color .14s ease;
}
.login-field .form-control {
  height: 48px; padding-left: 2.55rem; padding-right: .9rem; font-size: .95rem;
  background: #f8fafc; border: 1px solid #dde3ea; border-radius: 10px;
  transition: border-color .14s ease, box-shadow .14s ease, background-color .14s ease;
}
.login-field .form-control::placeholder { color: #a3abb4; }
.login-field .form-control:hover { border-color: #c5ccd4; }
.login-field .form-control:focus { background: #fff; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(47, 111, 208, .14); }
.login-field:focus-within .login-lead { color: var(--brand); }
#password { padding-right: 2.9rem; }

.login-eye {
  position: absolute; right: .4rem; top: 50%; transform: translateY(-50%);
  border: 0; background: transparent; color: #8a939e;
  font-size: 1rem; padding: .4rem .55rem; border-radius: 7px; line-height: 1; cursor: pointer;
}
.login-eye:hover { color: var(--brand); background: var(--surface-2); }
.login-eye:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* Chrome paints autofilled inputs a washed-out lilac; the inset shadow is the
   only way to override it. */
.login-field .form-control:-webkit-autofill,
.login-field .form-control:-webkit-autofill:hover,
.login-field .form-control:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  -webkit-text-fill-color: var(--bs-body-color);
  caret-color: var(--bs-body-color);
}

.login-submit {
  width: 100%; height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 0; border-radius: 10px;
  background: linear-gradient(135deg, #3b7be0, #2f5fd8); color: #fff;
  font-weight: 650; font-size: .98rem;
  margin-top: .4rem; cursor: pointer;
  box-shadow: 0 8px 20px rgba(47, 95, 216, .28);
  transition: transform .12s ease, box-shadow .14s ease, filter .14s ease;
}
.login-submit .bi { transition: transform .14s ease; }
.login-submit:hover  { filter: brightness(1.06); box-shadow: 0 10px 24px rgba(47, 95, 216, .36); }
.login-submit:hover .bi { transform: translateX(3px); }
.login-submit:active { transform: translateY(1px); box-shadow: 0 4px 12px rgba(47, 95, 216, .28); }
.login-submit:focus-visible { outline: 3px solid rgba(47, 111, 208, .35); outline-offset: 2px; }

.login-secure {
  margin: 1.6rem -2.1rem 0; padding: .85rem 1.2rem;
  background: var(--surface-2); border-top: 1px solid #edf0f4;
  font-size: .8rem; line-height: 1.5; color: var(--muted); text-align: center;
}
.login-secure .bi { color: var(--ok); margin-right: .35rem; }

.login-error {
  display: flex; align-items: flex-start; gap: .5rem;
  background: var(--crit-tint); border: 1px solid #f3c9c9;
  color: var(--crit-ink); border-radius: 10px;
  padding: .65rem .8rem; margin-bottom: 1.1rem;
  font-size: .88rem; line-height: 1.4;
}
.login-error .bi { flex: none; margin-top: .1rem; }

.login-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .2rem .45rem;
  margin-top: 2rem; font-size: .78rem; color: var(--ink-2); text-align: center;
}
.login-foot a { color: var(--brand-ink); font-weight: 650; text-decoration: none; white-space: nowrap; }
.login-foot a:hover { text-decoration: underline; }
.login-foot .bi { font-size: .72rem; margin-right: .25rem; }
.login-foot-sep { opacity: .5; }

/* Tablet and phone: brand panel becomes a compact banner above the form. */
@media (max-width: 991.98px) {
  .login-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .login-brand { padding: 1.1rem 1.25rem; gap: 0; }
  .login-brand-body, .login-art { display: none; }
  .login-brand-top { justify-content: center; }
  .login-main { padding: 1.5rem 1rem 1rem; }
}
@media (max-width: 575.98px) {
  .login-form-wrap { padding: 1.8rem 1.25rem 0; border-radius: 14px; }
  .login-secure { margin-left: -1.25rem; margin-right: -1.25rem; }
  .login-title { font-size: 1.4rem; }
}

@media (max-width: 575.98px) {
  .reading-value { font-size: calc(1.2rem * var(--fs)); }
  .kpi-value     { font-size: calc(1.3rem * var(--fs)); }
}
