*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0 }

:root {
  --bg:      #060910;
  --surface: #0c1018;
  --panel:   #101520;
  --card:    #141b26;
  --border:  #1c2535;
  --border2: #263040;
  --text:    #e8eef8;
  --muted:   #4d607a;
  --muted2:  #8496b8;
  --blue:    #4f8ef7;
  --blue2:   #3a7de8;
  --cyan:    #22d3ee;
  --green:   #22c55e;
  --yellow:  #f59e0b;
  --red:     #ef4444;
  --purple:  #a855f7;
}

html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── AUTH PAGES ──────────────────────────────── */
body.auth {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  background:
    radial-gradient(ellipse 60% 55% at 15% 70%, rgba(79,142,247,.09) 0%, transparent 55%),
    radial-gradient(ellipse 50% 50% at 85% 15%, rgba(168,85,247,.07) 0%, transparent 55%),
    var(--bg);
}
body.auth::before {
  content: '';
  position: fixed; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.014) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.014) 1px, transparent 1px);
  background-size: 50px 50px;
  pointer-events: none;
}

.auth-card {
  position: relative; z-index: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: 0 30px 90px rgba(0,0,0,.65), inset 0 1px 0 rgba(255,255,255,.05);
}

/* Top accent line */
.auth-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--cyan));
  border-radius: 18px 18px 0 0;
}

/* ── BRAND ───────────────────────────────────── */
.brand {
  display: flex; align-items: center; gap: .8rem;
  margin-bottom: 2rem;
}
.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(145deg, #1a3a6e, #2563eb);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
}
.brand-icon svg { width: 24px; height: 24px; }
.brand-text h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -.025em; }
.brand-text p  { font-size: .72rem; color: var(--muted2); margin-top: 2px; }

/* ── FORMS ───────────────────────────────────── */
.field { margin-bottom: .9rem; }
.field label {
  display: block; font-size: .72rem; font-weight: 500;
  color: var(--muted2); letter-spacing: .03em; margin-bottom: .38rem;
  text-transform: uppercase;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%; padding: .65rem .9rem;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  font-size: .875rem; font-family: inherit; outline: none;
  min-height: 42px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus {
  border-color: var(--blue);
  background: #0d1520;
  box-shadow: 0 0 0 3px rgba(79,142,247,.15), 0 1px 6px rgba(0,0,0,.3);
}

.btn-primary {
  width: 100%; margin-top: 1.1rem; padding: .72rem;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff; border: none; border-radius: 9px;
  font-size: .875rem; font-weight: 600; font-family: inherit;
  cursor: pointer; min-height: 44px; letter-spacing: .01em;
  box-shadow: 0 4px 16px rgba(79,142,247,.35);
  transition: opacity .15s, transform .1s, box-shadow .15s;
}
.btn-primary:hover { opacity: .92; box-shadow: 0 4px 20px rgba(79,142,247,.5); }
.btn-primary:active { transform: scale(.98); }

.err-pill {
  margin-top: .8rem; padding: .55rem .9rem;
  background: rgba(239,68,68,.1); border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px; color: #fca5a5; font-size: .78rem;
}

/* ── DASHBOARD LAYOUT ────────────────────────── */
body.dash { display: flex; flex-direction: column; min-height: 100vh; }

/* Accent top bar */
body.dash::before {
  content: '';
  display: block; height: 2px;
  background: linear-gradient(90deg, var(--blue), var(--purple), var(--cyan), var(--green));
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
}

.dash-header {
  background: rgba(16,21,32,.95);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 58px; margin-top: 2px;
  display: flex; align-items: center; gap: .9rem;
  flex-shrink: 0; position: sticky; top: 2px; z-index: 20;
}

.dash-brand { display: flex; align-items: center; gap: .6rem; flex-shrink: 0; }
.dash-brand .bi {
  width: 28px; height: 28px;
  background: linear-gradient(145deg,#1a3a6e,#2563eb);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(37,99,235,.4);
}
.dash-brand .bi svg { width: 16px; height: 16px; }
.dash-brand span { font-size: .9rem; font-weight: 700; letter-spacing: -.02em; }

.admin-badge {
  font-size: .62rem; font-weight: 700;
  padding: .14rem .48rem; border-radius: 5px;
  background: rgba(79,142,247,.14); color: var(--blue);
  border: 1px solid rgba(79,142,247,.22);
  text-transform: uppercase; letter-spacing: .08em;
}

.vr { width: 1px; height: 22px; background: var(--border); flex-shrink: 0; }

.live-pill {
  display: flex; align-items: center; gap: .38rem;
  padding: .24rem .65rem; border-radius: 100px;
  border: 1px solid var(--border); font-size: .72rem; color: var(--muted);
  background: rgba(255,255,255,.03);
  transition: all .25s;
}
.live-pill.on {
  background: rgba(34,197,94,.08);
  border-color: rgba(34,197,94,.22); color: #86efac;
}
.live-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  transition: background .25s;
}
.live-pill.on .live-dot {
  background: var(--green); box-shadow: 0 0 6px var(--green);
  animation: blink 2.5s ease infinite;
}
@keyframes blink {
  0%,100% { box-shadow: 0 0 6px var(--green); }
  50%      { box-shadow: 0 0 12px var(--green), 0 0 20px rgba(34,197,94,.3); }
}

.hdr-spacer { flex: 1; }
.hdr-user { font-size: .75rem; color: var(--muted); }
.hdr-user strong { color: var(--muted2); font-weight: 500; }

.btn-logout {
  padding: .3rem .7rem;
  background: transparent; border: 1px solid var(--border);
  color: var(--muted); border-radius: 7px;
  font-size: .73rem; font-family: inherit; cursor: pointer;
  transition: all .15s;
}
.btn-logout:hover {
  border-color: var(--red); color: var(--red);
  background: rgba(239,68,68,.07);
}

/* ── MAIN ────────────────────────────────────── */
.main {
  flex: 1; padding: 1.75rem 1.5rem;
  max-width: 1040px; width: 100%; margin: 0 auto;
}

/* ── KPI CARDS ───────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: .75rem; margin-bottom: 1.75rem;
}

.kpi-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 1rem 1.1rem;
  display: flex; flex-direction: column; gap: .5rem;
  position: relative; overflow: hidden;
  transition: border-color .2s, transform .15s;
}
.kpi-card:hover { border-color: var(--border2); transform: translateY(-1px); }

/* Subtle gradient top accent per card */
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
}
.kpi-blue::before   { background: linear-gradient(90deg, var(--blue), var(--cyan)); }
.kpi-green::before  { background: linear-gradient(90deg, var(--green), var(--cyan)); }
.kpi-yellow::before { background: linear-gradient(90deg, var(--yellow), var(--green)); }
.kpi-purple::before { background: linear-gradient(90deg, var(--purple), var(--blue)); }

