/* TokenStrata Shared Theme v2.0 */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;700&display=swap');

:root {
  --bg:      #060b18;
  --bg2:     #0a0f1e;
  --bg3:     #0f1629;
  --card:    #111827;
  --card2:   #1a2235;
  --card3:   #1e2d45;
  --border:  rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --blue:    #00d4ff;
  --blue2:   #0099cc;
  --purple:  #7c3aed;
  --purple2: #a855f7;
  --green:   #10b981;
  --yellow:  #f59e0b;
  --orange:  #f97316;
  --red:     #ef4444;
  --pink:    #ec4899;
  --text:    #f8fafc;
  --text2:   #94a3b8;
  --text3:   #64748b;
  --text4:   #475569;
  --gradient:        linear-gradient(135deg, #00d4ff, #7c3aed);
  --gradient-green:  linear-gradient(135deg, #10b981, #0d9488);
  --gradient-gold:   linear-gradient(135deg, #f59e0b, #f97316);
  --gradient-purple: linear-gradient(135deg, #7c3aed, #ec4899);
  --sidebar-w: 240px;
  --topbar-h:  64px;
  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Inter", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* ── Background glow ── */
body::before {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 80% 50% at 15% 15%, rgba(0,212,255,0.04), transparent 60%),
    radial-gradient(ellipse 60% 50% at 85% 85%, rgba(124,58,237,0.04), transparent 60%);
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; position: fixed; top: 0; left: 0; z-index: 100;
  overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.logo-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; font-weight: 900; color: #fff; flex-shrink: 0;
}
.logo-text {
  font-size: 1.05rem; font-weight: 800; letter-spacing: -.3px;
  background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.role-badge {
  font-size: .62rem; font-weight: 700; letter-spacing: .8px;
  text-transform: uppercase; padding: 2px 8px; border-radius: 4px;
  margin-left: 2px; white-space: nowrap;
}
.role-badge.admin    { background: rgba(239,68,68,.15);   color: #fca5a5; }
.role-badge.org      { background: rgba(0,212,255,.12);   color: var(--blue); }
.role-badge.member   { background: rgba(16,185,129,.12);  color: var(--green); }
.role-badge.provider { background: rgba(124,58,237,.15);  color: var(--purple2); }
.role-badge.reseller { background: rgba(245,158,11,.15);  color: var(--yellow); }

.nav-section {
  padding: .75rem 1.5rem .3rem;
  font-size: .62rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px; color: var(--text4);
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: .6rem 1.5rem;
  color: var(--text3); text-decoration: none;
  font-size: .84rem; font-weight: 500;
  transition: all .15s; cursor: pointer;
  border: none; background: none; width: 100%; text-align: left;
  position: relative;
}
.nav-item:hover { color: var(--text2); background: rgba(255,255,255,.03); }
.nav-item.active { color: var(--blue); background: rgba(0,212,255,.06); }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 4px; bottom: 4px;
  width: 3px; background: var(--blue); border-radius: 0 3px 3px 0;
}
.nav-item .icon { font-size: .95rem; width: 20px; text-align: center; flex-shrink: 0; }
.nav-item .badge-num {
  margin-left: auto; font-size: .65rem; font-weight: 800;
  background: var(--red); color: #fff;
  padding: 1px 6px; border-radius: 999px; min-width: 18px; text-align: center;
}

.sidebar-bottom {
  margin-top: auto; padding: 1rem 1.5rem;
  border-top: 1px solid var(--border); flex-shrink: 0;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 800; flex-shrink: 0;
}
.user-info { overflow: hidden; flex: 1; }
.user-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role-text { font-size: .68rem; color: var(--text3); }
.logout-btn {
  background: none; border: none; color: var(--text4); cursor: pointer;
  font-size: .78rem; padding: .45rem 0; display: flex; align-items: center;
  gap: 6px; margin-top: .6rem; transition: color .2s; width: 100%; font-family: inherit;
}
.logout-btn:hover { color: var(--red); }

/* ── Main content ── */
.main { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }
.topbar {
  height: var(--topbar-h); background: var(--bg2);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2rem; position: sticky; top: 0; z-index: 50; flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-title { font-size: 1rem; font-weight: 700; letter-spacing: -.3px; }
.topbar-right { display: flex; align-items: center; gap: 1rem; }
.topbar-search {
  padding: .45rem 1rem; background: rgba(255,255,255,.04);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: .82rem; font-family: inherit;
  outline: none; width: 200px; transition: all .2s;
}
.topbar-search:focus { border-color: rgba(0,212,255,.3); width: 260px; }
.topbar-search::placeholder { color: var(--text4); }

.badge-live {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.2);
  font-size: .7rem; font-weight: 700; color: var(--green);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:.5;transform:scale(1.5)} }

.content { padding: 2rem; flex: 1; }

/* ── Sections (tab pages) ── */
.section { display: none; animation: fadeIn .2s ease; }
.section.active { display: block; }
@keyframes fadeIn { from{opacity:0;transform:translateY(6px)} to{opacity:1;transform:translateY(0)} }

/* ── Stats grid ── */
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1.1rem; margin-bottom: 1.75rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 1.1rem; margin-bottom: 1.75rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr;      gap: 1.1rem; margin-bottom: 1.75rem; }

/* ── Stat card ── */
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.2rem 1.4rem;
  transition: all .2s; position: relative; overflow: hidden;
}
.stat-card:hover { border-color: rgba(0,212,255,.12); transform: translateY(-2px); }
.stat-card::after {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  opacity: 0; transition: opacity .2s;
}
.stat-card:hover::after { opacity: 1; background: var(--gradient); }
.stat-label {
  font-size: .72rem; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: .5rem;
  display: flex; align-items: center; gap: 6px;
}
.stat-val { font-size: 1.85rem; font-weight: 900; letter-spacing: -1.5px; line-height: 1.1; }
.stat-sub { font-size: .72rem; color: var(--text3); margin-top: .35rem; }
.stat-delta { font-size: .72rem; margin-top: .35rem; display: flex; align-items: center; gap: 4px; }
.stat-delta.up   { color: var(--green); }
.stat-delta.down { color: var(--red); }
.stat-blue   .stat-val { background: var(--gradient);        -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-green  .stat-val { background: var(--gradient-green);  -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-gold   .stat-val { background: var(--gradient-gold);   -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.stat-purple .stat-val { background: var(--gradient-purple); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

/* ── Panel ── */
.panel {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 1.25rem;
}
.panel-header {
  padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.panel-title { font-size: .88rem; font-weight: 700; }
.panel-sub   { font-size: .75rem; color: var(--text3); }
.panel-body  { padding: 1.4rem 1.5rem; }
.panel-footer { padding: .75rem 1.5rem; border-top: 1px solid var(--border); background: rgba(255,255,255,.015); }

/* ── Table ── */
.ts-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.ts-table th {
  text-align: left; padding: 0 .75rem .75rem 0;
  font-size: .68rem; font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: .5px;
  border-bottom: 1px solid var(--border);
}
.ts-table td {
  padding: .75rem .75rem .75rem 0; border-bottom: 1px solid rgba(255,255,255,.03);
  color: var(--text2); vertical-align: middle;
}
.ts-table tr:last-child td { border-bottom: none; }
.ts-table tr:hover td { color: var(--text); background: rgba(255,255,255,.015); }
.ts-table tr:hover td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.ts-table tr:hover td:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* ── Tags ── */
.tag {
  display: inline-block; padding: 2px 9px; border-radius: 4px;
  font-size: .68rem; font-weight: 700; letter-spacing: .3px;
}
.tag-green  { background: rgba(16,185,129,.1);  color: var(--green);   border: 1px solid rgba(16,185,129,.15); }
.tag-blue   { background: rgba(0,212,255,.1);   color: var(--blue);    border: 1px solid rgba(0,212,255,.15); }
.tag-yellow { background: rgba(245,158,11,.1);  color: var(--yellow);  border: 1px solid rgba(245,158,11,.15); }
.tag-red    { background: rgba(239,68,68,.1);   color: var(--red);     border: 1px solid rgba(239,68,68,.15); }
.tag-purple { background: rgba(124,58,237,.12); color: var(--purple2); border: 1px solid rgba(124,58,237,.2); }
.tag-orange { background: rgba(249,115,22,.1);  color: var(--orange);  border: 1px solid rgba(249,115,22,.15); }
.tag-gray   { background: rgba(255,255,255,.06); color: var(--text3);  border: 1px solid var(--border); }
.tag-gold   { background: rgba(245,158,11,.12);  color: #f59e0b;        border: 1px solid rgba(245,158,11,.2); }

/* ── Buttons ── */
.btn-primary {
  padding: .65rem 1.4rem; border: none; border-radius: var(--radius-sm);
  background: var(--gradient); color: #fff; font-size: .84rem; font-weight: 700;
  font-family: inherit; cursor: pointer; transition: all .2s;
  box-shadow: 0 4px 16px rgba(0,212,255,.18);
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-primary:hover { box-shadow: 0 4px 24px rgba(0,212,255,.32); transform: translateY(-1px); }
.btn-secondary {
  padding: .6rem 1.2rem; border: 1px solid var(--border2); border-radius: var(--radius-sm);
  background: rgba(255,255,255,.05); color: var(--text2); font-size: .82rem; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-secondary:hover { background: rgba(255,255,255,.09); color: var(--text); }
.btn-danger {
  padding: .6rem 1.2rem; border: 1px solid rgba(239,68,68,.2); border-radius: var(--radius-sm);
  background: rgba(239,68,68,.08); color: #fca5a5; font-size: .82rem; font-weight: 600;
  font-family: inherit; cursor: pointer; transition: all .2s;
  display: inline-flex; align-items: center; gap: 7px;
}
.btn-danger:hover { background: rgba(239,68,68,.15); }
.btn-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  color: var(--text3); cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: .9rem; transition: all .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.1); color: var(--text); }

/* ── Form elements ── */
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-size: .78rem; font-weight: 600; color: var(--text2); margin-bottom: .45rem; }
.field input, .field select, .field textarea {
  width: 100%; padding: .68rem 1rem;
  background: rgba(255,255,255,.04); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-size: .875rem; font-family: inherit; outline: none; transition: all .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: rgba(0,212,255,.4); box-shadow: 0 0 0 3px rgba(0,212,255,.07);
}
.field input::placeholder { color: var(--text4); }
.field select option { background: #1e293b; }

/* ── Loading skeleton ── */
.skeleton {
  background: linear-gradient(90deg,rgba(255,255,255,.04) 25%,rgba(255,255,255,.08) 50%,rgba(255,255,255,.04) 75%);
  background-size: 200%; animation: shimmer 1.6s infinite;
  border-radius: 6px; height: 1.1rem; margin: .35rem 0;
}
@keyframes shimmer { 0%{background-position:200%} 100%{background-position:-200%} }

/* ── Code / mono ── */
.mono { font-family: "JetBrains Mono", monospace; font-size: .82rem; color: var(--blue); }
.code-block {
  background: var(--bg3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem 1rem;
  font-family: "JetBrains Mono", monospace; font-size: .8rem;
  color: var(--blue); word-break: break-all; line-height: 1.6;
}

/* ── Empty state ── */
.empty-state {
  text-align: center; padding: 3rem 2rem;
  color: var(--text3); font-size: .875rem;
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; display: block; }
.empty-state h3 { font-size: 1rem; color: var(--text2); margin-bottom: .4rem; }

/* ── Alert / Flash ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius-sm); font-size: .84rem; line-height: 1.5; margin-bottom: 1rem; display: none; }
.alert.show-error   { display: block; background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.2);  color: #fca5a5; }
.alert.show-success { display: block; background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.2); color: #6ee7b7; }
.alert.show-info    { display: block; background: rgba(0,212,255,.06); border: 1px solid rgba(0,212,255,.15); color: var(--blue); }

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

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* ── Responsive ── */
@media(max-width:1200px) { .grid-4 { grid-template-columns: 1fr 1fr; } }
@media(max-width:900px)  { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media(max-width:768px)  {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 1rem; }
}
