:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff6ff;
  --primary-border: #bfdbfe;
  --bg: #f1f5f9;
  --card: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --warning: #b45309;
  --warning-soft: #fffbeb;
  --dark: #334155;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ---- Top bar ---- */
.topbar {
  background: var(--primary);
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.topbar .brand svg { width: 22px; height: 22px; }
.topbar .spacer { flex: 1; }
.topbar .top-link {
  color: #e0ecff;
  text-decoration: none;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar .top-link:hover { color: #fff; }
.topbar form { display: inline; }
.topbar .logout-btn {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  font: inherit;
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
}
.topbar .logout-btn:hover { background: rgba(255,255,255,0.28); }

/* ---- Layout ---- */
.container { max-width: 1040px; margin: 0 auto; padding: 28px 24px; }
.container-narrow { max-width: 620px; }

.center-wrap {
  min-height: calc(100vh - 56px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px;
}
.auth-card { width: 100%; max-width: 400px; box-shadow: 0 10px 30px rgba(15,23,42,0.08); }
.auth-card h1 { font-size: 20px; margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.auth-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 18px;
}
.auth-icon svg { width: 26px; height: 26px; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="url"], input[type="number"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
}
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.otp-input { text-align: center; font-size: 26px; letter-spacing: 10px; font-weight: 700; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 18px; border-radius: 8px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; line-height: 1;
}
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--dark); color: #fff; }
.btn-secondary:hover { background: #475569; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f8fafc; }
.btn-danger { background: transparent; color: var(--danger); border-color: #fecaca; padding: 7px 12px; font-size: 13px; }
.btn-danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; margin-top: 8px; }

/* ---- Alerts ---- */
.alert { padding: 12px 14px; border-radius: 8px; font-size: 14px; margin-bottom: 18px; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid #bbf7d0; }
.alert-info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid var(--primary-border); }
.alert-warn { background: var(--warning-soft); color: var(--warning); border: 1px solid #fde68a; }

.linkish { background: none; border: none; color: var(--primary); font: inherit; font-size: 13px; cursor: pointer; padding: 0; text-decoration: underline; }
.muted { color: var(--muted); }

/* ---- Admin toolbar + table ---- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }

.table-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; font-size: 14px; }
table.list th { background: #f8fafc; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); font-weight: 700; }
table.list tr:last-child td { border-bottom: none; }
table.list tr:hover td { background: #fafbfc; }
.uid-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; background: var(--primary-soft); color: var(--primary-dark); padding: 3px 8px; border-radius: 6px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-win { background: var(--primary-soft); color: var(--primary-dark); }
.pill-expired { background: var(--danger-soft); color: var(--danger); }
.pill-ok { background: var(--success-soft); color: var(--success); }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.link-cell a { color: var(--primary); text-decoration: none; word-break: break-all; }
.link-cell a:hover { text-decoration: underline; }

/* ---- Portal hero ---- */
.hero-card { text-align: center; padding: 40px 32px; }
.hero-badge { width: 64px; height: 64px; border-radius: 16px; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 18px; }
.hero-badge svg { width: 34px; height: 34px; }
.hero-card h1 { font-size: 22px; margin-bottom: 8px; }
.hero-card p { color: var(--muted); font-size: 15px; margin-bottom: 24px; max-width: 460px; margin-left: auto; margin-right: auto; }

/* ---- Modal ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,0.5); display: none; align-items: flex-start; justify-content: center; padding: 40px 16px; z-index: 50; overflow-y: auto; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; overflow: hidden; box-shadow: 0 20px 60px rgba(15,23,42,0.3); }
.modal-head { background: var(--dark); color: #fff; padding: 16px 22px; display: flex; align-items: center; justify-content: space-between; }
.modal-head h2 { font-size: 16px; font-weight: 600; }
.modal-close { background: none; border: none; color: #cbd5e1; font-size: 22px; line-height: 1; cursor: pointer; }
.modal-close:hover { color: #fff; }

/* ---- Stepper (FortiClient-style) ---- */
.stepper { display: flex; border-bottom: 1px solid var(--border); }
.step { flex: 1; text-align: center; padding: 14px 8px 12px; background: #f8fafc; border-top: 3px solid transparent; }
.step .num { font-size: 18px; font-weight: 700; font-style: italic; color: var(--muted); }
.step .lbl { font-size: 13px; color: var(--muted); margin-top: 2px; }
.step.active { background: #fff; border-top-color: var(--primary); }
.step.active .num, .step.active .lbl { color: var(--primary); }
.step.done .num, .step.done .lbl { color: var(--success); }
.step.done .num::after { content: " \2713"; }

.modal-body { padding: 26px 28px; min-height: 180px; }
.modal-body h3 { font-size: 16px; margin-bottom: 6px; }
.modal-body .step-sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }
.modal-foot { padding: 16px 22px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; gap: 10px; }

.spec-list { list-style: none; }
.spec-row { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.spec-row:last-child { border-bottom: none; }
.spec-ico { width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.spec-ico svg { width: 20px; height: 20px; }
.spec-ico.ok { background: var(--success-soft); color: var(--success); }
.spec-ico.bad { background: var(--danger-soft); color: var(--danger); }
.spec-ico.info { background: var(--primary-soft); color: var(--primary); }
.spec-main .k { font-size: 13px; color: var(--muted); }
.spec-main .v { font-size: 15px; font-weight: 600; color: var(--text); margin-top: 1px; }

.congrats { text-align: center; padding: 10px 0 6px; }
.congrats .check { width: 68px; height: 68px; border-radius: 50%; background: var(--success-soft); color: var(--success); display: inline-flex; align-items: center; justify-content: center; margin-bottom: 16px; }
.congrats .check svg { width: 36px; height: 36px; }
.congrats h3 { font-size: 20px; margin-bottom: 8px; }
.congrats p { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.loading { color: var(--muted); font-size: 14px; text-align: center; padding: 30px 0; }

@media (max-width: 560px) {
  .step .lbl { display: none; }
  .topbar { padding: 0 16px; }
  .container { padding: 20px 16px; }
}
