/* ============================================================
   MES — Sodium Glow Edition
   Manufacturing Execution System Design System
   v1.0 · Phase 1
   ============================================================ */

/* ===== 1. Tokens ===== */
:root {
  /* Surfaces — Graphite 5 levels */
  --bg:           #0b0d12;
  --bg-elevated:  #11141b;
  --card:         #161a23;
  --card-hover:   #1c2130;
  --card-active:  #232a3c;
  --overlay:      rgba(11, 13, 18, 0.74);
  --surface:      #161a23;
  --surface-2:    #1c2130;
  --surface-3:    #232a3c;

  /* Sodium Glow */
  --amber:        #f59e0b;
  --amber-light:  #fcd34d;
  --amber-deep:   #b45309;
  --amber-hot:    #fb923c;
  --amber-grad:   linear-gradient(135deg, #fcd34d 0%, #f59e0b 50%, #b45309 100%);
  --amber-glow:   radial-gradient(ellipse 80% 60% at 50% 30%, rgba(245,158,11,0.18), transparent 70%);
  --amber-soft:   rgba(245,158,11,0.10);
  --amber-line:   rgba(245,158,11,0.30);
  --shadow-amber: 0 12px 40px rgba(245,158,11,0.18);
  --ring-amber:   0 0 0 3px rgba(245,158,11,0.22);

  /* Text — bone white */
  --text:         #eef2f5;
  --text-muted:   rgba(238,242,245,0.66);
  --text-dim:     rgba(238,242,245,0.40);
  --text-faint:   rgba(238,242,245,0.20);

  /* Borders */
  --border:        rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --border-amber:  rgba(245, 158, 11, 0.30);

  /* Status — 5 stage signal lights */
  --st-run:    #22c55e;  --st-run-soft:  rgba(34,197,94,0.12);
  --st-idle:   #94a3b8;  --st-idle-soft: rgba(148,163,184,0.10);
  --st-warn:   #f59e0b;  --st-warn-soft: rgba(245,158,11,0.12);
  --st-down:   #ef4444;  --st-down-soft: rgba(239,68,68,0.12);
  --st-pm:     #a855f7;  --st-pm-soft:   rgba(168,85,247,0.12);

  /* Steel (secondary technical) */
  --steel:       #64748b;
  --steel-soft:  rgba(100,116,139,0.12);

  /* Data Viz palette (8 — heat-map order) */
  --viz-1:#f59e0b; --viz-2:#fb923c; --viz-3:#fcd34d; --viz-4:#22c55e;
  --viz-5:#06b6d4; --viz-6:#a855f7; --viz-7:#ef4444; --viz-8:#84cc16;

  /* Radii */
  --r-sm:6px; --r:11px; --r-md:14px; --r-lg:20px; --r-xl:28px; --r-pill:999px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.40);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.40);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.50);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.60);

  /* Motion */
  --ease:     cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --spring:   cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 120ms; --t-base: 200ms; --t-slow: 320ms;

  /* Type stacks */
  --kr:   'Pretendard Variable', -apple-system, sans-serif;
  --en:   'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'IBM Plex Mono', ui-monospace, monospace;

  /* Layout */
  --side-w:        260px;
  --topbar-h:      0px;
  --content-pad:   28px;

  /* Glass */
  --glass-bg:   rgba(11, 13, 18, 0.72);
  --glass-blur: blur(14px) saturate(140%);
}

/* ===== 2. Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--kr);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Industrial drafting grid (radial-masked) */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(245,158,11,0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,158,11,0.025) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent);
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, black, transparent);
}

/* Sodium glow at top */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--amber-glow);
  pointer-events: none;
  z-index: 0;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* Scrollbar — graphite */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.06);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(245,158,11,0.30); }

/* ===== 3. Sidebar — Always Open · Brand + User + Search + Telemetry + Nav ===== */
.m-side {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--side-w);
  background: var(--bg-elevated);
  border-right: 1px solid var(--border);
  z-index: 90;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Brand block at top */
