/* ============================================================
   NEXUS//ADS — dark bento console
   slate #0d1117 · panels #131a22 · steel-cyan accent #4cc9f0
   ============================================================ */

:root {
  --bg: #0d1117;
  --panel: #131a22;
  --panel-2: #0f151c;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --fg: #e8ecf1;
  --fg-2: #a9b1ba;
  --muted: #8a8e97;
  --accent: #4cc9f0;
  --accent-dim: rgba(76, 201, 240, .12);
  --green: #4ade80;
  --amber: #fbbf24;
  --red: #f87171;
  --mono: Consolas, "Cascadia Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-font-smoothing: antialiased; }

body {
  font-family: "Segoe UI", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -.005em;
  font-variant-numeric: tabular-nums;
}

a { color: inherit; text-decoration: none; }

::selection { background: rgba(76, 201, 240, .28); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .12); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }

/* ---------- layout ---------- */

.layout { display: flex; min-height: 100vh; }

.main { flex: 1; min-width: 0; padding: 20px 26px 40px; }

/* ---------- sidebar ---------- */

.irail {
  width: 236px; flex: none;
  border-right: 1px solid var(--line);
  background: var(--panel-2);
  padding: 14px 10px 14px;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}

.hdr { padding: 8px 8px 16px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }

.brand {
  font-size: 15px; font-weight: 700; letter-spacing: -.02em;
  color: var(--fg);
}
.brand .sl { color: var(--accent); }

.hdr .name { font-size: 12.5px; color: var(--fg-2); margin-top: 3px; }
.hdr .sub {
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  margin-top: 8px; letter-spacing: .04em;
}
.hdr .sub .led {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
  flex: none;
}

.irail nav { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); padding: 10px 8px 5px;
}

.irail nav a {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; border-radius: 6px;
  color: var(--fg-2); font-size: 13.5px;
  transition: background .12s, color .12s;
}
.irail nav a svg { width: 16px; height: 16px; flex: none; opacity: .78; }
.irail nav a:hover { background: rgba(255, 255, 255, .04); color: var(--fg); }
.irail nav a.active {
  background: rgba(76, 201, 240, .10);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(76, 201, 240, .22);
}
.irail nav a.active svg { opacity: 1; }

.irail nav a .n {
  margin-left: auto;
  font-family: var(--mono); font-size: 11.5px; color: var(--muted);
  border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; line-height: 1.6;
}
.irail nav a.active .n { color: var(--accent); border-color: rgba(76, 201, 240, .3); }

/* sidebar footer */
.hend { margin-top: auto; border-top: 1px solid var(--line); padding: 12px 8px 0; }

.wsmeta {
  font-family: var(--mono); font-size: 12px; letter-spacing: .05em;
  color: var(--muted); display: flex; flex-direction: column; gap: 3px;
  margin-bottom: 12px;
}
.wsmeta .wsk { color: rgba(255, 255, 255, .72); margin-right: 6px; }
.wsmeta .wsk + * { color: var(--fg-2); }

.out {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--muted);
  padding: 6px 2px; transition: color .12s;
}
.out svg { width: 16px; height: 16px; }
.out:hover { color: var(--red); }

/* ---------- status band ---------- */

.hero.sysline {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
  font-family: var(--mono); font-size: 11.5px; letter-spacing: .07em;
  color: var(--fg-2);
  border: 1px solid var(--line); border-radius: 8px;
  background: linear-gradient(180deg, rgba(76, 201, 240, .06), rgba(76, 201, 240, 0) 55%), var(--panel);
  padding: 9px 14px; margin-bottom: 16px;
  position: relative; overflow: hidden;
}
.hero.sysline::before {
  content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(76, 201, 240, .7), transparent);
}
.hero .dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
  margin-right: 7px;
}
.hero .sep { color: rgba(255, 255, 255, .18); margin: 0 9px; }
.hero .keys { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--muted); letter-spacing: .02em; }

