/* ============================================================================
   Siphrix — Console  ·  login gate + unified operator shell
   Integrates the account console, operator dashboard and web console under
   one theme. Talks to the live service tier when present; mock demo otherwise.
   ============================================================================ */

/* ===================== LOGIN (command-center split) ===================== */
.login-canvas { position: fixed; inset: 0; z-index: 0; opacity: .55; }
.login-split {
  position: relative; z-index: var(--z-content); min-height: 100vh;
  display: grid; grid-template-columns: 1.05fr .95fr; align-items: stretch;
}
@media (max-width: 880px) { .login-split { grid-template-columns: 1fr; } }

.login-brand {
  position: relative; display: flex; flex-direction: column; justify-content: center;
  gap: 1.1rem; padding: clamp(2rem, 6vw, 5rem); overflow: hidden;
  border-right: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(43,212,189,.06), transparent 60%);
}
@media (max-width: 880px) { .login-brand { display: none; } }
.login-brand .brand { font-size: 1.3rem; }
.login-h1 { font-size: clamp(2rem, 3.6vw, 3.2rem); font-weight: 800; line-height: 1.08; letter-spacing: -.03em; margin-top: .6rem; }
.login-lead { color: var(--ink-2); font-size: 1.05rem; max-width: 42ch; }
.login-points { list-style: none; padding: 0; margin: .6rem 0 0; display: flex; flex-direction: column; gap: .8rem; }
.login-points li { display: flex; align-items: center; gap: .7rem; color: var(--ink-2); font-size: .96rem; }
.login-points li span { font-size: 1.1rem; }
.login-feed { margin-top: 1.4rem; display: flex; flex-direction: column; gap: .4rem; max-width: 360px; }
.login-feed .lf { display: flex; align-items: center; gap: .6rem; font-family: var(--font-mono); font-size: .76rem;
  padding: .45rem .7rem; border-radius: 9px; border: 1px solid var(--line); background: rgba(255,255,255,.02);
  opacity: 0; transform: translateY(6px); animation: lf-in .4s var(--ease-out) forwards; }
@keyframes lf-in { to { opacity: 1; transform: none; } }
.login-feed .lf .v { margin-left: auto; font-weight: 700; }
.login-feed .lf.allow .v { color: var(--allow); } .login-feed .lf.block .v { color: var(--block); } .login-feed .lf.abort .v { color: var(--abort); }

.login-forms { display: grid; place-items: center; padding: 90px var(--gut) 3rem; }
.login-card { width: 100%; max-width: 420px; padding: 2.2rem; border-radius: var(--radius-lg); position: relative; z-index: 1; }
.login-card .brand { font-size: 1.4rem; margin-bottom: .3rem; }
.login-card .login-sub { color: var(--ink-2); font-size: .95rem; margin-bottom: 1.6rem; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .82rem; color: var(--ink-3); margin-bottom: .45rem; font-family: var(--font-mono); letter-spacing: .04em; }
.field input {
  width: 100%; padding: .8rem .95rem; border-radius: 11px; background: var(--bg-1);
  border: 1px solid var(--line-2); transition: border-color var(--t-fast);
}
.field input:focus { outline: none; border-color: var(--line-teal); box-shadow: 0 0 0 3px rgba(43,212,189,.12); }
.login-err { color: var(--block); font-size: .85rem; min-height: 20px; margin: .2rem 0 .6rem; }
.login-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 1.2rem; font-size: .82rem; }
.login-status { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-3); }
.login-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.login-status.online .dot { background: var(--allow); box-shadow: 0 0 8px var(--allow); }
.login-status.offline .dot { background: var(--abort); }
.login-demo { color: var(--teal); text-decoration: underline; text-underline-offset: 3px; }
.login-hint { margin-top: 1.4rem; padding: .9rem 1rem; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line); font-size: .8rem; color: var(--ink-3); }
.login-hint code { color: var(--teal); }

/* ===================== APP SHELL ===================== */
.app { display: none; min-height: 100vh; grid-template-columns: 248px minmax(0,1fr); }
.app.show { display: grid; }
@media (max-width: 860px) { .app.show { grid-template-columns: 1fr; } }

