/* ════════════════════════════════════════════════════════════════════════
   METAL CRAFT SOLUTIONS — Industrial IoT Platform
   Design System  ·  light-default, auto day/night
   Type: IBM Plex Sans (UI) + IBM Plex Mono (numerics)
════════════════════════════════════════════════════════════════════════ */

/* ── TOKENS ──────────────────────────────────────────────────────────── */
:root, [data-theme="light"] {
  --bg:          #e2f0ff;
  --bg-2:        #edf6ff;
  --surface:     #ffffff;
  --surface-2:   #f0f8ff;
  --surface-3:   #d8ecff;
  --frost:       rgba(255,255,255,0.80);
  --rail:        #0f1d33;          /* sidebar / topbar dark rail */
  --rail-2:      #16263f;
  --rail-text:   #c3d0e4;
  --rail-sub:    #7d90ac;
  --rail-active: #2563eb;

  --text:        #0f1b2d;
  --text-2:      #334d6e;
  --text-3:      #6b88a8;
  --border:      #b8d8f8;
  --border-2:    #8bbde8;
  --hairline:    rgba(14,100,235,0.07);

  --brand:       #2563eb;
  --brand-2:     #1d4ed8;
  --brand-soft:  rgba(37,99,235,0.10);
  --cyan:        #0ea5e9;
  --cyan-soft:   rgba(14,165,233,0.13);
  --green:       #10b981;
  --green-soft:  rgba(16,185,129,0.12);
  --amber:       #f59e0b;
  --amber-soft:  rgba(245,158,11,0.13);
  /* Held: a program started but not progressing. Deliberately a colder yellow
     than --amber so "Held" and "Idle" do not read as the same state. */
  --yellow:      #ca8a04;
  --yellow-soft: rgba(202,138,4,0.13);
  --red:         #ef4444;
  --red-soft:    rgba(239,68,68,0.12);
  --violet:      #7c3aed;
  --violet-soft: rgba(124,58,237,0.12);

  --shadow-sm:   0 1px 2px rgba(15,27,45,0.06), 0 1px 3px rgba(15,27,45,0.04);
  --shadow-md:   0 4px 12px rgba(15,27,45,0.06), 0 2px 4px rgba(15,27,45,0.04);
  --shadow-lg:   0 18px 48px rgba(15,27,45,0.12), 0 6px 16px rgba(15,27,45,0.06);
  --shadow-rail: 0 8px 30px rgba(8,15,30,0.18);

  --r-sm: 8px;  --r-md: 12px; --r-lg: 16px; --r-xl: 22px;
  --ease: cubic-bezier(.22,.61,.36,1);
  color-scheme: light;
}

[data-theme="dark"] {
  --bg:          #0a1422;
  --bg-2:        #0d1a2c;
  --surface:     #121f33;
  --surface-2:   #16263f;
  --surface-3:   #1c2f4a;
  --frost:       rgba(18,31,51,0.66);
  --rail:        #0a1422;
  --rail-2:      #101e33;
  --rail-text:   #cdd9ec;
  --rail-sub:    #6b7e9c;
  --rail-active: #3b82f6;

  --text:        #eef3fb;
  --text-2:      #aab8cd;
  --text-3:      #6b7e9c;
  --border:      rgba(255,255,255,0.09);
  --border-2:    rgba(255,255,255,0.14);
  --hairline:    rgba(255,255,255,0.06);

  --brand:       #3b82f6;
  --brand-2:     #2563eb;
  --brand-soft:  rgba(59,130,246,0.16);
  --cyan:        #38bdf8;
  --cyan-soft:   rgba(56,189,248,0.16);
  --green:       #34d399;
  --green-soft:  rgba(52,211,153,0.15);
  --amber:       #fbbf24;
  --amber-soft:  rgba(251,191,36,0.15);
  --yellow:      #e3c14a;
  --yellow-soft: rgba(227,193,74,0.15);
  --red:         #f87171;
  --red-soft:    rgba(248,113,113,0.16);
  --violet:      #a78bfa;
  --violet-soft: rgba(167,139,250,0.16);

  --shadow-sm:   0 1px 2px rgba(0,0,0,0.4);
  --shadow-md:   0 6px 18px rgba(0,0,0,0.4);
  --shadow-lg:   0 22px 54px rgba(0,0,0,0.55);
  --shadow-rail: 0 8px 30px rgba(0,0,0,0.5);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
::selection { background: var(--brand-soft); }

html { height: 100%; }
body {
  font-family: 'IBM Plex Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .5s var(--ease), color .5s var(--ease);
}
.mono { font-family: 'IBM Plex Mono', ui-monospace, monospace; font-feature-settings: "tnum" 1; }
.tnum { font-variant-numeric: tabular-nums; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* ── APP FRAME ───────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--rail-w, 248px) 1fr;
  height: 100vh;
  transition: grid-template-columns .32s var(--ease);
}
.app.rail-collapsed { --rail-w: 76px; }

/* ── SIDEBAR ─────────────────────────────────────────────────────────── */
.rail {
  background: var(--rail);
  color: var(--rail-text);
  display: flex; flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.05);
  position: relative; z-index: 40;
  overflow: hidden;
}
.rail-head {
  height: 64px; flex-shrink: 0;
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.brandmark { width: 34px; height: 34px; flex-shrink: 0; display: block; }
.brand-words { min-width: 0; transition: opacity .2s; }
.brand-words .bw-name { font-size: 14px; font-weight: 700; letter-spacing: -0.2px; color: #fff; white-space: nowrap; }
.brand-words .bw-sub  { font-size: 10.5px; color: var(--rail-sub); white-space: nowrap; letter-spacing: .3px; }
.rail-collapsed .brand-words { opacity: 0; pointer-events: none; }

.rail-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 12px 12px 8px; }
.rail-scroll::-webkit-scrollbar { width: 0; }
.nav-group-label {
  font-size: 10px; font-weight: 600; letter-spacing: 1.4px; text-transform: uppercase;
  color: var(--rail-sub); padding: 14px 12px 7px; white-space: nowrap;
}
.rail-collapsed .nav-group-label { opacity: 0; height: 8px; padding: 6px 0; }

.nav-item {
  display: flex; align-items: center; gap: 13px;
  height: 42px; padding: 0 13px; margin: 2px 0;
  border-radius: 10px; cursor: pointer;
  color: var(--rail-text); text-decoration: none;
  font-size: 13.5px; font-weight: 500;
  position: relative; white-space: nowrap;
  transition: background .16s, color .16s;
}
.nav-item .ni-ico { width: 20px; height: 20px; flex-shrink: 0; display: grid; place-items: center; }
.nav-item .ni-ico svg { width: 19px; height: 19px; stroke: currentColor; }
.nav-item .ni-label { flex: 1; transition: opacity .2s; }
.nav-item .ni-badge {
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 20px;
  background: var(--red); color: #fff; font-family: 'IBM Plex Mono', monospace;
}
.nav-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-item.active { background: linear-gradient(100deg, rgba(37,99,235,0.30), rgba(37,99,235,0.12)); color: #fff; }
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; border-radius: 0 3px 3px 0; background: var(--rail-active);
}
.rail-collapsed .nav-item { justify-content: center; padding: 0; }
.rail-collapsed .nav-item .ni-label, .rail-collapsed .nav-item .ni-badge { opacity: 0; width: 0; pointer-events: none; }

/* tooltip when collapsed */
.rail-collapsed .nav-item[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--rail-2); color: #fff; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 7px; white-space: nowrap; z-index: 60;
  box-shadow: var(--shadow-rail); border: 1px solid rgba(255,255,255,0.08);
}
.rail-foot { flex-shrink: 0; padding: 10px 12px 14px; border-top: 1px solid rgba(255,255,255,0.06); }
.rail-user {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 11px;
  cursor: pointer; transition: background .15s;
}
.rail-user:hover { background: rgba(255,255,255,0.06); }
.avatar {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
}
.rail-user-meta { min-width: 0; transition: opacity .2s; }
.rail-user-meta .ru-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; }
.rail-user-meta .ru-role { font-size: 11px; color: var(--rail-sub); white-space: nowrap; }
.rail-collapsed .rail-user-meta { opacity: 0; width: 0; }

