/* ==========================================================================
   DevCore Portal — stylesheet
   Destination: devcore/apps/portal/public/css/portal.css
   Pairs with the redesigned views/partials/topbar.ejs + foot.ejs (sidebar shell).
   Every class name the existing EJS views already use is preserved.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  /* night palette */
  --night: #0b0b11; --night2: #121019; --night3: #17161f; --night4: #211f2e;
  --panel: #151320;
  --violet: #6b4fe0; --violet-lt: #8b7bf0; --violet-lter: #a99bf7;
  --nsignal: #f04525; --ngood: #7de08a; --nwarn: #e0b34f; --ninfo: #5B9FD7;
  --ntext: #ECEBF2; --ntext70: rgba(236,235,242,.70); --ntext50: rgba(236,235,242,.48); --ntext34: rgba(236,235,242,.34);
  --line: rgba(236,235,242,.08); --line-strong: rgba(236,235,242,.16);
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --r-sm: 10px; --r-md: 14px; --r-lg: 18px;
  --sidebar-w: 256px;
  --panel-grad: linear-gradient(160deg, rgba(48,46,68,.26), rgba(16,16,26,.14));
  --panel-grad-strong: linear-gradient(160deg, rgba(48,46,68,.32), rgba(16,16,26,.2));
  --accent-grad: linear-gradient(120deg, rgba(107,79,224,.16), rgba(16,16,26,.2));

  background: var(--night); color: var(--ntext);
  font-family: 'Archivo', system-ui, sans-serif; line-height: 1.6; font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--violet-lter); }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; }
::selection { background: rgba(139,123,240,.32); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(236,235,242,.13); border-radius: 8px; border: 2px solid var(--night); }
::-webkit-scrollbar-thumb:hover { background: rgba(236,235,242,.24); }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--violet-lt); outline-offset: 2px; border-radius: var(--r-sm);
}

/* --- motion --------------------------------------------------------------- */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rowIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes sheen { 0% { transform: translateX(-120%); } 100% { transform: translateX(220%); } }
@keyframes livePulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 8px 1px rgba(125,224,138,.7); }
  50% { opacity: .5; box-shadow: 0 0 3px 0 rgba(125,224,138,.3); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   SHELL — sidebar + content column (opened in topbar.ejs, closed in foot.ejs)
   ========================================================================== */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  display: flex; flex-direction: column; gap: 2px;
  padding: 22px 16px; border-right: 1px solid var(--line);
  background: linear-gradient(180deg, var(--night2), #0d0c13);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 11px; padding: 4px 8px 22px; }
.sidebar .brand:hover { color: inherit; }
.sidebar .brand-mark {
  width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: linear-gradient(150deg, var(--violet-lt), var(--violet));
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 22px -8px rgba(107,79,224,.9);
}
.sidebar .brand-name { font-weight: 700; letter-spacing: -.01em; font-size: .95rem; line-height: 1.15; }
.sidebar .brand-sub { font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ntext34); }

.nav-group { font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ntext34); padding: 16px 10px 6px; }
.nav-group:first-of-type { padding-top: 8px; }

.sidebar nav { display: contents; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 11px; font-size: .9rem; color: var(--ntext50);
  transition: background-color .16s ease, color .16s ease;
}
.nav-item svg { flex: none; }
.nav-item:hover { background: rgba(236,235,242,.05); color: var(--ntext); }
.nav-item.active { color: #fff; font-weight: 600; background: linear-gradient(90deg, rgba(139,123,240,.2), rgba(139,123,240,.03)); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: var(--violet-lt); box-shadow: 0 0 12px 1px rgba(139,123,240,.8);
}
.nav-item.active svg { color: var(--violet-lt); }
.nav-count {
  margin-left: auto; font-family: var(--mono); font-size: .62rem; font-weight: 500;
  color: var(--night); background: var(--violet-lt); border-radius: 20px; padding: 1px 7px;
}

