/* ==========================================================================
   SmartCast — Shared design system
   Apple-inspired, clinical, minimal. Used by index.html and dashboard.html
   ========================================================================== */

:root {
  --sc-bg: #fbfbfd;
  --sc-bg-alt: #f5f5f7;
  --sc-surface: #ffffff;
  --sc-text: #1d1d1f;
  --sc-text-secondary: #6e6e73;
  --sc-text-tertiary: #86868b;
  --sc-border: #d2d2d7;
  --sc-accent: #0071e3;
  --sc-accent-hover: #0077ed;
  --sc-accent-dark: #0058b0;
  --sc-success: #1ea672;
  --sc-warning: #d9822b;
  --sc-danger: #d93025;
  --sc-dark: #1d1d1f;
  --sc-dark-surface: #101012;
  --sc-radius-s: 10px;
  --sc-radius-m: 18px;
  --sc-radius-l: 28px;
  --sc-shadow-s: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
  --sc-shadow-m: 0 4px 16px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --sc-shadow-l: 0 20px 60px rgba(0,0,0,0.12);
  --sc-font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sc-maxw: 1180px;
  --sc-nav-h: 64px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sc-font);
  background: var(--sc-bg);
  color: var(--sc-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img { max-width: 100%; display: block; }

a { color: inherit; text-decoration: none; }

.container {
  max-width: var(--sc-maxw);
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- Language toggle ---------- */
[data-i18n], [data-i18n-html] { transition: opacity .15s ease; }
html[lang="en"] [data-lang="de"],
html[lang="de"] [data-lang="en"] { display: none !important; }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--sc-bg-alt);
  border-radius: 100px;
  padding: 3px;
  font-size: 13px;
  font-weight: 600;
}
.lang-switch button {
  border: none;
  background: transparent;
  color: var(--sc-text-secondary);
  padding: 5px 12px;
  border-radius: 100px;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}
.lang-switch button.active {
  background: var(--sc-surface);
  color: var(--sc-text);
  box-shadow: var(--sc-shadow-s);
}

/* ---------- Nav ---------- */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--sc-nav-h);
  display: flex;
  align-items: center;
  background: rgba(251,251,253,0.8);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
}
.nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: -0.01em;
}
.nav-brand img { height: 22px; width: auto; }
.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 14px;
  color: var(--sc-text-secondary);
  font-weight: 500;
}
.nav-links a:hover { color: var(--sc-text); }
.nav-actions { display: flex; align-items: center; gap: 14px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 12px 24px;
  border-radius: 100px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--sc-accent); color: #fff; }