.rail-toggle {
  position: absolute; top: 74px; right: -12px; z-index: 50;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-sm); transition: transform .3s var(--ease);
}
.rail-toggle:hover { color: var(--brand); }
.rail-toggle svg { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.rail-collapsed .rail-toggle svg { transform: rotate(180deg); }

/* ── MAIN COLUMN ─────────────────────────────────────────────────────── */
.col { display: flex; flex-direction: column; min-width: 0; height: 100vh; }

.topbar {
  height: 64px; flex-shrink: 0;
  background: var(--frost);
  backdrop-filter: blur(16px) saturate(160%); -webkit-backdrop-filter: blur(16px) saturate(160%);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px; padding: 0 22px;
  position: relative; z-index: 30;
}
.tb-title { min-width: 0; }
.tb-title h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.3px; line-height: 1.1; }
.tb-title .tb-crumb { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.tb-spacer { flex: 1; }

.search {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; height: 38px; width: 260px;
  transition: border-color .15s, box-shadow .15s, width .2s;
}
.search:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); width: 300px; }
.search svg { width: 16px; height: 16px; stroke: var(--text-3); flex-shrink: 0; }
.search input { border: none; background: none; outline: none; font-size: 13px; color: var(--text); width: 100%; font-family: inherit; }
.search .kbd { font-size: 10.5px; color: var(--text-3); border: 1px solid var(--border-2); border-radius: 5px; padding: 1px 5px; font-family: 'IBM Plex Mono', monospace; }

.shift-pill {
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 13px; height: 38px;
}
.shift-pill .sp-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.shift-pill .sp-meta { line-height: 1.15; }
.shift-pill .sp-k { font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); }
.shift-pill .sp-v { font-size: 12.5px; font-weight: 600; }
.clock { text-align: right; line-height: 1.15; padding-right: 2px; }
.clock .clk-time { font-size: 14px; font-weight: 600; font-family: 'IBM Plex Mono', monospace; letter-spacing: .5px; }
.clock .clk-date { font-size: 10.5px; color: var(--text-3); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  position: relative; transition: all .15s;
}
.icon-btn:hover { color: var(--brand); border-color: var(--border-2); background: var(--surface); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn .dot-badge {
  position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--red); border: 2px solid var(--surface);
}

/* ── PAGE / SCROLL AREA ──────────────────────────────────────────────── */
.page { flex: 1; overflow-y: auto; padding: 24px; scroll-behavior: smooth; }
.page-in { max-width: 1560px; margin: 0 auto; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.view { animation: viewIn .4s var(--ease) both; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 4px 2px 14px; }
.section-head h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.2px; }
.section-head .sh-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.section-head + .section-head { margin-top: 26px; }

/* ── BUTTONS / CHIPS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  font-family: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  border-radius: 9px; padding: 8px 15px; border: 1px solid transparent;
  transition: all .15s; white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; stroke: currentColor; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 4px 12px var(--brand-soft); }
.btn-primary:hover { background: var(--brand-2); transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface); border-color: var(--border-2); color: var(--text); }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 8px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  font-family: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: var(--text-3);
  padding: 6px 13px; border-radius: 7px; transition: all .15s; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--surface); color: var(--brand); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .seg button.active { background: var(--surface-3); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; }

/* status semantic */
.s-run    { --c: var(--green);  --cs: var(--green-soft); }
.s-idle   { --c: var(--amber);  --cs: var(--amber-soft); }
.s-alarm  { --c: var(--red);    --cs: var(--red-soft); }
/* Held is blue, not a second amber. Idle and Held were both in the
   yellow-orange family and could not be told apart on the factory floor. */
.s-held   { --c: #2f6fe0;      --cs: rgba(47,111,224,.13); }

/* Operating-mode chip on the machine card. Monospace so AUTO / JOG / MDI line
   up across a grid of cards and the eye can scan the column. */
.mode-badge   { font-family: ui-monospace, "SF Mono", Menlo, monospace;
                letter-spacing:.04em; font-size:10px; }
/* AUTO was grey on grey and read as disabled - the one mode that means the
   machine can actually run was the only one you could not see. It is cyan now:
   legible, and distinct from the green RUNNING badge it usually sits beside,
   so the two do not blur into one green smear. */
.mode-auto    { --c: var(--cyan);  --cs: var(--cyan-soft); }
/* Every manual mode - JOG, MDI, EDIT, MPG, REF - means a person is at the
   control. One colour for all of them, because that is the distinction that
   matters when you are scanning a wall of cards. */
.mode-manual  { --c: var(--brand); --cs: var(--brand-soft); }
.s-disc   { --c: #8b5cf6;      --cs: rgba(139,92,246,.12); }   /* CNC unreachable */

/* Disconnected block — replaces the utilisation bars, whose 0% readings are
   indistinguishable from a machine that simply sat idle. */
.mc-disc      { padding:10px 12px; border:1px solid rgba(139,92,246,.35);
                border-radius:8px; background:rgba(139,92,246,.08); }
.mc-disc-hd   { display:flex; align-items:center; gap:6px; color:#f97316;
                font-weight:700; font-size:11px; letter-spacing:.04em; margin-bottom:8px; }
.mc-disc-hd svg { width:14px; height:14px; }
.mc-disc-row  { display:flex; justify-content:space-between; align-items:center;
                font-size:11.5px; padding:2px 0; color:var(--text-3); }
.mc-disc-row b { color:var(--text); font-weight:600; }
.mc-disc-ok   { color:var(--green) !important; }
.s-maint  { --c: var(--brand);  --cs: var(--brand-soft); }
.s-off    { --c: var(--text-3); --cs: var(--surface-3); }
.chip.byst { background: var(--cs); color: var(--c); }
.chip.byst .chip-dot { background: var(--c); }

/* ── CARD ────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-sm);
  transition: box-shadow .25s var(--ease), transform .25s var(--ease), border-color .2s;
}
.card-pad { padding: 18px; }

/* ── KPI ─────────────────────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 15px 16px 13px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
  transition: transform .22s var(--ease), box-shadow .22s var(--ease);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi-ico { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--cs, var(--brand-soft)); color: var(--c, var(--brand)); }
.kpi-ico svg { width: 18px; height: 18px; stroke: currentColor; }
.kpi-trend { font-size: 11.5px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; display: inline-flex; align-items: center; gap: 3px; }
.kpi-trend.up { color: var(--green); } .kpi-trend.down { color: var(--red); } .kpi-trend.flat { color: var(--text-3); }
.kpi-val { font-size: 28px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; line-height: 1; letter-spacing: -0.5px; }
.kpi-val .ku { font-size: 14px; color: var(--text-3); font-weight: 600; margin-left: 2px; }
.kpi-lbl { font-size: 11.5px; color: var(--text-3); margin-top: 6px; font-weight: 500; }
.kpi-spark { position: absolute; right: 0; bottom: 0; width: 86px; height: 38px; opacity: .9; }

/* ── MACHINE CARD ────────────────────────────────────────────────────── */
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; }
.mcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden; position: relative;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .2s;
  display: flex; flex-direction: column;
}
.mcard::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--text-3)); }
.mcard:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.mcard.alarm { border-color: color-mix(in srgb, var(--red) 45%, var(--border)); }
.mc-head { padding: 15px 17px 12px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mc-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.mc-thumb {
  width: 42px; height: 42px; border-radius: 10px; flex-shrink: 0; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-2); border: 1px solid var(--border);
}
.mc-thumb svg { width: 22px; height: 22px; stroke: currentColor; }
.mc-name { font-size: 15px; font-weight: 700; letter-spacing: -0.2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-model { font-size: 11px; color: var(--text-3); font-family: 'IBM Plex Mono', monospace; margin-top: 1px; }
.mc-live { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; display: inline-flex; align-items: center; gap: 5px; color: var(--c); }
.mc-live .lv-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.mc-live .lv-dot.beat { animation: beat 2s ease infinite; box-shadow: 0 0 0 0 var(--c); }
@keyframes beat { 0%{box-shadow:0 0 0 0 var(--cs);} 60%{box-shadow:0 0 0 7px transparent;} 100%{box-shadow:0 0 0 0 transparent;} }

.mc-alarm-banner { background: var(--red-soft); color: var(--red); font-size: 11.5px; font-weight: 600; padding: 6px 17px; display: flex; align-items: center; gap: 7px; border-top: 1px solid color-mix(in srgb, var(--red) 25%, transparent); }
.mc-alarm-banner svg { width: 14px; height: 14px; }

.mc-metrics { padding: 6px 17px 4px; display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; }
.mc-metric { text-align: center; padding: 7px 4px; }
.mc-metric .mm-val { font-size: 19px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; line-height: 1; letter-spacing: -0.5px; }
.mc-metric .mm-lbl { font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-top: 4px; }

.mc-bars { padding: 10px 17px 6px; display: flex; flex-direction: column; gap: 9px; border-top: 1px solid var(--hairline); }
.bar-row .bar-hd { display: flex; justify-content: space-between; font-size: 10.5px; margin-bottom: 4px; }
.bar-row .bar-k { color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.bar-row .bar-v { font-weight: 700; font-family: 'IBM Plex Mono', monospace; }
.track { height: 6px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.track .fill { height: 100%; border-radius: 4px; transition: width .9s var(--ease); }

.mc-foot { margin-top: auto; padding: 11px 17px; border-top: 1px solid var(--hairline); display: flex; align-items: center; gap: 9px; }
.op { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
.op .op-av { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-3); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-2); flex-shrink: 0; }
.op .op-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.op .op-k { font-size: 9.5px; color: var(--text-3); }

/* ── MACHINE CARD v2 (rich, reference-matched) ──────────────────────── */
.mc-badges { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; align-content: flex-start; max-width: 150px; }
.badge2 {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
  padding: 3px 9px; border-radius: 20px; background: var(--cs); color: var(--c); white-space: nowrap;
}
.badge2 .b2-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c); }
.badge2 .b2-dot.beat { animation: beat 2s ease infinite; }