/* sidebar */
.app-side {
  position: sticky; top: 0; align-self: start; height: 100vh; display: flex; flex-direction: column;
  border-right: 1px solid var(--line); background: var(--bg-1); padding: 1.2rem .9rem;
}
/* scrim is mobile-only; never a static grid item on desktop */
.app-scrim { display: none; }
@media (max-width: 860px) {
  .app-side {
    position: fixed; inset: 0 30% 0 0; z-index: var(--z-modal); height: 100vh;
    transform: translateX(-105%); transition: transform var(--t) var(--ease);
    box-shadow: var(--shadow-2);
  }
  .app.menu-open .app-side { transform: none; }
  .app-scrim { display: block; position: fixed; inset: 0; z-index: calc(var(--z-modal) - 1); background: rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: opacity var(--t); }
  .app.menu-open .app-scrim { opacity: 1; pointer-events: auto; }
}
.app-side .brand { padding: .3rem .5rem 1.2rem; }
.side-nav { display: flex; flex-direction: column; gap: .2rem; overflow-y: auto; flex: 1; }
.side-label { font-size: .68rem; text-transform: uppercase; letter-spacing: .14em; color: var(--ink-3); padding: 1rem .7rem .4rem; }
.side-link {
  display: flex; align-items: center; gap: .7rem; padding: .6rem .7rem; border-radius: 10px;
  color: var(--ink-2); font-size: .92rem; font-weight: 500; transition: all var(--t-fast); cursor: pointer;
}
.side-link svg { width: 18px; height: 18px; flex: none; opacity: .8; }
.side-link:hover { color: var(--ink); background: rgba(255,255,255,.04); }
.side-link.active { color: var(--teal); background: rgba(43,212,189,.08); }
.side-link.active svg { opacity: 1; }
.side-link .pill { margin-left: auto; font-size: .68rem; background: var(--block); color: #fff; border-radius: 999px; padding: .05rem .4rem; font-weight: 700; }
.side-foot { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: .5rem; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .4rem .5rem; font-size: .82rem; }
.side-user .av { width: 30px; height: 30px; border-radius: 9px; background: var(--grad-teal); color: var(--ink-on-teal); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-user .su-meta { overflow: hidden; }
.side-user .su-meta b { display: block; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user .su-meta span { color: var(--ink-3); font-size: .72rem; }
.side-logout { margin-top: .5rem; width: 100%; text-align: left; padding: .5rem .7rem; border-radius: 8px; color: var(--ink-3); font-size: .85rem; }
.side-logout:hover { color: var(--block); background: rgba(224,85,107,.08); }

/* main */
.app-main { min-height: 100vh; overflow-x: hidden; }
.app-top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 1rem;
  padding: 1rem clamp(1rem,3vw,2rem); border-bottom: 1px solid var(--line);
  background: rgba(8,12,18,.8); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.app-burger { display: none; }
@media (max-width: 860px) { .app-burger { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line-2); border-radius: 10px; } }
.app-top h1 { font-size: 1.2rem; font-weight: 650; }
.app-top .mode-badge { margin-left: auto; }
.app-view { padding: clamp(1.2rem, 3vw, 2rem); max-width: 1100px; }

/* ===================== WIDGETS ===================== */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.4rem; }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi-card { padding: 1.2rem; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-3); }
.kpi-card .k-label { font-size: .76rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .1em; }
.kpi-card .k-val { font-size: 2rem; font-weight: 700; font-family: var(--font-mono); margin: .3rem 0; }
.kpi-card .k-sub { font-size: .8rem; color: var(--ink-3); }
.kpi-card.allow .k-val { color: var(--allow); } .kpi-card.block .k-val { color: var(--block); } .kpi-card.abort .k-val { color: var(--abort); }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-2); margin-bottom: 1.4rem; overflow: hidden; }
.panel-head { display: flex; align-items: center; gap: .8rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.panel-head h3 { font-size: 1rem; }
.panel-head .ph-actions { margin-left: auto; display: flex; gap: .5rem; }
.panel-body { padding: 1.2rem; }
.panel-body.flush { padding: 0; }

/* table */
.dtable { width: 100%; border-collapse: collapse; font-size: .86rem; }
.dtable th, .dtable td { text-align: left; padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); }
.dtable th { color: var(--ink-3); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; position: sticky; top: 0; background: var(--bg-2); }
.dtable tr:hover td { background: rgba(255,255,255,.02); }
.dtable code { font-size: .82em; color: var(--ink-2); }
.v-tag { font-family: var(--font-mono); font-size: .7rem; font-weight: 700; padding: .2rem .5rem; border-radius: 6px; }
.v-tag.allow { color: var(--allow); background: rgba(43,212,189,.12); }
.v-tag.block { color: var(--block); background: rgba(224,85,107,.12); }
.v-tag.abort { color: var(--abort); background: rgba(246,167,64,.12); }

