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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  background: #f5f6fa;
  color: #1a1a2e;
}

/* ── Login ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 360px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.logo-icon { font-size: 36px; }
.login-logo h1 { font-size: 22px; font-weight: 700; margin-top: 4px; }
.login-logo p  { font-size: 13px; color: #888; margin-top: 2px; }

/* ── Navbar ── */
.navbar {
  display: flex;
  align-items: center;
  background: #1a1a2e;
  color: #fff;
  padding: 0 24px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.nav-brand { font-weight: 700; font-size: 16px; margin-right: 32px; }
.nav-links  { display: flex; gap: 4px; flex: 1; }
.nav-link   { padding: 6px 14px; border-radius: 8px; cursor: pointer; color: #aaa; font-size: 13px; }
.nav-link.active { background: rgba(255,255,255,.1); color: #fff; }
.nav-right  { display: flex; align-items: center; gap: 12px; }
.nav-user   { font-size: 13px; color: #bbb; }

/* ── Main ── */
.main-content { max-width: 1400px; margin: 0 auto; padding: 28px 24px; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }

.search-bar { margin-bottom: 16px; }
.search-bar input {
  width: 340px;
  padding: 9px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
}
.search-bar input:focus { border-color: #0ea5e9; }

/* ── Table ── */
.table-wrap {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  overflow-x: auto;
}

table { width: 100%; border-collapse: collapse; }
thead tr { background: #f8fafc; border-bottom: 2px solid #e8ecf0; }
th {
  text-align: left;
  padding: 12px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}
td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  font-size: 13px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

.id-cell {
  font-family: monospace;
  font-size: 11px;
  color: #64748b;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-cell {
  font-family: monospace;
  font-size: 12px;
  color: #334155;
  letter-spacing: .5px;
}

.loading-row { text-align: center; color: #999; padding: 32px !important; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.badge-active   { background: #dcfce7; color: #166534; }
.badge-expired  { background: #fee2e2; color: #991b1b; }
.badge-enabled  { background: #22c55e; color: #fff; }
.badge-disabled { background: #ef4444; color: #fff; }

/* ── Buttons ── */
.btn-primary {
  background: #0ea5e9;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-primary:hover:not(:disabled) { background: #0284c7; }
.btn-primary:disabled { opacity: .6; cursor: default; }

.btn-outline {
  background: transparent;
  color: #334155;
  border: 1px solid #cbd5e1;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .2s;
}
.btn-outline:hover { background: #f1f5f9; }

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; margin-top: 8px; padding: 11px; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: #64748b;
  padding: 5px;
  border-radius: 6px;
  font-size: 15px;
  transition: background .15s, color .15s;
}
.btn-icon:hover { background: #f1f5f9; color: #0ea5e9; }
.btn-icon.danger:hover { background: #fee2e2; color: #dc2626; }

.actions-cell { display: flex; gap: 4px; align-items: center; }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; font-weight: 600; color: #475569; }
.field input,
.field select {
  padding: 9px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color .2s;
}
.field input:focus,
.field select:focus { border-color: #0ea5e9; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.field-spacer { display: block; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }

.modal-box {
  background: #fff;
  border-radius: 16px;
  padding: 28px;
  width: 540px;
  max-width: 95vw;
  box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal-sm { width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background .15s;
}
.modal-close:hover { background: #f1f5f9; color: #334155; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
}

/* ── Key box ── */
.key-box {
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  padding: 14px;
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 2px;
  color: #0f172a;
}

/* ── Misc ── */
.error-msg {
  background: #fee2e2;
  color: #991b1b;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.hidden { display: none !important; }

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .search-bar input { width: 100%; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
}
