/* Customer Demo Control (simdemo/panel.py) - served as a file because of the strict CSP */
:root {
  color-scheme: light dark;
  --bg: #f4f6f9; --card: #ffffff; --fg: #1d2330; --muted: #667085; --line: #dfe3ea;
  --accent: #1f5fd1; --accent-fg: #ffffff; --ok: #1a7f37; --ng: #c62828; --warn: #9a6700;
  --down: #8a94a6; --badge: #e8f0fe; --badge-fg: #1f4fa8; --bar: #2563eb; --bar-high: #c62828;
  --bar-bg: #e8ebf0; --banner: #fff4c2; --banner-fg: #5c4400; --inactive: #f7f8fa;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --card: #1b2028; --fg: #e6e9ef; --muted: #98a2b3; --line: #2c333f;
    --accent: #6ea0ff; --accent-fg: #0b1220; --ok: #4ac26b; --ng: #ff6b6b; --warn: #e3b341;
    --down: #6b7487; --badge: #233150; --badge-fg: #b8cdfa; --bar: #6ea0ff; --bar-high: #ff6b6b;
    --bar-bg: #2a303a; --banner: #3d3410; --banner-fg: #f3dc8b; --inactive: #171b22;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg);
  font: 14px/1.5 "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 0 0 8px; }
button {
  font: inherit; padding: 6px 14px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--fg);
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
button.outline-danger { border-color: var(--ng); color: var(--ng); }
button.small { padding: 2px 10px; }
input, select { font: inherit; color: inherit; background: var(--card); }
input[type=number] { width: 7em; padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; }
select { padding: 3px 6px; border: 1px solid var(--line); border-radius: 4px; }
.muted { color: var(--muted); }
.spacer { flex: 1; }

.top {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.user { color: var(--muted); }
.time { font-variant-numeric: tabular-nums; }
.time.soon { color: var(--ng); font-weight: 600; }
.banner { background: var(--banner); color: var(--banner-fg); padding: 6px 20px; font-weight: 600; }

.layout { display: grid; grid-template-columns: 240px 1fr; gap: 16px; padding: 16px 20px; }
main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; }

.devices h2 { margin-left: 4px; }
.device-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.device { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; }
.device.selected { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.device .line { display: flex; align-items: center; gap: 4px 6px; flex-wrap: wrap; }
.device .name { font-weight: 600; }
.device .sub { font-size: 12px; }
.device-select { display: none; width: 100%; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--down); margin-right: 4px; }
.dot.ok { background: var(--ok); }
.dot.ng { background: var(--ng); }
.dot.down { background: var(--down); }
.dot.stopped { background: var(--line); border: 1px solid var(--down); }
.dot.muted { background: var(--warn); }
.snmp-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.snmp-row h3 { margin: 0; }
.snmp-state { font-weight: 600; }
.snmp-state.muted-state { color: var(--warn); }
.snmp-state.ng-state { color: var(--ng); }
.metric h3 .badge { margin-left: 6px; vertical-align: middle; }
.metric .applied { font-size: 12px; }
.badge { display: inline-block; white-space: nowrap; font-size: 12px; padding: 0 8px; border-radius: 10px; background: var(--badge); color: var(--badge-fg); }
.badge.warn { background: var(--banner); color: var(--banner-fg); margin-left: 8px; }

.dev-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.dev-name { font-size: 17px; font-weight: 700; margin-right: 8px; }
.dev-status { display: flex; align-items: center; gap: 2px; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.metric .current { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.metric .current .mode { font-size: 13px; font-weight: 400; margin-left: 6px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0; }
.row.end { justify-content: flex-end; }
.slider input[type=range] { flex: 1; min-width: 140px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.table-wrap { overflow-x: auto; }
table.ifs { border-collapse: collapse; width: 100%; min-width: 860px; }
.ifs th, .ifs td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.ifs th { font-size: 12px; color: var(--muted); font-weight: 600; }
.ifs td.num { font-variant-numeric: tabular-nums; }
.ifs td.descr { max-width: 220px; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.ifs tr.inactive td { background: var(--inactive); color: var(--muted); }
.rate { min-width: 130px; }
.rate .val { display: inline-block; min-width: 82px; text-align: right; font-variant-numeric: tabular-nums; }
.bar { display: inline-block; width: 40px; height: 6px; background: var(--bar-bg); border-radius: 3px; margin-left: 6px; vertical-align: middle; overflow: hidden; }
.bar .fill { display: block; height: 100%; background: var(--bar); }
.bar .fill.high { background: var(--bar-high); }
.note { font-size: 12px; color: var(--muted); margin: 8px 0 0; padding-left: 0; list-style: none; }

.changes { list-style: none; margin: 0; padding: 0; }
.changes li { display: flex; gap: 12px; flex-wrap: wrap; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.changes .when { font-variant-numeric: tabular-nums; }
.changes .ok { color: var(--ok); }
.changes .ng { color: var(--ng); }

.toasts { position: fixed; top: 64px; right: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: min(520px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: 6px; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--ok); box-shadow: 0 2px 8px rgba(0,0,0,.15); cursor: pointer; }
.toast.error { border-left-color: var(--ng); }
.toast.warn { border-left-color: var(--warn); }

dialog { border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; background: var(--card); color: var(--fg); width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.35); }
fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; }
legend { padding: 0 4px; font-weight: 600; }
.fixed { display: inline-flex; gap: 6px; align-items: center; }
.fixed.off { opacity: .55; }
.pct.over { color: var(--ng); }
.trap-row { display: block; margin: 8px 0; }
.error { color: var(--ng); margin: 6px 0; }
.cf-list { margin: 8px 0; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 30; padding: 16px; }
.overlay-box { max-width: 480px; text-align: center; }
.notice-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; }
.notice { max-width: 520px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; padding: 12px 16px; }
  .device-list { display: none; }
  .device-select { display: block; }
  .top { padding: 10px 16px; }
}
