/* RedPhantom License Admin — calm dark, layered surfaces, one controlled crimson accent */

:root {
  color-scheme: dark;
  --bg:            #0d0d10;
  --surface:       #141418;
  --surface-2:     #1a1a1f;
  --surface-3:     #222228;
  --border:        rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text:          #ececf1;
  --text-2:        #a2a2ad;
  --text-3:        #6d6d78;
  --accent:        #e5484d;
  --accent-hover:  #d13f44;
  --accent-soft:   rgba(229, 72, 77, 0.13);
  --accent-text:   #f08084;
  --green:         #3fba6f;
  --green-text:    #5fce8e;
  --green-soft:    rgba(63, 186, 111, 0.12);
  --amber-text:    #e8b44f;
  --zinc-soft:     rgba(255, 255, 255, 0.06);
  --ring:          rgba(255, 255, 255, 0.10);
  --radius:        9px;
  --radius-lg:     14px;
  --font:          "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono:          ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --ease:          160ms cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 var(--font);
  font-feature-settings: "cv11", "ss01";
}

::selection { background: rgba(229, 72, 77, 0.30); }

/* Thin, unobtrusive scrollbars */
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.14) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }

.hidden { display: none !important; }
.muted { color: var(--text-3); }
.small-text { font-size: 12px; font-weight: 400; letter-spacing: 0; }
code {
  font-family: var(--mono); font-size: 12px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; color: var(--text-2);
}

/* ── Brand ─────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 11px; }
.brand h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.02em; }
.brand h1 span { color: var(--text-3); font-weight: 400; }
.brand.small h1 { font-size: 14px; }
.brand-mark {
  width: 11px; height: 11px; border-radius: 4px;
  background: var(--accent);
  box-shadow: 0 0 14px rgba(229, 72, 77, 0.40);
  flex: none;
}

/* ── Login ─────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 520px 340px at 50% 30%, rgba(229, 72, 77, 0.055), transparent 70%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 36px 32px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
  animation: rise 300ms var(--ease);
}
.login-card .brand { margin-bottom: 20px; }
.login-card p { margin-bottom: 24px; font-size: 13px; color: var(--text-2); line-height: 1.65; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-foot {
  position: absolute; bottom: 22px; left: 0; right: 0;
  text-align: center; font-size: 11.5px; letter-spacing: 0.02em;
}

/* ── Inputs ────────────────────────────────────────── */
input[type="password"], input[type="text"],
input[type="email"], input[type="number"], select {
  width: 100%;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: var(--mono);
  outline: none;
  transition: border-color var(--ease), box-shadow var(--ease), background var(--ease);
}
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: rgba(255,255,255,0.20); }
input:focus, select:focus {
  border-color: rgba(255,255,255,0.28);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 0 0 3px var(--ring);
}
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6' fill='none'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236d6d78' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  font-family: var(--font);
  cursor: pointer;
}
select option { background: var(--surface-2); color: var(--text); }

/* ── Buttons ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  padding: 8px 14px;
  font-size: 13px; font-weight: 500; font-family: var(--font);
  cursor: pointer;
  transition: background var(--ease), color var(--ease),
              border-color var(--ease), opacity var(--ease), transform var(--ease);
  white-space: nowrap;
}
.btn:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.btn-primary {
  background: var(--text); color: #0d0d10; font-weight: 600;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.btn-primary:hover { background: #ffffff; color: #0d0d10; }

.btn-secondary {
  background: var(--surface-2); border-color: var(--border-strong); color: var(--text);
}
.btn-secondary:hover { background: var(--surface-3); border-color: rgba(255,255,255,0.20); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: rgba(255,255,255,0.06); color: var(--text); }

.btn-danger { color: var(--accent-text); }
.btn-danger:hover { background: var(--accent-soft); color: #fca5a5; }

.btn-destructive {
  background: var(--accent); color: #fff; font-weight: 600;
}
.btn-destructive:hover { background: var(--accent-hover); color: #fff; }

.btn-block { width: 100%; padding: 11px; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 7px; }

.error-text {
  color: var(--accent-text); font-size: 12.5px; margin-top: 14px;
  display: flex; align-items: center; gap: 7px;
}
.error-text::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); flex: none;
}

/* ── Shell: sidebar + main ─────────────────────────── */
.dash { display: flex; min-height: 100vh; }