.sidebar-foot { margin-top: auto; padding-top: 18px; }
.sidebar-user {
  display: flex; align-items: center; gap: 8px; padding: 8px;
  border: 1px solid var(--line); border-radius: 12px; background: rgba(236,235,242,.03);
}
.sidebar-user .who { flex: 1; min-width: 0; display: flex; align-items: center; gap: 11px; padding: 2px; border-radius: 9px; transition: background-color .16s ease; }
.sidebar-user .who:hover { background: rgba(236,235,242,.06); color: inherit; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  background: linear-gradient(150deg, var(--violet-lt), #4b39b8);
  display: flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: var(--night);
}
.sidebar-user .name { display: block; font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .role-badge {
  display: block; font-family: var(--mono); font-size: .6rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ntext50); border: 0; padding: 0;
}
.logout-btn { background: none; border: 0; color: var(--ntext50); cursor: pointer; padding: 4px; display: flex; flex: none; transition: color .16s ease; }
.logout-btn:hover { color: #fff; }

.content {
  min-width: 0;
  background:
    radial-gradient(120% 80% at 88% -8%, rgba(107,79,224,.16), transparent 46%),
    radial-gradient(90% 60% at 0% 4%, rgba(139,123,240,.07), transparent 40%),
    var(--night);
}

.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px clamp(20px, 3vw, 34px);
  border-bottom: 1px solid var(--line);
  background: rgba(11,11,17,.74); backdrop-filter: blur(16px);
}
.appbar .org { font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ntext50); }
.appbar .where { font-size: 1.12rem; font-weight: 700; letter-spacing: -.01em; }

/* ==========================================================================
   PAGE
   ========================================================================== */
main.page { padding: 26px 0 70px; animation: fadeIn .3s ease both; }
.wrap { max-width: 1300px; margin-inline: auto; padding-inline: clamp(20px, 3vw, 34px); }

.page-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.eyebrow { font-family: var(--mono); font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ntext50); }
h1.title { font-size: clamp(1.35rem, 2.4vw, 1.7rem); animation: fadeUp .5s ease both; }
h2 { font-size: 1.1rem; font-weight: 700; }

/* A live/status strip: <div class="livebar"> … </div> */
.livebar {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 16px 20px; margin-bottom: 20px;
  border: 1px solid rgba(139,123,240,.22); border-radius: var(--r-lg);
  background: var(--accent-grad); animation: fadeUp .5s ease both;
}
.livebar::after {
  content: ""; position: absolute; top: 0; bottom: 0; width: 120px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(236,235,242,.06), transparent);
  animation: sheen 3.6s ease-in-out .6s infinite;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ngood); animation: livePulse 2.4s ease-in-out infinite; }
.live-label { display: inline-flex; align-items: center; gap: 7px; font-family: var(--mono); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ngood); }
.live-meta { font-family: var(--mono); font-size: .72rem; color: var(--ntext50); }
.livebar .spacer, .page-head .spacer { flex: 1; }

.hr { height: 1px; border: 0; background: var(--line-strong); margin: 28px 0; }
.muted { color: var(--ntext50); }
.mono { font-family: var(--mono); }

/* ==========================================================================
   CARDS / GRIDS / STATS
   ========================================================================== */
.card {
  border: 1px solid var(--line); border-radius: var(--r-md); padding: 22px;
  background: var(--panel-grad); min-width: 0;
  animation: fadeUp .55s ease both;
  transition: transform .22s cubic-bezier(.2,.7,.3,1), border-color .22s ease, box-shadow .22s ease;
}
a.card:hover, .card.is-interactive:hover {
  transform: translateY(-3px); border-color: rgba(139,123,240,.34);
  box-shadow: 0 26px 54px -34px rgba(0,0,0,.95); color: inherit;
}
.card-kicker { font-family: var(--mono); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ntext50); }
.card h2 { font-size: 1rem; margin-bottom: 14px; }

