:root {
  --navy: #243445;
  --teal: #4F7A8C;
  --sky: #D4E2EC;
  --beige: #F2EBE4;
  --white: #FFFFFF;
  --steel: #8AA4B3;
  --run: #C9A46C;
  --accent: #C9A46C;

  --green-900: #2F4156;
  --green-700: #567C8D;
  --green-600: #567C8D;
  --green-100: #C8D9E6;
  --green-50: #F5EFEB;
  --amber: #C9A46C;
  --red: #2F4156;
  --slate-900: #2F4156;
  --slate-700: #2F4156;
  --slate-600: #567C8D;
  --slate-500: #567C8D;
  --slate-400: #567C8D;
  --slate-200: #C8D9E6;
  --slate-100: #C8D9E6;
  --slate-50: #F5EFEB;
  --white: #FFFFFF;
  --navy-rgb: 36, 52, 69;
  --teal-rgb: 79, 122, 140;
  --sky-rgb: 212, 226, 236;
  --beige-rgb: 242, 235, 228;
  --accent-rgb: 201, 164, 108;
  --shadow: 0 10px 28px rgba(36, 52, 69, 0.1);
  --shadow-lg: 0 22px 48px rgba(36, 52, 69, 0.16), 0 4px 12px rgba(36, 52, 69, 0.06);
  --shadow-glow: 0 0 0 1px rgba(212, 226, 236, 0.55), 0 18px 40px rgba(36, 52, 69, 0.14);
  --ring-soft: 0 0 0 1px rgba(212, 226, 236, 0.7);
  --radius: 10px;
  --navbar-green: #2F4156;
  --forest-green: #567C8D;
  --lime: #C8D9E6;
  --earth-brown: #2F4156;
  --surface: #FFFFFF;
  --hairline: rgba(212, 226, 236, 0.85);
  --panel-border: rgba(79, 122, 140, 0.22);
  --glow-teal: rgba(79, 122, 140, 0.45);
  --glow-sky: rgba(212, 226, 236, 0.35);
  --glow-accent: rgba(201, 164, 108, 0.4);

  --font-ui: "IBM Plex Sans", "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-display: "Space Grotesk", "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--beige); }

body {
  font-family: var(--font-ui);
  background:
    radial-gradient(ellipse 70% 45% at 8% 0%, rgba(var(--sky-rgb), 0.55), transparent 55%),
    radial-gradient(ellipse 55% 40% at 92% 100%, rgba(var(--teal-rgb), 0.12), transparent 50%),
    var(--beige);
  color: var(--navy);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  isolation: isolate;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- Ambient industrial field ---------- */
.hmi-ambient {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.hmi-ambient-grid { display: none !important; }

.hmi-ambient-glow {
  position: absolute;
  width: 62vw;
  height: 46vh;
  left: -8%;
  top: -12%;
  background: radial-gradient(circle, rgba(var(--teal-rgb), 0.22) 0%, rgba(var(--sky-rgb), 0.1) 42%, transparent 72%);
  animation: hmi-aura-drift 18s ease-in-out infinite alternate;
}

.hmi-ambient-glow-2 {
  position: absolute;
  width: 50vw;
  height: 40vh;
  right: -10%;
  bottom: 8%;
  background: radial-gradient(circle, rgba(var(--navy-rgb), 0.14) 0%, rgba(var(--accent-rgb), 0.08) 46%, transparent 74%);
  animation: hmi-aura-drift 22s ease-in-out infinite alternate-reverse;
}

.hmi-ambient-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(var(--sky-rgb), 0.1) 48%, transparent 52%, transparent 100%);
  background-size: 100% 220%;
  animation: hmi-scan 14s linear infinite;
  opacity: 0.5;
}

@keyframes hmi-aura-drift {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(6%, 8%, 0) scale(1.08); }
}

@keyframes hmi-scan {
  0% { background-position: 0 -40%; }
  100% { background-position: 0 140%; }
}