.m-side__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px 14px;
  text-decoration: none;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(245,158,11,0.05), transparent 70%);
}
.m-side__logo {
  width: 36px; height: 36px;
  background: var(--amber-grad);
  border-radius: var(--r);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #0b0d12;
  font-size: 16px;
  box-shadow: var(--shadow-amber);
  flex-shrink: 0;
}
.m-side__brand-text {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  line-height: 1.1;
}
.m-side__brand-title {
  font-family: var(--kr);
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}
.m-side__brand-sub {
  font-family: var(--en);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: var(--text-faint);
  text-transform: uppercase;
  margin-top: 3px;
}
.m-side__brand-badge {
  font-family: var(--en);
  font-size: 9px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--amber-soft);
  border: 1px solid var(--border-amber);
  color: var(--amber-light);
  letter-spacing: 0.10em;
}

/* User block (bottom) */
.m-side__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}
.m-side__avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--amber-grad);
  color: #0b0d12;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(245,158,11,0.20);
}
.m-side__user-info {
  flex: 1;
  min-width: 0;
  line-height: 1.25;
}
.m-side__user-name {
  font-family: var(--kr);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.m-side__user-role {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.m-side__bell {
  position: relative;
  width: 32px; height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--bg-elevated);
  color: var(--text-muted);
  text-decoration: none;
  flex-shrink: 0;
  transition: all var(--t-fast) var(--ease);
}
.m-side__bell:hover { color: var(--amber); border-color: var(--border-amber); }
.m-side__bell-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 6px; height: 6px;
  background: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--amber);
}

/* Search trigger */
.m-side__search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 14px 0;
  height: 36px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
  font-family: inherit;
}
.m-side__search:hover { border-color: var(--border-amber); color: var(--text); }
.m-side__search i { font-size: 12px; color: var(--text-dim); flex-shrink: 0; }
.m-side__search-text {
  flex: 1;
  text-align: left;
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-side__search kbd {
  font-family: var(--mono);
  font-size: 9px;
  padding: 2px 5px;
  border-radius: 3px;
  background: var(--surface-3);
  color: var(--text-dim);
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* Telemetry block */
.m-side__tele {
  padding: 12px 14px 6px;
}
.m-side__tele-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--en);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: rgba(238,242,245,0.62);
  text-transform: uppercase;
  padding: 8px 4px 6px;
}
.m-side__tele-pulse {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 9px;
  color: var(--amber);
  font-weight: 700;
}
.m-side__tele-pulse::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 6px var(--amber);
  animation: m-pulse 1.6s ease-in-out infinite;
}

.m-side-tele {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  margin-bottom: 5px;
  transition: border-color var(--t-fast) var(--ease), background var(--t-base) var(--ease);
  cursor: default;
}
.m-side-tele:hover { border-color: var(--border-strong); }
.m-side-tele i {
  width: 14px;
  text-align: center;
  color: var(--amber);
  font-size: 11px;
  flex-shrink: 0;
}
.m-side-tele__lbl {
  font-family: var(--en);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.10em;
  color: rgba(238,242,245,0.78);
  text-transform: uppercase;
  flex: 1;
}
.m-side-tele__val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.m-side-tele.--good .m-side-tele__val { color: var(--st-run); }
.m-side-tele.--warn {
  border-color: var(--border-amber);
  background: linear-gradient(90deg, var(--amber-soft), transparent 80%);
}
.m-side-tele.--warn .m-side-tele__val { color: var(--amber-light); }
.m-side-tele.--warn i { color: var(--amber-light); }
.m-side-tele.--crit .m-side-tele__val { color: var(--st-down); }
.m-side-tele.is-flash {
  animation: m-flash 240ms var(--ease);
}
@keyframes m-flash {
  0%   { background: var(--amber-soft); border-color: var(--border-amber); }
  100% { background: var(--surface); }
}

/* Nav */
.m-side__nav {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0 12px;
}
.m-side__nav::-webkit-scrollbar { width: 4px; }

.m-side__group {
  font-family: var(--en);
  font-size: 9.5px;
  font-weight: 700;
  color: rgba(238,242,245,0.58);
  letter-spacing: 0.16em;
  padding: 12px 22px 4px;
  white-space: nowrap;
  text-transform: uppercase;
}

