/* ═══════════════════════════════════════
   Peko Admin — unified dark theme
   Matches homepage: #070400 base, amber accents
   ═══════════════════════════════════════ */

:root {
  --bg:      #fff8ed;
  --bg2:     #fff0d2;
  --o1:      #ffd54d;
  --o2:      #ff9f1c;
  --o3:      #ff7a00;
  --o4:      #c85a04;
  --text:    #2f1d0a;
  --text-soft:#6a4926;
  --border:  rgba(255, 122, 0, 0.16);
  --border-h:rgba(255, 122, 0, 0.36);
  --card:    rgba(255, 255, 255, 0.78);
  --dim:     rgba(47, 29, 10, 0.66);
  --hint:    rgba(47, 29, 10, 0.44);
  --input-bg:rgba(255, 255, 255, 0.7);
  --sb-w:    260px;
  --radius:  16px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,146,43,0.6) rgba(255,146,43,0.1);
}

/* Webkit scrollbars (Chrome, Safari, Edge) */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255,146,43,0.05);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(255,146,43,0.7), rgba(255,100,30,0.6));
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
  box-shadow: 0 0 8px rgba(255,146,43,0.4), inset 0 0 4px rgba(255,255,255,0.1);
  transition: all 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(255,146,43,0.9), rgba(255,100,30,0.8));
  box-shadow: 0 0 14px rgba(255,146,43,0.6), inset 0 0 6px rgba(255,255,255,0.15);
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: url('assets/bg.png') center center / cover no-repeat fixed;
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

body::before {
  content: none;
}

body::after {
  content: none;
}

@keyframes ambientShift {
  0%, 100% { opacity: 0.85; }
  50%       { opacity: 1;    }
}

a { color: var(--o2); text-decoration: none; }
a:hover { color: var(--o1); }

/* ── Particles ── */
.particle-field {
  position: fixed; inset: 0;
  overflow: hidden; pointer-events: none; z-index: 2;
}
.particle {
  position: absolute; bottom: -20px;
  border-radius: 50%;
  box-shadow: 0 0 20px currentColor;
  animation: particleRise var(--dur, 10s) var(--del, 0s) ease-in infinite;
}
@keyframes particleRise {
  0%   { transform: translateY(0) scale(1);   opacity: var(--op, .35); }
  70%  { opacity: var(--op, .35); }
  100% { transform: translateY(-110vh) scale(0.2); opacity: 0; }
}

/* ── Spinner ── */
.spinner {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Btn primary ── */
.btn-primary {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 24px;
  background: linear-gradient(135deg, var(--o2) 0%, var(--o3) 100%);
  background-size: 200% auto; color: #fff;
  font-size: 13px; font-weight: 700; font-family: inherit;
  border: none; border-radius: 12px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(247,103,7,.4), inset 0 1px 0 rgba(255,255,255,0.1);
  transition: background-position .4s, box-shadow .3s, transform .15s, opacity .2s;
  white-space: nowrap; flex-shrink: 0;
}
.btn-primary:hover  { background-position: right center; box-shadow: 0 10px 28px rgba(247,103,7,.6), inset 0 1px 0 rgba(255,255,255,0.15); }
.btn-primary:active { transform: scale(.94); }
.btn-primary:disabled { opacity: .5; cursor: default; }

/* ══ SPLASH ══ */
.splash {
  position: fixed; inset: 0; z-index: 500;
  background:
    radial-gradient(ellipse 130% 65% at -5% 2%,  rgba(255,215,90,0.55) 0%, transparent 52%),
    radial-gradient(ellipse 80%  110% at 105% 96%, rgba(255,148,38,0.45) 0%, transparent 55%),
    linear-gradient(155deg, #fffef9 0%, #fff7e8 22%, #fff0d4 50%, #ffe7bd 75%, #ffde9f 100%);
  display: flex; align-items: center; justify-content: center;
}

.splash-center {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 22px;
}

.sp-img {
  width: 72px; height: 72px; border-radius: 50%; object-fit: cover;
  border: 2.5px solid rgba(255,180,60,.4);
  box-shadow: 0 0 30px rgba(255,146,43,.5);
  animation: glowPulse 3s ease-in-out infinite;
}
@keyframes glowPulse { 0%,100%{transform:scale(1);opacity:.8} 50%{transform:scale(1.07);opacity:1} }

.sp-text {
  font-size: 13px; font-weight: 500;
  color: rgba(47, 29, 10, 0.55); letter-spacing: .4px;
}

.sp-bar-track {
  width: 200px; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,.1); overflow: hidden;
}
.sp-bar-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, #ff922b, #ffbe3d);
  box-shadow: 0 0 10px rgba(255,146,43,.7);
  animation: barLoad 1.6s cubic-bezier(.4,0,.2,1) forwards;
}
@keyframes barLoad {
  0%   { width: 0%; }
  60%  { width: 80%; }
  85%  { width: 92%; }
  100% { width: 100%; }
}

/* ══ AUTH ══ */
.auth-bg {
  position: fixed; inset: 0; z-index: 0;
  background: transparent; /* body gradient shows through */
}

.auth-amb {
  position: absolute; border-radius: 50%;
  filter: blur(90px); pointer-events: none;
}
.a1 {
  width: 720px; height: 720px; top: -200px; left: 50%; transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255,185,52,.34) 0%, rgba(255,155,30,.14) 45%, transparent 70%);
  animation: ambFloatC 9s ease-in-out infinite;
}
.a2 {
  width: 520px; height: 520px; bottom: -90px; right: -110px;
  background: radial-gradient(circle, rgba(255,118,0,.26) 0%, rgba(255,88,0,.10) 50%, transparent 70%);
  animation: ambFloatTR 12s ease-in-out infinite;
}
.a3 {
  width: 680px; height: 680px; top: -160px; left: -160px;
  background: radial-gradient(circle, rgba(255,225,105,.28) 0%, rgba(255,195,60,.10) 50%, transparent 70%);
  animation: ambFloatTL 16s ease-in-out infinite;
}
.a4 {
  width: 480px; height: 480px; bottom: -90px; left: -90px;
  background: radial-gradient(circle, rgba(255,148,48,.22) 0%, rgba(255,120,28,.07) 50%, transparent 70%);
  animation: ambFloatBL 20s ease-in-out infinite;
}
@keyframes ambFloatC  { 0%,100%{transform:translateX(-50%) scale(1);opacity:.85} 50%{transform:translateX(-50%) scale(1.12);opacity:1} }
@keyframes ambFloatTR { 0%,100%{transform:translate(0,0) scale(1)}  50%{transform:translate(-55px,-38px) scale(1.09)} }
@keyframes ambFloatTL { 0%,100%{transform:translate(0,0) scale(1)}  50%{transform:translate(65px, 45px) scale(1.08)} }
@keyframes ambFloatBL { 0%,100%{transform:translate(0,0) scale(1)}  50%{transform:translate(42px,-32px) scale(1.06)} }

