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

:root {
  --accent:       #6366f1;
  --accent-dark:  #4f46e5;
  --accent-light: #eef2ff;
  --danger:       #ef4444;
  --danger-light: #fef2f2;
  --success:      #22c55e;
  --success-light:#f0fdf4;
  --gray-50:      #f9fafb;
  --gray-100:     #f3f4f6;
  --gray-200:     #e5e7eb;
  --gray-400:     #9ca3af;
  --gray-600:     #4b5563;
  --gray-700:     #374151;
  --gray-900:     #111827;
  --radius:       10px;
  --shadow:       0 4px 24px rgba(0,0,0,.08);
  --shadow-sm:    0 1px 4px  rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
nav .logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: .5rem;
}
nav .logo svg { width: 22px; height: 22px; }
nav .nav-right { display: flex; align-items: center; gap: 1rem; }
nav .user-name { font-size: .875rem; color: var(--gray-600); }

/* ── AUTH PAGES ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: linear-gradient(135deg, var(--accent-light) 0%, #f8fafc 60%);
}
.auth-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
}
.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .25rem;
}
.auth-card .subtitle {
  color: var(--gray-600);
  font-size: .9rem;
  margin-bottom: 1.75rem;
}
.auth-card .switch-link {
  margin-top: 1.25rem;
  text-align: center;
  font-size: .875rem;
  color: var(--gray-600);
}
.auth-card .switch-link a { color: var(--accent); text-decoration: none; font-weight: 500; }

/* ── DASHBOARD LAYOUT ── */
.page { max-width: 900px; margin: 2rem auto; padding: 0 1.25rem; }
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}
.page-header h2 { font-size: 1.4rem; font-weight: 700; }
.page-header p  { color: var(--gray-600); font-size: .875rem; margin-top: .2rem; }

/* ── CARD ── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

/* ── FORM ── */
.form-group { margin-bottom: 1.1rem; }
label {
  display: block;
  font-size: .825rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
}
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%;
  padding: .6rem .85rem;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  font-size: .95rem;
  color: var(--gray-900);
  background: #fff;
  transition: border .15s, box-shadow .15s;
  outline: none;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border-radius: 7px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-ghost   { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-200); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-danger  { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-full    { width: 100%; justify-content: center; padding: .7rem; }
.btn-sm      { padding: .35rem .75rem; font-size: .8rem; }

/* ── INLINE CREATE-KEY FORM ── */
.create-key-form {
  display: flex;
  gap: .75rem;
  align-items: flex-end;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
  flex-wrap: wrap;
}
.create-key-form .form-group { margin: 0; flex: 1; min-width: 180px; }

/* ── KEYS TABLE ── */
.keys-table { width: 100%; border-collapse: collapse; }
.keys-table th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--gray-400);
  padding: .75rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}
.keys-table td {
  padding: .9rem 1.5rem;
  font-size: .875rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.keys-table tr:last-child td { border-bottom: none; }
.keys-table tr:hover td { background: var(--gray-50); }

.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-active  { background: var(--success-light); color: #16a34a; }
.badge-revoked { background: var(--gray-100);       color: var(--gray-400); }

.key-prefix {
  font-family: "Courier New", monospace;
  background: var(--gray-100);
  padding: .15rem .45rem;
  border-radius: 5px;
  font-size: .825rem;
  color: var(--gray-700);
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}
.empty-state svg { width: 40px; height: 40px; margin-bottom: .75rem; opacity: .4; }
.empty-state p   { font-size: .9rem; }

/* ── ALERT ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 1.1rem;
}
.alert-error   { background: var(--danger-light);  color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: var(--success-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert svg { flex-shrink: 0; width: 16px; height: 16px; margin-top: .1rem; }

/* ── MODAL ── */
.modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 500px;
  padding: 2rem;
}
.modal h3  { font-size: 1.15rem; font-weight: 700; margin-bottom: .5rem; }
.modal p   { font-size: .875rem; color: var(--gray-600); margin-bottom: 1.25rem; }
.key-display {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: .75rem 1rem;
  margin-bottom: 1rem;
  overflow: hidden;
}
.key-display code {
  flex: 1;
  font-family: "Courier New", monospace;
  font-size: .85rem;
  word-break: break-all;
  color: var(--accent-dark);
}
.copy-btn {
  flex-shrink: 0;
  background: var(--accent-light);
  border: none;
  border-radius: 6px;
  padding: .35rem .6rem;
  cursor: pointer;
  color: var(--accent);
  font-size: .75rem;
  font-weight: 600;
  transition: background .15s;
}
.copy-btn:hover { background: #e0e7ff; }
.modal-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 7px;
  padding: .7rem .9rem;
  font-size: .8rem;
  color: #92400e;
  margin-bottom: 1.25rem;
  display: flex;
  gap: .5rem;
}
.modal-footer { display: flex; justify-content: flex-end; }

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

/* ── RESPONSIVE ── */
@media (max-width: 600px) {
  .keys-table th:nth-child(3),
  .keys-table td:nth-child(3),
  .keys-table th:nth-child(4),
  .keys-table td:nth-child(4) { display: none; }
}