.m-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 22px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.m-nav-item i {
  font-size: 14px;
  width: 18px;
  text-align: center;
  color: var(--text-dim);
  flex-shrink: 0;
  transition: color var(--t-fast) var(--ease);
}
.m-nav-item:hover {
  color: var(--text);
  background: var(--surface);
}
.m-nav-item:hover i { color: var(--amber); }
.m-nav-item.is-active {
  color: var(--amber-light);
  background: var(--amber-soft);
}
.m-nav-item.is-active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--amber-grad);
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 12px rgba(245,158,11,0.50);
}
.m-nav-item.is-active i { color: var(--amber); }

.m-side__divider {
  height: 1px;
  background: var(--border);
  margin: 8px 16px;
}

.m-side__bottom {
  padding: 6px 0 12px;
  border-top: 1px solid var(--border);
}

/* Mobile floating hamburger */
.m-mobile-toggle {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  width: 40px; height: 40px;
  border-radius: var(--r);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text);
  z-index: 95;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  box-shadow: var(--shadow-md);
  transition: all var(--t-fast) var(--ease);
}
.m-mobile-toggle:hover { color: var(--amber); border-color: var(--border-amber); }

/* Mobile backdrop */
.m-side-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 89;
}
.m-side-backdrop.is-open { display: block; }

/* ===== 5. Main content ===== */
.m-main {
  margin-left: var(--side-w);
  min-height: 100vh;
  padding: var(--content-pad);
  position: relative;
  z-index: 1;
}

.m-page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.m-page-head h1 {
  margin: 0 0 4px;
  font-family: var(--kr);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.m-page-head h1 i {
  margin-right: 10px;
  font-size: 18px;
  color: var(--amber);
}
.m-page-head__sub {
  margin: 0;
  font-size: 12px;
  color: var(--text-dim);
}
.m-page-head__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ===== 6. KPI Card ===== */
.m-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.m-kpi-grid--3 { grid-template-columns: repeat(3, 1fr); }
.m-kpi-grid--2 { grid-template-columns: repeat(2, 1fr); }

.m-kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  overflow: hidden;
  transition: border-color var(--t-base) var(--ease),
              transform var(--t-fast) var(--ease),
              box-shadow var(--t-base) var(--ease);
}
.m-kpi:hover {
  border-color: var(--border-amber);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.m-kpi::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 80% 50% at 50% 0%, rgba(245,158,11,0.06), transparent 70%);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease);
  pointer-events: none;
}
.m-kpi:hover::before { opacity: 1; }

