/* Same tokens as the main site (styles.css) — different layout entirely (a data-dense app shell,
   not a marketing page), so this isn't shared with it rather than forked from it. */
:root {
  --bg: #17181a;
  --card: #1c1e20;
  --card-solid: #1c1e20;
  --card-raised: #212325;
  --row-hover: #24262a;

  --text: #ffffff;
  --text-dim: #a3a3a3;
  --text-faint: #6b6b6b;

  --blue: #3b82f6;
  --blue-bright: #60a5fa;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --purple: #a855f7;

  --outline: rgba(255, 255, 255, 0.08);
  --outline-bright: rgba(255, 255, 255, 0.16);

  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Poppins', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-md: 0 8px 24px -8px rgba(0,0,0,0.45);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background:
    radial-gradient(900px 500px at 100% -10%, rgba(59,130,246,0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: var(--font); cursor: pointer; }
code { font-family: var(--mono); }
::selection { background: rgba(59,130,246,0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2b2d30; border-radius: 999px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #383b3f; }

/* ------------------------------------------------------------------------------- login gate */
.login-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-gate[hidden], .shell[hidden] { display: none; }

.login-card {
  width: 100%;
  max-width: 380px;
  text-align: center;
  background: linear-gradient(180deg, var(--card-raised), var(--card));
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 44px 36px;
  box-shadow: var(--shadow-md);
  animation: rise 0.5s cubic-bezier(0.22,1,0.36,1) both;
}
.login-icon {
  width: 56px; height: 56px;
  margin: 0 auto 20px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(59,130,246,0.18), rgba(59,130,246,0.05));
  border: 1px solid rgba(59,130,246,0.25);
  color: var(--blue-bright);
}
.login-icon svg { width: 27px; height: 27px; }
.login-card h1 { font-size: 20px; margin: 0 0 8px; letter-spacing: -0.01em; }
.login-card p { font-size: 13px; color: var(--text-dim); line-height: 1.55; margin: 0 0 24px; }
.login-denied { color: var(--red) !important; margin: 14px 0 0 !important; }

.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--blue); color: #fff;
  border: none; border-radius: var(--radius-sm);
  padding: 11px 22px;
  font-size: 13.5px; font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.12) inset, 0 4px 14px -4px rgba(59,130,246,0.5);
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { background: var(--blue-bright); box-shadow: 0 1px 0 rgba(255,255,255,0.16) inset, 0 6px 18px -4px rgba(59,130,246,0.6); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: default; box-shadow: none; }

.btn-ghost {
  background: var(--card-raised); color: var(--text);
  border: 1px solid var(--outline); border-radius: var(--radius-sm);
  padding: 9px 16px; font-size: 13px;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-ghost:hover { background: var(--row-hover); border-color: var(--outline-bright); }

/* ------------------------------------------------------------------------------- app shell */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--card-raised) 0%, var(--bg) 340px);
  border-right: 1px solid var(--outline);
  display: flex; flex-direction: column;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  padding: 0 10px 26px;
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--blue-bright); box-shadow: 0 0 10px var(--blue-bright); }
.accent { color: var(--blue-bright); }

.sidebar-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: none; border: none; border-left: 2px solid transparent; color: var(--text-dim);
  font-size: 13.5px; text-align: left;
  padding: 9px 12px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  position: relative;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; transition: transform 0.15s ease; }