.auth-wrap {
  position: relative; z-index: 2; min-height: 100vh;
  display: flex; align-items: center; justify-content: center; padding: 24px 16px;
}

.auth-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(255, 245, 225, 0.92));
  color: var(--text);
  border: 1px solid rgba(255, 122, 0, 0.18);
  border-radius: 22px; padding: 36px 28px 30px;
  backdrop-filter: blur(24px);
  box-shadow: 0 28px 64px rgba(95, 39, 0, 0.12), 0 0 0 1px rgba(255,159,28,.08) inset;
  animation: cardIn .45s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardIn { from{opacity:0;transform:translateY(20px) scale(.98)} to{opacity:1;transform:none} }

.auth-stage {
  position: relative; width: 80px; height: 80px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
}
.a-glow {
  position: absolute; width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,159,28,.35) 0%, transparent 70%);
  filter: blur(12px); animation: glowPulse 2.5s ease-in-out infinite;
}
.a-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid rgba(255,122,0,.25);
}
.ar1 { width: 86px; height: 86px; animation: ringFade 2.5s ease-in-out infinite; }
.ar2 { width: 110px; height: 110px; animation: ringFade 2.5s ease-in-out .7s infinite; }
.a-img {
  width: 60px; height: 60px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,159,28,.35);
  box-shadow: 0 0 20px rgba(255,159,28,.25);
  position: relative; z-index: 2;
}

.auth-title { font-size: 20px; font-weight: 800; text-align: center; margin-bottom: 5px; letter-spacing: -.3px; color: var(--text); }
.auth-sub   { font-size: 12px; color: var(--dim); text-align: center; margin-bottom: 24px; }

.auth-form { display: flex; flex-direction: column; gap: 13px; }

.setup-note {
  font-size: 12px; color: var(--o2);
  background: rgba(255,146,43,.08); border: 1px solid rgba(255,146,43,.2);
  border-radius: 10px; padding: 10px 13px; line-height: 1.5;
}

/* ── Form fields ── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.75); }

.field input, .field textarea,
.field-group input, .field-group textarea {
  width: 100%;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 122, 0, 0.15);
  border-radius: 12px; padding: 11px 14px;
  color: var(--text); font-size: 13px; font-family: inherit;
  outline: none; resize: vertical;
  transition: border-color .25s, background .25s, box-shadow .25s, transform .15s;
}
.field input::placeholder, .field textarea::placeholder,
.field-group input::placeholder, .field-group textarea::placeholder { color: rgba(47, 29, 10, 0.35); }
.field input:focus, .field textarea:focus,
.field-group input:focus, .field-group textarea:focus {
  border-color: rgba(255, 122, 0, 0.5);
  background: rgba(255, 159, 28, 0.06);
  box-shadow: 0 0 0 4px rgba(255, 122, 0, 0.10), inset 0 1px 2px rgba(255,122,0,0.05);
  transform: translateY(-1px);
}
textarea.mono { font-family: "Fira Code", "Courier New", monospace; font-size: 11.5px; line-height: 1.55; }

.ferr {
  font-size: 12px; color: #ff9999;
  background: rgba(255,80,80,.12); border: 1px solid rgba(255,80,80,.28);
  border-radius: 12px; padding: 12px 14px;
  line-height: 1.5;
}

/* ══ DASHBOARD ══ */
.dash {
  display: flex; min-height: 100vh;
  background: transparent;
  position: relative;
  z-index: 10;
}

.dash::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 1700px 1050px at 5% 30%,  rgba(255,178,48,.26) 0%, transparent 48%),
    radial-gradient(ellipse 1350px  820px at 95% 65%, rgba(255,115,0,.20) 0%, transparent 50%),
    radial-gradient(ellipse  950px  950px at 50% 115%, rgba(255,178,58,.15) 0%, transparent 60%),
    radial-gradient(ellipse  750px  520px at 50% -40%, rgba(255,210,78,.12) 0%, transparent 55%);
  pointer-events: none;
  z-index: -1;
  animation: dashAmbient 20s ease-in-out infinite;
}

@keyframes dashAmbient {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1.15; }
}

/* Sidebar */
.sidebar {
  width: var(--sb-w); flex-shrink: 0;
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.94) 0%, rgba(255, 240, 210, 0.97) 100%);
  color: var(--text);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
  backdrop-filter: blur(25px);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  z-index: 40;
  box-shadow: 8px 0 24px rgba(95, 39, 0, 0.08);
  overscroll-behavior: none;
}

.sidebar::before {
  content: '';
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sb-w);
  height: 100vh;
  background: radial-gradient(ellipse 600px 800px at 50% -50%, rgba(255,146,43,.1) 0%, transparent 50%),
              radial-gradient(ellipse 500px 800px at 50% 100%, rgba(255,100,30,.06) 0%, transparent 50%),
              linear-gradient(180deg, rgba(255,146,43,.04) 0%, transparent 40%, rgba(255,100,30,.02) 100%);
  pointer-events: none;
  z-index: -1;
  animation: sidebarAmbient 22s ease-in-out infinite;
}

@keyframes sidebarAmbient {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 1.1; }
}

.sb-top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 22px 18px 18px;
}

.sb-brand { display: flex; align-items: center; gap: 11px; min-width: 0; }

.sb-avatar-wrap { position: relative; flex-shrink: 0; }
.sb-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,159,28,.45); }
.sb-online {
  position: absolute; bottom: 0; right: 0;
  width: 10px; height: 10px; border-radius: 50%;
  background: #277a3c; border: 2px solid var(--bg);
  animation: onlinePulse 2s ease-in-out infinite;
}
@keyframes onlinePulse { 0%,100%{box-shadow:0 0 0 0 rgba(39,122,60,.5)} 70%{box-shadow:0 0 0 5px rgba(39,122,60,0)} }

.sb-name { font-size: 13px; font-weight: 700; line-height: 1.2; color: var(--text); }
.sb-user { font-size: 11px; color: var(--dim); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 130px; }

.sb-close-btn {
  display: none; background: none; border: none; color: var(--dim);
  cursor: pointer; padding: 4px; border-radius: 6px;
  transition: color .2s, background .2s;
  flex-shrink: 0;
}
.sb-close-btn:hover { color: var(--text); background: rgba(255,122,0,.08); }

.sb-divider { height: 1px; background: rgba(255, 122, 0, 0.14); margin: 0 16px; }

.sb-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; overscroll-behavior: none; }

.sb-section-label {
  font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
  color: var(--text-soft); padding: 4px 10px 8px;
}