/* ---------- Blueprint industrial floor ---------- */
.machine-floor {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.42;
  mask-image: radial-gradient(ellipse 92% 78% at 50% 42%, #000 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 92% 78% at 50% 42%, #000 35%, transparent 100%);
}
.machine-svg {
  width: 100%;
  height: 100%;
  display: block;
}
.bp-frame {
  fill: none;
  stroke: #2F4156;
  stroke-width: 1.7;
  opacity: 0.7;
}
.bp-frame-fill {
  fill: #C8D9E6;
  stroke: #2F4156;
  stroke-width: 1.5;
  opacity: 0.75;
}
.bp-fill { fill: #567C8D; opacity: 0.55; }
.bp-fill.soft { fill: #2F4156; opacity: 0.45; }
.bp-label {
  fill: #2F4156;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  opacity: 0.75;
}
.bp-tag {
  fill: #567C8D;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  opacity: 0.7;
}
.bp-mini {
  fill: #567C8D;
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.1em;
  opacity: 0.65;
}
.bp-trace {
  stroke: #567C8D;
  stroke-width: 1.4;
  stroke-dasharray: 5 7;
  opacity: 0.45;
  animation: bp-flow 2.4s linear infinite;
}
.bp-trace-slow { animation-duration: 3.6s; opacity: 0.35; }
.bp-trace-fast { animation-duration: 1.6s; }
@keyframes bp-flow { to { stroke-dashoffset: -48; } }
.bp-node {
  fill: #C8D9E6;
  stroke: #2F4156;
  stroke-width: 1;
  opacity: 0.7;
}
.bp-pulse {
  fill: #567C8D;
  opacity: 0.85;
  filter: drop-shadow(0 0 3px rgba(86, 124, 141, 0.55));
}
.bp-pulse.alt { fill: #2F4156; }
.bp-led {
  fill: #C8D9E6;
  opacity: 0.4;
  animation: bp-led 2.2s ease-in-out infinite;
}
.bp-led.a { animation-delay: 0s; }
.bp-led.b { animation-delay: 0.35s; }
.bp-led.c { animation-delay: 0.7s; }
.bp-led.d { animation-delay: 1.05s; }
@keyframes bp-led {
  0%, 100% { fill: #C8D9E6; opacity: 0.35; }
  45% { fill: #567C8D; opacity: 1; }
}
.bp-gantry {
  animation: bp-gantry 6.5s ease-in-out infinite;
}
@keyframes bp-gantry {
  0%, 100% { transform: translateX(48px); }
  50% { transform: translateX(220px); }
}
.bp-spindle {
  transform-origin: 0px 120px;
  animation: bp-spin 1.1s linear infinite;
}
@keyframes bp-spin { to { transform: rotate(360deg); } }
.bp-press {
  animation: bp-press 2.8s ease-in-out infinite;
}
@keyframes bp-press {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(36px); }
}
.bp-belt {
  stroke: #567C8D;
  stroke-width: 2.5;
  stroke-dasharray: 10 8;
  animation: bp-flow 1.2s linear infinite;
}
.bp-part { animation: bp-carry 8s linear infinite; }
.bp-part.p2 { animation-delay: -2.6s; }
.bp-part.p3 { animation-delay: -5.2s; }
@keyframes bp-carry {
  0% { transform: translate(24px, 10px); opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { transform: translate(470px, 10px); opacity: 0; }
}
.bp-ring {
  fill: none;
  stroke: #567C8D;
  stroke-width: 1.4;
  opacity: 0.55;
  transform-origin: 40px 40px;
  animation: bp-ring 2.8s ease-out infinite;
}
.bp-ring.delay { animation-delay: 1.4s; }
@keyframes bp-ring {
  0% { transform: scale(0.7); opacity: 0.7; }
  100% { transform: scale(1.35); opacity: 0; }
}
.bp-tank {
  fill: none;
  stroke: #567C8D;
  stroke-width: 1.4;
  opacity: 0.65;
}
.bp-level {
  fill: rgba(86, 124, 141, 0.35);
  animation: bp-level 4.5s ease-in-out infinite;
}
@keyframes bp-level {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
.bp-wave {
  fill: none;
  stroke: #2F4156;
  stroke-width: 1.6;
  stroke-dasharray: 6 8;
  animation: bp-flow 2s linear infinite;
  opacity: 0.65;
}
.bp-arm {
  transform-origin: 0px 0px;
  animation: bp-arm 5.5s ease-in-out infinite;
}
@keyframes bp-arm {
  0%, 100% { transform: rotate(-8deg); }
  50% { transform: rotate(18deg); }
}
.bp-rail {
  stroke: #C8D9E6;
  stroke-width: 1.2;
  opacity: 0.7;
}
.bp-scanbar {
  fill: #567C8D;
  opacity: 0.45;
  transform-origin: left center;
  animation: bp-scanbar 3.2s ease-in-out infinite;
}
@keyframes bp-scanbar {
  0%, 100% { transform: scaleX(0.35); opacity: 0.3; }
  50% { transform: scaleX(1); opacity: 0.75; }
}
body.dash-fullscreen .machine-floor,
body.dashboard-view-page .machine-floor { display: none; }
body.html-designer-page .machine-floor { opacity: 0.22; }
.auth-body .machine-floor { opacity: 0.22; }

@media (prefers-reduced-motion: reduce) {
  .machine-floor * { animation: none !important; }
}

/* ---------- Theme motion layers ---------- */
.hmi-ambient-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
  color: var(--teal);
}
body[data-bg-motion="none"] .hmi-ambient { opacity: 0; visibility: hidden; }
body[data-bg-motion="blueprint"] .machine-floor { display: block; }
body[data-bg-motion="blueprint"] .hmi-ambient-glow,
body[data-bg-motion="blueprint"] .hmi-ambient-glow-2,
body[data-bg-motion="blueprint"] .hmi-ambient-scan { display: block; }

body[data-bg-motion="orbit"] .ambient-orbit { display: block; }
body[data-bg-motion="orbit"] .machine-floor { display: none; }
body[data-bg-motion="particles"] .ambient-particles { display: block; }
body[data-bg-motion="particles"] .machine-floor { display: none; }
body[data-bg-motion="circuit"] .ambient-circuit { display: block; }
body[data-bg-motion="circuit"] .machine-floor { display: none; }
body[data-bg-motion="aurora"] .ambient-aurora { display: block; }
body[data-bg-motion="aurora"] .hmi-ambient-glow,
body[data-bg-motion="aurora"] .hmi-ambient-glow-2 { display: block; }
body[data-bg-motion="aurora"] .machine-floor { display: none; }
body[data-bg-motion="scan_field"] .hmi-ambient-scan { display: block; opacity: 0.8; }
body[data-bg-motion="scan_field"] .hmi-ambient-glow { display: block; }
body[data-bg-motion="scan_field"] .machine-floor { display: none; }

.ambient-orbit .ring {
  position: absolute;
  border: 1.5px solid rgba(86, 124, 141, 0.28);
  border-radius: 50%;
  animation: orbit-spin calc(28s * var(--motion-speed, 1)) linear infinite;
}
.ambient-orbit .r1 { width: 420px; height: 420px; left: 8%; top: 18%; }
.ambient-orbit .r2 { width: 280px; height: 280px; right: 12%; top: 28%; animation-direction: reverse; animation-duration: calc(20s * var(--motion-speed, 1)); }
.ambient-orbit .r3 { width: 160px; height: 160px; left: 42%; bottom: 16%; animation-duration: calc(14s * var(--motion-speed, 1)); }
.ambient-orbit .dot {
  position: absolute;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 12px rgba(86,124,141,.45);
  animation: orbit-float calc(10s * var(--motion-speed, 1)) ease-in-out infinite;
}
.ambient-orbit .d1 { left: 22%; top: 36%; }
.ambient-orbit .d2 { right: 24%; bottom: 30%; animation-delay: -3s; }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
@keyframes orbit-float {
  0%, 100% { transform: translateY(0); opacity: 0.55; }
  50% { transform: translateY(-18px); opacity: 1; }
}

.ambient-particles span {
  position: absolute;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--teal);
  opacity: 0.45;
  animation: particle-drift calc(12s * var(--motion-speed, 1)) linear infinite;
}
.ambient-particles span:nth-child(1) { left: 8%; top: 70%; animation-delay: 0s; }
.ambient-particles span:nth-child(2) { left: 18%; top: 55%; animation-delay: -2s; width: 3px; height: 3px; }
.ambient-particles span:nth-child(3) { left: 30%; top: 78%; animation-delay: -4s; }
.ambient-particles span:nth-child(4) { left: 46%; top: 62%; animation-delay: -1s; width: 4px; height: 4px; }
.ambient-particles span:nth-child(5) { left: 58%; top: 80%; animation-delay: -3s; }
.ambient-particles span:nth-child(6) { left: 70%; top: 50%; animation-delay: -5s; }
.ambient-particles span:nth-child(7) { left: 78%; top: 68%; animation-delay: -2.5s; width: 3px; height: 3px; }
.ambient-particles span:nth-child(8) { left: 88%; top: 58%; animation-delay: -6s; }
.ambient-particles span:nth-child(9) { left: 40%; top: 40%; animation-delay: -1.5s; }
.ambient-particles span:nth-child(10) { left: 62%; top: 34%; animation-delay: -4.5s; width: 6px; height: 6px; }
@keyframes particle-drift {
  0% { transform: translateY(40px); opacity: 0; }
  15% { opacity: 0.55; }
  85% { opacity: 0.4; }
  100% { transform: translateY(-70vh); opacity: 0; }
}

.ambient-circuit svg { width: 100%; height: 100%; color: var(--teal); }
.ambient-circuit .ac-trace {
  stroke-dasharray: 6 8;
  animation: bp-flow calc(2.4s * var(--motion-speed, 1)) linear infinite;
}
.ambient-circuit .ac2 { animation-duration: calc(3.2s * var(--motion-speed, 1)); }
.ambient-circuit .ac3 { animation-duration: calc(1.8s * var(--motion-speed, 1)); }
.ambient-circuit .ac-pulse { opacity: 0.8; }

.ambient-aurora .aurora {
  position: absolute;
  width: 48vw; height: 38vh; border-radius: 50%;
  filter: blur(40px);
  animation: aurora-drift calc(18s * var(--motion-speed, 1)) ease-in-out infinite alternate;
}
.ambient-aurora .a1 { left: -8%; top: 10%; background: rgba(86,124,141,0.22); }
.ambient-aurora .a2 { right: -6%; top: 35%; background: rgba(47,65,86,0.16); animation-delay: -4s; }
.ambient-aurora .a3 { left: 30%; bottom: 5%; background: rgba(200,217,230,0.28); animation-delay: -8s; width: 36vw; height: 28vh; }
@keyframes aurora-drift {
  0% { transform: translate3d(0,0,0) scale(1); }
  100% { transform: translate3d(4%,6%,0) scale(1.12); }
}

/* Header motion variants */
.nav-layer-circuit,
.nav-layer-wave,
.nav-layer-particles,
.nav-layer-sheen,
.nav-layer-traces { display: none; }
body[data-header-motion="none"] .navbar-pattern { display: none; }
body[data-header-motion="traces"] .nav-layer-traces { display: block; }
body[data-header-motion="circuit"] .nav-layer-circuit { display: block; }
body[data-header-motion="wave"] .nav-layer-wave { display: block; }
body[data-header-motion="particles"] .nav-layer-particles { display: block; }
body[data-header-motion="scan"] .navbar-scan { opacity: 1; }
body[data-header-motion="pulse_edge"] .navbar::after {
  height: 3px;
  animation-duration: calc(2.4s * var(--motion-speed, 1));
}
body[data-header-motion="sheen"] .nav-layer-sheen { display: block; }
body[data-header-motion="sheen"] .navbar::after {
  height: 2px;
  opacity: 1;
  animation: nav-edge-glow calc(3.2s * var(--motion-speed, 1)) ease-in-out infinite;
}

.nav-layer-sheen {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.nav-sheen-beam {
  position: absolute;
  top: -40%;
  left: -30%;
  width: 42%;
  height: 180%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(var(--sky-rgb), 0.05) 35%,
    rgba(255, 255, 255, 0.22) 50%,
    rgba(var(--teal-rgb), 0.1) 65%,
    transparent 100%
  );
  transform: skewX(-18deg);
  animation: nav-sheen-sweep calc(6.5s * var(--motion-speed, 1)) ease-in-out infinite;
}
.nav-sheen-glow {
  position: absolute;
  inset: auto 8% -18px 8%;
  height: 36px;
  background: radial-gradient(ellipse at center, rgba(var(--accent-rgb), 0.35), transparent 70%);
  filter: blur(6px);
  animation: nav-sheen-breathe calc(3.8s * var(--motion-speed, 1)) ease-in-out infinite;
}
.nav-sheen-dots {
  position: absolute;
  inset: 0;
}
.nav-sheen-dots i {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(var(--sky-rgb), 0.65);
  box-shadow: 0 0 10px rgba(var(--teal-rgb), 0.45);
  animation: nav-sheen-dot calc(4.8s * var(--motion-speed, 1)) ease-in-out infinite;
}
.nav-sheen-dots i:nth-child(1) { left: 14%; top: 58%; }
.nav-sheen-dots i:nth-child(2) { left: 28%; top: 32%; animation-delay: -0.7s; }
.nav-sheen-dots i:nth-child(3) { left: 46%; top: 62%; animation-delay: -1.4s; }
.nav-sheen-dots i:nth-child(4) { left: 62%; top: 28%; animation-delay: -2.1s; }
.nav-sheen-dots i:nth-child(5) { left: 76%; top: 54%; animation-delay: -2.8s; }
.nav-sheen-dots i:nth-child(6) { left: 88%; top: 36%; animation-delay: -3.4s; }
@keyframes nav-sheen-sweep {
  0%, 12% { transform: translateX(-15%) skewX(-18deg); opacity: 0; }
  28% { opacity: 0.9; }
  58% { transform: translateX(240%) skewX(-18deg); opacity: 0.45; }
  72%, 100% { transform: translateX(260%) skewX(-18deg); opacity: 0; }
}
@keyframes nav-sheen-breathe {
  0%, 100% { opacity: 0.25; transform: scaleX(0.85); }
  50% { opacity: 0.85; transform: scaleX(1.05); }
}
@keyframes nav-sheen-dot {
  0%, 100% { opacity: 0.15; transform: scale(0.7); }
  40% { opacity: 1; transform: scale(1.15); }
  70% { opacity: 0.4; transform: scale(0.9); }
}

.nav-wave-path {
  stroke-dasharray: 12 10;
  animation: bp-flow calc(3s * var(--motion-speed, 1)) linear infinite;
}
.nav-wave-path.delay { animation-duration: calc(4.2s * var(--motion-speed, 1)); animation-delay: -1s; }

.nav-layer-particles { position: absolute; inset: 0; }
.nav-layer-particles i {
  position: absolute;
  width: 4px; height: 4px; border-radius: 50%;
  background: rgba(200,217,230,0.55);
  animation: nav-particle calc(6s * var(--motion-speed, 1)) linear infinite;
}
.nav-layer-particles i:nth-child(1) { left: 12%; top: 60%; }
.nav-layer-particles i:nth-child(2) { left: 28%; top: 30%; animation-delay: -1s; }
.nav-layer-particles i:nth-child(3) { left: 44%; top: 55%; animation-delay: -2s; }
.nav-layer-particles i:nth-child(4) { left: 58%; top: 25%; animation-delay: -0.5s; }
.nav-layer-particles i:nth-child(5) { left: 70%; top: 50%; animation-delay: -1.5s; }
.nav-layer-particles i:nth-child(6) { left: 82%; top: 35%; animation-delay: -2.5s; }
.nav-layer-particles i:nth-child(7) { left: 90%; top: 65%; animation-delay: -3s; }
.nav-layer-particles i:nth-child(8) { left: 36%; top: 70%; animation-delay: -3.5s; }
@keyframes nav-particle {
  0% { transform: translateY(8px); opacity: 0; }
  30% { opacity: 0.8; }
  100% { transform: translateY(-28px); opacity: 0; }
}

body[data-motion-speed="slow"] .nav-trace { animation-duration: 4.2s; }
body[data-motion-speed="fast"] .nav-trace { animation-duration: 1.5s; }
body[data-radius="sharp"] .metric-card,
body[data-radius="sharp"] .card,
body[data-radius="sharp"] .btn-action,
body[data-radius="sharp"] .brand-plate { border-radius: 4px !important; }
body[data-radius="round"] .metric-card,
body[data-radius="round"] .card,
body[data-radius="round"] .btn-action,
body[data-radius="round"] .brand-plate { border-radius: 14px !important; }

/* ---------- Layout templates ---------- */
body[data-layout="compact"] .main-container { padding: 1rem 1.1rem 2rem; max-width: 1100px; }
body[data-layout="compact"] .dashboard-header { padding: 1rem 1.15rem; }
body[data-layout="compact"] .dashboard-header h1 { font-size: 1.25rem; }
body[data-layout="compact"] .metrics-grid { gap: 0.75rem; }
body[data-layout="compact"] .metric-card { min-height: 104px; padding: 1.35rem 0.85rem 0.8rem; }

body[data-layout="wide"] .main-container { max-width: 1560px; padding-left: 1.5rem; padding-right: 1.5rem; }
body[data-layout="wide"] .metrics-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.15rem; }
body[data-layout="wide"] .metrics-grid:has(> .metric-card:nth-child(3):last-child) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* Stacked — only shrink the dashboard overview shell, not Settings / tables */
body[data-layout="stacked"] .main-container:has(> .metrics-grid) > .metrics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-width: 720px;
}
body[data-layout="stacked"] .main-container:has(> .metrics-grid) > .quick-actions-card {
  max-width: 720px;
}
body[data-layout="stacked"] .main-container:has(> .metrics-grid) > .dashboard-header {
  max-width: 720px;
}

/*
  Dual Rail — TWO-COLUMN dashboard only when the page has metrics + quick actions.
  Must NOT affect Admin Settings / lists / designers (those also use .main-container + .dashboard-header).
*/
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 1.1rem 1.25rem;
  align-items: start;
}
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .dashboard-header,
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .page-head {
  grid-column: 1 / -1;
}
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .metrics-grid {
  grid-column: 1;
  grid-row: 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.85rem;
  align-self: start;
}
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .quick-actions-card {
  grid-column: 2;
  grid-row: 2;
  margin-top: 0;
  align-self: stretch;
  min-height: 100%;
}
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .quick-actions-card .buttons-row {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.55rem;
}
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .quick-actions-card .btn-action {
  width: 100%;
}
/* Any extra sections under the dual-rail shell stay full width */
body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > :not(.dashboard-header):not(.page-head):not(.metrics-grid):not(.quick-actions-card) {
  grid-column: 1 / -1;
}
@media (max-width: 960px) {
  body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) {
    display: flex;
    flex-direction: column;
  }
  body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  body[data-layout="dual_rail"] .main-container:has(> .metrics-grid):has(> .quick-actions-card) > .quick-actions-card .buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
}

body[data-layout="focus_hero"] .dashboard-header { min-height: 150px; padding: 1.6rem 1.5rem; }
body[data-layout="focus_hero"] .dashboard-header h1 { font-size: 1.85rem; }
body[data-layout="focus_hero"] .metrics-grid { margin-top: 0.35rem; }

/* Hard reset: non-dashboard pages never inherit dual-rail grid auto-placement */
body[data-layout="dual_rail"] .main-container:not(:has(> .metrics-grid)) {
  display: block;
}
body[data-layout="dual_rail"] .theme-studio,
body[data-layout="dual_rail"] .theme-studio ~ * {
  width: 100%;
  max-width: 100%;
}

.navbar,
.flash-container,
.main-container,
.footer,
.auth-navbar {
  position: relative;
  z-index: 1;
}

/* ---------- Navbar ---------- */
.navbar {
  background:
    radial-gradient(ellipse 55% 120% at 12% -30%, rgba(var(--teal-rgb), 0.35), transparent 55%),
    radial-gradient(ellipse 40% 100% at 92% 120%, rgba(var(--accent-rgb), 0.18), transparent 50%),
    linear-gradient(180deg, color-mix(in srgb, var(--grad-a, var(--navy)) 88%, #000) 0%, var(--navy) 100%);
  color: var(--white);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1.4rem;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow:
    0 14px 34px rgba(var(--navy-rgb), 0.28),
    inset 0 -1px 0 rgba(var(--sky-rgb), 0.2);
  flex-wrap: wrap;
  gap: 12px;
  border-bottom: 1px solid rgba(var(--sky-rgb), 0.3);
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
  transform: translate3d(0, -28px, 0);
  animation: nav-bar-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes nav-bar-in {
  0% { opacity: 0; transform: translate3d(0, -28px, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}
.navbar-pattern {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.navbar-bp {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0.55;
}
.nav-trace {
  stroke-dasharray: 5 6;
  animation: nav-trace-flow 2.8s linear infinite;
}
.nav-trace-2 { animation-duration: 3.6s; animation-delay: -0.8s; }
.nav-trace-3 { animation-duration: 2.2s; animation-delay: -1.4s; }
@keyframes nav-trace-flow { to { stroke-dashoffset: -44; } }
.nav-pulse {
  opacity: 0.9;
  filter: drop-shadow(0 0 4px rgba(200, 217, 230, 0.55));
}
.nav-bp-label {
  fill: rgba(200, 217, 230, 0.28);
  font-family: "IBM Plex Mono", "JetBrains Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.28em;
}
.navbar-scan {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    transparent 42%,
    rgba(200, 217, 230, 0.08) 50%,
    transparent 58%,
    transparent 100%
  );
  background-size: 220% 100%;
  animation: nav-scan-sweep 7.5s ease-in-out infinite;
}
@keyframes nav-scan-sweep {
  0% { background-position: 120% 0; }
  100% { background-position: -120% 0; }
}

.navbar::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  z-index: 2;
  background: linear-gradient(90deg, transparent 0%, var(--teal) 18%, var(--sky) 50%, var(--teal) 82%, transparent 100%);
  background-size: 200% 100%;
  opacity: 0.95;
  animation: nav-edge-glow 4.8s linear infinite;
}
@keyframes nav-edge-glow {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.navbar > .brand-wrap,
.navbar > .navbar-right {
  position: relative;
  z-index: 2;
}
@keyframes nav-right-in {
  0% { opacity: 0; transform: translate3d(12px, 0, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .navbar::after,
  .navbar-scan,
  .nav-trace { animation: none !important; }
  .navbar,
  .navbar-right,
  .trikona-plate,
  .ell-plate,
  .shiran-plate,
  .brand-x,
  .dashboard-header,
  .dashboard-header h1,
  .dashboard-header p,
  .metric-card,
  .quick-actions-card,
  .action-group,
  .btn-action {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

.auth-navbar {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  align-items: center;
  padding: 0;
  margin: 0;
  background: transparent;
  box-shadow: none;
  width: auto;
}
.auth-navbar .nav-icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 217, 230, 0.28);
}
.auth-navbar .nav-icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  padding-right: 4px;
}
.brand-copy-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--white);
  line-height: 1.1;
}
.brand-copy-sub {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sky);
  line-height: 1.1;
  white-space: nowrap;
}

.brand-container {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--white);
  padding: 4px 12px;
  border-radius: 6px;
  text-decoration: none;
  border: 1px solid rgba(200, 217, 230, 0.7);
}

.brand-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  background: rgba(var(--navy-rgb), 0.22);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  border: 1px solid rgba(var(--sky-rgb), 0.28);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 6px 14px rgba(0,0,0,0.12);
  transition: box-shadow 0.25s ease, transform 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.brand-plate:hover {
  border-color: rgba(var(--sky-rgb), 0.5);
  box-shadow: 0 0 18px rgba(var(--teal-rgb), 0.32);
  background: rgba(var(--teal-rgb), 0.22);
}
.trikona-plate {
  width: 180px;
  padding: 6px 12px;
  background: transparent;
  border-color: rgba(200, 217, 230, 0.28);
  opacity: 0;
  transform: scale(1.28);
  transform-origin: left center;
  animation: brand-trikona-zoom 1.15s cubic-bezier(0.22, 1, 0.36, 1) 0.35s forwards;
  z-index: 3;
}
.trikona-plate img {
  width: 100%;
  height: 38px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.25));
}
.ell-plate {
  width: 118px;
  padding: 4px 10px;
  background: rgba(15, 22, 30, 0.28);
  border-color: rgba(var(--sky-rgb), 0.28);
  opacity: 0;
  transform: translate3d(-28px, 0, 0);
  animation: brand-from-trikona 0.95s cubic-bezier(0.22, 1, 0.36, 1) 0.95s forwards;
  z-index: 2;
}
.ell-plate img,
.ell-mark img {
  width: 100%;
  height: 36px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.22));
}
.shiran-plate {
  width: 132px;
  padding: 4px 10px;
  background: rgba(15, 22, 30, 0.28);
  border-color: rgba(200, 217, 230, 0.28);
  opacity: 0;
  transform: translate3d(-28px, 0, 0);
  animation: brand-from-ell 0.95s cubic-bezier(0.22, 1, 0.36, 1) 1.2s forwards;
  z-index: 1;
}
.shiran-plate img {
  width: 100%;
  height: 40px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.22));
}
@keyframes brand-trikona-zoom {
  0% { opacity: 0; transform: scale(1.32); }
  40% { opacity: 1; transform: scale(1.08); }
  100% { opacity: 1; transform: scale(1); }
}
@keyframes brand-from-trikona {
  0% { opacity: 0; transform: translate3d(-32px, 0, 0); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes brand-from-ell {
  0% { opacity: 0; transform: translate3d(-32px, 0, 0); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}

.brand-x {
  width: 1px;
  height: 36px;
  background: linear-gradient(var(--sky), var(--teal), var(--sky));
  opacity: 0;
  transform: scaleY(0.55);
  animation: brand-x-in 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards, brand-x-pulse 3.8s ease-in-out 1.8s infinite;
}
.brand-wrap > .brand-x:nth-of-type(1) { animation-delay: 1.05s, 1.9s; }
.brand-wrap > .brand-x:nth-of-type(2) { animation-delay: 1.3s, 2.1s; }
@keyframes brand-x-in {
  to { opacity: 0.7; transform: scaleY(1); }
}
@keyframes brand-x-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 0.9; }
}

.ell-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  background: #0d1218;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid rgba(200, 217, 230, 0.28);
  text-decoration: none;
}