.grid { display: grid; gap: 16px; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* Stat tiles — used bare inside .grid (transcript detail) or in a .card */
.stat {
  display: grid; gap: 4px; min-width: 0;
  border: 1px solid var(--line); border-radius: 13px; padding: 15px 16px;
  background: var(--panel-grad); animation: fadeUp .5s ease both;
  transition: transform .2s ease, border-color .2s ease;
}
.stat:hover { transform: translateY(-3px); border-color: rgba(139,123,240,.34); }
.stat .value { font-size: 1.55rem; font-weight: 700; letter-spacing: -.02em; }
.stat .label { font-family: var(--mono); font-size: .56rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ntext50); }
.stat .sub { font-family: var(--mono); font-size: .56rem; color: var(--violet-lter); }
.card .stat, .stat.bare { border: 0; padding: 0; background: none; animation: none; }
.card .stat:hover, .stat.bare:hover { transform: none; }

/* stagger the first several children of any grid */
.grid > *:nth-child(1) { animation-delay: 0s; }
.grid > *:nth-child(2) { animation-delay: .05s; }
.grid > *:nth-child(3) { animation-delay: .1s; }
.grid > *:nth-child(4) { animation-delay: .15s; }
.grid > *:nth-child(5) { animation-delay: .2s; }
.grid > *:nth-child(6) { animation-delay: .25s; }
.grid > *:nth-child(7) { animation-delay: .3s; }
.grid > *:nth-child(8) { animation-delay: .35s; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.table-wrap {
  border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto;
  background: var(--panel-grad); animation: fadeUp .6s ease both;
}
table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th {
  text-align: left; font-family: var(--mono); font-size: .6rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--ntext50); font-weight: 500;
  padding: 13px 12px; border-bottom: 1px solid var(--line-strong); white-space: nowrap;
}
td { padding: 13px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
thead + tbody tr:first-child td { border-top: 0; }
tbody tr { animation: rowIn .42s ease both; transition: background-color .14s ease; }
tbody tr:hover td { background: rgba(139,123,240,.055); }
tbody tr:nth-child(1) { animation-delay: 0s; }
tbody tr:nth-child(2) { animation-delay: .04s; }
tbody tr:nth-child(3) { animation-delay: .08s; }
tbody tr:nth-child(4) { animation-delay: .12s; }
tbody tr:nth-child(5) { animation-delay: .16s; }
tbody tr:nth-child(6) { animation-delay: .2s; }
tbody tr:nth-child(7) { animation-delay: .24s; }
tbody tr:nth-child(8) { animation-delay: .28s; }
tbody tr:nth-child(n+9) { animation-delay: .32s; }

/* ==========================================================================
   BADGES
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  font-family: var(--mono); font-size: .62rem; letter-spacing: .06em; text-transform: uppercase;
  border-radius: 999px; padding: 3px 10px; border: 1px solid transparent; color: var(--ntext50);
  background: rgba(236,235,242,.06);
}
.badge-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex: none; }
.badge-active, .badge-paid_verified, .badge-resolved, .badge-live {
  color: var(--ngood); background: rgba(125,224,138,.12); border-color: rgba(125,224,138,.3);
}
.badge-inactive, .badge-void, .badge-closed { color: var(--ntext50); background: rgba(236,235,242,.06); }
.badge-unpaid, .badge-fraud_flagged { color: var(--nsignal); background: rgba(240,69,37,.12); border-color: rgba(240,69,37,.34); }
.badge-marked_paid_pending_review, .badge-open { color: var(--nwarn); background: rgba(224,179,79,.12); border-color: rgba(224,179,79,.34); }
.badge-in_progress { color: var(--violet-lt); background: rgba(139,123,240,.14); border-color: rgba(139,123,240,.34); }

/* ==========================================================================
   BUTTONS / CHIPS
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 11px; font-size: .86rem; font-weight: 600;
  font-family: inherit; cursor: pointer; border: 1px solid var(--ntext);
  background: var(--ntext); color: var(--night);
  transition: transform .14s ease, opacity .16s ease, background-color .16s ease, border-color .16s ease, color .16s ease;
}
.btn:hover { opacity: .92; transform: translateY(-1px); color: var(--night); }
.btn:active { transform: translateY(0); }
.btn[disabled] { opacity: .45; cursor: default; transform: none; }

.btn-outline { background: transparent; color: var(--ntext); border-color: var(--line-strong); }
.btn-outline:hover { background: rgba(236,235,242,.06); border-color: var(--ntext70); color: var(--ntext); opacity: 1; }
.btn-violet { background: transparent; color: var(--violet-lter); border-color: rgba(139,123,240,.36); }
.btn-violet:hover { background: rgba(139,123,240,.16); color: #fff; opacity: 1; }
.btn-danger { background: rgba(240,69,37,.1); border-color: rgba(240,69,37,.3); color: var(--nsignal); }
.btn-danger:hover { background: rgba(240,69,37,.18); color: var(--nsignal); opacity: 1; }
.btn-sm { padding: 5px 12px; font-size: .78rem; border-radius: 9px; }
.btn-block { width: 100%; }

/* Filter chip rows: <div class="chips"><a class="chip is-on">…</a></div> */
.chips { display: flex; gap: 4px; flex-wrap: wrap; padding: 4px; width: fit-content; margin-bottom: 18px; border: 1px solid var(--line-strong); border-radius: 12px; background: rgba(236,235,242,.03); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: 9px;
  font-family: var(--mono); font-size: .72rem; color: var(--ntext50); border: 0;
  background: transparent; cursor: pointer; transition: background-color .16s ease, color .16s ease;
}
.chip:hover { color: var(--ntext); background: rgba(236,235,242,.05); }
.chip.is-on { background: rgba(139,123,240,.22); color: #fff; }
.chip .n { color: var(--ntext34); }
.chip.is-on .n { color: var(--violet-lter); }

/* ==========================================================================
   FORMS
   ========================================================================== */
form.form-grid { display: grid; gap: 14px; max-width: 520px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-size: .75rem; color: var(--ntext50); }
.field input, .field select, .field textarea, .input {
  width: 100%; padding: 9px 12px; background: rgba(236,235,242,.04);
  border: 1px solid var(--line-strong); border-radius: 9px;
  font-size: .87rem; color: var(--ntext); font-family: inherit;
}
.field textarea { min-height: 92px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none; border-color: var(--violet-lt); box-shadow: 0 0 0 3px rgba(139,123,240,.16);
}
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.field .hint { font-family: var(--mono); font-size: .62rem; color: var(--ntext34); }
.check { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--ntext70); }
.check input { accent-color: var(--violet-lt); }

/* ==========================================================================
   NOTICES
   ========================================================================== */
.notice { border-radius: 12px; padding: 14px 16px; font-size: .85rem; line-height: 1.55; margin-bottom: 18px; animation: fadeUp .45s ease both; }
.notice-success { background: rgba(125,224,138,.1); border: 1px solid rgba(125,224,138,.4); color: #bff0c5; }
.notice-error { background: rgba(240,69,37,.1); border: 1px solid rgba(240,69,37,.42); color: #ffb4a3; }
.notice-warn { background: rgba(224,179,79,.12); border: 1px solid rgba(224,179,79,.4); color: #e0c07a; }
.notice-info { background: rgba(139,123,240,.12); border: 1px solid rgba(139,123,240,.36); color: var(--violet-lter); }

/* ==========================================================================
   KEY / VALUE ROWS
   ========================================================================== */
.kv {
  display: flex; justify-content: space-between; gap: 14px; min-width: 0;
  padding: 9px 0; border-top: 1px solid var(--line); font-size: .84rem;
  animation: rowIn .4s ease both;
}
.kv:first-of-type { border-top: 0; }
.kv .k { color: var(--ntext50); flex: none; }
.kv > span:last-child { text-align: right; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.kv:nth-of-type(1) { animation-delay: .16s; }
.kv:nth-of-type(2) { animation-delay: .21s; }
.kv:nth-of-type(3) { animation-delay: .26s; }
.kv:nth-of-type(4) { animation-delay: .31s; }
.kv:nth-of-type(5) { animation-delay: .36s; }
.kv:nth-of-type(6) { animation-delay: .41s; }
.kv:nth-of-type(n+7) { animation-delay: .46s; }

/* ==========================================================================
   USAGE / METER BARS
   ========================================================================== */
.usage { border: 1px solid var(--line); border-radius: var(--r-md); padding: 18px 20px; background: rgba(139,123,240,.06); }
.usage-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.usage-nums { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; }
.usage-nums .used { color: var(--ntext); }
.usage-nums .limit { color: var(--ntext50); font-weight: 500; }
.usage-remaining { font-family: var(--mono); font-size: .75rem; letter-spacing: .04em; color: var(--ntext50); }
.usage-bar, .meter { position: relative; height: 8px; border-radius: 999px; background: rgba(236,235,242,.08); overflow: hidden; }
.usage-bar > span, .meter > span {
  display: block; height: 100%; border-radius: 999px; transform-origin: left;
  background: linear-gradient(90deg, var(--violet), var(--violet-lter));
  animation: growX .9s cubic-bezier(.4,0,.2,1) both;
}
.usage-bar.warn > span, .meter.warn > span { background: linear-gradient(90deg, #d89a2a, var(--nwarn)); }
.usage-bar.over > span, .meter.over > span { background: linear-gradient(90deg, var(--nsignal), #f0714f); }
.meter-row { display: grid; gap: 4px; margin-bottom: 10px; }
.meter-row .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; }
.meter-row .lbl span:first-child { color: var(--ntext70); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-row .lbl span:last-child { font-family: var(--mono); }

/* Donut charts (SVG in the view; these just size + animate them) */
.donut { position: relative; width: 104px; height: 104px; flex: none; }
.donut svg { transform: rotate(-90deg); }
.donut circle { transition: stroke-width .16s ease, stroke-dasharray .9s cubic-bezier(.4,0,.2,1); }
.donut circle:hover { stroke-width: 15; }
.donut .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.05; }
.donut .center b { font-size: 1.15rem; font-weight: 800; }
.donut .center small { font-family: var(--mono); font-size: .54rem; color: var(--ntext50); }
.legend { display: grid; gap: 6px; min-width: 0; grid-template-columns: minmax(0, 1fr); }
.legend-row { display: flex; align-items: center; gap: 7px; font-size: .78rem; min-width: 0; }
.legend-row .sw { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.legend-row .nm { flex: 1; min-width: 0; color: var(--ntext70); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend-row .pc { font-family: var(--mono); }

/* Hour-of-day / per-day bar charts */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 112px; margin-top: 16px; }
.bars > span {
  flex: 1; min-height: 3px; border-radius: 3px 3px 0 0; background: rgba(139,123,240,.42);
  transform-origin: bottom; animation: growX .001ms both; cursor: crosshair; transition: filter .14s ease;
}
.bars > span:hover { filter: brightness(1.4); }
.bars > span.peak { background: var(--violet-lter); }
.axis { display: flex; justify-content: space-between; font-family: var(--mono); font-size: .56rem; color: var(--ntext34); margin-top: 6px; }

/* ==========================================================================
   CONVERSATIONS / MESSAGES
   ========================================================================== */
.messages { display: grid; gap: 11px; margin: 0 0 18px; }
.message {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 15px; font-size: .87rem;
  background: rgba(236,235,242,.03); animation: fadeUp .42s ease both; max-width: 84%;
}
.message .meta { font-family: var(--mono); font-size: .6rem; color: var(--ntext50); margin-bottom: 5px; }
.message.is-mine { justify-self: end; background: rgba(236,235,242,.08); border-color: var(--line-strong); border-radius: 12px 3px 12px 12px; }
.message.is-them { justify-self: start; background: rgba(107,79,224,.16); border-color: rgba(139,123,240,.28); border-radius: 3px 12px 12px 12px; }
.turn-buttons { display: flex; flex-wrap: wrap; gap: 6px; justify-self: start; }
.turn-buttons span { font-size: .75rem; border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 12px; color: var(--ntext70); }
.turn-step { justify-self: center; font-family: var(--mono); font-size: .6rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ntext34); }

/* ==========================================================================
   DISCLOSURE (raw logs, settings groups)
   ========================================================================== */
details { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--panel-grad); overflow: hidden; }
details + details { margin-top: 10px; }
summary {
  cursor: pointer; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; font-family: var(--mono); font-size: .72rem; color: var(--ntext70);
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "⌄"; font-family: inherit; font-size: 1rem; line-height: 1; color: var(--ntext50); transition: transform .2s ease; }
details[open] summary::after { transform: rotate(180deg); }
details[open] summary { border-bottom: 1px solid var(--line); color: var(--ntext); }
details > *:not(summary) { animation: fadeIn .26s ease both; }
details .table-wrap { border: 0; border-radius: 0; animation: none; }

/* ==========================================================================
   DIALOG
   ========================================================================== */
.dialog-backdrop {
  position: fixed; inset: 0; z-index: 90; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: rgba(6,6,10,.72); backdrop-filter: blur(4px); animation: fadeIn .2s ease both;
}
.dialog {
  width: min(480px, 100%); border: 1px solid rgba(139,123,240,.24); border-radius: var(--r-lg);
  background: linear-gradient(180deg, #171522, #100f18); box-shadow: 0 40px 90px -30px rgba(0,0,0,.9);
  animation: fadeUp .24s ease both;
}
.dialog-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 1.05rem; }
.dialog-body { padding: 22px; display: grid; gap: 14px; }
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 22px 22px; }

/* ==========================================================================
   DRAWER (side panel — optional progressive enhancement)
   ========================================================================== */
.drawer-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(6,6,10,.64); backdrop-filter: blur(3px); animation: fadeIn .2s ease both; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 61; width: min(700px, 97vw);
  display: flex; flex-direction: column; overflow-y: auto;
  background: linear-gradient(180deg, var(--panel), #0e0d15);
  border-left: 1px solid var(--line-strong); box-shadow: -40px 0 90px -30px rgba(0,0,0,.85);
  animation: fadeIn .28s ease both;
}
.drawer-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 14px; padding: 22px 26px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.drawer-body { padding: 22px 26px 44px; display: flex; flex-direction: column; gap: 20px; }
.icon-btn {
  width: 34px; height: 34px; flex: none; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--line-strong); border-radius: 9px; background: rgba(236,235,242,.04);
  color: var(--ntext70); cursor: pointer; transition: color .16s ease, background-color .16s ease;
}
.icon-btn:hover { color: #fff; background: rgba(236,235,242,.09); }

/* ==========================================================================
   EMPTY STATE
   ========================================================================== */
.empty {
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 48px 30px; text-align: center;
  background: var(--panel-grad-strong); animation: fadeUp .5s ease both;
}
.empty .icon { width: 54px; height: 54px; border-radius: 15px; background: rgba(139,123,240,.14); color: var(--violet-lter); display: flex; align-items: center; justify-content: center; margin: 0 auto 18px; }
.empty h3 { font-size: 1.05rem; margin-bottom: 8px; }
.empty p { color: var(--ntext50); font-size: .9rem; margin: 0 auto 18px; max-width: 440px; }

/* ==========================================================================
   LOGIN (no shell)
   ========================================================================== */
.login-shell {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(120% 90% at 82% -6%, #26243a 0%, #181726 40%, #101018 74%, #0c0c12 100%);
}
.login-card {
  width: min(400px, 100%); border: 1px solid var(--line-strong); border-radius: var(--r-lg); padding: 36px;
  background: linear-gradient(160deg, rgba(40,38,58,.72), rgba(16,16,26,.6));
  box-shadow: 0 50px 110px -50px rgba(0,0,0,.95); animation: fadeUp .5s ease both;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (max-width: 1000px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static; height: auto; flex-direction: row; align-items: center; gap: 6px;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 12px 16px;
  }
  .sidebar .brand { padding: 0 12px 0 0; }
  .sidebar .brand-text { display: none; }
  .nav-group { display: none; }
  .nav-item { padding: 8px 12px; white-space: nowrap; }
  .nav-item.active::before { top: auto; bottom: 0; left: 12px; right: 12px; width: auto; height: 2px; }
  .sidebar-foot { margin: 0 0 0 auto; padding: 0; }
  .sidebar-user { border: 0; background: none; padding: 0; }
  .sidebar-user .name, .sidebar-user .role-badge { display: none; }
  .message { max-width: 100%; }
}