.sidebar {
  width: 236px; flex: none;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
  padding: 22px 14px 16px;
  background: rgba(255, 255, 255, 0.015);
  border-right: 1px solid var(--border);
}
.sidebar .brand { padding: 0 10px; margin-bottom: 30px; }

.tabs { display: flex; flex-direction: column; gap: 3px; }
.tab {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; color: var(--text-3);
  padding: 9px 12px; font-size: 13.5px; font-weight: 500; font-family: var(--font);
  cursor: pointer; border-radius: var(--radius);
  transition: background var(--ease), color var(--ease);
  position: relative;
  text-align: left; width: 100%;
}
.tab svg { width: 16px; height: 16px; flex: none; }
.tab:hover { color: var(--text-2); background: rgba(255,255,255,0.04); }
.tab.active {
  color: var(--text);
  background: rgba(255,255,255,0.07);
}
.tab.active::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(229, 72, 77, 0.55);
}
.tab:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ring); }

.sidebar-foot {
  margin-top: auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
}
.sidebar-foot .btn { justify-content: flex-start; width: 100%; }
.sidebar-foot .btn svg { width: 15px; height: 15px; flex: none; }
.sidebar-foot .small-text { padding-left: 4px; font-size: 11px; }

.main {
  flex: 1; min-width: 0;
  padding: 34px 36px 60px;
  max-width: 1240px;
}

.page-head { margin-bottom: 26px; }
.page-head h1 {
  font-size: 21px; font-weight: 650; letter-spacing: -0.025em;
}
.page-head p { margin-top: 5px; font-size: 13px; color: var(--text-3); max-width: 560px; }

/* ── Banner (persistent errors) ────────────────────── */
.banner {
  margin: 0 0 20px;
  padding: 11px 16px;
  background: var(--accent-soft);
  border: 1px solid rgba(229, 72, 77, 0.30);
  border-radius: 12px;
  color: #f6a9ac;
  font-size: 13px;
  display: flex; align-items: center; gap: 9px;
}
.banner::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); flex: none;
}

/* ── Layout ────────────────────────────────────────── */
.tab-panel { animation: rise 260ms var(--ease); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.panel-head h2 {
  font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em;
  display: flex; align-items: center; gap: 10px;
}
.panel-actions { display: flex; gap: 8px; align-items: center; }
.panel-actions input { width: 200px; }

.count-pill {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 11px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  border-radius: 999px;
  padding: 2px 9px;
}

/* ── Stats grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: border-color var(--ease), background var(--ease);
}
.stat-card:hover { border-color: var(--border-strong); background: #16161a; }
.stat-card .stat-label {
  font-size: 11px; font-weight: 500; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.stat-card .stat-value {
  font-size: 28px; font-weight: 600; letter-spacing: -0.03em;
  margin-top: 8px; font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-card .stat-value.accent { color: var(--accent-text); }
.stat-card .stat-value.green { color: var(--green-text); }

/* ── Tables ────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left;
  font-size: 11px; font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface);
}
td {
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
}
tbody tr { transition: background var(--ease); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, 0.025); }
td .strong, td.strong { color: var(--text); font-weight: 500; }

.mono { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

/* Running-now: keep the dot column tight */
#tab-running th:first-child, #tab-running td:first-child {
  width: 36px; padding-right: 0;
}