.brand-container:hover { box-shadow: 0 0 0 1px var(--teal), 0 8px 18px rgba(86, 124, 141, 0.18); }

.brand-logo-svg { width: 36px; height: 36px; }

.brand-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.8px;
}

.brand-title .verdant-text { color: var(--navy); }
.brand-title .farms-text { color: var(--teal); }

.brand-tagline {
  font-size: 0.62rem;
  color: var(--teal);
  font-weight: 600;
  margin-top: 3px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hmi-live-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid rgba(200, 217, 230, 0.32);
  background: linear-gradient(180deg, rgba(86, 124, 141, 0.32), rgba(47, 65, 86, 0.35));
  border-radius: 5px;
  color: var(--sky);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(86, 124, 141, 0.22);
}

.hmi-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sky);
  box-shadow: 0 0 0 0 rgba(86, 124, 141, 0.55);
  animation: hmi-live-pulse 2.4s ease-out infinite;
}

@keyframes hmi-live-pulse {
  0% { box-shadow: 0 0 0 0 rgba(200, 217, 230, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(200, 217, 230, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 217, 230, 0); }
}

.nav-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.nav-links a { color: var(--sky); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 10px; border-radius: 6px; transition: background .2s; }
.nav-links a:hover, .nav-links a.active { background: rgba(255,255,255,0.16); }

.navbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translate3d(12px, 0, 0);
  animation: nav-right-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 1.25s forwards;
}
.navbar-right .nav-icon-btn + .nav-icon-btn { margin-left: 0; }

.nav-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(200, 217, 230, 0.28);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
  text-decoration: none;
}
.nav-icon-btn svg { width: 16px; height: 16px; }

.nav-icon-btn:hover {
  background: rgba(86, 124, 141, 0.45);
  box-shadow: 0 0 0 1px rgba(200, 217, 230, 0.25);
}
.nav-icon-btn:active { transform: translateY(1px); }
.nav-icon-btn svg { width: 18px; height: 18px; }

.user-pill {
  background-color: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(200, 217, 230, 0.28);
  padding: 4px 12px;
  border-radius: 6px;
  text-align: right;
}

