/* ============================================================
   SENTINEL — QPD Barrier Control
   Industrial control-room design system (light theme)
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* surfaces */
  --bg:        #EBEEF2;
  --bg-grid:   #E2E6EC;
  --panel:     #FFFFFF;
  --panel-2:   #F5F7FA;
  --panel-3:   #EEF1F5;
  --line:      #DCE1E8;
  --line-2:    #C8D0DA;

  /* ink */
  --ink:       #1A2230;
  --ink-2:     #44505F;
  --ink-3:     #6B7888;
  --ink-4:     #97A1B0;

  /* brand / interactive */
  --accent:    #1F5FD0;
  --accent-d:  #194FAD;
  --accent-bg: #E9F0FC;

  /* state colors */
  --open:      #15A06A;
  --open-bg:   #E2F4EC;
  --closed:    #46688F;
  --closed-bg: #E7EDF4;
  --fault:     #E8930C;
  --fault-bg:  #FBEFDA;
  --offline:   #94A0B2;
  --offline-bg:#EEF0F4;
  --alarm:     #DC3A34;
  --alarm-bg:  #FBE6E5;

  /* effects */
  --r:   10px;
  --r-sm:7px;
  --r-lg:14px;
  --sh:  0 1px 2px rgba(20,30,48,.06), 0 2px 8px rgba(20,30,48,.05);
  --sh-lg: 0 4px 16px rgba(20,30,48,.10), 0 1px 3px rgba(20,30,48,.07);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.45;
}
a { color: inherit; text-decoration: none; }

/* ---- Header strip ---- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  height: 60px; padding: 0 22px;
  background: #11202F;
  color: #E8EDF3;
  border-bottom: 3px solid var(--accent);
  position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(150deg, var(--accent), #2EA0E8);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
  position: relative; flex: none;
}
.brand .mark::before { content: ""; width: 16px; height: 3px; background: #fff; border-radius: 2px; box-shadow: 0 5px 0 rgba(255,255,255,.5), 0 -5px 0 rgba(255,255,255,.5); }
.brand .name { font-weight: 700; letter-spacing: .14em; font-size: 15px; }
.brand .sub { font-size: 10.5px; letter-spacing: .18em; color: #7E94A8; text-transform: uppercase; margin-top: 1px; }
.topbar .divider { width: 1px; height: 30px; background: rgba(255,255,255,.12); }
.topbar .spacer { flex: 1; }

.crumb { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: #9BB0C4; white-space: nowrap; }
.crumb b { color: #E8EDF3; font-weight: 600; }
.crumb .sep { color: #54677A; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 7px 11px; width: 270px;
  color: #C9D6E2;
}
.search:focus-within { border-color: var(--accent); background: rgba(255,255,255,.12); }
.search input { background: none; border: 0; outline: 0; color: #fff; font-family: var(--sans); font-size: 13px; width: 100%; }
.search input::placeholder { color: #6E8497; }
.search svg { flex: none; opacity: .7; }

.metric-pill { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.metric-pill .v { font-family: var(--mono); font-size: 14px; font-weight: 600; color: #E8EDF3; }
.metric-pill .l { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: #7E94A8; }

.alarm-badge {
  display: flex; align-items: center; gap: 8px;
  background: var(--alarm); color: #fff;
  padding: 7px 13px 7px 11px; border-radius: 8px;
  font-weight: 600; font-size: 13px;
  box-shadow: 0 0 0 1px rgba(255,255,255,.12), 0 4px 14px rgba(220,58,52,.4);
}
.alarm-badge.calm { background: rgba(255,255,255,.08); color: #9BB0C4; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }
.alarm-badge .dot { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
.alarm-badge.live .dot { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{ opacity:1 } 50%{ opacity:.35 } }
.alarm-badge .n { font-family: var(--mono); font-size: 15px; }

.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--open); box-shadow: 0 0 0 3px rgba(21,160,106,.25); animation: pulse 2s infinite; }

/* ---- State chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .03em;
  padding: 4px 9px; border-radius: 999px; line-height: 1;
  text-transform: uppercase;
}
.chip .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.chip.OPEN    { background: var(--open-bg);    color: #0C6E48; }
.chip.OPEN .sw{ background: var(--open); }
.chip.CLOSED  { background: var(--closed-bg);  color: #2F4A6B; }
.chip.CLOSED .sw{ background: var(--closed); }
.chip.FAULT   { background: var(--fault-bg);   color: #9A610A; }
.chip.FAULT .sw{ background: var(--fault); }
.chip.OFFLINE { background: var(--offline-bg); color: #5C677A; }
.chip.OFFLINE .sw{ background: var(--offline); }

/* ---- Cards & panels ---- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--sh); }
.panel-head { display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.panel-head .spacer { flex: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--sans); font-weight: 600; font-size: 13.5px;
  padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line-2);
  background: var(--panel); color: var(--ink); cursor: pointer;
  transition: all .14s ease;
}
.btn:hover { border-color: var(--ink-4); background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent-d); color: #fff; box-shadow: 0 1px 0 var(--accent-d), 0 4px 12px rgba(31,95,208,.25); }
.btn.primary:hover { background: var(--accent-d); }
.btn.open   { background: var(--open);   border-color: #0E8A5B; color: #fff; }
.btn.open:hover { filter: brightness(1.05); }
.btn.close  { background: var(--closed); border-color: #38567A; color: #fff; }
.btn.danger { background: var(--alarm);  border-color: #C42E29; color: #fff; }
.btn.ghost  { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-3); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 17px; height: 17px; }

/* ---- Mono data ---- */
.mono { font-family: var(--mono); }
.kvs { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; }
.kvs dt { color: var(--ink-3); font-size: 12.5px; }
.kvs dd { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--ink); text-align: right; }