.kpi-label {
  font-size: .67rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
}
.kpi-value {
  font-size: 1.6rem; font-weight: 700; letter-spacing: -.03em;
  font-family: 'JetBrains Mono', monospace; line-height: 1;
}
.kpi-sub { font-size: .72rem; color: var(--muted2); margin-top: auto; }

.kpi-blue   .kpi-value { color: #79c0ff; }
.kpi-green  .kpi-value { color: #86efac; }
.kpi-yellow .kpi-value { color: #fde68a; }
.kpi-purple .kpi-value { color: #d8b4fe; }

/* ── SECTIONS ────────────────────────────────── */
.section { margin-bottom: 2rem; }

.section-header {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: 1rem;
}
.section-icon {
  width: 28px; height: 28px;
  background: rgba(79,142,247,.1);
  border: 1px solid rgba(79,142,247,.18);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.section-icon svg { width: 14px; height: 14px; color: var(--blue); }
.section-title {
  font-size: .82rem; font-weight: 600; color: var(--text);
}
.section-count {
  font-size: .68rem; font-weight: 600;
  padding: .12rem .42rem; border-radius: 4px;
  background: rgba(79,142,247,.1); color: var(--blue);
  font-family: 'JetBrains Mono', monospace;
}

/* ── TABLE ───────────────────────────────────── */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--panel); border-radius: 12px;
  overflow: hidden; border: 1px solid var(--border);
}
.data-table th {
  background: var(--surface); padding: .55rem 1rem;
  font-size: .67rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted);
  text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: .6rem 1rem; font-size: .8rem;
  border-bottom: 1px solid rgba(28,37,53,.8);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(79,142,247,.04); }

.mono { font-family: 'JetBrains Mono', monospace; font-size: .75rem; color: var(--muted2); }
.nm   { font-weight: 500; color: var(--text); max-width: 160px; overflow: hidden; text-overflow: ellipsis; }

/* Mini bar in stats table */
.mini-bar-wrap { display: flex; align-items: center; gap: .45rem; min-width: 90px; }
.mini-bar-val  { font-family: 'JetBrains Mono', monospace; font-size: .73rem; color: var(--text); min-width: 44px; }
.mini-bar-track { flex: 1; height: 3px; background: rgba(255,255,255,.06); border-radius: 100px; min-width: 40px; }
.mini-bar-fill  { height: 100%; border-radius: 100px; transition: width .4s ease, background .4s ease; }
.fill-ok   { background: var(--green); }
.fill-warn { background: var(--yellow); }
.fill-crit { background: var(--red); }

.empty-cell { text-align: center; padding: 2.5rem !important; color: var(--muted); }

/* ── TOKEN CARDS ─────────────────────────────── */
.token-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: .75rem; margin-bottom: .85rem;
}

.token-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 11px; padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .65rem;
  transition: border-color .2s;
}
.token-card:hover { border-color: var(--border2); }