.user-pill .name { font-size: 0.78rem; font-weight: 700; color: var(--white); line-height: 1.1; }
.user-pill .role {
  font-size: 0.62rem;
  color: var(--sky);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.btn-logout {
  border: 1px solid rgba(200, 217, 230, 0.35);
  background: transparent;
  color: var(--white);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.btn-logout:hover {
  background: rgba(86, 124, 141, 0.4);
  box-shadow: 0 0 12px rgba(86, 124, 141, 0.25);
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(86,124,141,0.35); }
  50% { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(86,124,141,0); }
}

/* ---------- Animated logo ---------- */
.verdant-logo {
  display: flex;
  align-items: center;
  gap: 24px;
  background: var(--white);
  padding: 1.5rem 2.5rem;
  border-radius: 10px;
  box-shadow: 0 15px 35px rgba(47, 65, 86, 0.08);
  overflow: hidden;
  border: 1px solid var(--sky);
}

.verdant-logo .logo-svg { width: 150px; height: 160px; overflow: visible; flex-shrink: 0; }

.plant-sprout { transform-origin: 50px 75px; animation: plant-growth-sway 3.5s ease-in-out infinite alternate; }
@keyframes plant-growth-sway {
  0% { transform: scale(0.94) rotate(-3deg); }
  50% { transform: scale(1.04) rotate(2deg); }
  100% { transform: scale(1) rotate(-1deg); }
}

.circuit-node { animation: node-glow 1.8s ease-in-out infinite alternate; }
.circuit-node-2 { animation-delay: 0.6s; }
.circuit-node-3 { animation-delay: 1.2s; }
@keyframes node-glow {
  0% { r: 3.5px; fill: #567C8D; filter: drop-shadow(0 0 0px transparent); }
  100% { r: 6.5px; fill: #C8D9E6; filter: drop-shadow(0 0 8px #567C8D); }
}

.frame-pulse-left { animation: frame-flash-left 2.5s ease-in-out infinite alternate; }
.frame-pulse-right { animation: frame-flash-right 2.5s ease-in-out infinite alternate; animation-delay: 1.25s; }
@keyframes frame-flash-left { 0% { fill: #567C8D; } 100% { fill: #C8D9E6; } }
@keyframes frame-flash-right { 0% { fill: #C8D9E6; } 100% { fill: #FFFFFF; } }

.verdant-logo .brand-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.8px;
  line-height: 1;
  display: flex;
  gap: 14px;
  position: relative;
}
.text-verdant { color: #2F4156; }
.text-farms {
  color: #567C8D;
  background: linear-gradient(110deg, #567C8D 30%, #C8D9E6 50%, #567C8D 70%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: text-shine 3s linear infinite;
}
@keyframes text-shine {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.verdant-logo .brand-tagline {
  font-family: var(--font-ui);
  font-size: 0.85rem;
  font-weight: 600;
  color: #567C8D;
  margin-top: 8px;
  text-align: right;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.verdant-logo.compact {
  gap: 10px;
  padding: 4px 4px 4px 0;
  border-radius: 6px;
  box-shadow: none;
  background: transparent;
  border: none;
}
.verdant-logo.compact .logo-svg { width: 36px; height: 40px; }
.verdant-logo.compact .brand-title { font-size: 1.05rem; gap: 6px; }
.verdant-logo.compact .brand-tagline { font-size: 0.55rem; margin-top: 2px; text-align: left; color: var(--teal); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  line-height: 1.25;
  font-family: var(--font-ui);
  transition: filter .15s, transform .12s, box-shadow .2s, background .2s, border-color .2s;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, var(--teal) 0%, color-mix(in srgb, var(--navy) 40%, var(--teal)) 100%);
  color: var(--white);
  border-color: var(--teal);
  box-shadow: 0 8px 18px rgba(var(--teal-rgb), 0.28), inset 0 1px 0 rgba(255,255,255,0.22);
}
.btn-primary:hover {
  background: linear-gradient(180deg, var(--navy), color-mix(in srgb, var(--navy) 75%, var(--teal)));
  box-shadow: 0 0 20px rgba(var(--teal-rgb), 0.38);
}
.btn-outline { background: transparent; color: inherit; border: 1px solid rgba(255,255,255,0.5); }
.btn-danger { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-secondary {
  background: linear-gradient(180deg, var(--white), var(--beige));
  color: var(--navy);
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.8), 0 6px 14px rgba(var(--navy-rgb), 0.06);
}
.btn-secondary:hover {
  background: var(--sky);
  box-shadow: 0 0 0 1px var(--teal), 0 8px 16px rgba(var(--navy-rgb), 0.1);
}
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-link { background: none; color: var(--teal); font-weight: 700; text-decoration: none; }

/* ---------- Cards / layout ---------- */
.main-container {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.6rem 1.6rem 1rem 1.6rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.main { flex: 1; padding: 28px; width: 100%; max-width: 1200px; margin: 0 auto; }

.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 12px; }
.page-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: 0.04em;
}

.dashboard-header {
  background:
    radial-gradient(ellipse 65% 90% at 100% 0%, rgba(var(--accent-rgb), 0.22), transparent 50%),
    linear-gradient(125deg, var(--grad-a, var(--navy)) 0%, var(--navy) 52%, var(--grad-b, var(--teal)) 120%);
  color: var(--white);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.45rem 1.55rem 1.5rem;
  border: 1px solid rgba(var(--sky-rgb), 0.28);
  position: relative;
  overflow: hidden;
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(var(--sky-rgb), 0.28),
    inset 0 -1px 0 rgba(var(--navy-rgb), 0.35);
  opacity: 0;
  transform: translate3d(0, 14px, 0);
  animation: mg-panel-in 1s cubic-bezier(0.22, 1, 0.36, 1) 1.4s forwards;
}
.hmi-bezel {
  position: absolute;
  width: 18px;
  height: 18px;
  pointer-events: none;
  z-index: 2;
  opacity: 0.9;
}
.hmi-bezel.tl { top: 10px; left: 10px; border-top: 2px solid rgba(var(--sky-rgb), 0.85); border-left: 2px solid rgba(var(--sky-rgb), 0.85); }
.hmi-bezel.tr { top: 10px; right: 10px; border-top: 2px solid rgba(var(--sky-rgb), 0.85); border-right: 2px solid rgba(var(--sky-rgb), 0.85); }
.hmi-bezel.bl { bottom: 10px; left: 10px; border-bottom: 2px solid rgba(var(--teal-rgb), 0.75); border-left: 2px solid rgba(var(--teal-rgb), 0.75); }
.hmi-bezel.br { bottom: 10px; right: 10px; border-bottom: 2px solid rgba(var(--teal-rgb), 0.75); border-right: 2px solid rgba(var(--teal-rgb), 0.75); }
.hmi-header-scan {
  position: absolute;
  left: 0; right: 0;
  height: 36px;
  background: linear-gradient(180deg, transparent, rgba(var(--sky-rgb), 0.2), transparent);
  animation: hmi-header-scan 5.5s linear infinite;
  pointer-events: none;
}
@keyframes hmi-header-scan {
  0% { top: -28px; opacity: 0; }
  15% { opacity: 1; }
  100% { top: 110%; opacity: 0; }
}
.hmi-wave {
  position: absolute;
  right: 22px;
  top: 18px;
  width: 180px;
  height: 36px;
  opacity: 0.75;
  pointer-events: none;
}
.hmi-wave-line {
  fill: none;
  stroke: rgba(var(--sky-rgb), 0.9);
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-dasharray: 80 180;
  animation: hmi-wave-run 2.8s linear infinite;
}
@keyframes hmi-wave-run { to { stroke-dashoffset: -260; } }
.hmi-command-meta { display: none !important; }
.dashboard-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(115deg, rgba(var(--teal-rgb), 0.32), transparent 48%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 36%);
  animation: hmi-header-shift 16s ease-in-out infinite alternate;
  pointer-events: none;
}
@keyframes hmi-header-shift {
  0% { opacity: 0.7; transform: translateX(0); }
  100% { opacity: 1; transform: translateX(12px); }
}
.dashboard-header h1,
.dashboard-header p { position: relative; z-index: 1; }
.dashboard-header h1 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  letter-spacing: 0.05em;
  text-shadow: 0 2px 18px rgba(var(--navy-rgb), 0.35);
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  animation: mg-copy-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 1.55s forwards;
}
.dashboard-header p {
  font-size: 0.84rem;
  color: rgba(var(--sky-rgb), 0.92);
  margin-top: 8px;
  letter-spacing: 0.02em;
  padding-bottom: 8px;
  max-width: 52ch;
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  animation: mg-copy-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 1.68s forwards;
}
.dashboard-header::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(var(--accent-rgb), 0.75), rgba(var(--sky-rgb), 0.55), transparent);
  opacity: 0.9;
  pointer-events: none;
}
@keyframes dash-rise {
  from { opacity: 0; transform: translate3d(0, 8px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes mg-panel-in {
  0% { opacity: 0; transform: translate3d(0, 16px, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes mg-copy-in {
  0% { opacity: 0; transform: translate3d(0, 8px, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}
@keyframes mg-card-in {
  0% { opacity: 0; transform: translate3d(0, 16px, 0); }
  100% { opacity: 1; transform: translate3d(0, 0, 0); }
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  align-items: stretch;
}
/* Company admin (3 cards) — equal columns, no empty slot */
.metrics-grid:has(> .metric-card:nth-child(3):last-child) {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.metric-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92) 0%, rgba(var(--sky-rgb), 0.35) 48%, rgba(var(--beige-rgb), 0.95) 100%),
    var(--white);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.55rem 1.05rem 0.95rem;
  box-sizing: border-box;
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.85),
    inset 0 -1px 0 rgba(var(--navy-rgb), 0.04);
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  border-left: 4px solid var(--navy);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  position: relative;
  overflow: hidden;
  min-height: 124px;
  height: 100%;
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  animation: mg-card-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.28s ease, border-color 0.28s ease;
}
.metric-card:hover {
  transform: translateY(-4px);
  box-shadow:
    0 26px 48px rgba(var(--navy-rgb), 0.16),
    0 0 0 1px rgba(var(--teal-rgb), 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}
.metrics-grid .metric-card:nth-child(1) { animation-delay: 1.7s; }
.metrics-grid .metric-card:nth-child(2) { animation-delay: 1.82s; }
.metrics-grid .metric-card:nth-child(3) { animation-delay: 1.94s; }
.metrics-grid .metric-card:nth-child(4) { animation-delay: 2.06s; }
.metric-led {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 0 rgba(79, 122, 140, 0.45);
  animation: metric-led 2.2s ease-out infinite;
  z-index: 2;
}
.metrics-grid .metric-card:nth-child(2) .metric-led { animation-delay: 0.35s; }
.metrics-grid .metric-card:nth-child(3) .metric-led { animation-delay: 0.7s; }
.metrics-grid .metric-card:nth-child(4) .metric-led { animation-delay: 1.05s; }
.metrics-grid .metric-card:nth-child(2) .metric-trace { animation-delay: 0.4s; }
.metrics-grid .metric-card:nth-child(3) .metric-trace { animation-delay: 0.8s; }
.metrics-grid .metric-card:nth-child(4) .metric-trace { animation-delay: 1.2s; }
.metric-card.offline .metric-led { background: var(--navy); animation-name: metric-led-off; }
@keyframes metric-led {
  0% { box-shadow: 0 0 0 0 rgba(79, 122, 140, 0.5); }
  70% { box-shadow: 0 0 0 8px rgba(79, 122, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 122, 140, 0); }
}
@keyframes metric-led-off {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}
.metric-id { display: none !important; }
.metric-card::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 28px;
  top: 10px;
  height: 10px;
  background-image: repeating-linear-gradient(90deg, rgba(47, 65, 86, 0.16) 0 1px, transparent 1px 7px);
  opacity: 0.55;
  pointer-events: none;
}
.metric-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -18px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(86, 124, 141, 0.16), transparent 70%);
  animation: hmi-aura-drift 12s ease-in-out infinite alternate;
}
.metric-trace {
  display: block;
  height: 3px;
  width: 100%;
  margin-top: auto;
  padding-top: 12px;
  flex-shrink: 0;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  background-size: 140% 100%;
  background-repeat: no-repeat;
  background-origin: content-box;
  background-clip: content-box;
  animation: metric-trace 3.4s linear infinite;
  opacity: 0.7;
  box-sizing: content-box;
}
@keyframes metric-trace {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.metric-card.total-devices { border-left-color: var(--teal); }
.metric-card.online {
  border-left-color: var(--teal);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.95) 0%, rgba(var(--sky-rgb), 0.45) 55%, rgba(var(--teal-rgb), 0.12) 100%),
    var(--white);
}
.metric-card.online .metric-value { color: var(--teal); }
.metric-card.offline {
  border-left-color: var(--navy);
  background:
    linear-gradient(145deg, var(--beige) 0%, rgba(var(--sky-rgb), 0.4) 100%);
}
.metric-title {
  display: block;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--teal);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 0 0 0.4rem;
  min-height: 2.2em;
  line-height: 1.15;
  font-family: var(--font-mono);
  position: relative;
  z-index: 1;
}
.metric-value {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(1.55rem, 4.2vw, 2.25rem);
  font-weight: 700;
  color: var(--navy);
  line-height: 1;
  min-height: 1em;
  position: relative;
  z-index: 1;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
}

.quick-actions-card {
  background:
    linear-gradient(180deg, rgba(var(--sky-rgb), 0.35), transparent 22%),
    linear-gradient(165deg, var(--white) 0%, var(--beige) 100%);
  border-radius: calc(var(--radius) + 4px);
  padding: 1.35rem 1.4rem 1.45rem;
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  position: relative;
  overflow: hidden;
  opacity: 0;
  transform: translate3d(0, 16px, 0);
  animation: mg-panel-in 1s cubic-bezier(0.22, 1, 0.36, 1) 2.15s forwards;
}
.quick-actions-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: linear-gradient(
    180deg,
    var(--accent),
    var(--teal),
    var(--navy),
    var(--teal),
    var(--accent)
  );
  background-size: 100% 220%;
  opacity: 0.9;
  pointer-events: none;
  animation: qa-edge-flow 4.8s linear infinite;
  z-index: 2;
}
.quick-actions-card::after {
  content: "";
  position: absolute;
  top: -40%;
  left: -35%;
  width: 55%;
  height: 180%;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(var(--sky-rgb), 0.08) 38%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(var(--teal-rgb), 0.1) 62%,
    transparent 100%
  );
  transform: skewX(-18deg);
  animation: qa-sheen 7.5s ease-in-out infinite;
  pointer-events: none;
  z-index: 0;
}
@keyframes qa-sheen {
  0%, 18% { transform: translateX(-20%) skewX(-18deg); opacity: 0; }
  28% { opacity: 0.85; }
  55% { transform: translateX(220%) skewX(-18deg); opacity: 0.55; }
  70%, 100% { transform: translateX(240%) skewX(-18deg); opacity: 0; }
}
@keyframes qa-edge-flow {
  0% { background-position: 0% 0%; }
  100% { background-position: 0% 100%; }
}
@keyframes qa-panel-breathe {
  0%, 100% {
    box-shadow:
      var(--shadow-lg),
      inset 0 1px 0 rgba(255, 255, 255, 0.85),
      0 0 0 0 rgba(var(--teal-rgb), 0);
  }
  50% {
    box-shadow:
      0 22px 46px rgba(var(--navy-rgb), 0.14),
      inset 0 1px 0 rgba(255, 255, 255, 0.9),
      0 0 28px rgba(var(--teal-rgb), 0.12);
  }
}
.quick-actions-card h2 {
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 0;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.hmi-rack-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(var(--sky-rgb), 0.9);
  position: relative;
  z-index: 1;
}
.hmi-rack-head::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 72px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--teal), transparent);
  opacity: 0.9;
  animation: qa-underline 3.6s ease-in-out infinite;
  transform-origin: left center;
}
@keyframes qa-underline {
  0%, 100% { width: 56px; opacity: 0.55; }
  50% { width: 118px; opacity: 1; }
}
.action-group,
.buttons-row {
  position: relative;
  z-index: 1;
}
.quick-actions-card > .action-group {
  opacity: 0;
  transform: translate3d(0, 10px, 0);
  animation: mg-copy-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.quick-actions-card > .action-group:nth-child(4) { animation-delay: 2.28s; }
.quick-actions-card > .action-group:nth-child(5) { animation-delay: 2.4s; }
.quick-actions-card > .action-group:nth-child(6) { animation-delay: 2.52s; }
.quick-actions-card > .buttons-row {
  opacity: 0;
  transform: translate3d(0, 10px, 0);
  animation: mg-copy-in 0.85s cubic-bezier(0.22, 1, 0.36, 1) 2.32s forwards;
}
.quick-actions-card .btn-action {
  opacity: 0;
  transform: translate3d(0, 8px, 0);
  animation: mg-card-in 0.75s cubic-bezier(0.22, 1, 0.36, 1) 2.35s forwards;
}
.quick-actions-card > .buttons-row > .btn-action:nth-child(1),
.quick-actions-card > .action-group:nth-child(4) .btn-action:nth-child(1) { animation-delay: 2.32s; }
.quick-actions-card > .buttons-row > .btn-action:nth-child(2),
.quick-actions-card > .action-group:nth-child(4) .btn-action:nth-child(2) { animation-delay: 2.4s; }
.quick-actions-card > .buttons-row > .btn-action:nth-child(3),
.quick-actions-card > .action-group:nth-child(4) .btn-action:nth-child(3) { animation-delay: 2.48s; }
.quick-actions-card > .buttons-row > .btn-action:nth-child(4),
.quick-actions-card > .action-group:nth-child(4) .btn-action:nth-child(4) { animation-delay: 2.56s; }
.quick-actions-card > .action-group:nth-child(5) .btn-action:nth-child(1) { animation-delay: 2.44s; }
.quick-actions-card > .action-group:nth-child(5) .btn-action:nth-child(2) { animation-delay: 2.52s; }
.quick-actions-card > .action-group:nth-child(5) .btn-action:nth-child(3) { animation-delay: 2.6s; }
.quick-actions-card > .action-group:nth-child(5) .btn-action:nth-child(4) { animation-delay: 2.68s; }
.quick-actions-card > .action-group:nth-child(6) .btn-action:nth-child(1) { animation-delay: 2.56s; }
.quick-actions-card > .action-group:nth-child(6) .btn-action:nth-child(2) { animation-delay: 2.64s; }
.hmi-rack-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  animation: qa-hint-pulse 2.8s ease-in-out infinite;
}
@keyframes qa-hint-pulse {
  0%, 100% { opacity: 0.55; letter-spacing: 0.12em; }
  50% { opacity: 1; letter-spacing: 0.16em; }
}
.action-group + .action-group {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--sky);
}
.action-group-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 8px;
}
.buttons-row { display: flex; flex-wrap: wrap; gap: 0.7rem; }
.btn-action {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  min-height: 44px;
  padding: 11px 16px 11px 28px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 0.76rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.72), transparent 42%),
    linear-gradient(180deg, var(--white), var(--beige));
  color: var(--navy);
  text-decoration: none;
  text-align: center;
  line-height: 1.25;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  letter-spacing: 0.04em;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.85),
    0 8px 18px rgba(var(--navy-rgb), 0.08);
}
.btn-action::before {
  content: "";
  position: absolute;
  left: 11px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 0 0 2px rgba(47, 65, 86, 0.08);
}
.btn-action::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 30%, rgba(200, 217, 230, 0.45), transparent 70%);
  transform: translateX(-120%);
  animation: btn-sweep 4.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes btn-sweep {
  0%, 55% { transform: translateX(-120%); }
  85%, 100% { transform: translateX(120%); }
}
.btn-action.primary {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22), transparent 40%),
    linear-gradient(180deg, var(--teal) 0%, color-mix(in srgb, var(--navy) 35%, var(--teal)) 100%);
  color: var(--white);
  border-color: color-mix(in srgb, var(--teal) 70%, var(--navy));
  box-shadow:
    0 10px 22px rgba(var(--teal-rgb), 0.28),
    inset 0 1px 0 rgba(255,255,255,0.25);
}
.btn-action.primary::before {
  background: var(--accent);
  animation: metric-led 2.4s ease-out infinite;
}
.btn-action.primary:hover {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent 40%),
    linear-gradient(180deg, var(--navy), color-mix(in srgb, var(--navy) 80%, var(--teal)));
  box-shadow: 0 0 22px rgba(var(--teal-rgb), 0.38);
}
.btn-action:hover:not(.primary) {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.65), transparent 40%),
    var(--sky);
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(var(--navy-rgb), 0.12);
}