.btn-primary:hover { background: var(--sc-accent-hover); }
.btn-secondary { background: var(--sc-text); color: #fff; }
.btn-secondary:hover { background: #000; }
.btn-ghost { background: transparent; color: var(--sc-text); border-color: var(--sc-border); }
.btn-ghost:hover { border-color: var(--sc-text); }
.btn-small { padding: 8px 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Hero ---------- */
.hero {
  padding: 120px 0 90px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(0,113,227,0.08), transparent 60%),
    var(--sc-bg);
}
.eyebrow {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sc-accent);
  margin-bottom: 18px;
}
.hero h1 {
  font-size: clamp(40px, 6vw, 76px);
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 22px;
}
.hero p.lead {
  font-size: clamp(17px, 2vw, 22px);
  line-height: 1.5;
  color: var(--sc-text-secondary);
  max-width: 640px;
  margin: 0 auto 36px;
}
.hero-actions {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-visual {
  margin-top: 70px;
  border-radius: var(--sc-radius-l);
  overflow: hidden;
  background: linear-gradient(180deg, #0b0f14 0%, #1a2029 100%);
  box-shadow: var(--sc-shadow-l);
  position: relative;
  padding: 56px 40px;
}
.hero-visual .glow {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 20%, rgba(0,113,227,0.35), transparent 55%);
  pointer-events: none;
}
.hero-visual-photo { padding: 0; line-height: 0; }
.hero-visual-photo img { position: relative; display: block; width: 100%; height: auto; }

/* ---------- Sections ---------- */
section { padding: 100px 0; }
.section-alt { background: var(--sc-bg-alt); }
.section-head { text-align: center; max-width: 680px; margin: 0 auto 64px; }
.section-head h2 {
  font-size: clamp(30px, 4vw, 44px);
  letter-spacing: -0.02em;
  font-weight: 700;
  margin: 0 0 16px;
}
.section-head p {
  font-size: 18px;
  color: var(--sc-text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* ---------- Feature grid ---------- */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
  background: var(--sc-surface);
  border-radius: var(--sc-radius-m);
  padding: 36px 32px;
  box-shadow: var(--sc-shadow-s);
  border: 1px solid rgba(0,0,0,0.04);
}
.card .icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(0,113,227,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  color: var(--sc-accent);
}
.card h3 { font-size: 19px; margin: 0 0 10px; letter-spacing: -0.01em; }
.card p { margin: 0; color: var(--sc-text-secondary); font-size: 15px; line-height: 1.55; }

/* ---------- Product showcase ---------- */
.product-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
  margin-bottom: 90px;
}
.product-row:last-child { margin-bottom: 0; }
.product-row.reverse .product-copy { order: 2; }
.product-row.reverse .product-media { order: 1; }
.product-media {
  aspect-ratio: 4/3;
  border-radius: var(--sc-radius-l);
  background: linear-gradient(145deg, #eef1f5, #dde3ea);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.product-media .hex {
  width: 45%;
}
.product-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--sc-accent);
  background: rgba(0,113,227,0.1);
  padding: 6px 12px;
  border-radius: 100px;
  margin-bottom: 16px;
}
.product-copy h3 { font-size: 30px; letter-spacing: -0.02em; margin: 0 0 14px; }
.product-copy p { color: var(--sc-text-secondary); font-size: 16px; line-height: 1.6; margin: 0 0 18px; }
.product-copy ul { margin: 0 0 24px; padding: 0; list-style: none; }
.product-copy li {
  display: flex;
  gap: 10px;
  font-size: 15px;
  color: var(--sc-text);
  padding: 7px 0;
  border-top: 1px solid var(--sc-border);
}
.product-copy li:first-child { border-top: none; }
.product-copy li svg { flex-shrink: 0; color: var(--sc-success); margin-top: 2px; }
.product-more-link {
  display: inline-block; font-size: 14px; font-weight: 600; color: var(--sc-accent);
  text-decoration: none; transition: opacity .15s ease;
}
.product-more-link:hover { opacity: 0.7; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 32px; text-align: center; }
.stat-num { font-size: 44px; font-weight: 700; letter-spacing: -0.02em; color: var(--sc-text); }
.stat-label { font-size: 14px; color: var(--sc-text-secondary); margin-top: 6px; }

/* ---------- Team ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); gap: 24px; }
.team-card { text-align: center; }
.team-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: linear-gradient(135deg, var(--sc-accent), #00c6ff);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 26px; margin: 0 auto 16px;
}
.team-card h4 { margin: 0 0 4px; font-size: 16px; }
.team-card .role { color: var(--sc-accent); font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.team-card p { color: var(--sc-text-secondary); font-size: 14px; line-height: 1.5; margin: 0; }

/* ---------- CTA band ---------- */
.cta-band {
  background: var(--sc-dark);
  color: #fff;
  border-radius: var(--sc-radius-l);
  padding: 70px 40px;
  text-align: center;
  margin: 0 24px;
}
.cta-band h2 { font-size: clamp(28px,4vw,42px); margin: 0 0 16px; letter-spacing: -0.02em; }
.cta-band p { color: rgba(255,255,255,0.7); font-size: 17px; margin: 0 0 32px; }

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--sc-border);
  padding: 48px 0;
  color: var(--sc-text-tertiary);
  font-size: 12px;
}
footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}
footer nav { display: flex; gap: 20px; }
footer nav a:hover { color: var(--sc-text); }