/* ── Empty states ──────────────────────────────────── */
.empty-state {
  padding: 64px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.empty-state .empty-icon {
  width: 40px; height: 40px;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  background: rgba(255,255,255,0.03);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  margin-bottom: 10px;
}
.empty-state .empty-icon svg { width: 16px; height: 16px; }
.empty-state .empty-title { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.empty-state .empty-hint { font-size: 12.5px; color: var(--text-3); max-width: 380px; }

/* ── Skeleton loading ──────────────────────────────── */
.skel {
  display: block;
  height: 13px;
  border-radius: 5px;
  background: rgba(255,255,255,0.05);
  animation: skel-pulse 1.5s ease-in-out infinite;
}
@keyframes skel-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.skel-stat {
  height: 92px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  animation: skel-pulse 1.5s ease-in-out infinite;
}

/* ── Status dot & badges ───────────────────────────── */
.dot {
  display: inline-block;
  width: 7px; height: 7px; border-radius: 50%;
  background: #52525b;
}
.dot.live { background: var(--green); box-shadow: 0 0 8px rgba(63,186,111,0.5); }

.badge {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 500;
  border-radius: 999px;
  padding: 3px 11px 3px 9px;
  letter-spacing: 0.01em;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; flex: none;
}
.badge-active  { background: var(--green-soft); color: var(--green-text); }
.badge-active::before { background: var(--green); }
.badge-revoked { background: var(--accent-soft); color: var(--accent-text); }
.badge-revoked::before { background: var(--accent); }
.badge-expired { background: var(--zinc-soft); color: var(--text-2); }
.badge-expired::before { background: #71717a; }

/* ── Key cell + copy ───────────────────────────────── */
.key-cell { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.copy-btn {
  background: transparent; border: 1px solid transparent;
  color: var(--text-3);
  cursor: pointer; font-size: 11px; font-weight: 500; font-family: var(--font);
  padding: 3px 8px;
  border-radius: 6px;
  transition: background var(--ease), color var(--ease), border-color var(--ease);
}
.copy-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); border-color: var(--border-strong); }
.copy-btn.copied { color: var(--green-text); }

.row-actions { display: flex; gap: 6px; }

.expiring-soon { color: var(--amber-text); }

/* ── Toast notifications ───────────────────────────── */
#toast-root {
  position: fixed; right: 20px; bottom: 20px; z-index: 100;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: rgba(26, 26, 31, 0.92);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 13px; color: var(--text);
  min-width: 240px; max-width: 380px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.45);
  animation: toast-in 200ms var(--ease);
  transition: opacity 200ms ease, transform 200ms ease;
}
.toast::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; flex: none;
  background: var(--text-3);
}
.toast.toast-success::before { background: var(--green); }
.toast.toast-error::before { background: var(--accent); }
.toast.toast-leaving { opacity: 0; transform: translateY(6px); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(0, 0, 0, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: modal-fade 140ms ease;
}
.modal-card {
  width: 100%; max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.55);
  animation: modal-in 180ms var(--ease);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 12px;
}
.modal-head h2 { font-size: 14.5px; font-weight: 600; letter-spacing: -0.015em; }
.modal-body { padding: 6px 22px 22px; display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 12px; font-weight: 500; color: var(--text-2);
}
.field span em { color: var(--accent-text); font-style: normal; }
.field-row { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 10px; }

.modal-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 8px;
}

.key-reveal {
  display: flex; align-items: center; gap: 8px;
  background: rgba(0,0,0,0.30);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 11px 12px;
}
.key-reveal code {
  flex: 1; background: transparent; border: none; padding: 0;
  color: var(--text); font-size: 12.5px;
  word-break: break-all; user-select: all;
}

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 860px) {
  .dash { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap;
    padding: 12px 16px; gap: 10px;
    border-right: none; border-bottom: 1px solid var(--border);
  }
  .sidebar .brand { margin-bottom: 0; padding: 0; }
  .tabs { flex-direction: row; width: 100%; order: 3; }
  .tab { flex: 1; justify-content: center; padding: 7px 10px; font-size: 12.5px; }
  .tab svg { display: none; }
  .tab.active::before { display: none; }
  .sidebar-foot { margin-top: 0; border-top: none; padding: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .sidebar-foot .small-text { display: none; }
  .main { padding: 20px 14px 44px; }
  .panel-actions input { width: 140px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  th, td { padding: 12px 16px; }
  .field-row { grid-template-columns: 1fr; }
}