.m-kpi__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.m-kpi__lbl {
  font-family: var(--en);
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(238,242,245,0.72);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.m-kpi__icon {
  width: 30px; height: 30px;
  border-radius: var(--r-sm);
  background: var(--amber-soft);
  color: var(--amber);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}
.m-kpi__icon.--run  { background: var(--st-run-soft);  color: var(--st-run); }
.m-kpi__icon.--warn { background: var(--st-warn-soft); color: var(--st-warn); }
.m-kpi__icon.--down { background: var(--st-down-soft); color: var(--st-down); }
.m-kpi__icon.--info { background: rgba(6,182,212,0.12); color: #06b6d4; }
.m-kpi__icon.--violet { background: rgba(168,85,247,0.12); color: #a855f7; }

.m-kpi__num {
  font-family: var(--en);
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.m-kpi__num small {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  margin-left: 3px;
}
.m-kpi__delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--en);
  font-size: 11px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.m-kpi__delta--up   { color: var(--st-run); }
.m-kpi__delta--down { color: var(--st-down); }
.m-kpi__delta--flat { color: var(--text-dim); }

.m-kpi__bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.m-kpi__bar-fill {
  height: 100%;
  background: var(--amber-grad);
  border-radius: 2px;
  transition: width var(--t-slow) var(--ease);
  box-shadow: 0 0 8px rgba(245,158,11,0.40);
}
.m-kpi__bar-fill.--run  { background: linear-gradient(90deg, #4ade80, #22c55e); box-shadow: 0 0 8px rgba(34,197,94,0.40); }
.m-kpi__bar-fill.--warn { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.m-kpi__bar-fill.--down { background: linear-gradient(90deg, #fb7185, #ef4444); box-shadow: 0 0 8px rgba(239,68,68,0.40); }

.m-kpi__spark {
  height: 32px;
  width: 100%;
  margin-top: -4px;
}

/* KPI variants */
.m-kpi.--accent {
  border-color: var(--border-amber);
  background:
    linear-gradient(135deg, rgba(245,158,11,0.04) 0%, transparent 60%),
    var(--card);
}
.m-kpi.--accent .m-kpi__num { color: var(--amber-light); }

/* ===== 7. Status badges & LED dots ===== */
.m-led {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--st-idle);
  box-shadow: 0 0 8px var(--st-idle);
  flex-shrink: 0;
}
.m-led.--run  { background: var(--st-run);  box-shadow: 0 0 8px var(--st-run); animation: m-pulse 1.6s ease-in-out infinite; }
.m-led.--idle { background: var(--st-idle); box-shadow: 0 0 6px var(--st-idle); }
.m-led.--warn { background: var(--st-warn); box-shadow: 0 0 10px var(--st-warn); animation: m-pulse-fast 1.4s ease-in-out infinite; }
.m-led.--down { background: var(--st-down); box-shadow: 0 0 12px var(--st-down); animation: m-pulse-urgent 0.9s ease-in-out infinite; }
.m-led.--pm   { background: var(--st-pm);   box-shadow: 0 0 8px var(--st-pm); }

@keyframes m-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}
@keyframes m-pulse-fast {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.40; }
}
@keyframes m-pulse-urgent {
  0%, 100% { opacity: 1; box-shadow: 0 0 12px var(--st-down); }
  50%      { opacity: 0.55; box-shadow: 0 0 20px var(--st-down), 0 0 36px var(--st-down); }
}

.m-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-family: var(--en);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.m-chip.--run  { background: var(--st-run-soft);  color: var(--st-run);  border-color: rgba(34,197,94,0.30); }
.m-chip.--idle { background: var(--st-idle-soft); color: var(--st-idle); border-color: rgba(148,163,184,0.30); }
.m-chip.--warn { background: var(--st-warn-soft); color: var(--st-warn); border-color: rgba(245,158,11,0.30); }
.m-chip.--down { background: var(--st-down-soft); color: var(--st-down); border-color: rgba(239,68,68,0.30); }
.m-chip.--pm   { background: var(--st-pm-soft);   color: var(--st-pm);   border-color: rgba(168,85,247,0.30); }
.m-chip.--info { background: rgba(6,182,212,0.12); color: #06b6d4; border-color: rgba(6,182,212,0.30); }
.m-chip.--accent { background: var(--amber-soft); color: var(--amber-light); border-color: var(--border-amber); }

.m-chip--lg {
  padding: 5px 12px;
  font-size: 11.5px;
}

/* ===== 8. Cards ===== */
.m-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  position: relative;
  transition: border-color var(--t-base) var(--ease);
}
.m-card:hover { border-color: var(--border-strong); }
.m-card.is-interactive { cursor: pointer; }
.m-card.is-interactive:hover {
  border-color: var(--border-amber);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.m-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.m-card__head h3 {
  margin: 0;
  font-family: var(--kr);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.m-card__head h3 i { color: var(--amber); font-size: 13px; }
.m-card__head--ghost { border-bottom: none; padding-bottom: 0; }

.m-card__body {
  padding: 16px 18px;
}
.m-card__body--flush { padding: 0; }
.m-card__foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: rgba(0,0,0,0.10);
  font-size: 11px;
  color: var(--text-dim);
}

.m-card.--accent {
  border-color: var(--border-amber);
  background:
    linear-gradient(135deg, rgba(245,158,11,0.04) 0%, transparent 60%),
    var(--card);
}

/* Heat card (line / equipment summary) */
.m-heat-card {
  position: relative;
  padding: 16px 18px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  transition: all var(--t-base) var(--ease);
}
.m-heat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--st-idle);
}
.m-heat-card.--run::before  { background: var(--st-run); }
.m-heat-card.--warn::before { background: var(--st-warn); box-shadow: 0 0 16px rgba(245,158,11,0.30); }
.m-heat-card.--down::before { background: var(--st-down); box-shadow: 0 0 20px rgba(239,68,68,0.40); }
.m-heat-card.--pm::before   { background: var(--st-pm); }
.m-heat-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.m-heat-card.--down,
.m-heat-card.--warn { background: linear-gradient(135deg, var(--card-hover), var(--card)); }

.m-heat-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.m-heat-card__title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--kr);
  font-weight: 700;
  font-size: 13px;
}
.m-heat-card__sub {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text-faint);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.m-heat-card__num {
  font-family: var(--en);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.m-heat-card__num small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-dim);
  margin-left: 2px;
}
.m-heat-card__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
}
.m-heat-card__meta-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.m-heat-card__meta-item i { font-size: 9px; opacity: 0.70; }