/* KPI variant of hero (JS/extra markup safety) */
.hero.kpi {
  font-family: inherit; letter-spacing: -.005em;
  font-size: 14px; color: var(--fg);
  padding: 12px 16px;
}
.hero.kpi b { font-size: 20px; font-weight: 700; letter-spacing: -.02em; color: var(--accent); }

/* kbd capsule */
kbd, .kbd {
  font-family: var(--mono); font-size: 12px;
  color: var(--fg-2);
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 6px;
  background: rgba(255, 255, 255, .04);
}

/* ---------- page head ---------- */

.page-head { margin-bottom: 18px; }
.page-head h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2;
}
.page-head p { color: var(--muted); margin-top: 3px; font-size: 14px; }
.page-head .btn.tiny { margin-top: 4px; }

/* ---------- bento grid ---------- */

.bento { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.bento .card { margin-bottom: 0; }

/* ---------- card ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px 18px 18px;
  margin-bottom: 14px;
  position: relative;
  transition: border-color .15s, background .15s;
}
.card:hover { border-color: var(--line-2); background: #141c25; }

.card.glow::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(90deg, transparent, rgba(76, 201, 240, .8), transparent);
}

.card h2 {
  font-size: 13px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--fg-2);
  margin-bottom: 12px;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

/* KPI tile bits */
.card .cap {
  font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); display: flex; align-items: center; gap: 6px;
}
.card .big {
  font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15;
  margin-top: 5px;
}
.card .big em { font-style: normal; font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 7px; }
.card .delta { font-size: 12px; color: var(--green); margin-top: 3px; }
.card .delta.down { color: var(--amber); }

/* ---------- tables ---------- */

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left; font-size: 12px; font-weight: 500;
  color: var(--muted); text-transform: uppercase; letter-spacing: .08em;
  padding: 8px 10px; border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
td {
  text-align: left; padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px; color: var(--fg-2);
  vertical-align: middle;
}
td b { color: var(--fg); font-weight: 600; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .03); }

/* pending sync row (inline #fffdf5) → steel-cyan tint */
tr[style*="fffdf5"] td { background: rgba(76, 201, 240, .06) !important; }

/* ---------- badges & tags ---------- */

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 5px;
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .03em;
  border: 1px solid transparent;
}
.badge.active { background: rgba(74, 222, 128, .13); border-color: rgba(74, 222, 128, .3); color: var(--green); }
.badge.paused { background: rgba(251, 191, 36, .12); border-color: rgba(251, 191, 36, .3); color: var(--amber); }
.badge.verifying { background: var(--accent-dim); border-color: rgba(76, 201, 240, .35); color: var(--accent); animation: pulse 1.1s ease-in-out infinite; }

@keyframes pulse { 50% { opacity: .45; } }

/* inline-styled light badges on dark theme → cyan chip */
.badge[style] {
  background: var(--accent-dim) !important;
  color: var(--accent) !important;
  border: 1px solid rgba(76, 201, 240, .3);
}

.perm-tag {
  font-family: var(--mono); font-size: 12px;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(76, 201, 240, .22);
  padding: 1px 7px; border-radius: 4px;
  font-weight: 400; letter-spacing: .02em;
}

.mono { font-family: var(--mono); font-size: 12.5px; color: var(--muted); letter-spacing: 0; }

/* ---------- notice ---------- */

.notice {
  display: none;
  padding: 10px 14px; border-radius: 8px;
  font-size: 13.5px; margin-bottom: 14px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  color: var(--fg);
}
.notice.show { display: block; }
.notice.err { border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); color: var(--red); }
.notice.ok { border-color: rgba(74, 222, 128, .3); background: rgba(74, 222, 128, .08); color: var(--green); }

/* ---------- loading / empty states ---------- */