.mc-banner {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 17px; font-size: 11.5px; font-weight: 500;
  border-top: 1px solid var(--hairline);
}
.mc-banner .bn-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.mc-banner.off  { background: var(--red-soft);  color: var(--red); }
.mc-banner.off .bn-dot { background: var(--red); animation: beat 1.4s infinite; }
.mc-banner.late { background: var(--amber-soft); color: var(--amber); }
.mc-banner.late .bn-dot { background: var(--amber); animation: beat 1.4s infinite; }
.mc-banner b { font-weight: 700; }

.mc-soft-grid { padding: 6px 14px 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mc-soft { border-radius: 11px; padding: 9px 11px; text-align: center; border: 1px solid var(--border); }
.mc-soft .ms-lbl { font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--text-2); }
.mc-soft .ms-val { font-size: 17px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; margin: 4px 0 2px; line-height: 1; }
.mc-soft .ms-sub { font-size: 9.5px; color: var(--text-3); }
.mc-soft.tint-green  { background: var(--green-soft);  border-color: color-mix(in srgb, var(--green) 18%, transparent); }
.mc-soft.tint-green  .ms-val { color: var(--green); }
.mc-soft.tint-blue   { background: var(--brand-soft);  border-color: color-mix(in srgb, var(--brand) 18%, transparent); }
.mc-soft.tint-blue   .ms-val { color: var(--brand); }
.mc-soft.tint-violet { background: var(--violet-soft); border-color: color-mix(in srgb, var(--violet) 18%, transparent); }
.mc-soft.tint-violet .ms-val { color: var(--violet); }
.mc-soft.tint-cyan   { background: rgba(14,165,233,.1); border-color: rgba(14,165,233,.2); }
.mc-soft.tint-cyan   .ms-val { color: var(--cyan); }

.mc-parts2 { padding: 10px 14px; display: grid; grid-template-columns: 1fr 1fr; }
.mc-parts2 .part2 { text-align: center; }
.mc-parts2 .part2 + .part2 { border-left: 1px solid var(--hairline); }
.mc-parts2 .p2-val { font-size: 24px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; line-height: 1; letter-spacing: -0.5px; }
.mc-parts2 .p2-lbl { font-size: 10.5px; color: var(--text-3); margin-top: 4px; }

.mc-alarm-row { display: flex; align-items: center; gap: 7px; padding: 8px 14px; font-size: 12.5px; font-weight: 600; border-top: 1px solid var(--hairline); }
.mc-alarm-row svg { width: 16px; height: 16px; }
.mc-alarm-row.ok  { color: var(--green); }
.mc-alarm-row.bad { color: var(--red); background: var(--red-soft); }

.bar-row .bar-sep { color: var(--text-3); font-weight: 500; }
/* Two real segments side by side. The background used to be tinted to imply a
   second half that was never actually drawn. */
.track.dual { background: var(--surface-3); display: flex; }
.track.dual .fill { border-radius: 0; }
.track.dual .fill:first-child { border-radius: 4px 0 0 4px; }
.track.dual .fill:last-child  { border-radius: 0 4px 4px 0; }

.op-input {
  flex: 1; min-width: 0; border: 1px solid transparent; background: transparent;
  font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text);
  border-radius: 7px; padding: 5px 8px; outline: none; transition: all .14s;
}
.op-input:hover { border-color: var(--border); background: var(--surface-2); }
.op-input:focus { border-color: var(--brand); background: var(--surface-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.op-input::placeholder { color: var(--text-3); font-weight: 500; }
.mc-gear { width: 32px; height: 32px; flex-shrink: 0; }
.mc-gear svg { width: 16px; height: 16px; }
.mc-ts { font-size: 10px; color: var(--text-3); text-align: center; padding: 7px 14px; border-top: 1px solid var(--hairline); font-family: 'IBM Plex Mono', monospace; }

/* ── TABLE ───────────────────────────────────────────────────────────── */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); font-weight: 600; text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.tbl td { font-size: 13px; padding: 12px 14px; border-bottom: 1px solid var(--hairline); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--surface-2); }

/* ── GAUGE / CHART HELPERS ───────────────────────────────────────────── */
.gauge-wrap { display: grid; place-items: center; position: relative; }
.gauge-center { position: absolute; text-align: center; }
.gauge-center .gc-val { font-size: 26px; font-weight: 700; font-family: 'IBM Plex Mono', monospace; line-height: 1; }
.gauge-center .gc-lbl { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: .6px; margin-top: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend .lg { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-2); }
.legend .lg-sq { width: 10px; height: 10px; border-radius: 3px; }

/* ── AI PANEL ────────────────────────────────────────────────────────── */
/* Floating AI logo — orb with halo + gentle bob animation */
/* OLD simple AI FAB — only tooltip appears on hover */
.ai-fab {
  position: fixed; bottom: 26px; right: 26px; z-index: 80;
  width: 60px; height: 60px; border-radius: 50%; cursor: pointer; border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(37,99,235,.45), inset 0 -6px 14px rgba(0,0,0,.22), inset 0 6px 14px rgba(255,255,255,.28);
  transition: transform .28s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  animation: aiBlobFloat 3.4s ease-in-out infinite;
  overflow: visible;
}
/* glossy highlight — makes the blob read as 3D */
.ai-fab::before {
  content: ''; position: absolute; top: 8px; left: 13px;
  width: 22px; height: 15px; border-radius: 50%;
  background: radial-gradient(ellipse at 40% 35%, rgba(255,255,255,.62), transparent 70%);
  pointer-events: none;
}
/* soft halo pulse */
.ai-fab::after {
  content: ''; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(124,58,237,.45);
  opacity: 0; animation: aiBlobHalo 3.4s ease-out infinite; pointer-events: none;
}
@keyframes aiBlobFloat {
  0%,100% { transform: translateY(0)     scale(1,1); }
  50%     { transform: translateY(-7px)  scale(1.02,.98); }
}
@keyframes aiBlobHalo {
  0%   { opacity: .5; transform: scale(.9); }
  70%  { opacity: 0;  transform: scale(1.35); }
  100% { opacity: 0;  transform: scale(1.35); }
}
.ai-fab:hover {
  box-shadow: 0 18px 44px rgba(37,99,235,.6), inset 0 -6px 14px rgba(0,0,0,.22), inset 0 6px 14px rgba(255,255,255,.32);
  animation-play-state: paused;
  transform: translateY(-4px) scale(1.07);
}
.ai-fab.hidden { transform: scale(0); opacity: 0; pointer-events: none; }