/* ===== 9. Buttons ===== */
.m-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: var(--kr);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.m-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}
.m-btn:active { transform: scale(0.97); }
.m-btn:focus-visible { outline: none; box-shadow: var(--ring-amber); }

.m-btn--primary {
  background: var(--amber-grad);
  border-color: transparent;
  color: #0b0d12;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(245,158,11,0.20);
}
.m-btn--primary:hover {
  filter: brightness(1.10);
  box-shadow: 0 8px 24px rgba(245,158,11,0.32);
  transform: translateY(-1px);
}
.m-btn--ghost {
  background: transparent;
  border-color: var(--border-amber);
  color: var(--amber-light);
}
.m-btn--ghost:hover {
  background: var(--amber-soft);
  color: var(--amber);
}
.m-btn--subtle {
  background: var(--amber-soft);
  border-color: var(--border-amber);
  color: var(--amber-light);
}
.m-btn--critical {
  background: linear-gradient(135deg, #f87171, #dc2626);
  border-color: transparent;
  color: #fff;
}
.m-btn--sm { height: 28px; padding: 0 11px; font-size: 12px; }
.m-btn--lg { height: 44px; padding: 0 22px; font-size: 14px; }

/* ===== 10. Inputs ===== */
.m-input {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  transition: all var(--t-fast) var(--ease);
}
.m-input::placeholder { color: var(--text-faint); }
.m-input:focus {
  border-color: var(--border-amber);
  box-shadow: var(--ring-amber);
}
.m-input--mono { font-family: var(--mono); }

.m-select {
  appearance: none;
  background: var(--surface) url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%23eef2f5' stroke-opacity='0.40' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding-right: 32px;
}

/* ===== 11. Tables ===== */
.m-table-wrap {
  overflow-x: auto;
}
.m-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.m-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  text-align: left;
  font-family: var(--en);
  font-size: 10.5px;
  font-weight: 700;
  color: rgba(238,242,245,0.78);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}
.m-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.m-table tbody tr {
  transition: background var(--t-fast) var(--ease);
  position: relative;
}
.m-table tbody tr:hover { background: var(--card-hover); }
.m-table tbody tr:hover td:first-child {
  box-shadow: inset 3px 0 0 var(--amber);
}
.m-table tbody tr:last-child td { border-bottom: none; }

.m-table .--num   { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }
.m-table .--center { text-align: center; }
.m-table .--code  { font-family: var(--mono); color: var(--text); font-size: 11.5px; }

/* ===== 12. Grids ===== */
.m-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.m-grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.m-grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; }
.m-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.m-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }

/* ===== 13. Live event feed ===== */
.m-feed {
  max-height: 360px;
  overflow-y: auto;
  position: relative;
}
.m-feed__item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  position: relative;
  transition: background var(--t-fast) var(--ease);
}
.m-feed__item:hover { background: var(--card-hover); }
.m-feed__item:last-child { border-bottom: none; }
.m-feed__item.is-new { animation: m-feed-in 360ms var(--ease); }
@keyframes m-feed-in {
  0%   { opacity: 0; transform: translateX(-12px); background: var(--amber-soft); }
  100% { opacity: 1; transform: translateX(0); }
}