table.tele { width: 100%; border-collapse: collapse; }
table.tele th, table.tele td { text-align: left; padding: 10px 16px; border-bottom: 1px solid var(--line); font-size: 13px; }
table.tele th { font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-4); font-weight: 600; }
table.tele td.v { font-family: var(--mono); text-align: right; color: var(--ink); font-weight: 500; }
table.tele tr:last-child td { border-bottom: 0; }
table.tele td .unit { color: var(--ink-4); font-size: 11px; margin-left: 3px; }

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* utility */
.muted { color: var(--ink-3); }
.tiny { font-size: 11px; }
.up { text-transform: uppercase; letter-spacing: .08em; }
.flex { display: flex; }
.between { justify-content: space-between; }
.center { align-items: center; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }

/* tooltip (3D) */
.scene-tip {
  position: absolute; pointer-events: none; z-index: 30;
  background: rgba(17,32,47,.97); color: #E8EDF3;
  border: 1px solid rgba(255,255,255,.12); border-radius: 9px;
  padding: 9px 11px; font-size: 12px; min-width: 168px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  transform: translate(-50%, calc(-100% - 14px)); opacity: 0; transition: opacity .12s;
}
.scene-tip.show { opacity: 1; }
.scene-tip .tid { font-family: var(--mono); font-weight: 600; font-size: 13px; display: flex; align-items: center; gap: 7px; margin-bottom: 6px; }
.scene-tip .row { display: flex; justify-content: space-between; gap: 16px; color: #9BB0C4; padding: 1px 0; }
.scene-tip .row b { color: #E8EDF3; font-weight: 500; font-family: var(--mono); }
.scene-tip .hint { margin-top: 6px; font-size: 10px; color: #6E8497; }
.scene-tip .hint2 { margin-top: 6px; font-size: 10px; color: #6E8497; border-top: 1px solid rgba(255,255,255,.1); padding-top: 6px; }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(17,28,42,.5); backdrop-filter: blur(2px); display: grid; place-items: center; z-index: 100; opacity: 0; pointer-events: none; transition: opacity .15s; }
.modal-back.show { opacity: 1; pointer-events: auto; }
.modal { background: var(--panel); border-radius: var(--r-lg); box-shadow: var(--sh-lg); width: 420px; max-width: 92vw; overflow: hidden; transform: translateY(8px) scale(.98); transition: transform .15s; }
.modal-back.show .modal { transform: none; }
.modal .mh { padding: 20px 22px 0; }
.modal .mh h2 { margin: 0 0 6px; font-size: 19px; }
.modal .mb { padding: 14px 22px 0; color: var(--ink-2); }
.modal .mf { display: flex; gap: 10px; justify-content: flex-end; padding: 20px 22px 22px; }