.sb-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 10px 11px; border-radius: 11px;
  background: transparent; border: none; color: var(--dim);
  font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; position: relative;
  transition: color .25s, background .25s, box-shadow .25s;
}
.sb-item:hover { color: var(--text); background: rgba(255,122,0,.08); }
.sb-item.active {
  color: var(--o3); background: linear-gradient(90deg, rgba(255,159,28,.14), rgba(255,122,0,.08));
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--o3), 0 2px 8px rgba(255,122,0,0.08);
}

.sb-icon  { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }
.sb-label { flex: 1; }
.sb-arrow { font-size: 15px; color: var(--hint); transition: color .2s; }
.sb-item.active .sb-arrow { color: var(--o2); }

.sb-foot {
  padding: 14px 16px 20px; border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.sb-back {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--dim);
  padding: 7px 10px; border-radius: 9px;
  transition: color .2s, background .2s;
}
.auth-home-link {
  justify-content: center; margin-top: 8px;
}

/* ── Logs terminal ── */
.logs-panel .panel-body { padding: 0; }

/* ── Logs panel: compact button row that always fits ── */
.logs-panel .panel-header {
  flex-wrap: wrap;
  gap: 10px;
}
.logs-panel .ph-right {
  gap: 6px;
}
.logs-panel .btn-ghost,
.logs-panel .btn-debug,
.logs-panel .btn-mqtt,
.logs-panel .btn-restart {
  padding: 5px 10px;
  font-size: 11.5px;
  white-space: nowrap;
}
/* Hide text labels, show icon-only below 560px */
@media (max-width: 560px) {
  .logs-panel .btn-label { display: none; }
  .logs-panel .btn-ghost,
  .logs-panel .btn-debug,
  .logs-panel .btn-mqtt,
  .logs-panel .btn-restart {
    padding: 6px 8px;
    min-width: 32px;
    justify-content: center;
  }
  .logs-panel .log-status-text { display: none; }
}

.log-terminal {
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', ui-monospace, monospace;
  font-size: 12px; line-height: 1.65;
  background: #0d0d0d;
  color: #e0e0e0;
  border: 1px solid rgba(255,122,0,0.2);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  height: 520px; overflow-y: auto; overflow-x: hidden;
  padding: 14px 16px;
  scroll-behavior: smooth;
}

.log-empty {
  color: #6b7280; font-style: italic; padding: 8px 0;
}

.log-line {
  display: flex; align-items: baseline; gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: #e0e0e0;
  min-width: 0;
}

.log-ts {
  flex-shrink: 0;
  color: #6b7280;
  font-size: 11px;
  user-select: none;
}

.log-badge {
  flex-shrink: 0;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 4px;
  user-select: none;
  letter-spacing: 0.04em;
}