.m-feed__time {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  flex-shrink: 0;
  width: 56px;
  letter-spacing: 0.02em;
}
.m-feed__sev {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--st-idle);
  margin-top: 6px;
  flex-shrink: 0;
}
.m-feed__sev.--run  { background: var(--st-run); box-shadow: 0 0 6px var(--st-run); }
.m-feed__sev.--warn { background: var(--st-warn); box-shadow: 0 0 6px var(--st-warn); }
.m-feed__sev.--down { background: var(--st-down); box-shadow: 0 0 8px var(--st-down); }
.m-feed__sev.--pm   { background: var(--st-pm); box-shadow: 0 0 6px var(--st-pm); }
.m-feed__sev.--info { background: #06b6d4; box-shadow: 0 0 6px #06b6d4; }
.m-feed__msg {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  line-height: 1.5;
}
.m-feed__msg b { color: var(--text); font-weight: 600; }
.m-feed__msg .m-feed__code {
  font-family: var(--mono);
  color: var(--amber-light);
  font-size: 11px;
  font-weight: 700;
}
.m-feed__tag {
  display: inline-flex;
  font-family: var(--en);
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 3px;
  letter-spacing: 0.06em;
  margin-left: 6px;
  vertical-align: 2px;
}

/* ===== 14. Equipment 24h Clock Bar ===== */
.m-clock-bar {
  display: flex;
  width: 100%;
  height: 22px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
}
.m-clock-bar__seg {
  height: 100%;
  position: relative;
  transition: filter var(--t-fast) var(--ease);
}
.m-clock-bar__seg:hover { filter: brightness(1.30); }
.m-clock-bar__seg.--run  { background: var(--st-run); }
.m-clock-bar__seg.--idle { background: var(--st-idle); opacity: 0.40; }
.m-clock-bar__seg.--warn { background: var(--st-warn); }
.m-clock-bar__seg.--down { background: var(--st-down); }
.m-clock-bar__seg.--pm   { background: var(--st-pm); }

.m-clock-bar__legend {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  font-family: var(--mono);
  color: var(--text-dim);
  flex-wrap: wrap;
}
.m-clock-bar__legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.m-clock-bar__legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* ===== 15. Mini gauge / progress ===== */
.m-gauge {
  position: relative;
  height: 6px;
  background: var(--surface-3);
  border-radius: 3px;
  overflow: hidden;
}
.m-gauge__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--amber-grad);
  border-radius: 3px;
  transition: width var(--t-slow) var(--ease);
  box-shadow: 0 0 8px rgba(245,158,11,0.30);
}
.m-gauge__fill.--run  { background: linear-gradient(90deg, #4ade80, #22c55e); }
.m-gauge__fill.--warn { background: linear-gradient(90deg, #fcd34d, #f59e0b); }
.m-gauge__fill.--down { background: linear-gradient(90deg, #fb7185, #ef4444); }

/* ===== 16. Modal ===== */
.m-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: m-fade 200ms var(--ease);
}
.m-modal-backdrop.is-open { display: flex; }
.m-modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  max-width: 560px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 -20px 60px -20px rgba(245,158,11,0.18);
  animation: m-modal-in 240ms var(--ease);
  overflow: hidden;
}
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-modal-in {
  from { opacity: 0; transform: scale(0.96); }
  to   { opacity: 1; transform: scale(1); }
}

.m-demo-modal { max-width: 460px; padding: 32px 28px 24px; text-align: center; }
.m-demo-modal__icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: var(--amber-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  font-size: 28px;
  border: 1px solid var(--border-amber);
}
.m-demo-modal__title {
  font-family: var(--kr);
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
}
.m-demo-modal__msg {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0 0 22px;
}
.m-demo-modal__foot {
  display: flex;
  justify-content: center;
}
.m-demo-modal__foot .m-btn { min-width: 120px; }

/* ===== 17. Sheet (right slide) ===== */
.m-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  display: none;
  animation: m-fade 200ms var(--ease);
}
.m-sheet-backdrop.is-open { display: block; }
.m-sheet {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 92vw);
  background: var(--bg-elevated);
  border-left: 1px solid var(--border-strong);
  z-index: 1001;
  transform: translateX(100%);
  transition: transform 380ms var(--spring);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.m-sheet.is-open { transform: translateX(0); }

/* ===== 18. Toast ===== */
.m-toast-stack {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 2000;
  pointer-events: none;
}
.m-toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--r);
  box-shadow: var(--shadow-md);
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  animation: m-toast-in 360ms var(--spring);
  font-size: 12.5px;
}
.m-toast.--success { border-left: 3px solid var(--st-run); }
.m-toast.--warn    { border-left: 3px solid var(--st-warn); }
.m-toast.--error   { border-left: 3px solid var(--st-down); }
.m-toast.--info    { border-left: 3px solid var(--amber); }
@keyframes m-toast-in {
  from { opacity: 0; transform: translateY(40px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== 19. Empty state ===== */
.m-empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-dim);
}
.m-empty i {
  font-size: 42px;
  color: var(--text-faint);
  margin-bottom: 12px;
  display: block;
}
.m-empty h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--text);
  font-weight: 700;
}
.m-empty p {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.6;
}