/* platform rows (account console) */
.plat-row { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.plat-row:last-child { border-bottom: none; }
.plat-ic { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--bg-4); font-weight: 700; flex: none; }
.plat-meta { flex: 1; }
.plat-meta b { display: block; }
.plat-meta span { font-size: .8rem; color: var(--ink-3); }
.seg.sm button { padding: .35rem .75rem; font-size: .78rem; }
.seg.sm button.on.lvl-off { background: #3a4150; color: #fff; }
.seg.sm button.on.lvl-basic { background: var(--grad-teal); color: var(--ink-on-teal); }
.seg.sm button.on.lvl-strict { background: var(--block); color: #fff; }

/* rule builder — reads like a sentence */
.rule-builder { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; line-height: 2.4; }
.rb-text { color: var(--ink-2); font-size: .95rem; }
.rb-inline { width: auto; display: inline-block; }
.rb-grow { flex: 1; min-width: 180px; }
select.inp { cursor: pointer; }

/* forms */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; margin-bottom: .8rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }
.inp { width: 100%; padding: .7rem .85rem; border-radius: 10px; background: var(--bg-1); border: 1px solid var(--line-2); }
.inp:focus { outline: none; border-color: var(--line-teal); }
.chips-pick { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-pick { padding: .4rem .7rem; border-radius: 8px; border: 1px solid var(--line-2); font-size: .8rem; cursor: pointer; }
.chip-pick.on { border-color: var(--line-teal); background: rgba(43,212,189,.08); color: var(--teal); }

/* analytics bars */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 1rem 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; min-width: 0; }
.bar-seg { border-radius: 3px 3px 0 0; transition: height var(--t) var(--ease); }
.bar-seg.allow { background: var(--allow); } .bar-seg.block { background: var(--block); } .bar-seg.abort { background: var(--abort); }
.bar-label { text-align: center; font-size: .62rem; color: var(--ink-3); margin-top: .4rem; }
.rank-list { display: flex; flex-direction: column; gap: .6rem; }
.rank-item { display: flex; align-items: center; gap: .8rem; }
.rank-item .rk-bar { flex: 1; height: 8px; border-radius: 999px; background: var(--bg-4); overflow: hidden; }
.rank-item .rk-fill { height: 100%; background: var(--grad-teal); border-radius: 999px; }
.rank-item .rk-name { width: 150px; font-size: .85rem; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-item .rk-val { width: 36px; text-align: right; font-family: var(--font-mono); font-size: .82rem; color: var(--ink-3); }

/* empty / toast */
.view-empty { text-align: center; color: var(--ink-3); padding: 3rem 1rem; }
.toast { position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(120%); z-index: var(--z-modal);
  background: var(--bg-4); border: 1px solid var(--line-teal); border-radius: 12px; padding: .8rem 1.2rem; font-size: .88rem;
  box-shadow: var(--shadow-2); transition: transform var(--t) var(--spring); }
.toast.show { transform: translateX(-50%) translateY(0); }

.mode-badge.live { color: var(--allow); border-color: rgba(43,212,189,.4); background: rgba(43,212,189,.08); }
.mode-badge.demo { color: var(--abort); border-color: rgba(246,167,64,.4); background: rgba(246,167,64,.08); }

/* shell polish */
.side-link.active { position: relative; }
.side-link.active::before { content: ""; position: absolute; left: -9px; top: 50%; transform: translateY(-50%); width: 3px; height: 18px; border-radius: 3px; background: var(--grad-teal); box-shadow: 0 0 10px var(--allow-glow); }
.kpi-card { position: relative; overflow: hidden; transition: border-color var(--t), transform var(--t); }
.kpi-card:hover { transform: translateY(-2px); border-color: var(--line-teal); }
.kpi-card::after { content: ""; position: absolute; inset: auto -30% -60% auto; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(43,212,189,.10), transparent 70%); }
.kpi-card.block::after { background: radial-gradient(circle, rgba(224,85,107,.10), transparent 70%); }
.kpi-card.abort::after { background: radial-gradient(circle, rgba(246,167,64,.10), transparent 70%); }
.panel { transition: border-color var(--t); }
.panel-head { background: linear-gradient(180deg, rgba(255,255,255,.02), transparent); }
.app-top { position: relative; }
.app-top::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: var(--grad-line); opacity: .5; }
.mode-badge.live { animation: live-pulse 3s var(--ease) infinite; }
@keyframes live-pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(43,212,189,0);} 50% { box-shadow: 0 0 14px -2px var(--allow-glow);} }
@media (prefers-reduced-motion: reduce) { .mode-badge.live { animation: none; } }