/* ==========================================================================
   Auth (login) card — used on index.html login overlay
   ========================================================================== */
.auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(29,29,31,0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.auth-overlay.open { display: flex; }
.auth-card {
  background: var(--sc-surface);
  border-radius: var(--sc-radius-l);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--sc-shadow-l);
  position: relative;
}
.auth-card .close-btn {
  position: absolute; top: 18px; right: 18px;
  width: 30px; height: 30px; border-radius: 50%;
  border: none; background: var(--sc-bg-alt);
  cursor: pointer; font-size: 16px; color: var(--sc-text-secondary);
}
.auth-card h2 { text-align: center; font-size: 22px; margin: 0 0 6px; }
.auth-card .sub { text-align: center; color: var(--sc-text-secondary); font-size: 14px; margin: 0 0 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--sc-text); }
.field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--sc-radius-s);
  border: 1px solid var(--sc-border);
  font-family: inherit;
  font-size: 15px;
  background: var(--sc-bg-alt);
  transition: border-color .15s ease, background .15s ease;
}
.field input:focus { outline: none; border-color: var(--sc-accent); background: #fff; }
.auth-error {
  background: rgba(217,48,37,0.08);
  color: var(--sc-danger);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: var(--sc-radius-s);
  margin-bottom: 16px;
  display: none;
}
.auth-error.show { display: block; }
.auth-foot { text-align: center; font-size: 13px; color: var(--sc-text-secondary); margin-top: 18px; }

/* ==========================================================================
   Dashboard
   ========================================================================== */
.dash-shell { display: flex; min-height: 100vh; }
.dash-sidebar {
  width: 280px;
  flex-shrink: 0;
  background: var(--sc-surface);
  border-right: 1px solid var(--sc-border);
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.dash-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 4px; font-weight: 600; }
.dash-brand img { height: 20px; }
.dash-back-link {
  display: inline-block; font-size: 12px; color: var(--sc-text-tertiary);
  padding: 0 8px 22px; transition: color .15s ease;
}
.dash-back-link:hover { color: var(--sc-accent); }
.dash-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--sc-text-tertiary); padding: 0 8px; margin: 18px 0 10px;
}
.device-list { display: flex; flex-direction: column; gap: 6px; list-style: none; margin: 0; padding: 0; }
.device-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--sc-text-secondary);
  border: 1px solid transparent;
}
.device-item:hover { background: var(--sc-bg-alt); }
.device-item.active { background: rgba(0,113,227,0.1); color: var(--sc-accent); font-weight: 600; }
.device-item .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--sc-text-tertiary); flex-shrink: 0; }
.device-item.active .dot { background: var(--sc-accent); }
.device-item .dot.online { background: var(--sc-success); }
.device-item .meta { flex: 1; min-width: 0; }
.device-item .meta .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.device-item .meta .sub { font-size: 11px; color: var(--sc-text-tertiary); font-weight: 400; }
.device-delete-btn {
  flex-shrink: 0; width: 22px; height: 22px; border-radius: 50%; border: none;
  background: transparent; color: var(--sc-text-tertiary); font-size: 16px; line-height: 1;
  cursor: pointer; opacity: 0; transition: opacity .15s ease, background .15s ease, color .15s ease;
}
.device-item:hover .device-delete-btn { opacity: 1; }
.device-delete-btn:hover { background: rgba(217,48,37,0.1); color: var(--sc-danger); }

.dash-sidebar-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--sc-border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--sc-dark); color:#fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.user-chip .name { font-size: 13px; font-weight: 600; }
.user-chip .logout { font-size: 12px; color: var(--sc-accent); cursor: pointer; background:none; border:none; font-family:inherit; padding:0; }