/* ── Blob eyes ─────────────────────────────────────────────────────── */
.ai-eyes { display: flex; gap: 9px; align-items: center; pointer-events: none; }
.ai-eye {
  width: 13px; height: 13px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.28), inset 0 -2px 3px rgba(0,0,0,.12);
  transform-origin: center;
  /* blink timing is driven from JS (_aiStartBlinking) so it feels random */
}
/* click squash — Eney-style bounce */
.ai-fab.poke { animation: aiPoke .45s cubic-bezier(.34,1.56,.64,1); }
@keyframes aiPoke {
  0%   { transform: scale(1,1); }
  30%  { transform: scale(1.18,.8) translateY(5px); }
  55%  { transform: scale(.9,1.14) translateY(-7px); }
  75%  { transform: scale(1.05,.96) translateY(1px); }
  100% { transform: scale(1,1) translateY(0); }
}
/* thinking wobble + eye-roll live in ai-float.css (loaded last) */

/* "Lumo Bot" tooltip — appears only on hover */
.ai-fab-tip {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%) translateX(8px);
  padding: 8px 14px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #fff;
  font-size: 13px; font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: 10px;
  border: 1px solid rgba(124,58,237,0.4);
  box-shadow: 0 8px 24px rgba(0,0,0,0.45), 0 0 18px rgba(124,58,237,0.25);
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .22s var(--ease), transform .28s var(--ease);
}
.ai-fab-tip::after {
  /* arrow */
  content: '';
  position: absolute; right: -5px; top: 50%;
  transform: translateY(-50%) rotate(45deg);
  width: 9px; height: 9px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border-right: 1px solid rgba(124,58,237,0.4);
  border-top:   1px solid rgba(124,58,237,0.4);
}
.ai-fab:hover .ai-fab-tip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* AI panel header buttons (clear, fullscreen, close) */
.ai-head-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px; border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.1); color: rgba(255,255,255,.85);
  cursor: pointer; flex-shrink: 0;
  transition: all .18s var(--ease);
}
.ai-head-btn:hover {
  background: rgba(255,255,255,.2);
  border-color: var(--brand);
  color: #fff;
  transform: translateY(-1px);
}
.ai-head-btn svg { width: 16px; height: 16px; }

/* AI panel fullscreen mode */
.ai-panel.fullscreen {
  top: 0 !important; left: 0 !important; right: auto !important; bottom: auto !important;
  width: 100vw !important; max-width: 100vw !important;
  height: 100vh !important;
  border: none; border-radius: 0;
  transform: none !important;
}
.ai-panel.fullscreen .ai-body { max-width: 900px; margin: 0 auto; width: 100%; }
.ai-panel.fullscreen .ai-presets { max-width: 900px; margin: 0 auto; width: 100%; }
.ai-panel.fullscreen .ai-input { max-width: 900px; margin: 0 auto; width: 100%; }

/* AI thinking animation — three bouncing dots */
.ai-thinking {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 12px 16px !important;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.ai-thinking .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--brand);
  animation: aiThink 1.3s ease-in-out infinite;
}
.ai-thinking .dot:nth-child(2) { animation-delay: 0.15s; }
.ai-thinking .dot:nth-child(3) { animation-delay: 0.30s; }
.ai-thinking .label {
  font-size: 11.5px; color: var(--text-3); margin-left: 4px;
  font-style: italic;
}
@keyframes aiThink {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-7px); opacity: 1; }
}


/* Scrim disabled — page stays transparent & fully clickable while AI is open */
.ai-scrim { display: none !important; }

/* ── Floating AI panel — draggable card, edge-snap ─────────────────── */
.ai-panel {
  position: fixed; top: 80px; right: 26px; z-index: 100;
  width: 390px; max-width: 94vw;
  height: min(600px, calc(100vh - 120px));
  background: var(--surface);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 22px;
  box-shadow: 0 4px 12px rgba(0,0,0,.2), 0 24px 60px rgba(0,0,0,.42), inset 0 1px 0 rgba(255,255,255,.06);
  display: flex; flex-direction: column; overflow: hidden;
  opacity: 0; transform: scale(.9) translateY(16px); pointer-events: none;
  transition: opacity .26s var(--ease), transform .3s cubic-bezier(.34,1.56,.64,1);
}
.ai-panel.open { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
/* while dragging — no transition lag, slight lift */
.ai-panel.dragging {
  transition: none !important;
  cursor: grabbing;
  box-shadow: 0 12px 24px rgba(0,0,0,.3), 0 40px 90px rgba(0,0,0,.5);
  transform: scale(1.015) !important;
}

/* ── Edge-snap collapsed sliver ────────────────────────────────────── */
.ai-panel.snapped {
  width: 8px !important; min-width: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: linear-gradient(180deg, #2563eb, #7c3aed);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(124,58,237,.6);
  cursor: pointer;
}
.ai-panel.snapped > * { opacity: 0; pointer-events: none; transition: opacity .12s; }
.ai-panel.snapped::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.4), transparent);
  animation: aiSliverGlow 2.4s ease-in-out infinite;
}
@keyframes aiSliverGlow {
  0%,100% { opacity: .3; } 50% { opacity: .9; }
}
/* invisible hover catcher so the sliver is easy to grab */
.ai-edge-sensor {
  position: fixed; z-index: 99; display: none;
  background: transparent;
}
.ai-edge-sensor.active { display: block; }