.graphics-card {
  background: rgba(255, 255, 255, 0.72);
  border-radius: 10px;
  border: 1px solid var(--sky);
  padding: 1rem;
  margin-top: 0.5rem;
}
.svg-banner { width: 100%; height: 180px; }

@keyframes data-flow { 0% { stroke-dashoffset: 40; } 100% { stroke-dashoffset: 0; } }
.animated-data-line { stroke-dasharray: 6, 6; animation: data-flow 1.5s linear infinite; }

.card {
  background:
    linear-gradient(165deg, var(--white) 0%, color-mix(in srgb, var(--beige) 55%, var(--white)) 100%);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 22px;
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy), var(--teal), var(--accent), var(--sky));
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }

.stat { border-left: 4px solid var(--teal); }
.stat .stat-label { font-size: 12px; color: var(--teal); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; }
.stat .stat-value { font-size: 30px; font-weight: 700; color: var(--navy); margin-top: 4px; font-family: var(--font-display); }
.stat.amber { border-left-color: var(--teal); }
.stat.red { border-left-color: var(--navy); }

/* ---------- Industrial modules ---------- */
.hmi-module {
  background: var(--white);
  border: 1px solid var(--sky);
  border-radius: 8px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.hmi-module::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--teal);
}
.hmi-module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--sky);
}
.hmi-module-kicker {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 4px;
}
.hmi-module-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--sky);
  color: var(--teal);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 11px 12px;
  color: var(--navy);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--sky);
  background: var(--beige);
  font-family: var(--font-mono);
}
td { padding: 11px 12px; border-bottom: 1px solid var(--sky); }
tr:hover td { background: var(--beige); }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid transparent;
  transition: box-shadow 0.35s ease, background 0.35s ease, color 0.35s ease;
}
.badge-online,
.badge-success {
  background: var(--teal);
  color: var(--white);
  box-shadow: 0 0 0 0 rgba(86, 124, 141, 0.4);
  animation: hmi-active-glow 2.8s ease-in-out infinite;
}
.badge-offline,
.badge-secondary {
  background: var(--sky);
  color: var(--navy);
}
.badge-error { background: var(--navy); color: var(--white); }
.badge-warning { background: var(--beige); color: var(--navy); border-color: var(--teal); }
.badge-master_admin { background: var(--navy); color: var(--white); }
.badge-company_admin { background: var(--teal); color: var(--white); }
.badge-super_admin { background: var(--navy); color: var(--sky); }
.badge-admin { background: var(--sky); color: var(--navy); }
.badge-user { background: var(--beige); color: var(--navy); border-color: var(--sky); }
.mono { font-family: var(--font-mono); }