.nav-item:hover { background: var(--row-hover); color: var(--text); }
.nav-item.is-active {
  background: rgba(59,130,246,0.12); color: var(--blue-bright);
  border-left-color: var(--blue-bright); font-weight: 500;
}
.nav-badge {
  margin-left: auto;
  background: var(--green); color: #05170a;
  font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(34,197,94,0.15);
}
.nav-item.is-active .nav-badge { background: var(--blue-bright); color: #05121f; }

.sidebar-foot {
  display: flex; align-items: center; gap: 9px;
  padding-top: 14px; border-top: 1px solid var(--outline); margin-top: 10px;
  font-size: 12px; color: var(--text-dim);
}
.me-avatar { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; border: 1px solid var(--outline-bright); }
.sidebar-foot span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-btn {
  background: none; border: none; color: var(--text-faint);
  padding: 5px; border-radius: 6px; display: flex;
  transition: color 0.15s ease, background 0.15s ease;
}
.logout-btn:hover { color: var(--red); background: var(--row-hover); }
.logout-btn svg { width: 15px; height: 15px; }

.content { flex: 1; padding: 34px 40px 70px; max-width: 1180px; }

.panel { display: none; animation: rise 0.35s cubic-bezier(0.22,1,0.36,1) both; }
.panel.is-active { display: block; }

.panel-head { margin-bottom: 26px; }
.panel-head h2 { font-size: 22px; margin: 0 0 5px; letter-spacing: -0.015em; }
.panel-head p { font-size: 13px; color: var(--text-dim); margin: 0; }
.panel-head code { background: var(--card-raised); padding: 1px 6px; border-radius: 5px; font-size: 12px; border: 1px solid var(--outline); }

/* ------------------------------------------------------------------------------- stat tiles */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 20px;
}
.stat-tile {
  background: var(--card); border: 1px solid var(--outline); border-radius: var(--radius);
  padding: 18px 20px;
  display: flex; align-items: center; gap: 14px;
  animation: rise 0.4s cubic-bezier(0.22,1,0.36,1) both;
  animation-delay: calc(var(--i, 0) * 0.05s);
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
  position: relative; overflow: hidden;
}
.stat-tile::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: var(--tile-accent, var(--blue-bright)); opacity: 0.7;
}
.stat-tile[data-accent="blue"] { --tile-accent: var(--blue-bright); }
.stat-tile[data-accent="green"] { --tile-accent: var(--green); }
.stat-tile[data-accent="purple"] { --tile-accent: var(--purple); }
.stat-tile[data-accent="live"] { --tile-accent: var(--red); }
.stat-tile:hover { border-color: var(--outline-bright); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.stat-icon {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--tile-accent, var(--blue-bright)) 14%, transparent);
  color: var(--tile-accent, var(--blue-bright));
}
.stat-icon svg { width: 18px; height: 18px; }
.stat-label { display: block; font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 3px; }
.stat-value { display: block; font-size: 24px; font-weight: 700; font-family: var(--mono); letter-spacing: -0.02em; }

/* ------------------------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--outline); border-radius: var(--radius);
  padding: 22px 24px; margin-bottom: 16px;
  animation: rise 0.4s cubic-bezier(0.22,1,0.36,1) both;
}
.card-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.card-head h3 { font-size: 14px; margin: 0; font-weight: 600; }
.card-sub { font-size: 11.5px; color: var(--text-faint); margin: 2px 0 0; }
.legend { display: flex; gap: 14px; font-size: 11px; color: var(--text-faint); flex-wrap: wrap; padding-top: 2px; }
.legend-wrap { margin-bottom: 14px; }
.legend span { display: inline-flex; align-items: center; }
.legend-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }

.chart-row { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.chart-card-wide {}
@media (max-width: 980px) { .chart-row { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------------------- charts (hand-rolled SVG) */
.chart-card { padding-bottom: 10px; }
.chart { width: 100%; height: 170px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: var(--outline); stroke-width: 1; }
.chart-bar {
  transition: opacity 0.15s ease;
  transform-box: fill-box; transform-origin: bottom;
  animation: growUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: calc(var(--i, 0) * 0.03s);
  cursor: pointer;
}
.chart-bar:hover { opacity: 0.75; }
@keyframes growUp { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart-axis-label { opacity: 0; animation: rise 0.3s ease both; animation-delay: calc(var(--i, 0) * 0.03s + 0.2s); }

.chart-line { height: 190px; }
.chart-line-path {
  fill: none; stroke: var(--blue-bright); stroke-width: 2.25; stroke-linecap: round; stroke-linejoin: round;
  filter: drop-shadow(0 2px 6px rgba(59,130,246,0.35));
  stroke-dasharray: var(--len); stroke-dashoffset: var(--len);
  animation: drawLine 1.1s cubic-bezier(0.22,1,0.36,1) forwards;
}
@keyframes drawLine { to { stroke-dashoffset: 0; } }
.chart-line-fill { opacity: 0; animation: fadeIn 0.6s ease 0.5s forwards; }
@keyframes fadeIn { to { opacity: 1; } }
.chart-point {
  fill: var(--bg); stroke: var(--blue-bright); stroke-width: 2; r: 0;
  animation: popIn 0.3s cubic-bezier(0.22,1,0.36,1) forwards;
  animation-delay: calc(var(--i, 0) * 0.05s + 0.4s);
  cursor: pointer;
}
@keyframes popIn { to { r: 3.5; } }
.chart-point:hover { r: 5 !important; }

.chart-empty { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-faint); font-size: 12.5px; }
.chart-tooltip {
  position: fixed; pointer-events: none;
  background: var(--card-raised); border: 1px solid var(--outline-bright);
  border-radius: 7px; padding: 6px 10px; font-size: 11.5px; font-family: var(--mono);
  box-shadow: var(--shadow-md);
  transform: translate(-50%, -135%); white-space: nowrap; opacity: 0; transition: opacity 0.1s ease;
  z-index: 50;
}

