@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg:       #08090D;
  --nav:      #0C0D13;
  --card:     #111218;
  --raised:   #161820;
  --border:   #1A1D28;
  --border-2: #252836;
  --text:     #DDE1F0;
  --text-2:   #8B90A8;
  --text-3:   #555A72;
  --accent:   #6366F1;
  --accent-s: rgba(99,102,241,.12);
  --green:    #34D399;
  --amber:    #F59E0B;
  --red:      #F87171;
  --font:     'Plus Jakarta Sans', system-ui, sans-serif;
  --mono:     'JetBrains Mono', monospace;
}

*,*::before,*::after{margin:0;padding:0;box-sizing:border-box}
html{scroll-behavior:smooth;scrollbar-color:var(--border-2) var(--nav)}
body{font-family:var(--font);font-size:14px;background:var(--bg);color:var(--text);line-height:1.5;-webkit-font-smoothing:antialiased}
a{color:inherit;text-decoration:none}
button,input,select,textarea{font-family:inherit;color-scheme:dark}
body,.table-wrap,.modal-box,.chat-messages,.studio .model-list,.studio .chat-msgs,.studio .gen-ctrl,.studio .gen-out,.studio .pipe-panel{scrollbar-width:thin;scrollbar-color:var(--border-2) transparent}
*::-webkit-scrollbar{width:10px;height:10px}
*::-webkit-scrollbar-track{background:transparent}
*::-webkit-scrollbar-thumb{background:var(--border-2);border-radius:999px;border:2px solid transparent;background-clip:padding-box}
*::-webkit-scrollbar-thumb:hover{background:#363b4f;border:2px solid transparent;background-clip:padding-box}

/* ── Topnav ──────────────────────────────────────────────────────── */
.topnav{
  position:sticky;top:0;z-index:200;
  height:44px;
  background:var(--nav);
  border-bottom:1px solid var(--border);
}
.topnav-inner{
  max-width:1200px;margin:0 auto;padding:0 1.5rem;
  height:100%;display:flex;align-items:center;justify-content:space-between;gap:1.5rem;
}
.topnav-left{display:flex;align-items:center;gap:1.75rem}
.topnav-right{display:flex;align-items:center;gap:.625rem}

/* logo */
.nav-logo{display:flex;align-items:center;gap:.5rem;flex-shrink:0}
.nav-logo-mark{
  width:22px;height:22px;
  background:var(--accent);
  border-radius:5px;
  display:flex;align-items:center;justify-content:center;
  font-size:9px;font-weight:700;color:#fff;letter-spacing:-.01em;
}
.nav-logo-name{font-size:13px;font-weight:700;letter-spacing:-.01em}

/* nav links */
.nav-links{display:flex;align-items:center;gap:1px}
.nav-link{
  padding:.3125rem .625rem;
  font-size:13px;font-weight:500;
  color:var(--text-2);
  border-radius:5px;
  transition:color .1s,background .1s;
  white-space:nowrap;
}
.nav-link:hover{color:var(--text);background:rgba(255,255,255,.04)}
.nav-link.active{color:var(--text);background:var(--accent-s)}

/* user + logout */
.nav-username{font-size:12.5px;color:var(--text-2)}
.nav-sep{width:1px;height:14px;background:var(--border-2)}
.nav-logout{
  font-size:12.5px;color:var(--text-3);
  padding:.25rem .5rem;border:1px solid var(--border);border-radius:4px;
  transition:all .1s;cursor:pointer;background:transparent;
}
.nav-logout:hover{color:var(--text-2);border-color:var(--border-2)}

/* ── Main ────────────────────────────────────────────────────────── */
.main{min-height:calc(100vh - 44px)}
.container{max-width:1100px;margin:0 auto;padding:2rem 1.5rem}

/* ── Page header ─────────────────────────────────────────────────── */
.page-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:1.5rem;gap:1rem}
.page-header h1{font-size:1.125rem;font-weight:700;letter-spacing:-.01em}
.page-header p{font-size:12.5px;color:var(--text-2);margin-top:.2rem}
.header-actions{display:flex;gap:.5rem;flex-shrink:0;align-items:center}

/* ── Cards ───────────────────────────────────────────────────────── */
.card{background:var(--card);border:1px solid var(--border);border-radius:8px;padding:1.25rem;margin-bottom:1rem}
.card-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text-2);margin-bottom:1rem}

