/* ══ TAKT ── MTConnect × 現場センサー 稼働モニタリング ═══════
   レイアウトは 1920×1080（16:9）を基準にしている。
   センサー連携 OFF・設備未選択のときに縦スクロールなしで収まり、
   ON にすると右カラムにカードが積み上がって下へ伸びる。            */

:root {
  --bg: #0b1017;
  --panel: #141c26;
  --panel-2: #1a2431;
  --line: #26313f;
  --line-soft: #1d2733;
  --fg: #e6edf5;
  --fg-dim: #8b9bb0;
  --fg-faint: #61708a;

  --active: #35d07f;
  --ready: #f2c14e;
  --stopped: #e5534b;
  --accent: #4aa3ff;
  --demo: #ffb020;

  --topbar-h: 58px;
  --side-w: 400px;
  --gap: 11px;

  --radius: 11px;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;
  --sans: "Segoe UI", "Hiragino Sans", "Noto Sans JP", Meiryo, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

/* hidden 属性はレイアウト用の display 指定より優先させる */
[hidden] { display: none !important; }

/* センサー由来の表示は OFF でまとめて消える。OFF 専用の説明はその逆。 */
body[data-sensors="off"] [data-sensor] { display: none !important; }
body[data-sensors="on"] .off-only { display: none !important; }

/* ── トップバー ─────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 20px;
  background: linear-gradient(180deg, #141d29, #0e141d);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(140deg, #1f6feb, #38bdf8);
  color: #05121f;
}
.brand h1 {
  margin: 0; font-size: 20px; font-weight: 700; letter-spacing: .16em;
  display: flex; align-items: baseline; gap: 10px;
}
.brand-ja {
  font-size: 9.5px; font-weight: 600; letter-spacing: .18em; color: var(--fg-faint);
  padding-left: 10px; border-left: 1px solid var(--line);
}
.brand-sub { margin: 0; font-size: 11px; color: var(--fg-faint); }

.sensor-switch { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.switch {
  display: flex; align-items: center; gap: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 14px 4px 5px; cursor: pointer;
  transition: border-color .2s, background .2s;
}
.switch:hover { border-color: #3b4c62; }
.switch-track {
  width: 38px; height: 21px; border-radius: 999px; background: #2a3543;
  position: relative; transition: background .22s; flex: none;
}
.switch-knob {
  position: absolute; top: 3px; left: 3px; width: 15px; height: 15px;
  border-radius: 50%; background: #8b9bb0; transition: transform .22s, background .22s;
}
.switch-label { font-size: 12.5px; color: var(--fg-dim); }
.switch-state { font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--fg-dim); }
.switch[aria-checked="true"] { border-color: rgba(53,208,127,.5); background: rgba(53,208,127,.09); }
.switch[aria-checked="true"] .switch-track { background: rgba(53,208,127,.35); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(17px); background: var(--active); }
.switch[aria-checked="true"] .switch-state { color: var(--active); }
.switch-hint { margin: 0; font-size: 11px; color: var(--fg-faint); max-width: 460px; }

.topbar-tools { display: flex; align-items: center; gap: 13px; }

.conn {
  display: flex; align-items: center; gap: 7px;
  padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); font-size: 12px; color: var(--fg-dim); white-space: nowrap;
}
.conn .led { width: 7px; height: 7px; border-radius: 50%; background: #55606f; flex: none; }
.conn[data-state="ok"] { color: var(--active); border-color: rgba(53,208,127,.35); }
.conn[data-state="ok"] .led { background: var(--active); animation: pulse 2.4s infinite; }
.conn[data-state="error"] { color: var(--stopped); border-color: rgba(229,83,75,.4); }
.conn[data-state="error"] .led { background: var(--stopped); }
.conn[data-state="paused"] { color: var(--ready); }
.conn[data-state="paused"] .led { background: var(--ready); }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .4 } }

.field { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--fg-dim); }
select, .btn {
  font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 7px; padding: 4px 10px; cursor: pointer;
}
select:hover, .btn:hover { border-color: #3b4c62; }
.btn[data-paused="true"] { color: var(--ready); border-color: rgba(242,193,78,.45); }

.stamp { text-align: right; line-height: 1.15; }
.stamp-label { display: block; font-size: 9.5px; color: var(--fg-faint); letter-spacing: .06em; }
.stamp-value { font-family: var(--mono); font-size: 13px; }

/* ── ページ骨格（16:9 に収める） ─────────────────────── */

.page { max-width: 1760px; margin: 0 auto; padding: 16px 20px 30px; }

.card {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 13px 15px 15px; min-width: 0;
}
.card h3 {
  margin: 0 0 11px; font-size: 12px; font-weight: 600; letter-spacing: .07em;
  color: var(--fg-dim); text-transform: uppercase;
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
}
.card h3 .hint {
  font-size: 10.5px; text-transform: none; letter-spacing: 0;
  color: var(--fg-faint); font-weight: 400; text-align: right;
}
.canvas { width: 100%; display: block; }
.empty { color: var(--fg-faint); font-size: 12px; margin: 4px 0; }

.tacit {
  margin-top: 10px; padding: 8px 10px; border-radius: 7px;
  background: rgba(74,163,255,.07); border-left: 2px solid rgba(74,163,255,.5);
  font-size: 11px; color: var(--fg-dim); line-height: 1.7;
}
.tacit b {
  display: inline-block; min-width: 80px; color: var(--accent);
  font-weight: 600; font-size: 10px; letter-spacing: .04em;
}

/* ── 実データ / ダミーの区別 ─────────────────────────── */

.data-notice {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 8px 14px; margin-bottom: var(--gap); border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--demo);
  font-size: 11.5px; color: var(--fg-dim);
}
.data-notice .dn-txt b { color: var(--fg); font-weight: 650; }
.data-notice .dn-sep { width: 1px; height: 17px; background: var(--line); margin: 0 4px; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .06em;
  padding: 3px 8px; border-radius: 5px; white-space: nowrap;
}
.tag i { font-style: normal; font-size: 7.5px; line-height: 1; }
.tag.live { color: #06210f; background: var(--active); }
.tag.demo { color: #2a1c00; background: var(--demo); }

.chip-demo {
  display: inline-block; font-style: normal; font-weight: 700;
  font-size: 9px; letter-spacing: .08em; line-height: 1.5;
  padding: 1px 5px; border-radius: 3px; margin-right: 6px;
  background: var(--demo); color: #2a1c00; vertical-align: 1px;
}

/* ── アクションバー ─────────────────────────────────── */

.actionbar { display: grid; gap: 7px; margin-bottom: var(--gap); }
.actionbar:empty { display: none; }
.action {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 14px; border-radius: 9px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-left: 3px solid var(--c, var(--fg-faint));
}
.action.bad  { --c: var(--stopped); background: rgba(229,83,75,.09); border-color: rgba(229,83,75,.3); }
.action.warn { --c: var(--ready);   background: rgba(242,193,78,.08); border-color: rgba(242,193,78,.28); }
.action.ok   { --c: var(--active);  background: rgba(53,208,127,.06); border-color: rgba(53,208,127,.22); }
.action-icon { font-size: 18px; flex: none; }
.action b { display: block; font-size: 13.5px; font-weight: 650; }
.action span { font-size: 12px; color: var(--fg-dim); }
.action.bad b { color: #ff8b84; }
.action.warn b { color: var(--ready); }
.action.ok b { color: var(--active); }

/* ── KPI ────────────────────────────────────────────── */

.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px; margin-bottom: var(--gap);
}
.kpi {
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); padding: 11px 14px 9px;
}
.kpi.sensor {
  border-color: rgba(74,163,255,.22);
  background: linear-gradient(180deg, rgba(74,163,255,.06), transparent 60%), var(--panel);
}
.kpi-label { display: block; font-size: 11px; color: var(--fg-dim); }
.kpi-label em { display: block; font-style: normal; color: var(--fg-faint); font-size: 9.5px; }
.kpi-value { display: block; font-family: var(--mono); font-size: 25px; font-weight: 600; line-height: 1.25; }
.kpi-value small { font-size: 11.5px; color: var(--fg-dim); margin-left: 4px; font-weight: 400; }
.kpi-value.ok { color: var(--active); }
.kpi-value.bad, .kpi-value.bad small { color: var(--stopped); }
.kpi-src {
  display: block; margin-top: 2px; font-size: 9px; letter-spacing: .04em;
  color: var(--fg-faint); text-transform: uppercase;
}

/* ── 設備カード ─────────────────────────────────────── */

.machine-strip {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 10px; margin-bottom: var(--gap);
}

.machine-card {
  position: relative; text-align: left;
  display: flex; flex-direction: column;
  padding: 11px 12px 12px 15px;
  background: var(--panel); border: 1px solid var(--line-soft);
  border-radius: var(--radius); cursor: pointer; overflow: hidden;
  transition: border-color .15s, transform .15s;
}
.machine-card:hover { border-color: #33475f; transform: translateY(-1px); }
.machine-card[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(74,163,255,.3); }
.machine-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--st-color);
}
.machine-card.is-demo { border-color: rgba(255,176,32,.26); }
.machine-card.is-demo:hover { border-color: rgba(255,176,32,.5); }
.machine-card.alarming { animation: alarmGlow 1.6s ease-in-out infinite; }
@keyframes alarmGlow {
  0%,100% { box-shadow: 0 0 0 1px rgba(229,83,75,.35) }
  50%     { box-shadow: 0 0 0 4px rgba(229,83,75,.16) }
}

