:root {
  --bg: #0f1419;
  --surface: #1a2029;
  --surface-2: #232b36;
  --border: #2e3744;
  --text: #e6edf3;
  --muted: #8b98a9;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --green: #22c55e;
  --amber: #f59e0b;
  --red: #ef4444;
  --gray: #64748b;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 0.9rem; }

/* LOGIN */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-card h1 { font-size: 1.5rem; }
.login-card input {
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem;
}

/* TOPBAR */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; }

/* STATS */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  padding: 1.25rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}
.stat-card .n { font-size: 1.6rem; font-weight: 700; }
.stat-card .l { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

/* TOOLBAR */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  padding: 0 1.25rem 1rem;
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}
.filters select, .filters input {
  padding: 0.6rem 0.75rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.9rem;
}

/* BUTTONS */
button { cursor: pointer; font-size: 0.9rem; border: none; border-radius: 9px; }
.btn-primary { background: var(--primary); color: #fff; padding: 0.7rem 1.1rem; font-weight: 600; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-ghost { background: var(--surface-2); color: var(--text); padding: 0.6rem 0.9rem; border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--border); }
.btn-sm { padding: 0.4rem 0.7rem; font-size: 0.82rem; }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }

/* LIST */
.list-wrap { padding: 0 1.25rem 2rem; }
.lic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}
.lic-key {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.lic-meta { display: flex; flex-direction: column; gap: 0.15rem; flex: 1 1 200px; }
.lic-sub { color: var(--muted); font-size: 0.82rem; }
.lic-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge.inactive { background: rgba(100,116,139,0.2); color: var(--gray); }
.badge.expired { background: rgba(245,158,11,0.15); color: var(--amber); }
.badge.revoked { background: rgba(239,68,68,0.15); color: var(--red); }
.badge.lifetime { background: rgba(59,130,246,0.15); color: var(--primary); }

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card h2 { margin-bottom: 1rem; }
.modal-card label { display: block; margin: 0.8rem 0 0.3rem; font-size: 0.85rem; color: var(--muted); }
.modal-card input:not([type=radio]):not([type=checkbox]), .modal-card select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.95rem;
}
.radio-row { display: flex; gap: 1.2rem; }
.radio-row label { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; color: var(--text); }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.4rem; }

.error {
  background: rgba(239,68,68,0.12);
  color: var(--red);
  padding: 0.6rem 0.8rem;
  border-radius: 8px;
  font-size: 0.85rem;
  margin-top: 0.8rem;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.8rem 1.3rem;
  border-radius: 10px;
  z-index: 100;
  font-size: 0.9rem;
}
.toast.ok { border-color: var(--green); }
.toast.err { border-color: var(--red); }

@media (max-width: 600px) {
  .filters { margin-left: 0; width: 100%; }
  .filters select, .filters input { flex: 1 1 auto; }
  .lic-actions { width: 100%; }
}