.loading {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--line-2);
  border-radius: 8px;
  background: rgba(255, 255, 255, .015);
  padding: 14px 16px; margin: 4px 0;
}
.loading::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--accent);
  box-shadow: 0 0 8px rgba(76, 201, 240, .7);
  animation: pulse 1.1s ease-in-out infinite;
}

/* ---------- buttons ---------- */

button, .btn {
  font: inherit; font-size: 13.5px;
  color: var(--fg-2);
  background: rgba(255, 255, 255, .05);
  border: 1px solid var(--line-2);
  padding: 7px 14px; border-radius: 7px;
  cursor: pointer; text-decoration: none;
  display: inline-block;
  transition: filter .12s, color .12s, border-color .12s, background .12s;
}
button:hover, .btn:hover { color: var(--fg); border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .09); }

button.primary, .btn.primary {
  color: #062830;
  font-weight: 600;
  background: linear-gradient(180deg, #5fd4f6, #38b7dd);
  border-color: rgba(255, 255, 255, .25);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 4px 14px -6px rgba(76, 201, 240, .8);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.1); color: #062830; }

button.tiny, .btn.tiny { padding: 4px 10px; font-size: 12.5px; border-radius: 6px; }
td button.tiny + button.tiny, td button.tiny + a.btn.tiny, td a.btn.tiny + button.tiny, td a.btn.tiny + a.btn.tiny { margin-left: 6px; }

button:disabled { opacity: .45; cursor: not-allowed; }

/* Authorized pill (JS-generated on dashboard) */
button.authorized:disabled, button.authorized:disabled:hover {
  opacity: 1; cursor: default;
  background: rgba(74, 222, 128, .1);
  border-color: rgba(74, 222, 128, .3);
  color: var(--green);
}

/* ---------- tabs ---------- */

.tabs a {
  padding: 5px 13px; border-radius: 6px;
  font-size: 13px; color: var(--fg-2);
  border: 1px solid var(--line-2);
  transition: background .12s, color .12s, border-color .12s;
}
.tabs a:hover { color: var(--fg); background: rgba(255, 255, 255, .05); }
.tabs a.active {
  background: var(--accent-dim);
  border-color: rgba(76, 201, 240, .4);
  color: var(--accent);
}

/* ---------- forms ---------- */

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }

.field label {
  display: block; font-size: 12.5px; color: var(--fg-2);
  margin-bottom: 5px; font-family: var(--mono); letter-spacing: .02em;
}

select, input, textarea {
  font: inherit; font-size: 13.5px;
  padding: 8px 11px;
  border: 1px solid var(--line-2);
  border-radius: 7px;
  background: var(--panel-2);
  color: var(--fg);
  transition: border-color .12s, box-shadow .12s;
}

/* dark native controls — kill the white OS chrome */
select {
  appearance: none; -webkit-appearance: none;
  background-color: var(--panel-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='none' stroke='%238a8e97' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.field input, .field textarea, .field select { width: 100%; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; margin-bottom: 0; }
.field { min-width: 0; }

.field input:focus, .field textarea:focus, .field select:focus,
select:focus, input:focus, textarea:focus {
  outline: none;
  border-color: rgba(76, 201, 240, .55);
  box-shadow: 0 0 0 3px rgba(76, 201, 240, .12);
}
textarea { resize: vertical; }

.form-actions { grid-column: span 2; margin-top: 8px; display: flex; justify-content: flex-end; gap: 10px; }

select option { background: #131a22; color: #e8ecf1; }

/* revoke / destructive action */
#btnDis {
  color: var(--red);
  border-color: rgba(248, 113, 113, .32);
  background: rgba(248, 113, 113, .08);
  font-family: var(--mono); font-size: 12.5px; letter-spacing: .06em;
}
#btnDis:hover { color: #fff; background: rgba(248, 113, 113, .2); border-color: rgba(248, 113, 113, .5); }

/* TREE not loaded yet */
#tier:empty::after {
  content: "No level loaded \2014  pick an account, then press QUERY.";
  display: block;
  font-family: var(--mono); font-size: 12.5px; color: var(--muted);
  border: 1px dashed var(--line-2); border-radius: 8px;
  padding: 14px 16px;
}


/* ---------- overlays (confirm / invite) ---------- */

#confirmOverlay, #inviteOverlay {
  background: rgba(5, 10, 16, .72) !important;
  backdrop-filter: blur(3px);
}