.badge-log   { background: rgba(107,114,128,0.3); color: #d1d5db; }
.badge-info  { background: rgba(59,130,246,0.25); color: #60a5fa; }
.badge-warn  { background: rgba(217,119,6,0.25);  color: #fbbf24; }
.badge-error { background: rgba(239,68,68,0.25);   color: #f87171; }

.log-msg {
  flex: 1; color: #e0e0e0;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
  overflow: hidden;
}

.log-warn  .log-msg { color: #fbbf24; }
.log-error .log-msg { color: #f87171; }

/* status dot + text */
.log-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; flex-shrink: 0;
}
.log-dot.connected    { background: #4ade80; box-shadow: 0 0 6px #4ade8088; }
.log-dot.disconnected { background: #6b7280; }

.log-status-text {
  font-size: 12px; color: var(--dim); margin-right: 4px;
}

/* ghost buttons in log header */
.btn-ghost {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-family: inherit; font-weight: 600;
  padding: 8px 14px; border-radius: 10px; cursor: pointer;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 122, 0, 0.20);
  color: var(--dim);
  transition: all .25s;
  white-space: nowrap;
}
.btn-ghost:hover  { background: rgba(255, 159, 28, 0.12); color: var(--text); border-color: rgba(255,122,0,.35); }
.btn-ghost.active { background: rgba(255, 122, 0, 0.15); border-color: var(--o3); color: var(--o3); box-shadow: 0 0 12px rgba(255,122,0,0.10); }
.btn-mqtt {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  border: 1px solid;
}
.btn-mqtt:disabled { opacity: .5; cursor: default; }
.btn-mqtt.mqtt-on  {
  background: rgba(39,122,60,0.12); border-color: rgba(39,122,60,0.25);
  color: #277a3c;
}
.btn-mqtt.mqtt-on:hover  { background: rgba(39,122,60,0.20); }
.btn-mqtt.mqtt-off {
  background: rgba(179,71,29,0.12); border-color: rgba(179,71,29,0.25);
  color: #b3471d;
}
.btn-mqtt.mqtt-off:hover { background: rgba(179,71,29,0.20); }
.btn-debug {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  transition: background .2s, border-color .2s, color .2s;
  border: 1px solid;
}
.btn-debug:disabled { opacity: .5; cursor: default; }
.btn-debug.debug-on  {
  background: rgba(0,153,255,0.12); border-color: rgba(0,153,255,0.28);
  color: #0099ff;
}
.btn-debug.debug-on:hover  { background: rgba(0,153,255,0.22); }
.btn-debug.debug-off {
  background: rgba(100,100,100,0.08); border-color: rgba(100,100,100,0.22);
  color: #888;
}
.btn-debug.debug-off:hover { background: rgba(100,100,100,0.16); color: var(--text); }
.btn-restart {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-family: inherit; font-weight: 600;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  background: rgba(255, 159, 28, 0.12); border: 1px solid rgba(255,122,0,0.28);
  color: var(--o3); transition: background .2s, border-color .2s;
}
.btn-restart:hover    { background: rgba(255, 159, 28, 0.22); }
.btn-restart:disabled { opacity: .5; cursor: default; }

/* ── Share Post: custom audience dropdown ── */
.pd-wrap { position: relative; user-select: none; }

.pd-overlay { position: fixed; inset: 0; z-index: 10; }

.pd-trigger {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 10px 14px;
  border-radius: 12px; border: 1.5px solid var(--border);
  background: rgba(255,255,255,.88);
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  color: var(--text); cursor: pointer; text-align: left;
  transition: border-color .2s, box-shadow .2s, background .2s;
}
.pd-trigger:hover:not(:disabled) {
  border-color: rgba(255,122,0,.38);
  background: rgba(255,255,255,.96);
}
.pd-open .pd-trigger {
  border-color: rgba(255,122,0,.55);
  box-shadow: 0 0 0 3px rgba(255,122,0,.10);
  background: #fff;
}
.pd-disabled .pd-trigger { opacity: .55; cursor: not-allowed; }

.pd-trigger-icon {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0;
  background: rgba(255,145,43,.12); border: 1px solid rgba(255,122,0,.18);
  color: var(--o2);
}
.pd-trigger-label { flex: 1; }
.pd-arrow {
  flex-shrink: 0; color: var(--dim);
  transition: transform .2s ease;
}
.pd-open .pd-arrow { transform: rotate(180deg); }

.pd-menu {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 11;
  background: rgba(255,255,255,.98);
  border: 1.5px solid rgba(255,122,0,.22);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 10px 36px rgba(0,0,0,.11), 0 2px 10px rgba(247,99,7,.09);
  animation: pdDropIn .18s cubic-bezier(.2,.8,.2,1);
}
@keyframes pdDropIn {
  from { opacity: 0; transform: translateY(-8px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

.pd-option {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px 14px; border: none;
  background: none; font-family: inherit; cursor: pointer; text-align: left;
  border-bottom: 1px solid rgba(255,122,0,.07);
  transition: background .15s;
}
.pd-option:last-child { border-bottom: none; }
.pd-option:hover { background: rgba(255,145,43,.07); }
.pd-option-active { background: rgba(255,145,43,.11); }
.pd-option-active:hover { background: rgba(255,145,43,.15); }

.pd-opt-icon {
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: rgba(255,145,43,.10); border: 1px solid rgba(255,122,0,.16);
  color: var(--o2); transition: background .15s, border-color .15s;
}
.pd-option-active .pd-opt-icon {
  background: rgba(255,145,43,.18); border-color: rgba(255,122,0,.30);
}
.pd-opt-text { flex: 1; min-width: 0; }
.pd-opt-label { display: block; font-size: 13.5px; font-weight: 600; color: var(--text); }
.pd-opt-desc  { display: block; font-size: 11.5px; color: var(--dim); margin-top: 2px; }
.pd-check { flex-shrink: 0; color: var(--o2); }
.post-status {
  margin-top: 1rem; padding: 10px 14px; border-radius: 10px;
  font-size: 13px; line-height: 1.5; word-break: break-all;
}
.post-status.ok  { background: rgba(39,122,60,0.10); border: 1px solid rgba(39,122,60,0.25); color: #277a3c; }
.post-status.err { background: rgba(179,71,29,0.10); border: 1px solid rgba(179,71,29,0.25); color: #b3471d; }
.btn-share-trash { display: flex; align-items: center; justify-content: center; gap: 7px; }

.response-block {
  margin-top: .75rem; padding: 10px 14px; border-radius: 10px;
  font-size: 12.5px; line-height: 1.6; border: 1px solid transparent;
  display: flex; flex-direction: column; gap: 4px;
}
.response-block.response-ok  { background: rgba(39,122,60,0.07);  border-color: rgba(39,122,60,0.22); }
.response-block.response-err { background: rgba(179,71,29,0.07);  border-color: rgba(179,71,29,0.22); }
.response-block-title { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; opacity: .5; margin-bottom: 2px; }
.response-row  { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.response-label { opacity: .55; min-width: 90px; flex-shrink: 0; }
.response-value { font-weight: 500; word-break: break-all; }
.response-mono  { font-family: monospace; font-size: 11.5px; }
.response-link  { color: var(--accent, #ff7a00); word-break: break-all; }
.val-ok   { color: #277a3c; }
.val-err  { color: #b3471d; }
.val-warn { color: #a07000; }
.val-dim  { opacity: .45; }

.sb-back:hover { color: var(--text); background: rgba(255,122,0,.08); }
.sb-logout {
  display: flex; align-items: center; gap: 6px;
  background: rgba(255, 122, 0, .10); border: 1px solid rgba(255, 122, 0, .20);
  color: var(--o3); border-radius: 9px; padding: 8px 12px;
  font-size: 12px; font-family: inherit; cursor: pointer;
  transition: background .2s;
}
.sb-logout:hover { background: rgba(255,122,0,.16); }

/* Topbar (mobile) */
.topbar {
  display: none; align-items: center; gap: 12px;
  padding: 13px 16px;
  background: rgba(255, 255, 255, 0.90); border-bottom: 1px solid var(--border);
  color: var(--text);
  position: sticky; top: 0; z-index: 30; backdrop-filter: blur(16px);
}
.tb-menu {
  background: none; border: none; color: var(--dim); cursor: pointer; padding: 2px;
  transition: color .2s;
}
.tb-menu:hover { color: var(--text); }
.tb-title { flex: 1; font-size: 14px; font-weight: 600; color: var(--text); }
.tb-logo  { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; border: 1.5px solid rgba(255,159,28,.4); }

.sb-overlay {
  position: fixed; inset: 0; background: rgba(20, 10, 2, 0.35); z-index: 39;
  backdrop-filter: blur(3px);
}

/* ── Main content ── */
.dash-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
  padding: 32px 20px 110px; overflow-x: hidden;
  position: relative;
  background: transparent;
  animation: mainAmbient 25s ease-in-out infinite;
  min-width: 0;
  flex: 1;
}

.dash-main.has-right-panel {
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.dash-main-left {
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  justify-self: center;
}

/* Logs tab gets more breathing room — terminal content needs width */
.dash-main-left.logs-tab-active {
  max-width: min(960px, 100%);
}

/* Threads tab — table needs enough width to avoid horizontal scroll */
.dash-main-left.threads-tab-active {
  max-width: min(960px, 100%);
}

.dash-sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.ai-panel {
  min-height: 520px;
}

.ai-body {
  display: flex;
  flex-direction: column;
  min-height: 460px;
}

.chat-window {
  display: flex;
  flex-direction: column;
  min-height: 420px;
  max-height: calc(100vh - 340px);
  gap: 16px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  min-height: 320px;
  max-height: 100%;
  overflow-y: auto;
  border-radius: 22px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,159,28,0.14);
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.chat-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-status {
  margin-top: 10px;
  color: var(--dim);
  font-size: 13px;
}

.chat-form textarea {
  width: 100%;
  min-height: 90px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,159,28,0.22);
  background: rgba(255,255,255,0.96);
  color: var(--text);
  font: inherit;
}

.chat-form textarea:focus {
  outline: none;
  border-color: rgba(255,159,28,0.4);
  box-shadow: 0 0 0 4px rgba(255,159,28,0.12);
}

@keyframes mainAmbient {
  0%, 100% { opacity: 0.95; }
  50% { opacity: 1.2; }
}

/* Right sidebar panel */
.dash-main > .dash-sidebar-right {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Quick stats cards on right */
.quick-stat-card {
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255,248,235,0.88));
  border: 1px solid rgba(255,159,28,0.2);
  border-radius: 16px;
  padding: 20px;
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 24px rgba(95,39,0,0.08), inset 0 1px 0 rgba(255,159,28,0.1);
  transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.quick-stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle at top right, rgba(255,159,28,0.15), transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.quick-stat-card:hover {
  border-color: rgba(255,122,0,0.35);
  box-shadow: 0 12px 36px rgba(95,39,0,0.12), inset 0 1px 0 rgba(255,159,28,0.15);
  transform: translateY(-2px);
}

.qsc-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-soft);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.qsc-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--o3);
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.qsc-detail {
  font-size: 12px;
  color: var(--dim);
  position: relative;
  z-index: 1;
}

.qsc-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  margin-top: 8px;
  position: relative;
  z-index: 1;
}

.qsc-badge.status-ok {
  background: rgba(39,122,60,0.12);
  color: #277a3c;
  border: 1px solid rgba(39,122,60,0.25);
}

.qsc-badge.status-warn {
  background: rgba(184,134,11,0.12);
  color: #b8860b;
  border: 1px solid rgba(184,134,11,0.25);
}

.qsc-badge.status-err {
  background: rgba(179,71,29,0.12);
  color: #b3471d;
  border: 1px solid rgba(179,71,29,0.25);
}

.panel-wrap {
  max-width: 980px;
  background: rgba(255,255,255,0.8);
  border: 1px solid var(--border);
  border-radius: 20px; overflow: hidden;
  animation: panelIn .35s cubic-bezier(.2,.8,.2,1) both;
  box-shadow: 0 14px 36px rgba(95, 39, 0, 0.10), inset 0 1px 0 rgba(255,146,43,0.08);
  transition: border-color .3s, box-shadow .3s;
}
.panel-wrap:hover {
  border-color: rgba(255,146,43,0.25);
  box-shadow: 0 12px 40px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,146,43,0.15);
}
@keyframes panelIn { from{opacity:0;transform:translateY(16px)} to{opacity:1;transform:none} }

.chat-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.chat-panel-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 18px;
  background: rgba(255,159,28,0.08);
  border: 1px solid rgba(255,159,28,0.18);
  border-radius: 18px;
}

.chat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #b44f00;
  background: rgba(255,146,43,0.14);
  border-radius: 999px;
}

.chat-note {
  font-size: 12px;
  color: var(--dim);
  line-height: 1.45;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
  border-radius: 22px;
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(255,159,28,0.14);
}

.chat-message {
  max-width: 100%;
  padding: 12px 14px;
  border-radius: 18px;
  box-shadow: 0 10px 18px rgba(95, 39, 0, .08);
  line-height: 1.6;
}

.chat-message.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255,179,69,0.22), rgba(255,212,59,0.18));
  border: 1px solid rgba(255,159,28,0.22);
  color: #4b2f00;
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,159,28,0.16);
  color: #3c280c;
}

.chat-message-role {
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--o3);
}

.chat-message-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-empty {
  padding: 32px 14px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}

.chat-input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.chat-input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid rgba(255,159,28,0.22);
  background: rgba(255,255,255,0.97);
  color: var(--text);
  font: inherit;
}

.chat-input:focus {
  outline: none;
  border-color: rgba(255,159,28,0.4);
  box-shadow: 0 0 0 4px rgba(255,159,28,0.12);
}

.chat-input-row button {
  min-width: 110px;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 28px 32px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(90deg, rgba(255,159,28,.09), rgba(255,122,0,.03));
  backdrop-filter: blur(10px);
}
.ph-left  { display: flex; align-items: center; gap: 14px; }
.ph-right { display: flex; align-items: center; gap: 8px; flex-shrink: 1; min-width: 0; flex-wrap: wrap; }
.ph-icon  { font-size: 28px; color: var(--o3); }
.ph-title { font-size: 17px; font-weight: 800; margin-bottom: 3px; letter-spacing: -.3px; color: var(--text); }
.ph-sub   { font-size: 12px; color: var(--dim); }

.save-status { font-size: 12px; color: var(--dim); }
.save-status.ok  { color: #277a3c; }
.save-status.err { color: #b3471d; }

.panel-body { padding: 28px 32px; }

/* ── ID add-row (input + Add button, e.g. Admin IDs) ── */
.id-add-row {
  display: flex; gap: 8px; margin-bottom: 16px;
}

/* ── Field groups ── */
.fields-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.field-group { display: flex; flex-direction: column; gap: 5px; }
.field-group.mt { margin-top: 18px; }
.field-group label { font-size: 12px; font-weight: 600; color: var(--text); }
.field-hint { font-size: 11px; color: var(--hint); margin-bottom: 2px; }

/* ── How-to box ── */
.how-to {
  display: flex; gap: 14px; align-items: flex-start;
  background: linear-gradient(135deg, rgba(255,159,28,.10), rgba(255,122,0,.04)); 
  border: 1.5px solid rgba(255,146,43,.25);
  border-radius: 14px; padding: 18px 20px;
  font-size: 13px; line-height: 1.7; color: var(--text-soft);
  backdrop-filter: blur(8px);
}
.ht-icon { font-size: 22px; flex-shrink: 0; margin-top: 1px; color: var(--o3); }
.how-to strong { display: block; color: var(--o3); margin-bottom: 6px; font-size: 12.5px; }
.how-to ol { margin-left: 16px; }
.how-to li { margin-bottom: 3px; }
.how-to em { color: var(--o4); font-style: normal; }

/* ── Health bar ── */
.health-bar {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--dim); margin-top: 12px;
  padding: 10px 14px; border-radius: 12px;
  background: rgba(255,255,255,.65); border: 1px solid var(--border);
  transition: all .3s;
}
.health-bar.ok   { color: #277a3c; border-color: rgba(39,122,60,.25); background: rgba(39,122,60,.08); }
.health-bar.warn { color: #b8860b; border-color: rgba(184,134,11,.25); background: rgba(184,134,11,.08); }
.health-bar.err  { color: #b3471d; border-color: rgba(179,71,29,.25); background: rgba(179,71,29,.08); }
.hb-dot {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  flex-shrink: 0; animation: onlinePulse 2s ease-in-out infinite;
}

/* ── Key card ── */
.key-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(255, 245, 220, 0.85));
  border: 1px solid var(--border); border-radius: 14px; padding: 20px 22px 18px;
  transition: all .3s;
  box-shadow: inset 0 1px 0 rgba(255,122,0,0.08);
}
.key-card:hover {
  border-color: rgba(255,122,0,.25);
  box-shadow: 0 4px 16px rgba(95, 39, 0, 0.08), inset 0 1px 0 rgba(255,122,0,0.12);
}
.key-card-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
}
.key-icon { font-size: 24px; }
.key-name { font-size: 14px; font-weight: 700; margin-bottom: 2px; color: var(--text); }
.key-desc { font-size: 12px; color: var(--dim); }
.key-link {
  margin-left: auto; font-size: 12px; font-weight: 600; color: var(--o3);
  padding: 5px 11px; border-radius: 99px; border: 1px solid rgba(255,122,0,.25);
  transition: background .2s, color .2s;
  white-space: nowrap;
}
.key-link:hover { background: rgba(255,159,28,.08); color: var(--o4); }

.api-key-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 20px;
}
.api-key-row {
  border: 1px solid rgba(255,159,28,0.18);
  background: rgba(255,255,255,0.92);
  border-radius: 18px;
  padding: 18px 18px 14px;
  transition: border-color .25s, box-shadow .25s, transform .25s;
}
.api-key-row.success { border-color: rgba(39,122,60,0.25); box-shadow: 0 10px 24px rgba(39,122,60,0.08); }
.api-key-row.error   { border-color: rgba(179,71,29,0.25); box-shadow: 0 10px 24px rgba(179,71,29,0.08); }
.api-key-row:hover { transform: translateY(-1px); }
.api-key-row-top {
  display: flex; gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.api-key-input-group {
  flex: 1 1 380px;
}
.api-key-input-group label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.api-key-input-group input {
  width: 100%; padding: 12px 14px; border-radius: 14px;
  border: 1px solid rgba(255,159,28,0.2); background: rgba(255,255,255,0.94);
  color: var(--text); font-family: inherit; font-size: 14px;
}
.api-key-hint {
  margin-top: 8px; font-size: 12px; color: var(--dim); line-height: 1.5;
}
.api-key-actions {
  display: flex; gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
.api-key-actions .btn-primary { min-width: 108px; }
.api-key-status-row {
  margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap;
}
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px;
  background: rgba(255,159,28,0.12); color: var(--o4);
  font-size: 12px; font-weight: 700;
}
.tag-error { background: rgba(255,80,80,0.12); color: #b3471d; }
.tag-idle  { background: rgba(47,29,10,0.08); color: var(--dim); }
.tag-saved { background: rgba(39,122,60,0.12); color: #277a3c; }
.api-key-toolbar { margin-top: 16px; }
.api-key-saved-list {
  margin-top: 22px;
  padding: 18px 18px 16px;
  border-radius: 18px;
  background: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,159,28,0.18);
}
.api-key-saved-list h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--text);
}
.api-key-saved-list ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.saved-key-row {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,246,221,0.9);
  color: #3d2d04;
  font-size: 13px;
}
.saved-key-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.btn-small {
  padding: 8px 11px;
  font-size: 12px;
}
.tag-error { background: rgba(255,80,80,0.12); color: #b3471d; }
.tag-idle  { background: rgba(47,29,10,0.08); color: var(--dim); }
.tag-saved { background: rgba(39,122,60,0.12); color: #277a3c; }
.api-key-toolbar { margin-top: 16px; }
.panel-note {
  padding: 14px 16px; border-radius: 14px;
  background: rgba(255,159,28,0.08); border: 1px solid rgba(255,159,28,0.18);
  color: var(--text-soft); font-size: 13px; line-height: 1.6;
}
.api-key-summary {
  margin-top: 18px; font-size: 13px; color: var(--text);
}
.api-key-summary code {
  background: rgba(255,159,28,0.08); border: 1px solid rgba(255,159,28,0.18);
  border-radius: 10px; padding: 4px 8px; font-size: 12px; color: #5e3902;
}

/* Secret field */
.secret-wrap { position: relative; }
.secret-wrap input { padding-right: 44px; }
.vis-toggle {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 15px;
  color: var(--hint); padding: 2px; transition: color .2s;
}
.vis-toggle:hover { color: var(--text); }

/* ── Responsive ── */
@media (max-width: 1200px) {
  .dash-main {
    grid-template-columns: 1fr;
    padding: 24px 28px;
  }
  .dash-main > .dash-sidebar-right {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    grid-column: 1;
    gap: 14px;
  }
}

@media (max-width: 900px) {
  /* Stack topbar above content instead of side-by-side */
  .dash { flex-direction: column; }
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: min(86vw, 280px);
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .sb-close-btn { display: flex; }
  .topbar    { display: flex; width: 100%; flex-shrink: 0; }
  .dash-main { 
    padding: 18px 16px; 
    width: 100%; 
    min-width: 0;
    grid-template-columns: 1fr;
  }
  .dash-main > .dash-sidebar-right {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .panel-wrap { grid-column: 1; }
}

@media (max-width: 600px) {
  .dash-main {
    padding: 14px 12px;
    gap: 12px;
  }
  .dash-main > .dash-sidebar-right {
    grid-template-columns: 1fr;
  }
  .panel-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .ph-right     { width: 100%; justify-content: flex-start; gap: 6px; }
  .panel-body   { padding: 18px 16px; }
  .fields-grid  { grid-template-columns: 1fr; }
  .auth-card    { padding: 28px 20px 24px; }

  /* Key card — link drops below description on narrow screens */
  .key-card-head { flex-wrap: wrap; }
  .key-link      { margin-left: 0; margin-top: 6px; }

  /* How-to box — icon + text stack */
  .how-to { flex-direction: column; gap: 10px; }

  /* Logs: shrink terminal, hide timestamps to save space */
  .log-terminal { height: 420px; }
  .log-ts       { display: none; }
}

@media (max-width: 480px) {
  .dash-main    { padding: 12px 10px; }
  .panel-header { padding: 16px 14px; gap: 10px; }
  .panel-body   { padding: 14px 12px; }
  .ph-title     { font-size: 15px; }

  /* Auth card */
  .auth-card  { padding: 24px 16px 20px; border-radius: 18px; }
  .auth-title { font-size: 18px; }
  /* btn-primary full-width only in column contexts (auth form, panel header) */
  .auth-form .btn-primary,
  .ph-right   .btn-primary { width: 100%; justify-content: center; }

  /* ID add-row: stack input above button on small screens */
  .id-add-row              { flex-direction: column; }
  .id-add-row .btn-primary { width: 100%; justify-content: center; }

  /* Logs */
  .log-terminal { height: 360px; font-size: 11px; padding: 10px 12px; }
  .log-badge    { display: none; }
  .btn-ghost    { padding: 5px 9px; font-size: 11px; }

  /* Sidebar full-width on tiny phones */
  .sidebar  { width: 100%; }
  .topbar   { padding: 11px 12px; }
  .tb-title { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ══ THREADS TAB ══ */
.thread-search-row { margin-bottom: 18px; }
.thread-search-wrap {
  position: relative; display: flex; align-items: center;
}
.ts-icon {
  position: absolute; left: 12px; color: var(--dim); pointer-events: none;
}
.thread-search-input {
  width: 100%; padding: 9px 14px 9px 36px;
  border-radius: 10px; border: 1.5px solid var(--border);
  background: rgba(255,255,255,.8); font-family: inherit;
  font-size: 13px; color: var(--text); outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.thread-search-input:focus {
  border-color: rgba(255,122,0,.45);
  box-shadow: 0 0 0 3px rgba(255,122,0,.09);
}
.threads-msg { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 14px; }
.threads-msg-error { background: rgba(220,53,69,.09); border: 1px solid rgba(220,53,69,.2); color: #b91c1c; }

.threads-empty {
  text-align: center; padding: 52px 20px;
  color: var(--dim); font-size: 13px; line-height: 1.6;
}
.threads-empty-icon {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,145,43,.08); border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 14px; color: var(--o2);
}

/* ── Table (desktop default) ── */
.threads-table-wrap { overflow-x: auto; }
.threads-table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px; color: var(--text);
}
.threads-table thead th {
  text-align: left; padding: 10px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--dim);
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.threads-table tbody td {
  padding: 13px 16px; vertical-align: middle;
  border-bottom: 1px solid rgba(255,122,0,.07);
}
.threads-table tbody tr:last-child td { border-bottom: none; }
.threads-table tbody tr:hover td { background: rgba(255,145,43,.04); }
.threads-table tbody tr.tr-failed td { background: rgba(220,53,69,.03); }

.td-tid { max-width: 260px; }
.tid-text { display: block; font-family: "SF Mono","Fira Mono",monospace; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.td-key { min-width: 180px; max-width: 260px; }
.td-key .key-hint-text {
  font-family: "SF Mono","Fira Mono",monospace; font-size: 12px;
  color: var(--dim); letter-spacing: 1px;
}
.td-key .key-revealed {
  font-family: "SF Mono","Fira Mono",monospace; font-size: 11px;
  color: var(--text); letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px; display: block;
}
.td-fail { font-weight: 700; color: var(--dim); }
.td-fail.fail-warn { color: #b3471d; }
.td-date { font-size: 11.5px; color: var(--dim); white-space: nowrap; }
.td-actions { white-space: nowrap; display: flex; gap: 4px; align-items: center; }

/* status badges */
.t-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 10.5px; font-weight: 700; white-space: nowrap; margin-right: 3px;
}
.tbadge-active  { background: rgba(39,122,60,.12); border: 1px solid rgba(39,122,60,.25); color: #277a3c; }
.tbadge-failed  { background: rgba(179,71,29,.12); border: 1px solid rgba(179,71,29,.25); color: #b3471d; }
.tbadge-update  { background: rgba(255,145,43,.12); border: 1px solid rgba(255,122,0,.25); color: var(--o3); }
.tbadge-fail    { background: rgba(220,53,69,.10); border: 1px solid rgba(220,53,69,.2); color: #b91c1c; }
.tbadge-vip     { background: linear-gradient(135deg, rgba(255,193,7,.20), rgba(255,145,0,.18)); border: 1px solid rgba(217,119,6,.40); color: #92400e; font-weight: 800; letter-spacing: .3px; }
.tbadge-dm      { background: rgba(59,130,246,.10); border: 1px solid rgba(59,130,246,.25); color: #1d4ed8; }
.tbadge-group   { background: rgba(100,116,139,.09); border: 1px solid rgba(100,116,139,.22); color: #475569; }
.tr-dm          { background: rgba(59,130,246,.025); }
.tcard-dm       { border-left: 3px solid rgba(59,130,246,.35); }

/* VIP row highlight */
.tr-vip td { background: rgba(255,193,7,.04); }
.tr-vip:hover td { background: rgba(255,193,7,.09) !important; }
.tcard-vip { border-color: rgba(217,119,6,.35) !important; background: rgba(255,193,7,.05) !important; }

/* VIP column */
.td-vip { white-space: nowrap; }
.td-vip-none { color: var(--hint); font-size: 12px; }

/* VIP icon buttons */
.btn-icon-vip-on  { color: #92400e; border-color: rgba(217,119,6,.4); background: rgba(255,193,7,.15); }
.btn-icon-vip-on:hover  { background: rgba(255,193,7,.28); border-color: rgba(217,119,6,.6); color: #78350f; }
.btn-icon-vip-off { color: var(--dim); }
.btn-icon-vip-off:hover { background: rgba(255,193,7,.12); border-color: rgba(217,119,6,.35); color: #92400e; }

/* Add VIP Thread box */
.vip-add-box {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px;
  background: linear-gradient(135deg, rgba(255,193,7,.10), rgba(255,145,0,.07));
  border: 1px solid rgba(217,119,6,.28);
  border-radius: 14px;
  margin-bottom: 18px;
}
.vip-add-icon {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  background: linear-gradient(135deg, rgba(255,193,7,.25), rgba(255,145,0,.20));
  border: 1px solid rgba(217,119,6,.35);
  display: flex; align-items: center; justify-content: center;
  color: #92400e;
}
.vip-add-content { flex: 1; min-width: 0; }
.vip-add-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.vip-add-desc  { font-size: 12px; color: var(--dim); margin-bottom: 10px; line-height: 1.5; }
.vip-add-row   { display: flex; gap: 8px; flex-wrap: wrap; }
.vip-add-input {
  flex: 1; min-width: 160px; padding: 9px 13px;
  border: 1px solid rgba(217,119,6,.30); border-radius: 10px;
  background: rgba(255,255,255,.85); color: var(--text);
  font: inherit; font-size: 13px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.vip-add-input:focus { border-color: rgba(217,119,6,.6); box-shadow: 0 0 0 3px rgba(217,119,6,.10); }
.vip-add-input:disabled { opacity: .6; }
.vip-add-btn { padding: 9px 18px; font-size: 13px; }

@media (max-width: 600px) {
  .vip-add-box { flex-direction: column; gap: 10px; }
  .vip-add-row { flex-direction: column; }
  .vip-add-input, .vip-add-btn { width: 100%; }
}

/* icon-only action buttons */
.btn-icon-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,.7); border: 1px solid var(--border);
  color: var(--dim); cursor: pointer; transition: all .2s;
  flex-shrink: 0;
}
.btn-icon-sm:hover { background: rgba(255,145,43,.12); color: var(--o2); border-color: rgba(255,122,0,.3); }
.btn-icon-sm:disabled { opacity: .38; cursor: default; pointer-events: none; }
.btn-icon-warn:hover  { background: rgba(251,191,36,.15); color: #92400e; border-color: rgba(251,191,36,.4); }
.btn-icon-danger:hover { background: rgba(220,53,69,.12); color: #b91c1c; border-color: rgba(220,53,69,.3); }

/* ── Mobile cards (hidden on desktop) ── */
.threads-cards { display: none; gap: 12px; flex-direction: column; }
.thread-card {
  background: rgba(255,255,255,.7); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 16px;
  transition: box-shadow .2s;
}
.thread-card:hover { box-shadow: 0 4px 16px rgba(255,122,0,.1); }
.tcard-failed { border-color: rgba(179,71,29,.25); background: rgba(220,53,69,.03); }
.tcard-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.tcard-tid { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.tcard-tid code { font-size: 11.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; display: block; }
.tcard-badges { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.tcard-meta { display: flex; justify-content: space-between; font-size: 12px; color: var(--dim); margin-bottom: 12px; flex-wrap: wrap; gap: 4px; }
.tcard-actions { display: flex; gap: 6px; flex-wrap: wrap; }

@media (max-width: 700px) {
  .threads-table { display: none; }
  .threads-cards  { display: flex; }
}

/* ══ FLOATING CHAT BUTTON ══ */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 20px 13px 16px;
  background: linear-gradient(135deg, var(--o2) 0%, var(--o3) 100%);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(247,103,7,.45), 0 2px 8px rgba(0,0,0,.12);
  transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s;
  white-space: nowrap;
}
.chat-fab:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 0 14px 36px rgba(247,103,7,.55), 0 4px 12px rgba(0,0,0,.14);
}
.chat-fab:active { transform: scale(.97); }
.chat-fab-label { letter-spacing: -.1px; }

/* ══ CHAT DRAWER OVERLAY ══ */
.chat-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20,10,2,.28);
  backdrop-filter: blur(4px);
  z-index: 300;
}

/* ══ CHAT DRAWER ══ */
.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 100vw);
  z-index: 301;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fffaf0 0%, #fff4de 100%);
  border-left: 1px solid rgba(255,122,0,.18);
  box-shadow: -16px 0 48px rgba(95,39,0,.14);
}

.chat-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,122,0,.12);
  background: linear-gradient(90deg, rgba(255,159,28,.10), rgba(255,122,0,.04));
  flex-shrink: 0;
}
.chat-drawer-brand { display: flex; align-items: center; gap: 11px; }
.chat-drawer-avatar {
  width: 38px; height: 38px; border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,159,28,.4);
  box-shadow: 0 0 14px rgba(255,146,43,.25);
}
.chat-drawer-name  { font-size: 14px; font-weight: 800; color: var(--text); letter-spacing: -.2px; }
.chat-drawer-sub   { font-size: 11px; color: var(--dim); margin-top: 1px; }
.chat-drawer-close {
  background: rgba(255,122,0,.08);
  border: 1px solid rgba(255,122,0,.18);
  color: var(--dim);
  border-radius: 8px; padding: 6px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s;
}
.chat-drawer-close:hover { background: rgba(255,122,0,.16); color: var(--text); }

.chat-drawer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.chat-drawer-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 20px;
  text-align: center;
  color: var(--dim);
  font-size: 13px;
}
.chat-drawer-empty-icon { margin-bottom: 4px; }

.chat-drawer-msg {
  max-width: 88%;
  padding: 11px 14px;
  border-radius: 18px;
  line-height: 1.6;
  font-size: 13.5px;
  animation: msgIn .22s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.chat-drawer-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(255,159,28,.22), rgba(255,212,59,.18));
  border: 1px solid rgba(255,159,28,.28);
  color: #4b2f00;
  border-bottom-right-radius: 6px;
}
.chat-drawer-msg.assistant {
  align-self: flex-start;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,159,28,.16);
  color: #3c280c;
  border-bottom-left-radius: 6px;
  box-shadow: 0 2px 8px rgba(95,39,0,.06);
}
.chat-drawer-msg-role {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--o3);
  margin-bottom: 5px;
}
.chat-drawer-msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Typing indicator */
.chat-drawer-typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(255,159,28,.16);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 2px 8px rgba(95,39,0,.06);
}
.chat-drawer-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--o2); opacity: .5;
  animation: typingDot 1.1s ease-in-out infinite;
}
.chat-drawer-typing span:nth-child(2) { animation-delay: .18s; }
.chat-drawer-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes typingDot { 0%,80%,100%{transform:scale(1);opacity:.4} 40%{transform:scale(1.25);opacity:1} }

/* Input area */
.chat-drawer-form {
  padding: 14px 16px 20px;
  border-top: 1px solid rgba(255,122,0,.12);
  background: rgba(255,255,255,.6);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}
.chat-drawer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.chat-drawer-input {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 11px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255,159,28,.22);
  background: rgba(255,255,255,.97);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  resize: none;
  outline: none;
  transition: border-color .25s, box-shadow .25s;
  line-height: 1.5;
  overflow-y: hidden;
}
.chat-drawer-input:focus {
  border-color: rgba(255,122,0,.45);
  box-shadow: 0 0 0 4px rgba(255,122,0,.10);
}
.chat-drawer-actions { display: flex; gap: 6px; align-items: flex-end; }
.chat-drawer-send {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, var(--o2), var(--o3));
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(247,103,7,.4);
  transition: transform .15s, box-shadow .2s, opacity .2s;
}
.chat-drawer-send:hover  { transform: scale(1.08); box-shadow: 0 6px 18px rgba(247,103,7,.55); }
.chat-drawer-send:active { transform: scale(.93); }
.chat-drawer-send:disabled { opacity: .45; cursor: default; }

/* Drawer transitions */
.drawer-fade-enter-active, .drawer-fade-leave-active { transition: opacity .25s; }
.drawer-fade-enter-from, .drawer-fade-leave-to { opacity: 0; }

.drawer-slide-enter-active { transition: transform .3s cubic-bezier(.2,.8,.2,1); }
.drawer-slide-leave-active  { transition: transform .25s cubic-bezier(.4,0,1,1); }
.drawer-slide-enter-from, .drawer-slide-leave-to { transform: translateX(100%); }

/* Hide FAB when drawer is open */
.chat-fab { transition: transform .2s cubic-bezier(.2,.8,.2,1), box-shadow .2s, opacity .2s; }

@media (max-width: 480px) {
  .chat-fab { bottom: 18px; right: 16px; padding: 12px 16px 12px 14px; }
  .chat-fab-label { display: none; }
  .chat-drawer { width: 100vw; }
}

/* ── UI Modal ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(0,0,0,.45); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: #fff; border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,.22), 0 0 0 1px rgba(255,159,28,.1);
  padding: 28px 28px 22px; max-width: 400px; width: 100%;
  animation: slideUp .2s cubic-bezier(.2,.8,.2,1);
}
.modal-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 10px; letter-spacing: -.2px;
}
.modal-msg {
  font-size: 13.5px; color: var(--text-soft); line-height: 1.6;
}
.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px;
}
.modal-fade-enter-active, .modal-fade-leave-active { transition: opacity .2s; }
.modal-fade-enter-from, .modal-fade-leave-to { opacity: 0; }
.modal-fade-enter-active .modal-box { animation: slideUp .2s cubic-bezier(.2,.8,.2,1); }