@keyframes hmi-active-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(86, 124, 141, 0.28); }
  50% { box-shadow: 0 0 14px 2px rgba(86, 124, 141, 0.32); }
}

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.form-input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--sky); border-radius: 6px;
  font-size: 14px; background: var(--white); color: var(--navy);
  transition: border-color .2s, box-shadow .2s;
  font-family: var(--font-ui);
}
.form-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(86, 124, 141, 0.18);
}
.form-row { display: flex; gap: 12px; }
.form-row > * { flex: 1; }

/* ---------- Device settings ---------- */
.settings-summary { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.settings-summary > div { display: flex; justify-content: space-between; align-items: baseline; padding: 8px 10px; background: var(--beige); border-radius: 6px; font-size: 14px; border: 1px solid var(--sky); }
.settings-summary > div span { color: var(--teal); font-weight: 600; font-size: 13px; }
.settings-summary > div strong { color: var(--navy); font-size: 15px; }
@media (max-width: 480px) { .settings-summary { grid-template-columns: 1fr; } }

/* ---------- Flash ---------- */
.flash-container { position: fixed; top: 78px; right: 22px; z-index: 50; display: flex; flex-direction: column; gap: 10px; max-width: 380px; }
.flash { padding: 12px 16px; border-radius: 6px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow); position: relative; padding-right: 34px; animation: slideIn .25s ease; border: 1px solid var(--sky); }
.flash-success { background: var(--sky); color: var(--navy); border-left: 4px solid var(--teal); }
.flash-danger { background: var(--navy); color: var(--white); border-left: 4px solid var(--teal); }
.flash-warning { background: var(--beige); color: var(--navy); border-left: 4px solid var(--teal); }
.flash-info { background: var(--sky); color: var(--navy); border-left: 4px solid var(--navy); }
.flash-close { position: absolute; right: 8px; top: 6px; background: none; border: none; font-size: 18px; cursor: pointer; color: inherit; opacity: .6; }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse2{0%{box-shadow:0 0 0 0 rgba(86,124,141,.55);} 70%{box-shadow:0 0 0 11px rgba(86,124,141,0);} 100%{box-shadow:0 0 0 0 rgba(86,124,141,0);}}
@keyframes pulse2red{0%{box-shadow:0 0 0 0 rgba(47,65,86,.45);} 70%{box-shadow:0 0 0 11px rgba(47,65,86,0);} 100%{box-shadow:0 0 0 0 rgba(47,65,86,0);}}

/* ---------- Auth pages ---------- */
.auth-body {
  background:
    radial-gradient(900px 520px at 18% 0%, color-mix(in srgb, var(--teal) 55%, transparent) 0%, transparent 58%),
    linear-gradient(160deg, var(--navy) 0%, var(--teal) 100%);
  justify-content: center;
  align-items: center;
}
.auth-body .hmi-ambient { display: none; }
.auth-body::before { display: none; }
.auth-body .main-container, .auth-body .main { display: flex; justify-content: center; align-items: center; max-width: 100%; padding: 20px; }
.auth-card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(165deg, var(--white) 0%, color-mix(in srgb, var(--beige) 40%, var(--white)) 100%);
  border-radius: calc(var(--radius) + 4px);
  padding: 34px;
  box-shadow:
    0 28px 60px rgba(var(--navy-rgb), 0.35),
    inset 0 1px 0 rgba(255,255,255,0.7);
  border: 1px solid rgba(var(--sky-rgb), 0.95);
  position: relative;
}
.auth-card::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy), var(--teal), var(--accent), var(--sky));
  border-radius: calc(var(--radius) + 4px) calc(var(--radius) + 4px) 0 0;
}
.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.auth-card .brand-logo-img { width: 90px; height: 90px; border-radius: 18px; }
.auth-card .verdant-logo.compact { background: transparent; box-shadow: none; padding: 0; gap: 14px; }
.auth-card .verdant-logo.compact .logo-svg { width: 52px; height: 56px; }
.auth-card .verdant-logo.compact .brand-title { font-size: 1.5rem; gap: 8px; }
.auth-card .verdant-logo.compact .brand-tagline { font-size: 0.72rem; text-align: right; }

/* Register page brand stack */
.reg-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}
.reg-partners {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
  flex-wrap: wrap;
}
.reg-partner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.reg-partner img {
  display: block;
  object-fit: contain;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}
.reg-partner .reg-ell {
  width: 118px;
  height: auto;
}
.reg-partner .reg-shiran {
  width: 168px;
  height: auto;
}
.reg-partner span {
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--navy);
  font-weight: 700;
}
.auth-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; text-align: center; margin-bottom: 4px; color: var(--navy); letter-spacing: 0.04em; }
.auth-sub { text-align: center; color: var(--teal); font-size: 13px; margin-bottom: 22px; }
.auth-footer { text-align: center; font-size: 13px; margin-top: 18px; color: var(--teal); }
.auth-footer a { color: var(--navy); font-weight: 700; text-decoration: none; }

/* ---------- Landing ---------- */
.hero { text-align: center; padding: 70px 20px 40px; color: var(--white); }
.hero h1 { font-size: 40px; font-weight: 800; }
.hero .accent { color: var(--sky); }
.hero p { color: var(--sky); font-size: 17px; margin: 14px auto 30px; max-width: 620px; }
.hero .btn { margin: 6px; }
.hero-logo { font-size: 64px; }

/* ---------- Modal ---------- */
.url-box {
  font-family: var(--font-mono); font-size: 13px; background: var(--beige);
  border: 1px dashed var(--teal); color: var(--navy); border-radius: 6px;
  padding: 9px 12px; word-break: break-all; margin-top: 4px;
}

/* ---------- Widgets / dashboard designer ---------- */
.widget-grid {
  display: grid; gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.widget {
  background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 16px; min-height: 130px; display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .25s;
  border: 1px solid transparent;
}
.widget:hover { transform: translateY(-1px); }
.widget-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--teal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}
.widget-body { flex: 1; display: flex; align-items: center; justify-content: center; }
.widget-body.center { text-align: center; }
.widget-body.text { color: var(--navy); font-size: 14px; padding: 10px; }
.widget-value {
  font-size: var(--panel-font-size, 40px);
  font-weight: 700;
  line-height: 1.1;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
  transition: color 0.45s ease, text-shadow 0.45s ease;
}
.widget-unit { font-size: calc(var(--panel-font-size, 40px) * 0.45); font-weight: 700; margin-left: 4px; }
.widget-body.text { font-size: calc(var(--panel-font-size, 34px) * 0.42); }
.dash-nav-label { font-size: calc(var(--panel-font-size, 34px) * 0.45); }
.html-frame {
  width: 100%;
  height: 100%;
  min-height: 80px;
  border: 0;
  background: transparent;
  display: block;
}

.widget-item { border: 1px solid var(--sky); border-radius: 8px; padding: 12px; margin-bottom: 12px; background: var(--white); }
.widget-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; flex-wrap: wrap; }

.device-card { text-decoration: none; color: inherit; display: block; transition: transform .15s, box-shadow .15s, border-color .2s; }
.device-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 22px rgba(47, 65, 86, 0.12);
  border-color: var(--teal);
}

@media (max-width: 640px) {
  .widget-value { font-size: 30px; }
}