/* ------------------------------------------------------------------------------- sessions toolbar */
.session-toolbar { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.search-input {
  flex: 1; max-width: 380px;
  background: var(--card); border: 1px solid var(--outline); color: var(--text);
  border-radius: var(--radius-sm); padding: 10px 14px; font-family: var(--font); font-size: 13px;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.search-input:focus { outline: none; border-color: var(--blue); background: var(--card-raised); }
.search-input::placeholder { color: var(--text-faint); }
.check-field { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-dim); user-select: none; }
.check-field input { accent-color: var(--blue); width: 14px; height: 14px; }

.skin-head {
  width: 26px; height: 26px; border-radius: 7px; image-rendering: pixelated;
  background: var(--card-raised); border: 1px solid var(--outline); flex-shrink: 0; vertical-align: middle;
}
.session-user { display: flex; align-items: center; gap: 10px; font-weight: 500; }

.country-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--card-raised); border: 1px solid var(--outline);
  padding: 3px 9px 3px 6px; border-radius: 999px; font-size: 12px;
}
.country-pill .flag { font-size: 13px; }

.expand-btn {
  background: none; border: none; color: var(--text-faint);
  width: 24px; height: 24px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; transition: background 0.15s ease, transform 0.2s ease, color 0.15s ease;
}
.expand-btn:hover { background: var(--row-hover); color: var(--text); }
.expand-btn svg { width: 13px; height: 13px; }
.session-row.is-open .expand-btn { transform: rotate(90deg); color: var(--blue-bright); }
.session-row.is-open td { background: var(--row-hover); }