.mc-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.mc-id { min-width: 0; }
.mc-name { display: block; font-size: 14px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-type { display: block; font-size: 10px; color: var(--fg-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-state {
  flex: none; font-size: 10.5px; font-weight: 650; letter-spacing: .04em;
  padding: 3px 8px; border-radius: 999px; color: var(--st-color);
  background: color-mix(in srgb, var(--st-color) 16%, transparent);
}

/* 製品画像は透過余白を切り落として機械の外形＝画像の外形に揃えてあるので、
   同じ縦横比の枠に contain で置けば、どのカードも機械の高さと上下位置が揃う。 */
.mc-figure { position: relative; margin: 7px 0 6px; }
.mc-img {
  display: block; width: 100%; aspect-ratio: 1.9; object-fit: contain;
  padding: 6px; border-radius: 7px;
  background: linear-gradient(170deg, #f7f9fb, #dde4ec);
  border: 1px solid rgba(255,255,255,.08);
}
.mc-img-ph { background: radial-gradient(circle at 50% 40%, #24303f, #151d27 70%); }
.mc-figure .tag { position: absolute; left: 6px; top: 6px; font-size: 9px; padding: 2px 7px; }

.mc-op {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; margin-bottom: 6px; border-radius: 7px;
  background: var(--panel-2); border: 1px solid var(--line-soft);
}
.mc-op-icon { display: flex; flex: none; }
.mc-op-txt { min-width: 0; line-height: 1.3; }
.mc-op-txt b { display: block; font-size: 12px; font-weight: 650;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-op-txt span { display: block; font-size: 9.5px; color: var(--fg-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mc-op-here {
  margin-left: auto; flex: none; font-size: 9px; letter-spacing: .04em;
  padding: 2px 6px; border-radius: 999px;
  background: rgba(74,163,255,.16); color: var(--accent);
}
.mc-op-here.here { background: rgba(53,208,127,.18); color: var(--active); }

.mc-prog {
  font-family: var(--mono); font-size: 10.5px; color: var(--fg-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mc-stats { display: flex; gap: 13px; margin-top: 6px; }
.mc-stats b { display: block; font-family: var(--mono); font-size: 15px; font-weight: 600; }
.mc-stats b.warn { color: var(--ready); }
.mc-stats span { font-size: 9.5px; color: var(--fg-faint); }
.mc-kind {
  margin-top: 7px; font-size: 11px; font-family: var(--mono); line-height: 1.5;
  color: var(--k, transparent); background: color-mix(in srgb, var(--k, #000) 13%, transparent);
  border-radius: 5px; padding: 2px 8px; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 設備別 稼働タイムライン ────────────────────────── */

.fleet { margin-bottom: var(--gap); }
.fleet-rows { display: flex; flex-direction: column; gap: 6px; }
.fleet-row { display: grid; grid-template-columns: 210px minmax(0,1fr) 52px; align-items: center; gap: 10px; }
.fleet-name {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left;
}
.fleet-name:hover .fl-nm { color: var(--accent); }
.fl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--st-color); flex: none; }
.fl-nm { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fl-line { font-size: 9.5px; color: var(--fg-faint); white-space: nowrap; margin-left: auto; }
.fl-canvas { width: 100%; display: block; border-radius: 3px; }
.fl-util { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--fg-dim); }
/* 帯グラフ列と左右の位置を合わせる（名前列 210 + gap 10 / 稼働率列 52 + gap 10） */
.fleet-axis { margin-left: 220px; margin-top: 2px; width: calc(100% - 282px); }

/* ── シフト ─────────────────────────────────────────── */

.shift { border-radius: 8px; padding: 9px 11px; background: var(--panel-2); margin-bottom: 8px; }
.shift.next { opacity: .78; }
.shift-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 7px; }
.shift-badge {
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  background: rgba(53,208,127,.16); color: var(--active); letter-spacing: .06em;
}
.shift-badge.alt { background: rgba(139,155,176,.15); color: var(--fg-dim); }
.shift-head b { font-size: 13.5px; }
.shift-time { font-family: var(--mono); font-size: 11.5px; color: var(--fg-dim); }
.shift-left { margin-left: auto; font-size: 10.5px; color: var(--fg-faint); font-family: var(--mono); }

.members { display: grid; gap: 5px; }
.member { display: flex; align-items: center; gap: 9px; }
.member-txt { min-width: 0; }
.member-txt b { display: block; font-size: 12px; font-weight: 600; }
.member-txt span { font-size: 10px; color: var(--fg-faint); }
.member-dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.person-svg { flex: none; }

.handover {
  font-size: 11px; color: var(--fg-dim); line-height: 1.6;
  padding: 7px 10px; border-radius: 7px; background: rgba(242,193,78,.07);
  border-left: 2px solid rgba(242,193,78,.45);
}
.handover b { display: block; color: var(--ready); font-size: 10px; letter-spacing: .05em; }

/* ── 在席マップ ─────────────────────────────────────── */

.floor { border-radius: 8px; background: #0f151e; padding: 5px; }
.floor-svg { width: 100%; height: auto; display: block; }
.zone { fill: #131b25; stroke: #232f3d; stroke-width: .4; }
.zone-label { fill: #4c5a6e; font-size: 2.6px; font-family: var(--sans); }
.fm rect { fill: #1e2937; stroke: var(--c, #55606f); stroke-width: .8; }
.fm.alarm rect { animation: fmAlarm 1.2s infinite; }
@keyframes fmAlarm { 0%,100% { stroke-width: .8 } 50% { stroke-width: 2.2 } }
.fm-label { fill: #8b9bb0; font-size: 2.7px; text-anchor: middle; font-family: var(--sans); }
.fp { transition: transform 1s linear; }
.fp circle { stroke: #0f151e; stroke-width: .6; }
.fp.moving circle { stroke: #fff; stroke-opacity: .55; }
.fp-label { fill: #c3d0e0; font-size: 2.5px; text-anchor: middle; font-family: var(--sans); }

/* ── 素材残量 ───────────────────────────────────────── */

.materials { display: grid; gap: 7px; }
.mat { padding: 7px 9px; border-radius: 7px; background: var(--panel-2); }
.mat.low { background: rgba(242,193,78,.08); }
.mat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.mat-top b { font-size: 12px; font-weight: 600; }
.mat-qty { font-family: var(--mono); font-size: 16px; font-weight: 650; }
.mat-qty small { font-size: 10px; color: var(--fg-faint); font-weight: 400; }
.mat-track { height: 5px; border-radius: 999px; background: #101823; overflow: hidden; margin: 4px 0; }
.mat-track i { display: block; height: 100%; border-radius: 999px; transition: width .5s; }
.mat-note { font-size: 10.5px; color: var(--fg-dim); }
.mat-calc { margin-top: 1px; font-size: 9.5px; color: var(--fg-faint); font-family: var(--mono); }
.mat-calc .ok { color: var(--active); margin-left: 4px; }
.mat-calc .dim { margin-left: 4px; }

/* ── 個別ダッシュボード ─────────────────────────────── */

.detail { display: block; margin-bottom: var(--gap); }
.detail-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: var(--gap);
}
.detail-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.detail-img {
  width: 96px; aspect-ratio: 1.9; object-fit: contain; padding: 4px; border-radius: 7px;
  background: linear-gradient(170deg, #f7f9fb, #dde4ec); flex: none;
}
.detail-title h2 { margin: 0; font-size: 18px; font-weight: 650; }
.dmeta { font-size: 11px; color: var(--fg-faint); }
.close-detail { margin-left: auto; }

.badges { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.badge {
  font-size: 10.5px; padding: 3px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--panel);
  color: var(--fg-dim); font-family: var(--mono);
}
.badge b { color: var(--fg); font-weight: 600; }
.badge.good { border-color: rgba(53,208,127,.4); } .badge.good b { color: var(--active); }
.badge.warn { border-color: rgba(242,193,78,.45); } .badge.warn b { color: var(--ready); }
.badge.bad  { border-color: rgba(229,83,75,.5); }  .badge.bad b  { color: var(--stopped); }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--gap); margin-bottom: var(--gap); }
.span-4 { grid-column: span 4 } .span-5 { grid-column: span 5 }
.span-6 { grid-column: span 6 } .span-7 { grid-column: span 7 }
@media (max-width: 1280px) {
  .span-4, .span-5, .span-6, .span-7 { grid-column: span 12 }
}

.statebox {
  border-radius: 8px; padding: 10px 12px; margin-bottom: 9px;
  background: color-mix(in srgb, var(--st-color) 12%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--st-color) 32%, transparent);
}
.state-main { display: flex; align-items: center; gap: 9px; }
.state-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--st-color); flex: none; }
.state-text { font-size: 19px; font-weight: 700; color: var(--st-color); }
.state-sub { margin-top: 2px; font-size: 10.5px; color: var(--fg-dim); font-family: var(--mono); }

.kv { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.kv dt { font-size: 11.5px; color: var(--fg-dim); white-space: nowrap; }
.kv dd {
  margin: 0; font-family: var(--mono); font-size: 12px; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kv dd.na { color: var(--fg-faint); }

.stopbox {
  border-radius: 8px; padding: 10px 12px;
  background: color-mix(in srgb, var(--k, #55606f) 11%, var(--panel-2));
  border: 1px solid color-mix(in srgb, var(--k, #55606f) 32%, transparent);
}
.stopbox.ok { --k: var(--active); }
.stopbox-head { display: flex; align-items: baseline; justify-content: space-between; }
.stopbox b { font-size: 16px; font-weight: 700; color: var(--k, var(--active)); }
.stop-elapsed { font-family: var(--mono); font-size: 14px; color: var(--k); }
.stop-note { font-size: 11px; color: var(--fg-dim); }
.stop-facts { margin-top: 7px; display: grid; gap: 4px; }
.stop-facts div { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.stop-facts span { color: var(--fg-faint); white-space: nowrap; }
.stop-facts b { font-size: 11px; font-weight: 600; color: var(--fg); text-align: right; }

.m5 { margin-top: 9px; border-radius: 8px; background: #0f151e; border: 1px solid var(--line); padding: 8px 9px; }
.m5-head { display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--fg-dim); margin-bottom: 7px; }
.m5-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px var(--accent); }
.m5-note { margin-left: auto; font-size: 9.5px; color: var(--fg-faint); }
.m5-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.m5-btn {
  display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 6px 3px; border-radius: 6px; cursor: pointer;
  background: #17202c; border: 1px solid var(--line);
  font-size: 10px; color: var(--fg-dim); transition: .15s;
}
.m5-btn span { font-size: 14px; }
.m5-btn:hover { border-color: #3b4c62; color: var(--fg); }
.m5-btn.on { background: rgba(74,163,255,.16); border-color: var(--accent); color: #cfe4ff; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px; font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 3px; border-radius: 2px; background: currentColor; flex: none; }
.legend i.sw { width: 9px; height: 9px; border-radius: 3px; }

.util-bar { margin-top: 9px; }
.util-bar .track { height: 6px; border-radius: 999px; background: #101823; overflow: hidden; display: flex; }
.util-bar .track i { display: block; height: 100%; }
.util-bar .cap { margin-top: 5px; font-size: 11px; color: var(--fg-dim); }
.util-bar .cap b { color: var(--active); font-family: var(--mono); font-size: 13.5px; }

.loads { display: grid; gap: 6px; }
.load-row { display: grid; grid-template-columns: 40px 1fr 38px; align-items: center; gap: 8px; }
.load-row .nm { font-family: var(--mono); font-size: 11px; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; }
.load-row .track { height: 7px; border-radius: 999px; background: #101823; overflow: hidden; }
.load-row .track i { display: block; height: 100%; border-radius: 999px; transition: width .4s; }
.load-row .vl { font-family: var(--mono); font-size: 11px; text-align: right; }

.table-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 12px; }
.tbl th {
  text-align: left; font-size: 10px; font-weight: 600; letter-spacing: .05em;
  color: var(--fg-faint); padding: 0 7px 5px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 5px 7px; border-bottom: 1px solid var(--line-soft); font-family: var(--mono); white-space: nowrap; }
.tbl tr:last-child td { border-bottom: none; }
.tbl .num, .tbl td.num { text-align: right; }
.tbl .dim { color: var(--fg-faint); }
.tbl .unit { font-style: normal; font-size: 9.5px; color: var(--fg-faint); margin-left: 4px; }

.conds { display: grid; gap: 5px; max-height: 196px; overflow-y: auto; }
.cond {
  display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; background: var(--panel-2);
  border-left: 3px solid var(--c); font-size: 11.5px;
}
.cond .lv { font-size: 10px; font-weight: 700; color: var(--c); }
.cond .nm { color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cond .ty { font-family: var(--mono); font-size: 10px; color: var(--fg-faint); }
.cond.is-normal { opacity: .55; }

/* ── 通知センター ───────────────────────────────────── */

.alerts { display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
.alert {
  border-radius: 8px; padding: 9px 11px; background: var(--panel-2);
  border-left: 3px solid var(--fg-faint);
}
.alert.open { border-left-color: var(--stopped); background: rgba(229,83,75,.08); }
.alert.acked { border-left-color: var(--ready); background: rgba(242,193,78,.07); }
.alert.closed { opacity: .5; }
.alert-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.alert-state {
  font-size: 9.5px; font-weight: 700; padding: 2px 7px; border-radius: 4px;
  background: rgba(139,155,176,.16); color: var(--fg-dim); letter-spacing: .05em;
}
.alert.open .alert-state { background: rgba(229,83,75,.2); color: #ff9b95; }
.alert.acked .alert-state { background: rgba(242,193,78,.2); color: var(--ready); }
.alert-head b { font-size: 12.5px; }
.alert-title { font-size: 11px; color: var(--fg-dim); font-family: var(--mono); }
.alert-time { margin-left: auto; font-family: var(--mono); font-size: 14px; font-weight: 600; }
.alert-detail { margin-top: 2px; font-size: 11.5px; color: var(--fg-dim); }
.alert-meta { margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 10.5px; color: var(--fg-faint); }
.alert-meta .ok { color: var(--active); }

.sends { margin-top: 6px; display: grid; gap: 2px; border-top: 1px solid var(--line-soft); padding-top: 5px; }
.send { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--fg-dim); }
.send-t { font-family: var(--mono); color: var(--fg-faint); }
.send-ch { display: inline-flex; gap: 3px; }
.ch {
  width: 15px; height: 15px; border-radius: 4px; display: grid; place-items: center;
  background: var(--c); color: #fff; font-size: 8.5px; font-weight: 700; font-style: normal;
}
.send-nm { font-weight: 600; color: var(--fg); }
.send-tag { margin-left: auto; font-size: 9.5px; color: var(--fg-faint); }

/* ── イベントログ ───────────────────────────────────── */

.log { display: grid; gap: 1px; align-content: start; max-height: 400px; overflow-y: auto; font-size: 11.5px; }
.log-row { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 4px 3px; border-bottom: 1px solid var(--line-soft); }
.log-row time { font-family: var(--mono); color: var(--fg-faint); font-size: 10.5px; }
.log-row .msg { color: var(--fg-dim); }
.log-row .msg b { color: var(--fg); font-weight: 600; }
.log-tag {
  font-style: normal; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-right: 5px;
  background: rgba(139,155,176,.14); color: var(--fg-faint);
}
.log-row.lv-fault .msg b { color: var(--stopped); }
.log-row.lv-fault .log-tag { background: rgba(229,83,75,.18); color: #ff9b95; }
.log-row.lv-warning .msg b { color: var(--ready); }
.log-row.lv-ok .msg b { color: var(--active); }

/* ── センサー一覧 ───────────────────────────────────── */

.sensor-list { display: grid; gap: 6px; }
.sensor-item { display: flex; gap: 9px; align-items: flex-start; padding: 7px 9px; border-radius: 7px; background: var(--panel-2); }
.sensor-icon { font-size: 16px; flex: none; }
.sensor-item b { font-size: 12px; }
.sensor-dev { display: block; font-size: 10px; color: var(--fg-faint); font-family: var(--mono); }
.sensor-der { display: block; font-size: 10.5px; color: var(--fg-dim); margin-top: 1px; }
.sensor-der b { color: var(--accent); font-size: 10.5px; }

/* ── 講座への導線 ───────────────────────────────────── */

.cta {
  display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 26px;
  padding: 16px 22px 14px; border-radius: 12px;
  background: linear-gradient(135deg, #16233a, #101826 55%, #131d2a);
  border: 1px solid rgba(74,163,255,.28);
}
.cta-eyebrow { margin: 0 0 4px; font-size: 10px; letter-spacing: .12em; color: var(--accent); text-transform: uppercase; }
.cta h2 { margin: 0; font-size: 16px; line-height: 1.6; font-weight: 650; }
.cta-col h4 {
  margin: 0 0 6px; font-size: 11px; letter-spacing: .06em; color: var(--fg-dim);
  padding-bottom: 5px; border-bottom: 1px solid var(--line);
}
.cta-col ul { margin: 0; padding-left: 17px; font-size: 12px; color: var(--fg-dim); line-height: 1.75; }
.cta-col.accent h4 { color: var(--accent); border-color: rgba(74,163,255,.35); }
.cta-col.accent li { color: var(--fg); }
.cta-foot { grid-column: 1 / -1; margin: 4px 0 0; font-size: 11.5px; color: var(--fg-dim); }

.foot { margin: 0; font-size: 10.5px; color: var(--fg-faint); line-height: 1.7; }
.foot b { color: var(--fg-dim); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #2b3644; border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── 画面が狭いとき ─────────────────────────────────── */

@media (max-width: 1280px) {
  .fleet-row { grid-template-columns: 160px minmax(0,1fr) 46px; }
  .fleet-axis { margin-left: 170px; width: calc(100% - 226px); }
  .cta { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .page { padding: 12px; }
  .fleet-row { grid-template-columns: 120px minmax(0,1fr) 42px; }
  .fleet-axis { margin-left: 130px; width: calc(100% - 182px); }
}
