/* DPM Licence Manager — admin dashboard styles */

:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #94a3b8;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #e2e8f0;
  --brand: #0d7377;
  --brand-dark: #0a5c5f;
  --brand-soft: #e6f4f4;
  --green: #16a34a;
  --green-soft: #f0fdf4;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

.hidden { display: none !important; }

/* ============ Login ============ */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, #0d7377 0%, #0a3d40 100%);
}

.login-card {
  background: var(--card);
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.login-logo {
  width: 56px; height: 56px;
  margin: 0 auto 16px;
  background: var(--brand-soft);
  color: var(--brand);
  border-radius: 14px;
  font-size: 30px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-sub { color: var(--ink-faint); margin-bottom: 24px; font-size: 13px; }

.login-card input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
}

.login-card input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-error { color: var(--red); margin-top: 12px; font-size: 13px; }

/* ============ Topbar ============ */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 40px; height: 40px;
  background: var(--brand);
  color: #fff;
  border-radius: 10px;
  font-size: 22px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}

.topbar-brand strong { display: block; font-size: 15px; }
.brand-sub { display: block; font-size: 12px; color: var(--ink-faint); }
.topbar-actions { display: flex; gap: 10px; }

/* ============ Buttons ============ */
.btn {
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--line); }
.btn-ghost:hover { background: var(--bg); }
.btn-danger { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }

/* ============ Layout ============ */
.container { max-width: 1240px; margin: 0 auto; padding: 28px; }

/* ============ Stats ============ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}

.stat-value { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.5px; }
.stat-label { display: block; font-size: 12px; color: var(--ink-faint); margin-top: 2px; }

.stat-green .stat-value { color: var(--green); }
.stat-amber .stat-value { color: var(--amber); }
.stat-red .stat-value { color: var(--red); }
.stat-grey .stat-value { color: var(--ink-faint); }
.stat-blue .stat-value { color: var(--blue); }

/* ============ Filters ============ */
.filter-bar { display: flex; gap: 12px; margin-bottom: 16px; }

.filter-bar input[type="search"] {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  background: var(--card);
}

.filter-bar select {
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  background: var(--card);
  cursor: pointer;
}

.filter-bar input:focus, .filter-bar select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* ============ Table ============ */
.table-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lic-table { width: 100%; border-collapse: collapse; }

.lic-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.lic-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.lic-table tbody tr:last-child td { border-bottom: none; }
.lic-table tbody tr { cursor: pointer; transition: background 0.1s; }
.lic-table tbody tr:hover { background: #f8fafc; }

.key-mono {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  background: var(--bg);
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

.empty-cell { text-align: center; color: var(--ink-faint); padding: 40px !important; cursor: default; }

/* ============ Badges ============ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.badge-basic { background: var(--blue-soft); color: var(--blue); }
.badge-advanced { background: #f5f3ff; color: #7c3aed; }
.badge-active { background: var(--green-soft); color: var(--green); }
.badge-expired { background: var(--amber-soft); color: var(--amber); }
.badge-revoked { background: var(--red-soft); color: var(--red); }
.badge-suspended { background: #f1f5f9; color: var(--ink-soft); }

.expiry-warn { color: var(--amber); font-weight: 600; }
.expiry-over { color: var(--red); font-weight: 600; }

/* ============ Modals ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  padding: 20px;
}

.modal {
  background: var(--card);
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}

.modal-sm { width: 440px; }

.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 { font-size: 16px; }

.modal-close {
  background: none; border: none;
  font-size: 22px;
  color: var(--ink-faint);
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
.modal-close:hover { color: var(--ink); }

.modal-body { padding: 22px 24px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ============ Forms ============ */
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.form-row label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--ink-soft);
}

.form-row input, .form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13.5px;
  font-family: inherit;
}

.form-row input:focus, .form-row select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}

/* Tier picker */
.tier-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tier-option input { display: none; }

.tier-box {
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
}

.tier-box strong { display: block; margin-bottom: 4px; }
.tier-box span { font-size: 12px; color: var(--ink-faint); line-height: 1.4; }

.tier-option input:checked + .tier-box {
  border-color: var(--brand);
  background: var(--brand-soft);
}

/* Key created */
.created-note { color: var(--ink-soft); font-size: 13px; margin-bottom: 16px; }

.key-display {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px dashed var(--brand);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 12px;
  letter-spacing: 0.5px;
  user-select: all;
}

.created-meta { text-align: center; font-size: 12.5px; color: var(--ink-faint); margin-bottom: 16px; }

/* ============ Drawer ============ */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 520px;
  max-width: 92vw;
  background: var(--card);
  z-index: 45;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
}

.drawer-head h2 { font-size: 16px; }
.drawer-body { padding: 22px 24px; overflow-y: auto; flex: 1; }

.detail-key {
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 14px;
  background: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 20px;
  margin-bottom: 22px;
}

.detail-item span { display: block; font-size: 11.5px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.detail-item strong { font-size: 13.5px; font-weight: 600; }

.drawer-section { margin-bottom: 24px; }
.drawer-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.action-row { display: flex; flex-wrap: wrap; gap: 8px; }

.renew-row { display: flex; gap: 8px; margin-top: 10px; }
.renew-row select, .renew-row input[type="date"] {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
}

.site-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 13px;
}

.site-item .site-url { font-weight: 600; word-break: break-all; }
.site-item .site-meta { font-size: 11.5px; color: var(--ink-faint); }

.event-item {
  display: flex; gap: 10px;
  padding: 7px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--line);
}
.event-item:last-child { border-bottom: none; }
.event-time { color: var(--ink-faint); white-space: nowrap; font-size: 11.5px; }
.event-action { font-weight: 600; }
.event-detail { color: var(--ink-soft); word-break: break-all; }

/* ============ Toast ============ */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.toast-error { background: var(--red); }

@media (max-width: 900px) {
  .stats-row { grid-template-columns: repeat(3, 1fr); }
  .form-grid, .tier-picker { grid-template-columns: 1fr; }
}

/* ============ Publish update ============ */
.dpm-hint {
  display: block;
  font-size: 12px;
  color: var(--ink-faint);
  line-height: 1.4;
  padding-top: 2px;
}

#p-zip {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--paper, #fff);
  cursor: pointer;
}

#p-zip:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