/* ===== 20. Skeleton ===== */
.m-skel {
  background: linear-gradient(
    90deg,
    var(--surface) 0%,
    var(--surface-2) 50%,
    var(--surface) 100%
  );
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  animation: m-skel-shine 1.4s ease-in-out infinite;
}
@keyframes m-skel-shine {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== 21. Utilities ===== */
.u-mono       { font-family: var(--mono); }
.u-en         { font-family: var(--en); }
.u-tabular    { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.u-text-amber  { color: var(--amber-light); }
.u-text-run    { color: var(--st-run); }
.u-text-warn   { color: var(--st-warn); }
.u-text-down   { color: var(--st-down); }
.u-text-pm     { color: var(--st-pm); }
.u-text-dim    { color: var(--text-dim); }
.u-text-faint  { color: var(--text-faint); }
.u-text-muted  { color: var(--text-muted); }

.u-mb-0  { margin-bottom: 0; }
.u-mb-8  { margin-bottom: 8px; }
.u-mb-12 { margin-bottom: 12px; }
.u-mb-16 { margin-bottom: 16px; }
.u-mb-20 { margin-bottom: 20px; }
.u-mb-24 { margin-bottom: 24px; }
.u-mt-12 { margin-top: 12px; }
.u-mt-16 { margin-top: 16px; }
.u-mt-20 { margin-top: 20px; }

.u-flex            { display: flex; }
.u-flex-1          { flex: 1; }
.u-gap-6           { gap: 6px; }
.u-gap-8           { gap: 8px; }
.u-gap-10          { gap: 10px; }
.u-gap-12          { gap: 12px; }
.u-gap-16          { gap: 16px; }
.u-items-center    { align-items: center; }
.u-items-start     { align-items: flex-start; }
.u-justify-between { justify-content: space-between; }
.u-justify-center  { justify-content: center; }
.u-flex-wrap       { flex-wrap: wrap; }

.u-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== 22. Page transition ===== */
.m-main { animation: m-page-in 240ms var(--ease) both; }
@keyframes m-page-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== 23. Responsive ===== */
@media (max-width: 1280px) {
  .m-kpi-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1024px) {
  .m-grid-2, .m-grid-2-1, .m-grid-1-2 { grid-template-columns: 1fr; }
  .m-grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root {
    --content-pad: 14px;
  }
  .m-main { margin-left: 0; padding-top: 64px; }
  .m-side {
    transform: translateX(-100%);
    transition: transform var(--t-base) var(--ease);
  }
  .m-side.is-open { transform: translateX(0); }
  .m-mobile-toggle { display: inline-flex; }
  .m-kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .m-grid-3, .m-grid-4 { grid-template-columns: 1fr; }
  .m-page-head h1 { font-size: 20px; }
  .m-page-head__actions { width: 100%; }
}

@media (max-width: 480px) {
  .m-kpi-grid { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