.dash-main { flex: 1; min-width: 0; padding: 32px 40px 60px; }
.dash-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 30px; gap: 16px; flex-wrap: wrap; }
.dash-topbar h1 { font-size: 26px; letter-spacing: -0.02em; margin: 0; }
.dash-topbar .sub { color: var(--sc-text-secondary); font-size: 14px; margin-top: 4px; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; padding: 6px 12px; border-radius: 100px;
  background: rgba(30,166,114,0.1); color: var(--sc-success);
}
.status-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status-pill.offline { background: rgba(217,48,37,0.08); color: var(--sc-danger); }
.status-pill.stale { background: rgba(217,130,43,0.1); color: var(--sc-warning); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card { background: var(--sc-surface); border: 1px solid rgba(0,0,0,0.04); border-radius: var(--sc-radius-m); padding: 20px 22px; box-shadow: var(--sc-shadow-s); }
.kpi-card .label { font-size: 12px; color: var(--sc-text-tertiary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-card .value { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; margin-top: 6px; }
.kpi-card .value .unit { font-size: 15px; font-weight: 500; color: var(--sc-text-secondary); }

.panel { background: var(--sc-surface); border: 1px solid rgba(0,0,0,0.04); border-radius: var(--sc-radius-m); box-shadow: var(--sc-shadow-s); padding: 26px 26px 16px; margin-bottom: 24px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; flex-wrap: wrap; gap: 10px; }
.panel-head h3 { font-size: 16px; margin: 0; }
.chart-wrap { position: relative; height: 320px; margin-top: 10px; }

.chart-controls { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 4px; }
.chart-controls-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.range-switch {
  display: inline-flex; gap: 2px; background: var(--sc-bg-alt); border-radius: 100px; padding: 3px;
}
.range-switch button {
  border: none; background: transparent; color: var(--sc-text-secondary);
  padding: 6px 13px; border-radius: 100px; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600;
}
.range-switch button.active { background: var(--sc-surface); color: var(--sc-text); box-shadow: var(--sc-shadow-s); }
.chart-hint { font-size: 12px; color: var(--sc-text-tertiary); margin-top: 10px; }
.chart-stats {
  display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--sc-border); font-size: 12px; color: var(--sc-text-tertiary);
}
.chart-stats strong { color: var(--sc-text); font-size: 14px; margin-right: 4px; }

.spider-layout { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; margin-top: 10px; }
.spider-chart-wrap { position: relative; width: 320px; height: 320px; flex: 0 0 auto; }
.spider-readout { flex: 1 1 200px; min-width: 180px; }
.spider-readout .label { font-size: 12px; color: var(--sc-text-tertiary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.spider-readout .value { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin-top: 6px; }
.spider-readout .sub { font-size: 13px; color: var(--sc-text-secondary); margin-top: 6px; }

.sensor-mini-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 10px; }
.sensor-mini-card { background: var(--sc-bg-alt); border-radius: var(--sc-radius-s, 10px); padding: 14px 16px; }
.sensor-mini-label { font-size: 12px; color: var(--sc-text-tertiary); font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 8px; }
.sensor-mini-canvas-wrap { position: relative; height: 90px; }
@media (max-width: 720px) {
  .sensor-mini-grid { grid-template-columns: repeat(2, 1fr); }
  .spider-layout { justify-content: center; }
  .spider-chart-wrap { width: 100%; max-width: 320px; }
}

.preview-banner {
  background: linear-gradient(90deg, #d9822b, #e0a03f); color: #fff; text-align: center;
  font-size: 13px; font-weight: 600; padding: 10px 20px;
}

.motor-controls { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }
.motor-controls .btn { min-width: 160px; }

.empty-state { text-align: center; padding: 80px 20px; color: var(--sc-text-secondary); }
.empty-state h3 { color: var(--sc-text); margin-bottom: 8px; }

.dash-loading { display: flex; align-items: center; justify-content: center; height: 100vh; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid var(--sc-border); border-top-color: var(--sc-accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .dash-sidebar { position: fixed; left: -300px; z-index: 200; transition: left .2s ease; box-shadow: var(--sc-shadow-l); }
  .dash-sidebar.open { left: 0; }
  .dash-main { padding: 20px 18px 60px; }
  .product-row, .product-row.reverse { grid-template-columns: 1fr; }
  .product-row.reverse .product-copy, .product-row.reverse .product-media { order: initial; }
}
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
}
