* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: #f8fafc;
  color: #0f172a;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: #64748b; font-size: 14px; }
.error { color: #dc2626; font-size: 13px; margin: 4px 0 0; }

/* Auth screen */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a, #1e1b4b, #0f172a);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.4);
  text-align: center;
}
.auth-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  margin: 0 auto 12px;
}
.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-card form { margin-top: 20px; text-align: left; }

input, select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 12px;
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
}
label { font-size: 13px; font-weight: 500; color: #334155; display: block; margin-bottom: 4px; }
.hint { font-weight: 400; color: #94a3b8; }

.btn {
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,0.25);
}
.btn-primary:hover { opacity: 0.92; }
.btn-ghost {
  background: transparent;
  border: 1px solid #cbd5e1;
  color: #334155;
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* Dashboard shell */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(90deg, #0f172a, #1e1b4b);
  color: #fff;
}
.brand { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.brand-logo { font-size: 18px; }
.topbar .btn-ghost { color: #fff; border-color: rgba(255,255,255,0.3); }
.topbar .btn-ghost:hover { background: rgba(255,255,255,0.1); }

.content { max-width: 1100px; margin: 0 auto; padding: 24px; }

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat-tile {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.stat-tile .stat-label { font-size: 12px; color: #64748b; margin: 0 0 4px; }
.stat-tile .stat-value { font-size: 22px; font-weight: 700; margin: 0; }

.panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.03);
  overflow: hidden;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
}
.panel-header h2 { margin: 0; font-size: 16px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: #f8fafc; }
th { text-align: left; padding: 10px 20px; font-weight: 500; color: #64748b; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
td { padding: 12px 20px; border-top: 1px solid #f1f5f9; vertical-align: middle; }
tr:hover td { background: #f8fafc; }
.lab-name { font-weight: 600; color: #0f172a; }
.lab-id { font-size: 12px; color: #94a3b8; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}
.pill-active { background: #ecfdf5; color: #047857; }
.pill-expired { background: #fef2f2; color: #b91c1c; }
.pill-cancelled { background: #f1f5f9; color: #475569; }

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

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  background: #fff;
  border-radius: 14px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal h2 { margin: 0 0 4px; font-size: 18px; }
.modal-wide { max-width: 720px; }
.mono { font-family: ui-monospace, "SF Mono", monospace; font-size: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

.key-display {
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: #f1f5f9;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  margin: 12px 0 16px;
  color: #1e1b4b;
}

.empty-state { padding: 40px 20px; text-align: center; color: #94a3b8; }

.danger-panel { margin-top: 20px; border-color: #fecaca; padding: 16px 20px; }
.danger-panel .panel-header { border-bottom: none; padding: 0 0 4px; }
.danger-panel .muted { margin: 0 0 12px; }
.btn-danger {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
