/* Secret_StreamRelay dashboard layout on top of the ORCA kit (kit/tokens.css + kit/orca.css) */

html, body { margin: 0; min-height: 100%; background: #0e0f10; }
body { font-size: var(--fs-body); line-height: 1.5; user-select: text; }
.hidden { display: none !important; }
h1 { margin: 0; font-size: var(--fs-title); font-weight: 600; letter-spacing: .02em; }
h2 { margin: 0 0 16px; font-size: var(--fs-small); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.error { color: var(--red); min-height: 22px; font-size: var(--fs-small); }
.o-head__title { line-height: 1.2; }
.o-close svg, .o-close { display: grid; place-items: center; }
.o-close svg { width: 18px; height: 18px; }
.o-input { min-width: 0; }
select.o-input, textarea.o-input { color: var(--text); border: 0; outline: 0; }
select.o-input { appearance: none; padding-right: 36px; cursor: pointer;
  background: var(--box) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2373EFFF' d='m7 10 5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 10px center / 20px; }
textarea.o-input { height: auto; padding: 12px 16px; resize: vertical; line-height: 1.6; font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(440px, calc(100vw - 32px)); display: grid; gap: 16px; }

/* the window */
#app { padding: 24px; }
.shell { min-height: calc(100vh - 48px); padding: 28px 32px 32px; overflow: hidden; }
.shell::after {
  content: ''; position: absolute; right: -120px; bottom: -160px; width: 560px; height: 660px;
  background: url('kit/orca-logo.png') no-repeat center / contain; opacity: .04; pointer-events: none;
}
.top { margin-bottom: 32px; }
.body { position: relative; z-index: 1; display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 36px; }
main { min-width: 0; }

/* left menu */
.nav { display: grid; gap: 10px; align-content: start; }
.nav a {
  display: flex; align-items: center; gap: 14px; height: 52px; padding: 0 20px;
  border-radius: var(--r-row); background: var(--well); cursor: pointer; transition: background .15s;
}
.nav a:hover { background: rgba(42, 42, 42, .6); }
.nav a svg { width: 20px; height: 20px; flex: none; color: var(--text-2); }
.nav__en { font-size: var(--fs-small); font-weight: 600; letter-spacing: .04em; }
.nav__th { margin-left: auto; font-size: var(--fs-small); color: var(--text-2); font-weight: 400; }
.nav a.active { background: var(--acc-14); }
.nav a.active svg, .nav a.active .nav__en { color: var(--acc); }

/* page */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin-top: 4px; font-size: var(--fs-small); }
.states-head { margin-top: 40px; }
.tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.tools .o-input { height: 40px; }
.tools input.o-input { width: 200px; }
.tools .o-btn { height: 40px; }
.save { min-width: 200px; height: 48px; font-size: var(--fs-body); }
.box { padding: 24px; border-radius: var(--r-card); background: var(--card); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.split--wide { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.check { display: inline-flex; gap: 8px; align-items: center; color: var(--text-2); font-size: var(--fs-small); cursor: pointer; }
.check input { accent-color: var(--acc); width: 16px; height: 16px; }
.empty { padding: 32px 0; text-align: center; }
.form { display: grid; gap: 16px; align-content: start; }

/* KPI tiles */
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { display: grid; gap: 4px; align-content: start; padding: 20px 24px 14px; border-radius: var(--r-row); background: var(--box); }
.stat__label { font-size: var(--fs-small); color: var(--text-3); font-weight: 400; }
.stat__value { font-size: var(--fs-num); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat__value small { font-size: var(--fs-body); color: var(--text-2); }
.stat .delta { font-size: var(--fs-tiny); color: var(--text-2); }
.spark { display: block; width: 100%; height: 36px; margin-top: 8px; overflow: visible; }

/* trend chart */
.viz-card { margin-bottom: 20px; }
.viz-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.viz-head h2 { margin-bottom: 4px; }
.viz-sub { font-size: var(--fs-tiny); color: var(--text-3); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 10px; font-size: var(--fs-small); color: var(--text-2); }
.legend__item { display: inline-flex; align-items: center; gap: 8px; }
.legend__item i { width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.viz-plot { min-height: 260px; }
.trend { display: block; max-width: 100%; }
.trend .grid { stroke: #2c2c2c; stroke-width: 1; }
.trend .baseline { stroke: #3a3a3a; stroke-width: 1; }
.trend .axis { fill: var(--text-3); font-family: var(--font); font-size: 11px; font-variant-numeric: tabular-nums; }
.trend .crosshair { stroke: var(--text-2); stroke-width: 1; }
.trend .hit { fill: transparent; cursor: crosshair; outline: none; }

.viz-tip {
  position: absolute; z-index: 5; min-width: 190px; max-width: 300px; padding: 12px 14px;
  border-radius: var(--r-row); background: var(--panel); box-shadow: 0 0 0 1px var(--line), 0 12px 32px rgba(0, 0, 0, .5);
  font-size: var(--fs-small); pointer-events: none; opacity: 0; transition: opacity .12s;
}
.viz-tip.show { opacity: 1; }
.viz-tip__title { margin-bottom: 2px; font-size: var(--fs-tiny); color: var(--text-2); }
.viz-tip__total { margin-bottom: 6px; font-weight: 600; }
.viz-tip__row { display: grid; grid-template-columns: 12px auto minmax(0, 1fr); align-items: center; gap: 8px; line-height: 1.7; }
.viz-tip__row i { width: 12px; height: 2px; border-radius: 1px; background: var(--c); }
.viz-tip__row b { font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-tip__row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }

/* channel bars */
.hbars { display: grid; gap: 4px; }
.hbar { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr) 120px; align-items: center; gap: 12px; min-height: 30px; }
.hbar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-small); }
.hbar__name small { margin-left: 8px; color: var(--text-3); }
.hbar__track { height: 10px; }
.hbar__fill { display: block; height: 100%; min-width: 2px; border-radius: 0 4px 4px 0; background: var(--acc); }
.hbar__value { text-align: right; white-space: nowrap; font-size: var(--fs-small); font-weight: 600; font-variant-numeric: tabular-nums; }

/* events */
.events { display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
.event { display: grid; gap: 2px; padding: 10px 14px; border-radius: var(--r-row); background: var(--well); font-size: var(--fs-small); }
.event__meta { font-size: var(--fs-tiny); color: var(--text-3); font-variant-numeric: tabular-nums; }
.event__meta b { font-weight: 600; color: var(--text-2); }

/* tables: outlined header strip + rows in rounded wells */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0 8px; margin-top: -8px; }
th {
  height: 46px; padding: 0 16px; text-align: left; white-space: nowrap;
  font-size: var(--fs-tiny); font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
th:first-child { border-left: 1px solid var(--line); border-radius: var(--r-row) 0 0 var(--r-row); }
th:last-child { border-right: 1px solid var(--line); border-radius: 0 var(--r-row) var(--r-row) 0; }
td { height: 48px; padding: 6px 16px; background: var(--well); white-space: nowrap; font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
td:first-child { border-radius: var(--r-row) 0 0 var(--r-row); }
td:last-child { border-radius: 0 var(--r-row) var(--r-row) 0; }
tr:hover td { background: rgba(42, 42, 42, .6); }
tr[data-open] { cursor: pointer; }
td.preview { max-width: 360px; overflow: hidden; text-overflow: ellipsis; color: var(--text-2); }
.num { text-align: right; }
.dim { color: var(--text-3); }
.row-actions { display: flex; justify-content: flex-end; }
.row-actions .o-btn { height: 32px; padding: 0 14px; font-size: var(--fs-small); }
.tag { display: inline-flex; align-items: center; height: 24px; padding: 0 10px; border-radius: var(--r-chip); font-size: 12px; font-weight: 500; background: var(--soft); color: var(--text-2); }
.tag--acc { background: var(--acc-14); color: var(--acc); }
.tag--gold { background: rgba(255, 196, 107, .14); color: var(--gold); }
.tag--red { background: var(--red-17); color: var(--red); }
.dot { display: inline-block; width: 8px; height: 8px; margin-right: 8px; border-radius: 2px; background: var(--c); vertical-align: 1px; }
.more { margin-top: 8px; font-size: var(--fs-small); }

/* forward */
.forward-note { min-height: 22px; margin: -8px 0 16px; font-size: var(--fs-small); color: var(--text-2); }
.forward-note.is-red { color: var(--red); }
.forward-grid { display: grid; gap: 20px; }
.forward-box { display: grid; gap: 14px; align-content: start; }
.forward-box h2 { margin: 0; }
.forward-list { display: grid; gap: 8px; }
.forward-row { display: grid; grid-template-columns: minmax(0, 2fr) 16px minmax(0, 3fr) auto 64px; gap: 10px; align-items: center; padding: 8px 10px; border-radius: var(--r-row); background: var(--well); }
.forward-row .o-input { height: 40px; font-size: var(--fs-small); }
.forward-row .o-input:disabled { color: var(--text-2); cursor: default; }
.forward-row .arrow { font-style: normal; color: var(--text-3); text-align: center; }
.forward-row .o-btn { height: 36px; padding: 0 14px; font-size: var(--fs-small); }
.forward-row .tag { justify-self: end; }
.forward-row .check { white-space: nowrap; }
.forward-add { justify-self: start; height: 40px; }
.forward-empty { padding: 14px 0; font-size: var(--fs-small); color: var(--text-3); }

/* send */
.send-hint { margin-top: -8px; font-size: var(--fs-small); color: var(--text-2); }
.send-hint b { font-weight: 600; color: var(--acc); }
#send-result { display: grid; gap: 10px; font-size: var(--fs-small); }
.result-line { display: flex; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: var(--r-row); background: var(--well); }
.result-line b { font-weight: 600; }

/* dialog */
dialog.o-panel { width: min(720px, calc(100vw - 32px)); color: var(--text); border: 0; }
dialog::backdrop { background: rgba(0, 0, 0, .65); }
.dialog-head { margin-bottom: 14px; gap: 14px; }
.dialog-head .o-head__title { font-size: var(--fs-h2); white-space: normal; word-break: break-all; }
.dialog-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.code {
  max-height: 50vh; margin: 0 0 20px; padding: 16px; overflow: auto; border-radius: var(--r-row); background: var(--box);
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; right: 24px; bottom: 24px; z-index: 10; max-width: calc(100vw - 48px);
  padding: 14px 20px; border-radius: var(--r-row); background: var(--card); box-shadow: inset 3px 0 0 var(--acc);
  font-size: var(--fs-small); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: none; }
.toast.bad { box-shadow: inset 3px 0 0 var(--red); }

@media (max-width: 1100px) {
  .body { grid-template-columns: minmax(0, 1fr); }
  .nav { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .nav__th { display: none; }
  .split, .split--wide { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  #app { padding: 8px; }
  .shell { padding: 20px 16px; min-height: calc(100vh - 16px); }
  .top .o-head__sub, .top .o-hex { display: none; }
  .top .o-head__title { font-size: var(--fs-h2); }
  .tools, .tools .o-input, .tools input.o-input { width: 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hbar { grid-template-columns: minmax(0, 1fr) 90px; }
  .forward-row { grid-template-columns: minmax(0, 1fr) auto; }
  .forward-row .arrow { display: none; }
  .forward-row [data-field=channel], .forward-row [data-field=event] { grid-column: 1 / -1; }
  .hbar__track { display: none; }
}