.detail-row td { padding: 0; border-bottom: 1px solid var(--outline); }
.detail-row { display: none; }
.detail-row.is-open { display: table-row; }
.detail-inner {
  padding: 16px 18px; background: var(--card-raised);
  display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start;
  animation: rise 0.2s ease both;
  border-left: 2px solid var(--blue);
}
.detail-field { font-size: 12px; }
.detail-field span { display: block; color: var(--text-faint); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.detail-field code { font-size: 12px; background: var(--card); padding: 2px 6px; border-radius: 5px; border: 1px solid var(--outline); }

.term-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.term-badge {
  font-size: 11px; font-weight: 600; color: var(--red);
  background: rgba(239,68,68,0.12); padding: 3px 9px; border-radius: 999px;
  border: 1px solid rgba(239,68,68,0.25);
}
.btn-danger {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171;
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 12px; font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-danger:hover { background: rgba(239,68,68,0.2); border-color: rgba(239,68,68,0.45); }
.btn-sm { padding: 7px 13px; font-size: 12px; }

.term-reason-row { display: none; align-items: center; gap: 8px; margin-top: 12px; width: 100%; }
.term-reason-row.is-open { display: flex; animation: rise 0.2s ease both; }
.term-reason-row input {
  flex: 1; background: var(--card); border: 1px solid var(--outline); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 12.5px; font-family: var(--font);
}
.term-reason-row input:focus { outline: none; border-color: var(--outline-bright); }

/* ------------------------------------------------------------------------------- tables */
.table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.table th {
  text-align: left; color: var(--text-faint); font-weight: 500;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0 12px 12px; border-bottom: 1px solid var(--outline);
}
.table td { padding: 12px; border-bottom: 1px solid var(--outline); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:not(.detail-row) {
  transition: background 0.15s ease;
  animation: rise 0.3s ease both; animation-delay: calc(var(--i, 0) * 0.035s);
}
.table tbody tr:not(.detail-row):hover td { background: var(--row-hover); }
.table .mono { font-family: var(--mono); font-size: 12px; color: var(--text-dim); }
.table .dim { color: var(--text-faint); }
.session-row.is-stale-row { opacity: 0.72; }
.session-row.is-stale-row:hover { opacity: 1; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.dot.is-live { background: var(--green); box-shadow: 0 0 7px var(--green); animation: pulse 2s ease-in-out infinite; }
.dot.is-stale { background: var(--text-faint); }

.empty-state { color: var(--text-faint); font-size: 13px; text-align: center; padding: 32px 0; }
.empty-state svg { width: 28px; height: 28px; margin-bottom: 10px; opacity: 0.4; display: block; margin-inline: auto; }

/* ------------------------------------------------------------------------------- log feed */
.log-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-chip {
  background: var(--card); border: 1px solid var(--outline); color: var(--text-dim);
  font-size: 12px; padding: 7px 14px; border-radius: 999px;
  transition: all 0.15s ease;
}
.filter-chip:hover { border-color: var(--outline-bright); color: var(--text); }
.filter-chip.is-active { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 3px 10px -3px rgba(59,130,246,0.6); }

.log-day-header {
  font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.06em;
  margin: 22px 0 10px; padding-left: 2px;
}
.log-day-header:first-child { margin-top: 0; }

.log-feed { display: flex; flex-direction: column; gap: 8px; }
.log-row {
  display: flex; align-items: flex-start; gap: 13px;
  background: var(--card); border: 1px solid var(--outline); border-radius: var(--radius-sm);
  padding: 13px 15px;
  animation: slideIn 0.3s ease both;
  animation-delay: calc(var(--i, 0) * 0.03s);
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.log-row:hover { border-color: var(--outline-bright); transform: translateX(2px); }
.log-badge {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.log-badge.type-auth { background: rgba(239,68,68,0.14); }
.log-badge.type-hwid { background: rgba(59,130,246,0.14); }
.log-badge.type-sellauth { background: rgba(168,85,247,0.14); }
.log-badge.type-redeem { background: rgba(234,179,8,0.14); }
.log-badge.type-proxy { background: rgba(34,197,94,0.14); }
.log-badge.type-cloudflare { background: rgba(239,68,68,0.14); }
.log-badge.type-license { background: rgba(96,165,250,0.14); }

.log-body { flex: 1; min-width: 0; }
.log-summary { font-size: 13px; line-height: 1.4; }
.log-summary .ok { color: var(--green); }
.log-summary .fail { color: var(--red); }
.log-meta { font-size: 11px; color: var(--text-faint); margin-top: 4px; font-family: var(--mono); }
.log-time { font-size: 11px; color: var(--text-faint); flex-shrink: 0; white-space: nowrap; padding-top: 2px; }

.load-more { display: block; margin: 14px auto 0; }

/* ------------------------------------------------------------------------------- create license */
.create-card { max-width: 440px; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 7px; font-weight: 500; }
.field input, .field select {
  width: 100%; background: var(--card-raised); border: 1px solid var(--outline);
  border-radius: var(--radius-sm); padding: 11px 13px; color: var(--text);
  font-family: var(--font); font-size: 13.5px;
  transition: border-color 0.15s ease;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--blue); }
.field input::placeholder { color: var(--text-faint); }
.create-result {
  margin-top: 18px; padding: 15px; border-radius: var(--radius-sm);
  background: rgba(34,197,94,0.08); border: 1px solid rgba(34,197,94,0.25);
  font-size: 12.5px; animation: rise 0.3s ease both;
}
.create-result.is-error { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.25); }
.create-result code {
  display: block; margin-top: 8px; background: var(--card-raised);
  padding: 9px 11px; border-radius: 7px; font-size: 12.5px; word-break: break-all;
  border: 1px solid var(--outline);
}

/* ------------------------------------------------------------------------------- toast */
.toast {
  position: fixed; bottom: 22px; left: 50%;
  background: var(--card-raised); border: 1px solid var(--outline-bright);
  color: var(--text); padding: 12px 22px; border-radius: var(--radius-sm);
  font-size: 13px; opacity: 0; pointer-events: none;
  box-shadow: var(--shadow-md);
  transform: translateX(-50%) translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ------------------------------------------------------------------------------- animations */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: translateX(0); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.45; } }

/* ------------------------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 12px 16px; gap: 16px; background: var(--card-raised); }
  .sidebar-brand { padding: 0; }
  .sidebar-nav { flex-direction: row; flex: 1; overflow-x: auto; }
  .nav-item { border-left: none; border-bottom: 2px solid transparent; border-radius: var(--radius-sm); }
  .nav-item.is-active { border-left-color: transparent; border-bottom-color: var(--blue-bright); }
  .nav-item span, .nav-item { white-space: nowrap; }
  .sidebar-foot { display: none; }
  .content { padding: 20px 16px 40px; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
}
