/* SmartOps IoT — shared design system.
 *
 * Loaded before each page's inline <style>, which keeps only page-specific rules.
 * Every page previously duplicated its own :root token block; the tokens live here
 * now so light/dark and spacing stay consistent across the dashboard.
 */

:root {
  color-scheme: light dark;

  /* surfaces */
  --bg: #f5f8fd;
  --bg-tint-1: rgba(2, 132, 199, 0.10);
  --bg-tint-2: rgba(16, 185, 129, 0.07);
  --card: #ffffff;
  --card-2: #fbfdff;
  --bg-elevated: #ffffff;
  --field: #ffffff;

  /* lines + text */
  --border: #dde7f4;
  --border-strong: #c5d6ec;
  --text: #0f172a;
  --muted: #566a88;

  /* brand */
  --accent: #0284c7;
  --accent-2: #06b6d4;
  --accent-hover: #0369a1;

  /* status */
  --ok: #047857;
  --ok-bg: rgba(5, 150, 105, 0.10);
  --warn: #b45309;
  --warn-bg: rgba(217, 119, 6, 0.12);
  --danger: #b91c1c;
  --danger-bg: rgba(220, 38, 38, 0.10);

  --shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 12px 28px -14px rgba(15, 23, 42, 0.2);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070c16;
    --bg-tint-1: rgba(2, 132, 199, 0.16);
    --bg-tint-2: rgba(16, 185, 129, 0.09);
    --card: #0e1626;
    --card-2: #111c2f;
    --bg-elevated: #0e1626;
    --field: #0a1220;

    --border: #1e2b42;
    --border-strong: #2c3d5a;
    --text: #e7eefb;
    --muted: #94a5c2;

    --accent: #38bdf8;
    --accent-2: #22d3ee;
    --accent-hover: #7dd3fc;

    --ok: #34d399;
    --ok-bg: rgba(52, 211, 153, 0.12);
    --warn: #fbbf24;
    --warn-bg: rgba(251, 191, 36, 0.13);
    --danger: #f87171;
    --danger-bg: rgba(248, 113, 113, 0.12);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 16px 34px -16px rgba(0, 0, 0, 0.7);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1100px 560px at 8% -10%, var(--bg-tint-1), transparent 60%),
    radial-gradient(900px 480px at 96% 0%, var(--bg-tint-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.55;
  min-height: 100dvh;
}

/* ---------------------------------------------------------------- layout -- */

.container,
.wrap,
.mainShell {
  width: min(100% - 2rem, 1280px);
  margin-inline: auto;
  padding-block: clamp(1rem, 3vw, 2rem);
}

.grid {
  display: grid;
  gap: clamp(0.75rem, 1.6vw, 1.1rem);
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
}

.row {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(0.5rem, 1.4vw, 0.9rem);
  align-items: center;
}

.sections { display: grid; gap: clamp(0.85rem, 1.8vw, 1.15rem); }

/* A bare `1fr` track has min-width:auto and refuses to shrink below its
   content, which is what pushed the wide charts past the viewport edge.
   minmax(0, ...) lets the track shrink so inner scroll containers work. */
.sections > *,
.grid > * { min-width: 0; }

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

.card {
  min-width: 0;
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: clamp(0.9rem, 2vw, 1.35rem);
  box-shadow: var(--shadow);
}

.metric {
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.15rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.muted, .small { color: var(--muted); }
.small { font-size: 0.82rem; }

h1 { font-size: clamp(1.45rem, 1.05rem + 2vw, 2.15rem); letter-spacing: -0.022em; line-height: 1.15; }
h2 { font-size: clamp(1.1rem, 0.95rem + 0.7vw, 1.4rem); letter-spacing: -0.015em; }
h3 { font-size: 1rem; }

/* ---------------------------------------------------------------- brand --- */

.brand { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.brand-logo { inline-size: 48px; block-size: 48px; border-radius: 12px; flex: 0 0 auto; }
.brand-text { min-width: 0; }

/* --------------------------------------------------------------- controls -- */

input, select, textarea, button, .btn-primary, .nav-link {
  font: inherit;
  font-size: 0.92rem;
  border-radius: var(--radius-sm);
}

input, select, textarea {
  inline-size: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

:is(input, select, textarea, button, a):focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 30%, transparent);
}

button, .btn-primary {
  cursor: pointer;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border: none;
  color: #fff;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  box-shadow: 0 6px 16px -7px color-mix(in oklab, var(--accent) 75%, transparent);
  transition: transform 0.15s ease, filter 0.15s ease;
}
button:hover, .btn-primary:hover { transform: translateY(-1px); filter: saturate(1.08); }
button:active, .btn-primary:active { transform: translateY(0); }
button[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  text-decoration: none;
  font-weight: 500;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border-strong);
  transition: border-color 0.15s ease, color 0.15s ease;
}
.nav-link:hover { border-color: var(--accent); color: var(--accent); }

/* --------------------------------------------------------------- status --- */

.badge, .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--field);
  color: var(--muted);
  white-space: nowrap;
}
.badge::before, .pill::before {
  content: "";
  inline-size: 0.45rem;
  block-size: 0.45rem;
  border-radius: 50%;
  background: currentColor;
}

.badge.high, .pill.high {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in oklab, var(--danger) 38%, transparent);
}
.badge.medium, .pill.medium {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in oklab, var(--warn) 38%, transparent);
}
.badge.online, .pill.online, .badge.low, .pill.low {
  color: var(--ok);
  background: var(--ok-bg);
  border-color: color-mix(in oklab, var(--ok) 38%, transparent);
}
.badge.offline, .pill.offline {
  color: var(--muted);
  background: var(--field);
}

/* --------------------------------------------------------------- charts --- */

.chartBox, .chartInner, .trendWrap {
  position: relative;
  inline-size: 100%;
  min-width: 0;
}
.chartStack { display: grid; gap: clamp(0.85rem, 1.8vw, 1.15rem); }

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

table { inline-size: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 0.6rem 0.7rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
td { font-variant-numeric: tabular-nums; }
tr:last-child td { border-bottom: none; }

/* Wide content scrolls inside its own box; the page body never scrolls sideways. */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.table-scroll table { min-width: 34rem; }

/* ---------------------------------------------------------------- footer -- */

.site-footer {
  margin-top: clamp(1.5rem, 3.5vw, 2.5rem);
  border-top: 1px solid var(--border);
  padding-top: 1.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.footer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 1.25rem;
}
.site-footer h2 {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text);
  margin: 0 0 0.5rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.35rem; }
.site-footer a { color: var(--accent); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.footer-note { margin-top: 1.25rem; padding-top: 0.9rem; border-top: 1px solid var(--border); }

/* --------------------------------------------------------------- utility -- */

.hidden { display: none !important; }
.visually-hidden {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

img, svg, canvas { max-width: 100%; }

@media (max-width: 40rem) {
  .row { align-items: stretch; }
  .row > button, .row > .btn-primary { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