#confirmOverlay .card, #inviteOverlay .card {
  border-color: var(--line-2);
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, .8), 0 0 0 1px rgba(76, 201, 240, .08);
}

/* ---------- login ---------- */

.land { display: flex; min-height: 100vh; }
.land-left { flex: 1; background: var(--panel-2); color: var(--fg-2); display: flex; flex-direction: column; justify-content: center; padding: 60px 70px; }
.land-left h1 { font-size: 30px; color: var(--fg); font-weight: 700; letter-spacing: -.02em; }
.land-left p { margin-top: 12px; color: var(--muted); max-width: 420px; }
.land-right { flex: 1; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 16px; }

.fb-btn {
  display: inline-flex; align-items: center; gap: 10px;
  background: #1877f2; color: #fff; font-weight: 600; font-size: 15px;
  border: none; border-radius: 8px; padding: 13px 30px;
  text-decoration: none; transition: filter .12s;
}
.fb-btn:hover { filter: brightness(1.1); color: #fff; }

.foot-links { font-size: 12.5px; color: var(--muted); }
.foot-links a { color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.foot-links a:hover { color: var(--accent); }

/* ---------- misc ---------- */

p[style*="muted"] { color: var(--muted); }

@media (max-width: 1100px) {
  .bento { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- responsive: ≤900px ---------- */

@media (max-width: 900px) {
  .layout { flex-direction: column; }

  .irail {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center;
    border-right: none; border-bottom: 1px solid var(--line);
    padding: 8px 12px; gap: 6px;
    overflow-x: auto;
  }
  .hdr { border-bottom: none; margin-bottom: 0; padding: 4px 10px 4px 4px; }
  .hdr .name, .hdr .sub { display: none; }
  .irail nav { flex-direction: row; gap: 2px; }
  .nav-label { display: none; }
  .irail nav a { padding: 7px 9px; white-space: nowrap; }
  .irail nav a .n { display: none; }
  .hend { margin-top: 0; margin-left: auto; border-top: none; padding: 0; }
  .wsmeta { display: none; }

  .main { padding: 16px 14px 30px; }
  .bento { grid-template-columns: 1fr; }
}

/* ---------- responsive: ≤620px ---------- */

@media (max-width: 620px) {
  .irail { padding: 7px 8px; gap: 2px; }
  .hdr { padding: 4px 6px 4px 2px; }
  .brand { font-size: 14px; }
  .irail nav a { padding: 8px 9px; }
  .irail nav a .lbl { display: none; }
  .out span { display: none; }

  .hero.sysline { font-size: 10.5px; letter-spacing: .05em; padding: 8px 11px; }
  .hero .sep { margin: 0 6px; }
  .hero .keys { display: none; }

  .page-head h1 { font-size: 19px; }
  .card { overflow-x: auto; padding: 14px 14px 16px; }
  .card .big { font-size: 22px; }

  .form-grid { grid-template-columns: 1fr; }
  .form-actions { grid-column: span 1; }

  table { min-width: 520px; }
  th, td { padding: 8px 8px; }
  td button, td a.btn { white-space: nowrap; }
  td[style*="display:flex"] { flex-wrap: wrap; row-gap: 6px; }
  .act-wrap table { min-width: 0; }

  #wsassets table, #wsbox table { min-width: 0; }
  #wsassets table th:first-child, #wsassets table td:first-child,
  #wsbox table th:first-child, #wsbox table td:first-child { display: none; }
  #insights table { min-width: 460px; }
}