/* ── Stat grid ───────────────────────────────────────────────────── */
.stat-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:.75rem;margin-bottom:1rem}
.stat{background:var(--card);border:1px solid var(--border);border-radius:8px;padding:1.125rem}
.stat-label{font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.07em;color:var(--text-3);margin-bottom:.5rem}
.stat-value{font-size:1.625rem;font-weight:700;letter-spacing:-.02em;line-height:1}
.stat-sub{font-size:11.5px;color:var(--text-3);margin-top:.375rem;font-family:var(--mono)}

/* live dot */
.live{display:inline-flex;align-items:center;gap:.375rem;font-size:11.5px;font-weight:600;color:var(--green);font-family:var(--mono)}
.live::before{content:'';width:5px;height:5px;border-radius:50%;background:var(--green);box-shadow:0 0 4px var(--green);animation:blink 2s ease infinite}
@keyframes blink{0%,100%{opacity:1}50%{opacity:.25}}

/* progress */
.progress{height:3px;background:var(--raised);border-radius:2px;margin-top:.75rem;overflow:hidden}
.progress-fill{height:100%;background:var(--accent);transition:width .5s}
.progress-labels{display:flex;justify-content:space-between;font-size:11px;color:var(--text-3);margin-top:.3rem;font-family:var(--mono)}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn{
  display:inline-flex;align-items:center;gap:.375rem;
  padding:.375rem .875rem;border:none;border-radius:6px;
  font-size:13px;font-weight:600;cursor:pointer;
  transition:all .1s;white-space:nowrap;line-height:1.4;
}
.btn svg{width:13px;height:13px;stroke-width:2;flex-shrink:0}
.btn-primary{background:var(--accent);color:#fff}
.btn-primary:hover{background:#7577F3}
.btn-secondary{background:var(--raised);color:var(--text);border:1px solid var(--border)}
.btn-secondary:hover{background:var(--border);border-color:var(--border-2)}
.btn-ghost{background:transparent;color:var(--text-2);border:1px solid var(--border)}
.btn-ghost:hover{color:var(--text);border-color:var(--border-2)}
.btn-danger{background:rgba(248,113,113,.08);color:var(--red);border:1px solid rgba(248,113,113,.2)}
.btn-danger:hover{background:rgba(248,113,113,.15);border-color:rgba(248,113,113,.4)}
.btn-sm{padding:.25rem .625rem;font-size:12px}
.btn-sm svg{width:11px;height:11px}
.btn:disabled{opacity:.4;cursor:not-allowed}

/* ── Forms ───────────────────────────────────────────────────────── */
.form-row{margin-bottom:1rem}
.form-label{display:block;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--text-2);margin-bottom:.35rem}
.form-input{
  width:100%;padding:.5rem .75rem;
  background:var(--raised);border:1px solid var(--border);border-radius:6px;
  color:var(--text);font-size:13.5px;
  transition:border-color .1s,box-shadow .1s;
}
.form-input:focus{outline:none;border-color:var(--accent);box-shadow:0 0 0 3px rgba(99,102,241,.12)}
.form-input::placeholder{color:var(--text-3)}
select.form-input,
textarea.form-input{background:var(--raised);color:var(--text)}
select.form-input{
  cursor:pointer;appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='5' viewBox='0 0 10 5'%3E%3Cpath d='M0 0l5 5 5-5z' fill='%23363A4D'/%3E%3C/svg%3E");
  background-repeat:no-repeat;background-position:right .75rem center;background-size:8px;padding-right:2rem;
}
select.form-input option,
select.form-input optgroup{background:var(--raised);color:var(--text)}
.form-hint{font-size:11.5px;color:var(--text-3);margin-top:.25rem}
.form-actions{display:flex;gap:.5rem;margin-top:1.25rem;align-items:center}

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert{display:flex;align-items:flex-start;gap:.5rem;padding:.625rem .875rem;border-radius:6px;font-size:13px;margin-bottom:1rem}
.alert-error{background:rgba(248,113,113,.07);border:1px solid rgba(248,113,113,.2);color:var(--red)}
.alert-warning{background:rgba(245,158,11,.07);border:1px solid rgba(245,158,11,.2);color:var(--amber)}
.alert-info{background:var(--accent-s);border:1px solid rgba(99,102,241,.25);color:#A5B4FC}

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap{border:1px solid var(--border);border-radius:8px;overflow:hidden}
table{width:100%;border-collapse:collapse}
thead{background:var(--raised)}
th{padding:.5rem 1rem;text-align:left;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text-3);border-bottom:1px solid var(--border);white-space:nowrap}
td{padding:.625rem 1rem;font-size:13px;color:var(--text-2);border-bottom:1px solid var(--border)}
tbody tr:last-child td{border-bottom:none}
tbody tr:hover td{background:rgba(255,255,255,.015);color:var(--text)}
.td-name{font-weight:600;color:var(--text) !important}
td code{font-family:var(--mono);font-size:11.5px;background:var(--raised);padding:.1rem .35rem;border-radius:3px}
.empty-row td{text-align:center;padding:2.5rem;color:var(--text-3) !important}

/* ── Badges ──────────────────────────────────────────────────────── */
.badge{display:inline-flex;align-items:center;padding:.15rem .45rem;font-size:11px;font-weight:700;border-radius:4px;text-transform:uppercase;letter-spacing:.04em}
.badge-admin{background:var(--accent-s);color:#A5B4FC;border:1px solid rgba(99,102,241,.2)}
.badge-user{background:var(--raised);color:var(--text-3);border:1px solid var(--border)}
.badge-ok{background:rgba(52,211,153,.08);color:var(--green);border:1px solid rgba(52,211,153,.2)}
.badge-warn{background:rgba(251,191,36,.08);color:#f59e0b;border:1px solid rgba(251,191,36,.2)}
.badge-danger{background:rgba(248,113,113,.08);color:var(--red);border:1px solid rgba(248,113,113,.2)}

/* ── Modals ──────────────────────────────────────────────────────── */
.modal{display:none;position:fixed;inset:0;background:rgba(0,0,0,.6);backdrop-filter:blur(2px);z-index:500;align-items:center;justify-content:center}
.modal.show{display:flex}
.modal-box{background:var(--card);border:1px solid var(--border-2);border-radius:10px;width:90%;max-width:440px;max-height:90vh;overflow-y:auto;animation:pop .12s ease}
@keyframes pop{from{opacity:0;transform:scale(.97) translateY(-4px)}to{opacity:1;transform:none}}
.modal-head{display:flex;justify-content:space-between;align-items:center;padding:.875rem 1.125rem;border-bottom:1px solid var(--border)}
.modal-title{font-size:14px;font-weight:700}
.modal-close{background:none;border:none;color:var(--text-3);cursor:pointer;font-size:1.125rem;line-height:1;padding:.125rem;border-radius:3px;transition:color .1s}
.modal-close:hover{color:var(--text)}
.modal-body{padding:1.125rem}
.donate-modal-box{max-width:560px}
.nav-donate-btn{background:transparent;border:none;cursor:pointer;color:var(--text-3)}
.nav-donate-btn:hover{color:var(--text)}
.donate-tagline{font-size:13px;color:var(--text-2);margin:0 0 1.25rem;line-height:1.55}
.donate-coins{display:flex;gap:.875rem}
.donate-coin{flex:1;display:flex;flex-direction:column;align-items:center;gap:.75rem;padding:1rem;background:var(--raised);border:1px solid var(--border);border-radius:8px}
.donate-coin-label{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text-3)}
.donate-qr{display:block;border-radius:5px}
.donate-addr-row{display:flex;align-items:center;gap:.5rem;width:100%;background:var(--card);border:1px solid var(--border);border-radius:5px;padding:.375rem .5rem}
.donate-addr{flex:1;font-family:var(--mono);font-size:9px;color:var(--text-2);word-break:break-all;line-height:1.5;user-select:all}
.donate-copy{flex-shrink:0;background:none;border:1px solid var(--border);border-radius:4px;cursor:pointer;padding:.2rem .5rem;font-size:11px;font-weight:600;color:var(--text-3);font-family:var(--font);transition:color .1s,border-color .1s}
.donate-copy:hover{color:var(--text);border-color:var(--border-2)}
@media(max-width:480px){.donate-coins{flex-direction:column}}

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs{display:flex;gap:1px;border-bottom:1px solid var(--border);margin-bottom:1.25rem}
.tab{padding:.5rem .875rem;font-size:13px;font-weight:500;color:var(--text-2);background:none;border:none;cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;transition:color .1s}
.tab:hover{color:var(--text)}
.tab.active{color:var(--text);border-bottom-color:var(--accent)}
.tab-panel{display:none}
.tab-panel.active{display:block}

/* ── Token box ───────────────────────────────────────────────────── */
.token-box{display:flex;align-items:center;gap:.625rem;padding:.625rem .875rem;background:var(--raised);border:1px solid var(--border);border-radius:6px;margin:.875rem 0}
.token-box code{flex:1;font-family:var(--mono);font-size:11.5px;color:var(--accent);word-break:break-all}

/* ── Chat ────────────────────────────────────────────────────────── */
.chat-wrap{display:flex;flex-direction:column;height:calc(100vh - 44px - 2rem);background:var(--card);border:1px solid var(--border);border-radius:8px;overflow:hidden}
.chat-bar{display:flex;justify-content:space-between;align-items:center;padding:.625rem 1rem;border-bottom:1px solid var(--border);flex-shrink:0;gap:.75rem}
.chat-bar h2{font-size:13.5px;font-weight:700}
.chat-controls{display:flex;gap:.5rem;align-items:center}
.chat-messages{flex:1;overflow-y:auto;padding:1.125rem;scroll-behavior:smooth}
.chat-empty{text-align:center;padding:4rem 1rem;color:var(--text-3)}
.chat-empty h3{font-size:1rem;font-weight:600;color:var(--text-2);margin-bottom:.35rem}
.msg{display:flex;gap:.625rem;margin-bottom:1rem}
.msg-av{width:24px;height:24px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:9px;font-weight:700;flex-shrink:0;margin-top:1px;font-family:var(--mono)}
.msg-av.user{background:rgba(99,102,241,.15);color:var(--accent);border:1px solid rgba(99,102,241,.2)}
.msg-av.ai{background:var(--raised);color:var(--text-2);border:1px solid var(--border)}
.msg-body{flex:1}
.msg-meta{font-size:11px;color:var(--text-3);margin-bottom:.25rem;font-family:var(--mono)}
.msg-text{background:var(--raised);border:1px solid var(--border);border-radius:6px;padding:.5rem .75rem;font-size:13.5px;line-height:1.6;color:var(--text);word-wrap:break-word}
.msg.user .msg-text{background:rgba(99,102,241,.06);border-color:rgba(99,102,241,.15)}
.chat-foot{padding:.75rem 1rem;border-top:1px solid var(--border);flex-shrink:0}
.chat-input-row{display:flex;gap:.5rem;align-items:flex-end}
.chat-textarea{flex:1;padding:.5rem .75rem;background:var(--raised);border:1px solid var(--border);border-radius:6px;color:var(--text);font-size:13.5px;resize:none;min-height:38px;max-height:140px;line-height:1.5;transition:border-color .1s}
.chat-textarea:focus{outline:none;border-color:var(--accent)}
.chat-hint{font-size:11px;color:var(--text-3);margin-top:.375rem}

/* ── Login ───────────────────────────────────────────────────────── */
.login-wrap{min-height:100vh;display:flex;align-items:center;justify-content:center;background:var(--bg);padding:1.5rem}
.login-card{width:100%;max-width:360px;background:var(--card);border:1px solid var(--border-2);border-radius:10px;padding:2rem}
.login-logo{display:flex;align-items:center;gap:.625rem;margin-bottom:1.75rem}
.login-mark{width:30px;height:30px;background:var(--accent);border-radius:7px;display:flex;align-items:center;justify-content:center;font-size:11px;font-weight:700;color:#fff}
.login-logo-text h1{font-size:1.0625rem;font-weight:700;letter-spacing:-.01em}
.login-logo-text p{font-size:11.5px;color:var(--text-2)}
.login-footer{margin-top:1.25rem;text-align:center;font-size:11.5px;color:var(--text-3);font-family:var(--mono)}

/* ── Centered form (change pw, etc.) ─────────────────────────────── */
.centered-wrap{min-height:calc(100vh - 44px);display:flex;align-items:center;justify-content:center;padding:1.5rem}
.centered-card{width:100%;max-width:400px;background:var(--card);border:1px solid var(--border);border-radius:10px;padding:1.75rem}
.centered-card h1{font-size:1.0625rem;font-weight:700;margin-bottom:.375rem}
.centered-card .sub{font-size:12.5px;color:var(--text-2);margin-bottom:1.5rem}

/* ── Search bar ──────────────────────────────────────────────────── */
.search-bar{display:flex;gap:.5rem;margin-bottom:1rem}
.search-bar .form-input{flex:1}

/* ── Divider ─────────────────────────────────────────────────────── */
hr{border:none;border-top:1px solid var(--border);margin:1.125rem 0}

/* ── Utils ───────────────────────────────────────────────────────── */
.mono{font-family:var(--mono)}
.muted{color:var(--text-3)}
.dim{color:var(--text-2)}
.small{font-size:12.5px}
.text-green{color:var(--green)}
.text-red{color:var(--red)}
.text-amber{color:var(--amber)}
.flex{display:flex}.items-center{align-items:center}.gap-2{gap:.5rem}.mb-0{margin-bottom:0!important}

/* ── Responsive ──────────────────────────────────────────────────── */
@media(max-width:640px){
  .topnav-inner{padding:0 1rem}
  .nav-links{gap:0}
  .nav-link{padding:.3rem .5rem;font-size:12.5px}
  .container{padding:1.25rem 1rem}
}