/* connections / fleet */
.dot-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: .3rem; vertical-align: middle; }
.dot-status.on { background: var(--allow); box-shadow: 0 0 8px var(--allow); }
.dot-status.off { background: var(--ink-3); }
.dev-del { font-size: 1rem; }
.dv-token { margin-top: 1rem; padding: 1rem; border: 1px solid var(--line-teal); border-radius: var(--radius-sm); background: rgba(43,212,189,.05); }
.dv-token .token-row { display: flex; align-items: center; gap: .6rem; margin-top: .5rem; }
.dv-token code { flex: 1; font-size: .82rem; word-break: break-all; background: var(--bg-1); padding: .5rem .7rem; border-radius: 8px; border: 1px solid var(--line); color: var(--teal); }

.hide { display: none !important; }

/* ============================================================
   Help hints — small "?" chips with a plain-language bubble on
   hover or keyboard focus. Used across every console panel.
   ============================================================ */
.hint {
  display: inline-grid; place-items: center;
  width: 17px; height: 17px; margin-left: .45rem;
  border-radius: 50%;
  font-size: .68rem; font-weight: 700; line-height: 1;
  color: var(--ink-3); background: color-mix(in srgb, var(--ink-3) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink-3) 30%, transparent);
  cursor: help; position: relative; vertical-align: middle; flex: none;
}
.hint:hover, .hint:focus-visible { color: var(--teal, #2bd4bd); border-color: var(--teal, #2bd4bd); outline: none; }
.hint::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 9px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 300px;
  padding: .6rem .75rem; border-radius: 10px;
  background: #0d1520; color: #dfe6f0;
  border: 1px solid rgba(43, 212, 189, .35);
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.6);
  font-size: .78rem; font-weight: 500; line-height: 1.45; text-align: left;
  white-space: normal; letter-spacing: 0;
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
  z-index: 60;
}
.hint::before {
  content: "";
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 9px; height: 9px; background: #0d1520;
  border-right: 1px solid rgba(43,212,189,.35); border-bottom: 1px solid rgba(43,212,189,.35);
  opacity: 0; pointer-events: none; transition: opacity .12s ease;
  z-index: 61;
}
.hint:hover::after, .hint:focus-visible::after,
.hint:hover::before, .hint:focus-visible::before { opacity: 1; }
/* Panels near the left edge: keep the bubble on-screen */
.panel-head .hint::after { left: 0; transform: none; }
.panel-head .hint::before { left: 8px; transform: rotate(45deg); }

/* Bigger brand in the signed-in sidebar */
.app-side .brand .mark { width: 52px; height: 52px; }
.app-side .brand { font-size: 1.45rem; }