.modal { display: none; position: fixed; inset: 0; background: rgba(47, 65, 86, 0.45); z-index: 100; align-items: center; justify-content: center; padding: 20px; }
.modal.open { display: flex; }
.modal-card { background: var(--white); border-radius: 10px; width: 100%; max-width: 460px; padding: 26px; box-shadow: 0 20px 60px rgba(47, 65, 86, 0.3); border: 1px solid var(--sky); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-title { font-size: 18px; font-weight: 700; color: var(--navy); font-family: var(--font-display); }
.modal-close { background: none; border: none; font-size: 26px; cursor: pointer; color: var(--teal); line-height: 1; }

/* ---------- Company log ---------- */
.btn-add {
  background: var(--teal);
  color: #fff; border: none; border-radius: 6px;
  font-size: 0.85rem; font-weight: 700; padding: 11px 18px;
  cursor: pointer; box-shadow: 0 0 0 0 rgba(86,124,141,0.22);
  transition: transform .15s ease, box-shadow .2s ease, background .2s ease;
  white-space: nowrap;
}
.btn-add:hover { transform: translateY(-1px); background: var(--navy); box-shadow: 0 0 16px rgba(86,124,141,0.3); }

.log-card {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 24px 24px 8px;
  margin-bottom: 22px;
  border: 1px solid var(--sky);
}
.log-title {
  font-family: var(--font-display);
  font-size: 1.05rem; font-weight: 700; color: #2F4156;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}
.log-card table { border-collapse: collapse; }
.log-card thead th {
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--navy);
  padding: 0 14px 10px;
  border-bottom: 1px solid var(--sky);
  white-space: nowrap;
  background: var(--beige);
}
.log-card tbody td {
  padding: 12px 14px;
  font-size: 0.87rem;
  border-bottom: 1px solid var(--sky);
  vertical-align: middle;
}
tr.group-start td { border-top: 1px solid var(--sky); }
tr.group-end td { border-bottom: 2px solid var(--sky); }
td.company-cell {
  font-weight: 700;
  color: #2F4156;
  border-left: 3px solid transparent;
}
tr.group-start td.company-cell { border-left-color: #567C8D; }
td.company-cell.continued { color: transparent; border-left-color: #567C8D; position: relative; }
td.company-cell.continued::before {
  content: "";
  position: absolute; left: -3px; top: 0; bottom: 0; width: 3px;
  background: #567C8D; opacity: 0.35;
}
.log-card tr:hover td { background: #F5EFEB; }
.log-card .sno { color: var(--teal); font-weight: 600; }

.mac-id {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.2px;
  background: #F5EFEB;
  border: 1px solid var(--sky);
  border-radius: 4px;
  padding: 3px 8px;
  display: inline-block;
  color: var(--navy);
}
.mac-id.empty { color: var(--teal); background: transparent; border-style: dashed; }

.tag-badge {
  font-size: 0.75rem; font-weight: 600;
  background: #C8D9E6; color: #2F4156;
  border: 1px solid #567C8D;
  border-radius: 4px;
  padding: 3px 9px;
  display: inline-block;
}
.tag-badge.empty { color: var(--teal); background: transparent; border-style: dashed; }

.fw-badge {
  font-size: 0.75rem; font-weight: 700;
  padding: 3px 9px; border-radius: 4px;
  display: inline-block;
}
.fw-badge.ok { background: #C8D9E6; color: #2F4156; }
.fw-badge.pending { background: #F5EFEB; color: #567C8D; }
.fw-badge.empty { color: #567C8D; }

.mail-cell { color: var(--teal); font-size: 0.83rem; }
.mail-cell.empty { color: var(--teal); }

.date-cell { color: var(--teal); font-size: 0.82rem; white-space: nowrap; }

.del-btn {
  background: var(--navy); color: #fff; border: none;
  font-size: 0.78rem; font-weight: 700;
  padding: 6px 13px; border-radius: 6px; cursor: pointer;
  transition: transform .15s ease, background .2s ease, box-shadow .2s ease;
}
.del-btn:hover { transform: translateY(-1px); background: var(--teal); box-shadow: 0 0 12px rgba(86,124,141,0.3); }

.info-card {
  background: var(--white);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 24px 26px;
  border: 1px solid var(--sky);
}
.info-card h3 {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  color: var(--navy); margin-bottom: 12px;
}
.info-card ol { margin-left: 1.1rem; color: var(--teal); font-size: 0.87rem; line-height: 1.9; }
.info-card b { color: var(--navy); }

@media (max-width: 900px) {
  .log-card { overflow-x: auto; }
  .log-card table { min-width: 820px; }
}

/* ---------- Dashboard designer (Grafana-style) ---------- */
.designer-layout { display: flex; gap: 20px; align-items: flex-start; }

.design-canvas-wrap {
  flex: 1;
  min-width: 0;
  background: #2F4156;
  background-image:
    linear-gradient(rgba(200, 217, 230, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(200, 217, 230, 0.06) 1px, transparent 1px);
  background-size: 56px 56px;
  border-radius: 10px;
  padding: 18px;
  position: relative;
}

.design-canvas {
  position: relative;
  min-height: 420px;
  transition: height 0.15s ease;
}

.screen-tabs-view {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.screen-tab-view {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 8px 16px;
  border-radius: 4px;
  border: 1px solid var(--sky);
  background: var(--white);
  color: var(--navy);
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s, box-shadow .25s;
}
.screen-tab-view:hover { border-color: var(--teal); }
.screen-tab-view.active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
  box-shadow: 0 0 14px rgba(86, 124, 141, 0.35);
}
.view-canvas-frame {
  position: relative;
  margin: 0 auto;
  overflow: hidden;
  max-width: 100%;
  border: 1px solid var(--sky);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}
.view-canvas {
  position: relative;
  width: 1920px;
  height: 1080px;
  background: #ffffff;
  background-image:
    linear-gradient(rgba(47, 65, 86, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(47, 65, 86, 0.045) 1px, transparent 1px);
  background-size: 40px 40px;
  border-radius: 8px;
  overflow: hidden;
  transform-origin: top left;
}
.bg-html-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  pointer-events: none;
  z-index: 0;
  background: transparent;
}
.dash-html-status {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 239, 235, 0.92);
  pointer-events: auto;
}
.dash-html-status[hidden] { display: none !important; }
.dash-html-status-card {
  background: #fff;
  border: 1px solid rgba(47, 65, 86, 0.14);
  border-radius: 12px;
  padding: 20px 24px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(47, 65, 86, 0.08);
}
.dash-html-status-card strong {
  display: block;
  color: #2F4156;
  font-size: 16px;
  margin-bottom: 6px;
}
.dash-html-status-card p {
  margin: 0 0 12px;
  color: #567C8D;
  font-size: 13px;
  line-height: 1.45;
}
.bg-html-frame.is-template-dash,
.view-canvas.is-html-template .bg-html-frame {
  pointer-events: auto;
  z-index: 2;
  background: #E8EEF2;
}
.view-canvas.is-html-template {
  background-image: none !important;
  background-color: #E8EEF2;
  /* Fluid iframe — template's own @media mobile rules must see real viewport width */
  width: 100% !important;
  max-width: 100%;
  height: calc(100dvh - 168px) !important;
  min-height: 520px;
  transform: none !important;
  overflow: hidden;
}
.view-canvas-frame:has(.view-canvas.is-html-template) {
  width: 100% !important;
  max-width: 100%;
  height: calc(100dvh - 168px) !important;
  min-height: 520px;
  margin-left: 0 !important;
  margin-top: 0 !important;
}
body.dash-fullscreen .view-canvas.is-html-template,
body.dash-fullscreen .view-canvas-frame:has(.view-canvas.is-html-template) {
  height: 100dvh !important;
  min-height: 100dvh !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}
body.dashboard-view-page.tpl-mobile-chrome .main-container {
  padding: 10px 10px 16px;
}
body.dashboard-view-page.tpl-mobile-chrome .dash-view-head {
  margin-bottom: 8px;
  gap: 8px;
}
body.dashboard-view-page.tpl-mobile-chrome .hmi-module-kicker {
  font-size: 10px;
}
@media (max-width: 900px) {
  .view-canvas.is-html-template,
  .view-canvas-frame:has(.view-canvas.is-html-template) {
    height: calc(100dvh - 150px) !important;
    min-height: 420px;
    border-radius: 6px;
  }
  body.dashboard-view-page .main-container {
    padding-left: 10px;
    padding-right: 10px;
  }
  body.dashboard-view-page .dash-view-layout {
    margin-top: 8px;
  }
}
@media (max-width: 640px) {
  .view-canvas.is-html-template,
  .view-canvas-frame:has(.view-canvas.is-html-template) {
    height: calc(100dvh - 132px) !important;
    min-height: 360px;
  }
  body.dashboard-view-page .navbar {
    padding: 0.45rem 0.75rem;
  }
  body.dashboard-view-page .dash-view-head .page-title {
    font-size: 16px;
  }
  body.dashboard-view-page .dash-view-actions .btn {
    width: 100%;
    flex: none;
    text-align: center;
  }
  body.dashboard-view-page .screen-tabs-view {
    margin-bottom: 8px;
  }
}
.view-panel {
  position: absolute;
  z-index: 1;
  background: #ffffff;
  border: 1px solid #C8D9E6;
  border-radius: 6px;
  padding: 10px;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(47, 65, 86, 0.08);
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}
.view-panel.is-transparent {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.view-panel.is-transparent .widget {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  text-shadow: 0 1px 2px rgba(47, 65, 86, 0.35);
}
.view-panel .widget {
  background: transparent;
  box-shadow: none;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.view-panel .widget:hover { transform: none; }
.view-panel .widget-title { color: #2F4156; }
.view-panel .text-muted { color: #567C8D; }

.dash-nav-btn {
  width: 100%;
  height: 100%;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  background: rgba(47, 65, 86, 0.06);
  color: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 12px 14px;
  transition: background .15s, transform .15s, box-shadow .2s;
}
.dash-nav-btn:hover { background: rgba(86, 124, 141, 0.16); }
.dash-nav-btn:active { transform: scale(.98); }
.dash-nav-label { font-family: var(--font-display); letter-spacing: .08em; text-transform: uppercase; }
.dash-screen-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  width: 100%;
}
.dash-screen-chip {
  border: 1px solid rgba(47, 65, 86, 0.18);
  background: var(--sky);
  color: var(--navy);
  font-size: 12px;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .25s, color .15s;
}
.dash-screen-chip:hover { border-color: var(--teal); }
.dash-screen-chip.active {
  background: #567C8D;
  border-color: transparent;
  color: #FFFFFF;
  box-shadow: 0 0 14px rgba(86, 124, 141, 0.4);
}
.widget-image { position: relative; }
.widget-image-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.dash-view-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
body.dash-fullscreen {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}
body.dash-fullscreen .navbar,
body.dash-fullscreen .dash-view-head,
body.dash-fullscreen .dash-side-col,
body.dash-fullscreen .dash-back-btn,
body.dash-fullscreen .dash-view-head .text-muted,
body.dash-fullscreen .page-title,
body.dash-fullscreen .footer,
body.dash-fullscreen .flash-container,
body.dash-fullscreen .hmi-ambient,
body.dash-fullscreen .machine-floor,
body.dash-fullscreen .hmi-live-chip,
body.dash-fullscreen .screen-tabs-view,
body.dash-fullscreen .dash-view-actions {
  display: none !important;
}
body.dash-fullscreen .dash-view-layout {
  display: block !important;
  margin-top: 0;
  height: 100vh;
  height: 100dvh;
}
body.dash-fullscreen .dash-main-col {
  width: 100%;
  max-width: none;
  height: 100%;
}
body.dash-fullscreen .view-canvas {
  border-radius: 0;
}
body.dash-fullscreen .view-canvas-frame {
  border-radius: 0;
  border: none;
  box-shadow: none;
}
body.dash-fullscreen .view-canvas.is-html-template,
body.dash-fullscreen .view-canvas-frame:has(.view-canvas.is-html-template) {
  width: 100% !important;
  height: 100vh !important;
  height: 100dvh !important;
  min-height: 100vh !important;
  min-height: 100dvh !important;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0 !important;
}
body.dash-fullscreen .page-head {
  margin-bottom: 0;
}
body.dash-fullscreen .main-container,
body.dash-fullscreen .container,
body.dash-fullscreen main,
body.dash-fullscreen .content {
  max-width: none !important;
  width: 100%;
  padding: 0 !important;
  margin: 0 !important;
  height: 100vh;
  height: 100dvh;
}

.design-panel {
  position: absolute;
  background: #1a2d3d;
  border: 1px solid #3d5a6e;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  cursor: move;
}
.design-panel:hover { border-color: #567C8D; }
.design-panel.selected { border-color: #C8D9E6; box-shadow: 0 0 0 2px rgba(200, 217, 230, 0.35); }

.design-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid #3d5a6e;
  cursor: move;
  user-select: none;
  min-height: 36px;
}
.design-panel-head .d-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #C8D9E6;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.design-panel-head .d-type {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #8a9faa;
  background: rgba(255, 255, 255, 0.07);
  border-radius: 4px;
  padding: 2px 6px;
}
.design-panel-head .d-handle {
  display: flex;
  gap: 4px;
}
.design-panel-head .d-handle button {
  background: transparent;
  border: none;
  color: #8a9faa;
  cursor: pointer;
  font-size: 0.72rem;
  padding: 2px 5px;
  border-radius: 4px;
  line-height: 1;
}
.design-panel-head .d-handle button:hover { color: #fff; background: rgba(255,255,255,0.12); }
.design-panel-head .d-handle button.d-del:hover { color: #C8D9E6; }

.design-panel-body {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 8px;
  color: #C8D9E6;
}
.design-panel-body .widget {
  background: transparent;
  box-shadow: none;
  min-height: 0;
  width: 100%;
  height: 100%;
}
.design-panel-body .widget-value { color: #C8D9E6; }
.design-panel-body .text-muted { color: #8a9faa; }
.design-panel-body .widget-title { color: #8a9faa; }

.design-resize {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 50%, rgba(200, 217, 230, 0.9) 50%) 2px 2px / 8px 8px no-repeat,
    linear-gradient(135deg, transparent 50%, rgba(200, 217, 230, 0.5) 50%) 5px 5px / 8px 8px no-repeat;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.design-panel:hover .design-resize, .design-panel.selected .design-resize { opacity: 1; }

.design-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8a9faa;
  font-size: 0.9rem;
  pointer-events: none;
}

.designer-side {
  width: 300px;
  flex-shrink: 0;
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--sky);
}
.designer-side .d-side-head {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--sky);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--beige);
}
.designer-side .d-side-head h3 { font-size: 0.95rem; font-weight: 700; color: var(--navy); }
.designer-side .d-side-body { padding: 16px 18px; max-height: 70vh; overflow-y: auto; }

.panel-tpl {
  display: block;
  width: 100%;
  text-align: left;
  background: var(--beige);
  border: 1px solid var(--sky);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.panel-tpl:hover { border-color: var(--teal); background: var(--white); transform: translateY(-1px); }
.panel-tpl .pt-name { font-size: 0.85rem; font-weight: 700; color: var(--navy); }
.panel-tpl .pt-desc { font-size: 0.72rem; color: var(--teal); margin-top: 2px; }

.d-side-body .form-label { font-size: 12px; }
.d-side-body .form-input { font-size: 13px; padding: 8px 10px; }

.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-field input[type="color"] {
  width: 42px;
  height: 34px;
  border: 1px solid var(--sky);
  border-radius: 6px;
  background: #fff;
  padding: 2px;
  cursor: pointer;
}
.color-field input[type="text"] {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}
.color-swatches { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--sky);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { box-shadow: 0 0 0 2px var(--teal); }

.d-save-bar { display: flex; gap: 8px; margin-top: 12px; }
.d-save-bar .btn { flex: 1; text-align: center; }

.d-grid-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.d-grid-toolbar .d-z { font-size: 0.75rem; color: #8a9faa; font-family: var(--font-mono); }

.d-side-actions { display: flex; gap: 8px; margin-top: 14px; }
.d-side-actions .btn { flex: 1; text-align: center; }

@media (max-width: 1024px) {
  .designer-layout { flex-direction: column; }
  .designer-side { width: 100%; }
}

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--teal); padding: 40px 10px; font-size: 14px; }
.section-title { font-size: 15px; font-weight: 700; color: var(--navy); margin-bottom: 14px; font-family: var(--font-display); letter-spacing: 0.04em; }
.text-muted { color: var(--teal); font-size: 13px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 18px; }
.footer {
  background: linear-gradient(180deg, var(--grad-a, var(--navy)), var(--navy));
  color: var(--sky);
  text-align: center;
  padding: 0.85rem;
  font-size: 0.72rem;
  margin-top: auto;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-family: var(--font-mono);
  border-top: 1px solid rgba(var(--sky-rgb), 0.28);
  box-shadow: 0 -10px 28px rgba(var(--navy-rgb), 0.08);
}
.hero-body { background: linear-gradient(160deg, #2F4156, #567C8D); min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 20px; }

@media (max-width: 900px) {
  .metrics-grid,
  .metrics-grid:has(> .metric-card:nth-child(3):last-child),
  body[data-layout="wide"] .metrics-grid,
  body[data-layout="wide"] .metrics-grid:has(> .metric-card:nth-child(3):last-child),
  body[data-layout="stacked"] .metrics-grid,
  body[data-layout="dual_rail"] .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: none;
    gap: 0.75rem;
  }
  .metric-card {
    min-height: 108px;
    padding: 1.4rem 0.85rem 0.85rem;
  }
  .metric-title {
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    min-height: 2.3em;
  }
  .metric-value { font-size: 1.75rem; }
  .hmi-wave { display: none; }
  .buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
  }
  .btn-action {
    width: 100%;
    min-height: 44px;
  }
}

@media (max-width: 900px), (pointer: coarse) {
  html { scroll-behavior: auto; }
  .hmi-ambient-glow,
  .hmi-ambient-glow-2,
  .hmi-ambient-scan,
  .ambient-orbit .ring,
  .ambient-orbit .dot,
  .ambient-particles span,
  .ambient-aurora,
  .navbar::after,
  .navbar-scan,
  .nav-trace,
  .hmi-header-scan,
  .hmi-wave,
  .metric-led,
  .metric-trace,
  .qa-edge-flow,
  .qa-sheen,
  .qa-underline,
  .qa-hint-pulse,
  .btn-sweep,
  .brand-x,
  .hmi-live-chip,
  .machine-floor * {
    animation: none !important;
  }
  .hmi-ambient-scan,
  .machine-floor,
  .ambient-orbit,
  .ambient-particles,
  .ambient-circuit,
  .ambient-aurora,
  .navbar-scan {
    display: none !important;
  }
  .hmi-ambient-glow,
  .hmi-ambient-glow-2 {
    animation: none !important;
    transform: none !important;
    opacity: 0.55;
  }
}

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .navbar {
    padding: 0.55rem 0.85rem;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 10px;
  }
  .brand-wrap {
    flex: 1 1 auto;
    min-width: 0;
    gap: 8px;
  }
  .brand-copy-sub { display: none; }
  .main-container { padding: 1rem; }
  .main { padding: 14px; }
  .hero h1 { font-size: 28px; }
  .form-row { flex-direction: column; }
  .hmi-live-chip,
  .brand-x { display: none; }
  .trikona-plate { width: 110px; height: 44px; padding: 4px 8px; }
  .ell-plate { width: 88px; height: 44px; padding: 4px 6px; display: flex; }
  .shiran-plate { width: 100px; height: 44px; padding: 4px 8px; }
  .trikona-plate img,
  .ell-plate img,
  .shiran-plate img { height: 30px; }

  .btn {
    min-height: 40px;
    padding: 10px 14px;
  }
  .btn-sm {
    min-height: 36px;
    padding: 8px 12px;
  }
  .btn-block { width: 100%; }

  .buttons-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .btn-action {
    width: 100%;
    min-height: 44px;
    padding: 12px 14px 12px 28px;
  }

  .auth-body .main-container,
  .auth-body .main {
    padding: 16px 12px;
    align-items: stretch;
  }
  .auth-card {
    width: 100%;
    max-width: 100%;
    padding: 1.45rem 1.1rem 1.25rem;
    box-sizing: border-box;
  }
  .auth-card .btn,
  .auth-card .btn-block {
    min-height: 46px;
    width: 100%;
  }

  .metrics-grid,
  .metrics-grid:has(> .metric-card:nth-child(3):last-child),
  body[data-layout="wide"] .metrics-grid,
  body[data-layout="stacked"] .metrics-grid,
  body[data-layout="dual_rail"] .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
  }
  .metric-card {
    min-height: 100px;
    padding: 1.3rem 0.7rem 0.75rem;
  }
  .metric-title {
    font-size: 0.56rem;
    letter-spacing: 0.06em;
    min-height: 2.4em;
    margin-bottom: 0.3rem;
  }
  .metric-value { font-size: 1.55rem; }
  .metric-led { top: 10px; right: 10px; width: 7px; height: 7px; }
}

@media (max-width: 900px) {
  .screen-tabs-view {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .screen-tab-view { white-space: nowrap; flex-shrink: 0; }
}
@media (max-width: 640px) {
  .dash-view-head {
    flex-direction: column;
    align-items: flex-start;
  }
  .dash-view-head .page-title { font-size: 18px; }
  .dash-view-head .text-muted { font-size: 12px; }
  .dash-view-actions {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    justify-content: stretch;
  }
  .dash-view-actions .btn {
    width: 100%;
    min-height: 40px;
    font-size: 12px;
    padding: 9px 10px;
    box-sizing: border-box;
  }
  .screen-tabs-view {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .screen-tab-view {
    font-size: 12px;
    padding: 6px 12px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .navbar-right { gap: 6px; }
  .user-pill .name { font-size: 0.7rem; }
  .user-pill .role { display: none; }
  .btn-logout { font-size: 11px; padding: 4px 8px; }
  .nav-icon-btn svg { width: 16px; height: 16px; }
  #tcTextPopup {
    width: 90vw !important;
    max-width: 340px;
    padding: 16px !important;
  }
  #tcTextPopup .tc-popup-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- History Table Widget ---------- */
.widget-history { display: flex; flex-direction: column; height: 100%; }
.widget-history .widget-title { flex-shrink: 0; }
.history-table-wrap { flex: 1; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.history-table-view { width: 100%; border-collapse: collapse; font-size: 11px; font-family: var(--font-mono); min-width: 600px; }
.history-table-view th { position: sticky; top: 0; background: #2F4156; padding: 6px 10px; text-align: left; font-weight: 600; letter-spacing: 0.5px; text-transform: uppercase; white-space: nowrap; border-bottom: 1px solid rgba(200,217,230,0.25); color: #C8D9E6; z-index: 1; }
.history-table-view td { padding: 5px 10px; border-bottom: 1px solid rgba(47,65,86,0.08); white-space: nowrap; opacity: 0.9; color: #2F4156; }
.history-table-view tr:hover td { background: #F5EFEB; }
.history-ts-col { opacity: 0.65; font-size: 10px; }

/* ---------- Industrial chart / gauge / control states ---------- */
.widget svg polyline,
.hmi-chart-line {
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 3px rgba(86, 124, 141, 0.35));
  animation: hmi-line-draw 1.8s ease-out;
}
@keyframes hmi-line-draw {
  from { stroke-dasharray: 280; stroke-dashoffset: 280; }
  to { stroke-dasharray: 280; stroke-dashoffset: 0; }
}
.widget svg path {
  transition: stroke-dasharray 0.7s ease;
}

.widget-toggle .badge-success,
.widget .badge-success {
  position: relative;
}

.ls-dot {
  transition: background 0.4s ease;
}

/* Temperature control chrome (does not override inline saved colors) */
.tc-screen-card {
  position: relative;
}
.tc-screen-btn:hover {
  filter: brightness(1.06);
  box-shadow: 0 0 16px rgba(86, 124, 141, 0.3);
}
.tc-inline-input:focus {
  box-shadow: 0 0 0 3px rgba(86, 124, 141, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