.tc-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.tc-name { font-weight: 600; font-size: .82rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

.tc-preview {
  padding: .4rem .65rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px;
  font-family: 'JetBrains Mono', monospace; font-size: .72rem; color: #79c0ff;
  word-break: break-all; line-height: 1.4;
}

.tc-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: .5rem; flex-wrap: wrap;
}
.tc-last { font-size: .7rem; color: var(--muted); }
.tc-last span { color: var(--muted2); }

.tc-actions { display: flex; gap: .4rem; }

.btn-copy {
  padding: .24rem .6rem;
  background: rgba(79,142,247,.12); color: var(--blue);
  border: 1px solid rgba(79,142,247,.22); border-radius: 6px;
  font-size: .7rem; font-family: inherit; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn-copy:hover { background: rgba(79,142,247,.22); }
.btn-copy.copied { background: rgba(34,197,94,.12); color: var(--green); border-color: rgba(34,197,94,.25); }

.btn-revoke {
  padding: .24rem .6rem;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 6px;
  font-size: .7rem; font-family: inherit; cursor: pointer;
  transition: all .15s;
}
.btn-revoke:hover { border-color: var(--red); color: var(--red); background: rgba(239,68,68,.07); }

/* Empty tokens */
.tokens-empty {
  text-align: center; padding: 2.5rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; color: var(--muted);
}
.tokens-empty svg { width: 32px; height: 32px; margin: 0 auto .75rem; display: block; opacity: .3; }

/* ── TOKEN BANNER ────────────────────────────── */
.token-banner {
  padding: 1rem 1.1rem; margin-bottom: 1.1rem;
  background: rgba(34,197,94,.06); border: 1px solid rgba(34,197,94,.2);
  border-radius: 10px; position: relative;
}
.token-banner::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--green), var(--cyan));
  border-radius: 10px 10px 0 0;
}
.token-banner p { font-size: .78rem; color: var(--muted2); margin-bottom: .5rem; }
.token-banner p strong { color: #86efac; }
.token-banner code {
  display: block; font-family: 'JetBrains Mono', monospace; font-size: .78rem; color: #79c0ff;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; padding: .6rem .85rem; word-break: break-all;
}

/* ── CREATE TOKEN FORM ───────────────────────── */
.create-form {
  display: flex; gap: .6rem; flex-wrap: wrap;
  padding: .85rem 1rem;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 11px;
}
.create-form input[type="text"] {
  flex: 1; min-width: 180px; height: 38px; padding: 0 .9rem;
  font-size: .82rem;
}
.btn-create {
  padding: 0 1.1rem; height: 38px;
  background: linear-gradient(135deg, var(--blue), var(--blue2));
  color: #fff; border: none; border-radius: 8px;
  font-size: .82rem; font-weight: 600; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  box-shadow: 0 2px 10px rgba(79,142,247,.3);
  transition: opacity .15s;
}
.btn-create:hover { opacity: .88; }

/* ── RESPONSIVE ──────────────────────────────── */
@media (max-width: 768px) {
  .main { padding: 1.25rem 1rem; }
  .dash-header { padding: 0 1rem; gap: .65rem; }
  .admin-badge { display: none; }
  .hdr-user { display: none; }
  .vr { display: none; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .6rem; margin-bottom: 1.25rem; }
  .kpi-value { font-size: 1.3rem; }
  .token-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .auth-card { padding: 2rem 1.25rem; border-radius: 14px; }
  .main { padding: 1rem .85rem; }
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: .5rem; }
  .kpi-card { padding: .85rem; }
  .kpi-value { font-size: 1.15rem; }
  .data-table th, .data-table td { padding: .45rem .7rem; }
  .create-form { flex-direction: column; }
  .create-form input[type="text"], .btn-create { width: 100%; }
}