.ai-head { padding: 14px 16px; display: flex; align-items: center; gap: 11px; border-bottom: 1px solid var(--border); background: linear-gradient(120deg, var(--brand-soft), transparent); cursor: grab; user-select: none; }
.ai-head:active { cursor: grabbing; }
.ai-head .ai-ava { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg,#2563eb,#7c3aed); display: grid; place-items: center; color: #fff; }
.ai-head .ai-ava svg { width: 20px; height: 20px; }
.ai-head h3 { font-size: 14px; font-weight: 700; color: #fff; }
.ai-head .ai-sub { font-size: 11px; color: rgba(255,255,255,.6); display: flex; align-items: center; gap: 5px; }
.ai-head .ai-sub .pulse { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: beat 2s infinite; }
.ai-body { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 14px; background: none; }
/* Floating bubbles — each message is its own card with a drop shadow */
.ai-msg {
  max-width: 88%; padding: 12px 15px; border-radius: 18px;
  font-size: 13px; line-height: 1.55;
  animation: aiMsgIn .32s cubic-bezier(.34,1.56,.64,1);
}
@keyframes aiMsgIn {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-msg.bot {
  background: var(--surface-2);
  border: 1px solid rgba(255,255,255,.09);
  border-bottom-left-radius: 6px; align-self: flex-start;
  box-shadow: 0 2px 6px rgba(0,0,0,.16), 0 8px 20px rgba(0,0,0,.22);
}
.ai-msg.me {
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  border-bottom-right-radius: 6px; align-self: flex-end;
  box-shadow: 0 2px 6px rgba(37,99,235,.28), 0 8px 22px rgba(124,58,237,.32);
}
.ai-msg.bot strong { color: var(--brand); }

/* ── Feedback (thumbs) under each AI reply ─────────────────────────── */
.ai-fb { display: flex; gap: 6px; margin-top: 8px; }
.ai-fb button {
  width: 26px; height: 26px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: rgba(255,255,255,.05);
  color: var(--text-3); display: grid; place-items: center; font-size: 12px;
  transition: all .15s var(--ease);
}
.ai-fb button:hover { transform: translateY(-2px); border-color: var(--brand); color: var(--brand); }
.ai-fb button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.ai-tbl { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 12px; }
.ai-tbl th, .ai-tbl td { padding: 4px 8px; border: 1px solid var(--border); text-align: left; }
.ai-tbl th { background: rgba(59,130,246,.12); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .3px; }
.ai-tbl td { font-variant-numeric: tabular-nums; }
.ai-tbl tr:nth-child(even) td { background: rgba(255,255,255,.03); }
.ai-h2 { font-size: 14px; font-weight: 700; margin: 8px 0 4px; color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 3px; }
.ai-h3 { font-size: 13px; font-weight: 600; margin: 6px 0 2px; color: var(--text); }
.ai-li { padding-left: 14px; position: relative; margin: 2px 0; }
.ai-li::before { content: '•'; position: absolute; left: 2px; color: var(--brand); font-weight: 700; }
.ai-usage-panel { border-bottom: 1px solid var(--border); background: var(--surface); max-height: 420px; overflow-y: auto; }
.ai-usage-card { padding: 16px 18px; position: relative; }
.ai-usage-close { position: absolute; top: 10px; right: 14px; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; }
.ai-usage-close:hover { color: var(--text); }
.ai-usage-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.ai-usage-model { font-size: 11px; color: var(--text-3); margin-bottom: 12px; }
.ai-usage-section { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin: 14px 0 6px; border-top: 1px solid var(--border); padding-top: 10px; }
.ai-usage-section:first-of-type { border-top: none; margin-top: 0; }
.ai-usage-bar-wrap { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; margin-bottom: 10px; overflow: hidden; }
.ai-usage-bar { height: 100%; border-radius: 3px; transition: width .4s; }
.ai-usage-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; color: var(--text-2); }
.ai-usage-row strong { color: var(--text); }
.ai-usage-hint { font-size: 10px; color: var(--text-3); margin-top: 8px; text-align: center; }
.ai-hist-list { max-height: 280px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.ai-hist-user, .ai-hist-bot { font-size: 12px; padding: 6px 10px; border-radius: 8px; line-height: 1.4; }
.ai-hist-user { background: rgba(59,130,246,.15); align-self: flex-end; text-align: right; max-width: 85%; }
.ai-hist-bot { background: rgba(255,255,255,.06); align-self: flex-start; max-width: 85%; }
.ai-hist-label { font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: .4px; margin-right: 6px; color: var(--brand); }
.ai-hist-bot .ai-hist-label { color: rgba(255,255,255,.5); }
.ai-hist-text { color: var(--text-2); }
.ai-hist-load { width: 100%; padding: 8px; border-radius: 8px; border: 1px solid var(--brand); background: rgba(59,130,246,.1); color: var(--brand); font-size: 12px; font-weight: 600; cursor: pointer; margin-top: 6px; transition: all .15s; }
.ai-hist-load:hover { background: var(--brand); color: #fff; }
.ai-sess-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; transition: all .15s; margin-bottom: 3px; }
.ai-sess-row:hover { background: rgba(99,102,241,.08); border-color: rgba(99,102,241,.2); }
.ai-sess-active { background: rgba(99,102,241,.15) !important; border-color: rgba(99,102,241,.4) !important; }
.ai-download-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; margin: 6px 0; border-radius: 8px; background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff !important; text-decoration: none; font-weight: 600; font-size: 12px; transition: all .15s; }
.ai-download-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(37,99,235,.4); }
.ai-presets { padding: 0 18px 8px; display: flex; gap: 7px; flex-wrap: wrap; }
.ai-preset { font-size: 11.5px; font-weight: 600; padding: 6px 11px; border-radius: 20px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); cursor: pointer; transition: all .15s; }
.ai-preset:hover { border-color: var(--brand); color: var(--brand); }
.ai-input { padding: 14px 16px; border-top: 1px solid var(--border); display: flex; gap: 9px; align-items: flex-end; }
.ai-input textarea { flex: 1; resize: none; border: 1px solid var(--border); background: var(--surface-2); border-radius: 12px; padding: 10px 13px; font-family: inherit; font-size: 13px; color: var(--text); outline: none; max-height: 90px; }
.ai-input textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.ai-send { width: 40px; height: 40px; border-radius: 12px; border: none; background: var(--brand); color: #fff; cursor: pointer; display: grid; place-items: center; flex-shrink: 0; }
.ai-send svg { width: 18px; height: 18px; }

/* ── MODAL ───────────────────────────────────────────────────────────── */
.modal-scrim { position: fixed; inset: 0; background: rgba(8,15,30,.5); backdrop-filter: blur(3px); z-index: 110; display: none; align-items: center; justify-content: center; padding: 24px; }
.modal-scrim.open { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl); width: 100%; max-width: 960px; max-height: 90vh; overflow: hidden; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; animation: viewIn .26s var(--ease); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 16px; font-weight: 700; }
.modal-body { overflow-y: auto; padding: 22px; }

/* ── MISC ────────────────────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.divider { height: 1px; background: var(--border); margin: 18px 0; }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { background: var(--rail); color: #fff; font-size: 13px; font-weight: 500; padding: 11px 17px; border-radius: 11px; box-shadow: var(--shadow-rail); display: flex; align-items: center; gap: 9px; animation: viewIn .3s var(--ease); }
.toast svg { width: 16px; height: 16px; }

/* ── RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 1180px) { .kpi-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 980px) {
  .app { grid-template-columns: 0 1fr; }
  .rail { position: fixed; left: 0; top: 0; bottom: 0; width: 248px; transform: translateX(-100%); transition: transform .3s var(--ease); }
  .app.rail-open .rail { transform: none; }
  .rail-toggle { display: none; }
  .search { width: 150px; } .search:focus-within { width: 180px; }
}
@media (max-width: 720px) {
  .page { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2,1fr); }
  .shift-pill, .search .kbd, .clock .clk-date { display: none; }
  .mgrid { grid-template-columns: 1fr; }
}
.hide-mobile { }
@media (max-width: 980px) { .menu-btn { display: grid !important; } }
.menu-btn { display: none; }

/* ── FORMS / SETTINGS ────────────────────────────────────────────────── */
.sfield {
  width: 220px; max-width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 9px 12px; font-size: 13px; font-family: inherit; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.sfield:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }
select.sfield { width: 100%; cursor: pointer; }
.flbl { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-3); margin-bottom: 6px; }

.tg { position: relative; display: inline-block; width: 42px; height: 24px; cursor: pointer; }
.tg input { opacity: 0; width: 0; height: 0; }
.tg-track { position: absolute; inset: 0; background: var(--border-2); border-radius: 20px; transition: background .25s; }
.tg-track::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .25s var(--ease); }
.tg input:checked + .tg-track { background: var(--brand); }
.tg input:checked + .tg-track::before { transform: translateX(18px); }

.theme-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 8px; }
.theme-opt {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 13px;
  padding: 18px 12px; cursor: pointer; font-family: inherit; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  transition: all .18s;
}
.theme-opt svg { width: 24px; height: 24px; stroke: currentColor; }
.theme-opt:hover { border-color: var(--border-2); color: var(--text); }
.theme-opt.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px var(--brand-soft); }

.set-cat {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  font-family: inherit; font-size: 13px; font-weight: 500; color: var(--text-2);
  background: none; border: none; border-radius: 10px; padding: 10px 11px; cursor: pointer;
  transition: background .14s, color .14s;
}
.set-cat .ni-ico { width: 18px; height: 18px; display: grid; place-items: center; }
.set-cat .ni-ico svg { width: 17px; height: 17px; stroke: currentColor; }
.set-cat:hover { background: var(--surface-2); color: var(--text); }
.set-cat.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }

/* ── Production Summary selectors ─────────────────────────────────────── */
.ps-sel {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 30px 7px 12px;
  font: 500 13px/1.2 inherit; cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3e%3cpath d='M5.23 7.21a.75.75 0 011.06.02L10 11.06l3.71-3.83a.75.75 0 111.08 1.04l-4.25 4.39a.75.75 0 01-1.08 0L5.21 8.27a.75.75 0 01.02-1.06z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 16px;
  transition: border-color .15s, box-shadow .15s;
}
.ps-sel:hover  { border-color: var(--brand); }
.ps-sel:focus  { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ── Production Summary — responsive ──────────────────────────────────── */
@media (max-width: 720px) {
  .ps-grid { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════════════════════════════════════
   RESPONSIVE — covers phone (<640), tablet (<960), laptop (<1280), desktop
   Goal: machine cards & KPIs reflow cleanly. No content collapse / hidden.
════════════════════════════════════════════════════════════════════════ */

/* Machine card grid — auto-fit so any number of machines stays readable.
   max-width on each card prevents a single card from stretching full width. */
.mgrid, #dash-mgrid, #live-mgrid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)) !important;
  gap: 14px;
  justify-content: start;
}
.mcard { max-width: 460px; }

/* KPI grid responsive */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr) !important; }
}
@media (max-width: 960px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr) !important; }
  /* Analytics 4-col KPI strip */
  .view > div[style*="grid-template-columns:repeat(4,1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Analytics 2-col rows */
  .view > div[style*="grid-template-columns:2fr 1fr"],
  .view > div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}
@media (max-width: 720px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr) !important; }
  /* Status cards (Live Monitoring) */
  .view > div[style*="grid-template-columns:repeat(3,1fr)"] {
    grid-template-columns: 1fr !important;
  }
  /* Side rail collapses to drawer on small screens */
  .section-head {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 10px;
  }
  .section-head .seg, .section-head > div[style*="display:flex"] {
    width: 100%;
    overflow-x: auto;
  }
  /* Tables horizontally scroll */
  .tbl { font-size: 12px; }
  /* Bigger touch targets */
  .btn, button { min-height: 36px; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr !important; }
  .card-pad { padding: 14px 12px !important; }
  h2 { font-size: 18px !important; }
  .mono { font-size: 28px !important; }
  /* Gauges row → single column */
  #live-gauges { grid-template-columns: 1fr !important; }
}

/* Detail modal grid (Last Cycle 4-up KPIs) */
@media (max-width: 720px) {
  .dv-grid.dv-grid-4 { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 480px) {
  .dv-grid.dv-grid-4 { grid-template-columns: 1fr !important; }
}

/* Health dot on machine cards. Only the emergency state pulses — a steady dot
   for everything else, so movement on the page always means something. */
@keyframes hpulse {
  0%, 100% { opacity: 1;   transform: scale(1);    }
  50%      { opacity: .45; transform: scale(1.25); }
}

/* Second half of a split bar. Text colours were being borrowed for this, which
   read as "disabled" rather than "the other half of the measurement". */
:root { --slate: #64748b; --pale: #cbd5e1; --pale-fg: #64748b; --teal: #0d9488; }
:root:not([data-theme="light"]) { --slate: #7c8da5; --pale: #e2e8f0; --pale-fg: #94a3b8; --teal: #2dd4bf; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --slate: #7c8da5; --pale: #e2e8f0; --pale-fg: #94a3b8; --teal: #2dd4bf; } }
:root[data-theme="dark"] { --slate: #7c8da5; --pale: #e2e8f0; --pale-fg: #94a3b8; --teal: #2dd4bf; }

/* ── Machine card polish ──────────────────────────────────────────────────
   The card now carries four bars, a health badge and a metric row. Without a
   clear hierarchy that reads as a wall of numbers, so the work here is spacing
   and weight rather than decoration: labels recede, values lead, and the eye
   gets a resting point between groups.

   Motion is deliberately limited. The cards update in place every ten seconds,
   so anything that animates on data change would twitch continuously; only
   hover and the bars themselves move. */

.mcard {
  transition: transform .18s var(--ease), box-shadow .18s var(--ease),
              border-color .18s var(--ease);
}
.mcard:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0,0,0,.12));
}

/* Bars: label above, figures right, generous room between rows. */
.mc-bars .bar-row + .bar-row { margin-top: 11px; }
.bar-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; margin-bottom: 5px;
}
.bar-k {
  font-size: 10px; font-weight: 600; letter-spacing: .4px;
  text-transform: uppercase; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bar-v { font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.bar-sep { color: var(--text-3); font-weight: 500; margin-left: 4px; }

/* A touch taller than the old 6px: two segments need to be separable at a
   glance, and the colour is doing the work. */
.track, .track.dual { height: 7px; border-radius: 5px; }
.track.dual .fill { transition: width .6s var(--ease); }

/* Metric row: the number is the point, the label is context. */
.mc-metric .mm-val { font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.mc-metric .mm-lbl {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-3);
}

/* Tabular figures everywhere a value updates, so digits do not jitter
   sideways as they change. */
.bar-v, .dv-kpi-v, .dv-field-v, .ms-val { font-variant-numeric: tabular-nums; }

/* Streaming reply — the partial answer while the model is still writing.
   Shown as plain text on purpose; it is replaced by the fully rendered
   message the moment the turn finishes. The caret marks it as still arriving. */
.ai-msg.ai-streaming {
  white-space: pre-wrap;
  opacity: .92;
}
.ai-msg.ai-streaming::after {
  content: "\258B";
  margin-left: 2px;
  animation: aiCaret 1s steps(2, start) infinite;
}
@keyframes aiCaret { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) {
  .ai-msg.ai-streaming::after { animation: none; }
}

/* ── Accessibility: high contrast and reduced motion ─────────────────────────
   Both were switches on the Settings page that did nothing at all. They are
   worth having here rather than being deleted with the rest: a shop floor is
   bright, screens get dirty, and a wall display that animates is a distraction
   in a control room.

   Applied as attributes on <html>, the same way the theme is, so one mechanism
   covers all three and the setting survives a page change without a reload. */
[data-motion="reduced"] *,
[data-motion="reduced"] *::before,
[data-motion="reduced"] *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Contrast is raised by moving the TOKENS, not by overriding rules one by one:
   every component already draws from them, so nothing gets missed and nothing
   needs a second definition to drift out of step. */
[data-contrast="high"] {
  --text:       #000000;
  --text-2:     #1a2432;
  --text-3:     #3d4b5c;   /* was the faintest grey - unreadable in daylight */
  --border:     #64748b;
  --hairline:   #94a3b8;
  --surface-2:  #eef2f7;
}
[data-contrast="high"]:not([data-theme="light"]) {
  --text:       #ffffff;
  --text-2:     #e8eef7;
  --text-3:     #c3cede;
  --border:     #7c8da5;
  --hairline:   #5a6b82;
  --surface-2:  #1c2634;
}
/* Thicker rules and a visible focus ring: the parts that are decoration at
   normal contrast and information at high contrast. */
[data-contrast="high"] .card,
[data-contrast="high"] table th,
[data-contrast="high"] table td { border-color: var(--border) !important; }
[data-contrast="high"] :focus-visible {
  outline: 3px solid var(--brand) !important;
  outline-offset: 2px !important;
}


/* ── Click-and-talk ─────────────────────────────────────────────────────────
   The mic sits inside .ai-input beside send. Three states, and they must be
   distinguishable at a glance on a factory floor: idle is quiet, recording is
   red and pulsing, working is dimmed and unclickable. */
.ai-mic { width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); cursor: pointer; display: grid; place-items: center;
  transition: background .15s, color .15s, border-color .15s; }
.ai-mic svg { width: 18px; height: 18px; }
.ai-mic:hover { border-color: var(--brand); color: var(--brand); }
.ai-mic[data-state="rec"] { background: #E5484D; border-color: #E5484D;
  color: #fff; animation: micPulse 1.15s ease-in-out infinite; }
.ai-mic[data-state="work"] { opacity: .5; cursor: default; }
@keyframes micPulse { 0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,.45); }
                      50%     { box-shadow: 0 0 0 7px rgba(229,72,77,0); } }
@media (prefers-reduced-motion: reduce) { .ai-mic[data-state="rec"] { animation: none; } }

.ai-mic-lang { flex-shrink: 0; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-2); font-family: inherit; font-size: 12px; padding: 0 6px;
  cursor: pointer; outline: none; }
.ai-mic-lang:focus { border-color: var(--brand); }

.ai-mic-hint { padding: 0 16px 10px; font-size: 11.5px; color: var(--text-2);
  min-height: 0; }
.ai-mic-hint:empty { padding: 0; }
.ai-mic-hint.bad { color: #E5484D; }


/* -- Live voice bar --------------------------------------------------------
   Sits above the composer. The timer is the important part: live audio bills
   per minute, so the running cost is visible WHILE it runs, not afterwards. */
.lv-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 16px 0; }
.lv-btn { border: 1px solid var(--brand); background: transparent;
  color: var(--brand); border-radius: 20px; padding: 6px 16px; cursor: pointer;
  font: 600 12.5px/1 inherit; }
.lv-btn:hover { background: var(--brand-soft); }
.lv-btn[data-on="1"] { background: #E5484D; border-color: #E5484D; color: #fff; }
.lv-status { font-size: 11.5px; color: var(--text-2); }
.lv-status.on { color: #12A150; }
.lv-status.bad { color: #E5484D; }
.lv-status.busy { color: var(--brand); }
.lv-meter { font: 500 11.5px/1 ui-monospace, monospace; color: var(--text-2);
  font-variant-numeric: tabular-nums; }
.lv-meter.warn { color: #E5484D; }
.lv-wake { display: flex; align-items: center; gap: 5px; margin-left: auto;
  font-size: 11.5px; color: var(--text-2); cursor: pointer; }
.lv-wake input { margin: 0; cursor: pointer; }

/* ── Team & Access (15 Sep 2026) ─────────────────────────────────────── */
.team-view { display:flex; flex-direction:column; gap:16px; }
.team-head { display:flex; align-items:flex-end; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.team-title { font-size:18px; font-weight:700; color:var(--text); }
.team-sub, .team-meta { font-size:12px; color:var(--text-3); }
.team-card { padding:6px 0; overflow:hidden; }
.team-empty { padding:28px; text-align:center; color:var(--text-3); font-size:13px; }
.team-rows { display:flex; flex-direction:column; }
.team-row { display:grid; grid-template-columns:minmax(200px,2fr) 1.2fr 1fr 1fr 2fr; gap:12px; align-items:center;
  padding:12px 18px; border-bottom:1px solid var(--hairline); }
.team-row:last-child { border-bottom:0; }
.team-row-head { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); font-weight:600; }
.team-user { display:flex; align-items:center; gap:10px; min-width:0; }
.team-avatar { width:34px; height:34px; border-radius:50%; background:var(--brand-soft); color:var(--brand);
  display:grid; place-items:center; font-weight:700; flex-shrink:0; }
.team-name { font-weight:600; font-size:13.5px; color:var(--text); }
.team-you { font-size:10.5px; padding:1px 6px; border-radius:10px; background:var(--surface-3); color:var(--text-2); font-weight:600; }
.team-badge { font-weight:600; font-size:12.5px; padding:2px 8px; border-radius:5px; }
.team-st { font-size:12px; font-weight:600; padding:2px 8px; border-radius:10px; }
.team-st.on { background:rgba(16,185,129,.14); color:#10b981; }
.team-st.off { background:rgba(239,68,68,.14); color:#ef4444; }
.team-st.temp { background:rgba(245,158,11,.16); color:#f59e0b; }
.team-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }
.team-audit summary { cursor:pointer; padding:12px 18px; font-weight:600; font-size:13.5px; }
.team-login { display:grid; grid-template-columns:130px 1fr 1fr; gap:10px; padding:8px 18px; font-size:12.5px;
  border-top:1px solid var(--hairline); color:var(--text-2); }
.team-login.bad { color:#ef4444; }
.team-field { display:flex; flex-direction:column; gap:5px; font-size:12.5px; color:var(--text-2); margin-bottom:10px; }
.team-field .sfield { width:100%; }
.team-grid2 { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.team-label { font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--text-3); font-weight:600; margin:14px 0 8px; }
.team-desc { font-size:12.5px; color:var(--text-2); line-height:1.55; margin:0 0 12px; }
.team-note { font-size:12px; color:var(--text-3); margin-top:8px; line-height:1.5; }
.team-role-opt { display:flex; gap:12px; align-items:flex-start; padding:11px 13px; border:2px solid var(--border);
  border-radius:9px; cursor:pointer; margin-bottom:8px; transition:border-color .15s; }
.team-role-opt.sel { border-color:var(--brand); }
.team-role-opt input { margin-top:3px; }
.team-radio { display:flex; gap:8px; align-items:center; font-size:13px; color:var(--text); margin-bottom:6px; cursor:pointer; }
.team-error { margin-top:10px; padding:9px 12px; border-radius:8px; background:rgba(239,68,68,.12); color:#ef4444; font-size:12.5px; }
.team-foot { display:flex; gap:10px; justify-content:flex-end; align-items:center; margin-top:16px; flex-wrap:wrap; }
.team-secret { display:flex; align-items:center; gap:10px; padding:12px 14px; border-radius:9px; background:var(--surface-2);
  border:1px dashed var(--border-2); }
.team-secret code { flex:1; font-family:'IBM Plex Mono',monospace; font-size:17px; letter-spacing:.04em; word-break:break-all; color:var(--text); }
.team-pages { display:grid; grid-template-columns:1fr 1fr; gap:4px 14px; max-height:50vh; overflow:auto; }
.team-page { display:flex; gap:8px; align-items:center; padding:6px 4px; font-size:13px; color:var(--text); cursor:pointer; border-radius:6px; }
.team-page.changed { background:var(--brand-soft); }
.team-page .team-meta { margin-left:auto; }
.team-perms { display:flex; flex-direction:column; gap:6px; }
.team-perm { display:flex; justify-content:space-between; align-items:center; gap:10px; font-size:13px; color:var(--text); }
.team-perm .sfield { width:170px; }
.team-btnrow { display:flex; gap:8px; flex-wrap:wrap; }
.team-lock { position:fixed; inset:0; z-index:9999; background:rgba(3,10,25,.72); backdrop-filter:blur(6px);
  display:grid; place-items:center; padding:16px; }
.team-lock-card { width:100%; max-width:420px; background:var(--surface); border:1px solid var(--border); border-radius:14px; padding:24px; }
@media (max-width: 820px) {
  .team-row-head { display:none; }
  .team-row { grid-template-columns:1fr 1fr; gap:8px 12px; padding:14px 16px; }
  .team-user, .team-actions { grid-column:1 / -1; }
  .team-actions { justify-content:flex-start; }
  .team-row [data-l]::before { content:attr(data-l); display:block; font-size:10.5px; color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; margin-bottom:2px; }
  .team-grid2, .team-pages { grid-template-columns:1fr; }
  .team-login { grid-template-columns:1fr; gap:2px; }
}

/* Team & Access — ERP grid (17 Sep 2026) */
.team-erp{display:flex;flex-direction:column;gap:2px;max-height:52vh;overflow:auto}
.team-erp-row{display:grid;grid-template-columns:150px 1fr;gap:8px;align-items:center;padding:6px 0;border-bottom:1px solid var(--hairline)}
.team-erp-mod{font-weight:600;font-size:13px}
.team-erp-acts{display:flex;flex-wrap:wrap;gap:4px 14px}
@media (max-width:600px){.team-erp-row{grid-template-columns:1fr}}

/* ERP inside Metal Craft (17 Sep 2026) */
.erp-view{height:calc(100vh - 118px);margin:-8px -8px 0}
.erp-frame{width:100%;height:100%;border:0;border-radius:14px;background:transparent;display:block}
@media (max-width:820px){.erp-view{height:calc(100vh - 96px);margin:-4px}}

/* ── Home: one card per area (views-home.js) ──────────────────────────── */
.home-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(300px,1fr));gap:16px}
.home-card{padding:16px 18px;cursor:pointer;transition:transform .12s ease,box-shadow .12s ease;display:flex;flex-direction:column;gap:10px;min-height:170px}
.home-card:hover,.home-card:focus-visible{transform:translateY(-2px);box-shadow:0 8px 24px rgba(15,23,42,.12);outline:none}
.home-head{display:flex;align-items:center;gap:10px}
.home-ico svg{width:26px;height:26px;display:block}
.home-title{font-size:16px;font-weight:800;flex:1}
.home-open{font-size:12px;color:var(--text-3);font-weight:600}
.home-card:hover .home-open{color:var(--text)}
.home-body{display:flex;flex-direction:column;gap:8px}
.home-stats{display:flex;gap:18px;flex-wrap:wrap}
.home-stat-v{font-size:24px;font-weight:800;line-height:1.1}
.home-stat-l{font-size:11px;color:var(--text-3)}
.home-kpi{font-size:13px;color:var(--text-2)}
.home-kpi span{font-size:22px;font-weight:800;color:var(--text);margin-right:4px}
.home-kpi em{font-style:normal;color:var(--text-3);margin-left:6px;font-size:12px}
.home-sub{font-size:12px;color:var(--text-3);line-height:1.55}
.home-bar{display:flex;height:8px;border-radius:4px;overflow:hidden;background:var(--surface-3)}
.home-bar span{display:block;height:100%}
.home-row{display:flex;justify-content:space-between;gap:8px;font-size:12.5px;padding:2px 0;border-bottom:1px dashed var(--border)}
.home-links{display:flex;gap:6px;flex-wrap:wrap;margin-top:2px}
.home-links a{font-size:11.5px;font-weight:600;padding:3px 9px;border:1px solid var(--border);border-radius:999px;color:var(--text-2);cursor:pointer;background:var(--surface-2)}
.home-links a:hover{color:var(--text);border-color:var(--text-3)}
@media (max-width:520px){.home-grid{grid-template-columns:1fr}}

/* Menu items outside the area opened from Home (app.js _applyArea). */
.rail-scroll .area-off{display:none!important}

/* ── TPM overview (views-tpm.js) ──────────────────────────────────────── */
.tpm-tiles{display:grid;grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:12px;margin-bottom:14px}
.tpm-tile{padding:14px 16px;display:flex;flex-direction:column;gap:3px}
.tpm-l{font-size:10.5px;color:var(--text-3);letter-spacing:.4px;font-weight:700}
.tpm-v{font-size:28px;font-weight:800;line-height:1.15}
.tpm-s{font-size:11.5px;color:var(--text-3)}
.tpm-d{font-size:11.5px;color:var(--text-3);font-weight:600}
.tpm-link{font-size:12px;font-weight:700;color:var(--accent,#2563eb);cursor:pointer}
.tpm-two{display:grid;grid-template-columns:1fr 1fr;gap:14px}
@media (max-width:900px){.tpm-two{grid-template-columns:1fr}}

/* ── Home branding: company logo + watermark ─────────────────────────── */
.home-view{position:relative;isolation:isolate;min-height:calc(100vh - 110px)}
.home-watermark{position:absolute;inset:0;z-index:-1;pointer-events:none;background:no-repeat center 60%/min(46vw,520px) auto;opacity:.06}
[data-theme="dark"] .home-watermark{opacity:.08;filter:grayscale(1) brightness(1.8)}
.home-brand{display:flex;align-items:center;gap:14px;margin:4px 0 18px}
.home-logo{width:56px;height:56px;border-radius:14px;flex:0 0 56px;display:flex;align-items:center;justify-content:center;
  font-weight:800;font-size:20px;color:#fff;background:linear-gradient(135deg,#2563eb,#7c3aed)}
.home-logo.has-img{background:var(--surface);border:1px solid var(--border);padding:6px}
.home-logo img{max-width:100%;max-height:100%;object-fit:contain;display:block}
.home-company{font-size:12px;font-weight:700;color:var(--text-3);letter-spacing:.5px;text-transform:uppercase}
.logo-preview{width:140px;height:140px;border:1px dashed var(--border);border-radius:14px;display:flex;align-items:center;justify-content:center;background:var(--surface-2);overflow:hidden}
.logo-preview img{max-width:90%;max-height:90%;object-fit:contain}

/* ── Account menu (click your name, bottom of the side menu) ─────────── */
.rail-user{cursor:pointer;border-radius:10px;transition:background .12s}
.rail-user:hover,.rail-user:focus-visible{background:var(--surface-2);outline:none}
.user-menu{position:fixed;z-index:1000;min-width:230px;background:var(--surface);border:1px solid var(--border);
  border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,.28);padding:6px;display:flex;flex-direction:column}
.user-menu .um-head{padding:8px 10px 10px;border-bottom:1px solid var(--border);margin-bottom:4px;display:flex;flex-direction:column;gap:2px}
.user-menu .um-head span{font-size:11.5px;color:var(--text-3)}
.user-menu button{all:unset;cursor:pointer;padding:9px 10px;border-radius:8px;font-size:13px;color:var(--text)}
.user-menu button:hover,.user-menu button:focus-visible{background:var(--surface-2)}
.user-menu .um-out{color:var(--red);font-weight:700}

/* ── Top bar search results + bell (views-home.js) ────────────────────── */
.search{position:relative}
.gs-results{position:absolute;top:calc(100% + 6px);left:0;right:0;z-index:1000;background:var(--surface);border:1px solid var(--border);
  border-radius:12px;box-shadow:0 12px 32px rgba(0,0,0,.28);padding:6px;max-height:60vh;overflow:auto}
.gs-item{padding:8px 10px;border-radius:8px;font-size:13px;cursor:pointer;display:flex;gap:10px;align-items:center}
.gs-item.on,.gs-item:hover{background:var(--surface-2)}
.gs-kind{font-size:10.5px;font-weight:700;color:var(--text-3);min-width:62px;text-transform:uppercase;letter-spacing:.3px}
.gs-none{padding:10px;font-size:12.5px;color:var(--text-3)}
#bell-btn{position:relative}
.bell-count{position:absolute;top:2px;right:2px;min-width:17px;height:17px;padding:0 4px;border-radius:9px;background:var(--red);
  color:#fff;font-size:10.5px;font-weight:800;display:flex;align-items:center;justify-content:center;line-height:1}
.bell-count[hidden]{display:none}
.bell-panel{position:fixed;z-index:1000;width:min(380px,calc(100vw - 16px));max-height:70vh;overflow:auto;background:var(--surface);
  border:1px solid var(--border);border-radius:14px;box-shadow:0 16px 40px rgba(0,0,0,.32);padding:6px}
.bp-head{padding:10px 12px;font-weight:800;display:flex;justify-content:space-between;border-bottom:1px solid var(--border);margin-bottom:4px}
.bp-head span{font-weight:600;font-size:12px;color:var(--text-3)}
.bp-item{display:flex;gap:10px;padding:9px 10px;border-radius:10px;cursor:pointer}
.bp-item:hover,.bp-item:focus-visible{background:var(--surface-2);outline:none}
.bp-item.unread .bp-title{font-weight:800}
.bp-dot{width:9px;height:9px;border-radius:50%;flex:0 0 9px;margin-top:5px}
.bp-title{font-size:13px;font-weight:600}
.bp-body{font-size:12px;color:var(--text-3);margin-top:1px}
.bp-at{font-size:11px;color:var(--text-3);margin-top:2px}
.bp-empty{padding:18px 12px;font-size:12.5px;color:var(--text-3)}
#gs-kbd{white-space:nowrap}

/* ── Home: full-width cards + Today strip ────────────────────────────── */
.home-grid{grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
.home-card{min-height:220px}
.home-today{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin-bottom:16px}
.home-today:empty{display:none}
.today-item{all:unset;cursor:pointer;display:flex;flex-direction:column;gap:2px;padding:12px 14px;border-radius:12px;
  background:var(--surface);border:1px solid var(--border);border-top:3px solid var(--border);transition:transform .12s}
.today-item:hover,.today-item:focus-visible{transform:translateY(-2px);outline:none}
.today-item.good{border-top-color:var(--green)}
.today-item.warn{border-top-color:var(--amber)}
.today-item.bad{border-top-color:var(--red)}
.today-v{font-size:24px;font-weight:800;line-height:1.1}
.today-v small{font-size:14px;color:var(--text-3);font-weight:700}
.today-l{font-size:11.5px;color:var(--text-3);font-weight:600}
.today-s{font-size:11px;color:var(--text-3)}

/* Every alarm on a machine, one per line (edge >= 2.7.5 sends them all). */
.alm-lines{display:inline-flex;flex-direction:column;gap:2px;min-width:0}
.alm-line{display:block;overflow:hidden;text-overflow:ellipsis}
.alm-more{display:block;opacity:.8;font-size:.92em;cursor:help}
