:root {
  --primary: #004594;
  --secondary: #ffd100;
  --bg: #f4f6fa;
  --text: #1f2937;
  --border: #d7dde8;
  --danger: #b91c1c;
  --ok: #15803d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: #6b7280; }
.mt { margin-top: 12px; }
.row-gap { display: flex; gap: 8px; align-items: center; margin-top: 10px; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #0b2a5b, #004594 60%, #0b2a5b);
}
.login-card { width: 340px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card p { margin: 0; }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.topbar .brand { font-size: 16px; }
.topbar .muted { color: #c7d6ee; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions select { min-width: 180px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 10px 18px 0;
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  padding: 9px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-weight: 600;
  color: #4b5563;
  white-space: nowrap;
}
.tab:hover { background: #eef2f9; }
.tab.active { background: var(--bg); border-color: var(--border); color: var(--primary); }

main { padding: 18px; display: grid; gap: 16px; max-width: 1400px; margin: 0 auto; }

/* ── Cards / tables ────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
.card h2 { margin: 0 0 12px; font-size: 16px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; }

.grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.kpi { background: #fff; border-radius: 10px; padding: 14px 16px; box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
.kpi .label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 4px; }
.kpi .hint { font-size: 12px; color: #6b7280; margin-top: 2px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: #6b7280;
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  white-space: nowrap;
}
tbody td { padding: 8px 10px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
tbody tr:hover { background: #f8fafc; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Forms ─────────────────────────────────────────────────────────────── */
label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: #4b5563; }
input, select, button { font: inherit; }
input, select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  min-width: 120px;
}
input:focus, select:focus { outline: 2px solid rgba(0, 69, 148, 0.25); border-color: var(--primary); }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }

button { cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid transparent; font-weight: 600; }
button.primary { background: var(--primary); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.ghost { background: #fff; border-color: var(--border); color: var(--primary); }
button.ghost:hover { background: #eef2f9; }
button.danger { background: var(--danger); color: #fff; }
button.mini { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.active { background: #dcfce7; color: #166534; }
.badge.blocked { background: #fee2e2; color: #991b1b; }
.badge.inactive { background: #e5e7eb; color: #374151; }
.badge.expired { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.err { background: #fee2e2; color: #991b1b; }

.error { color: var(--danger); font-weight: 600; }
.ok { color: var(--ok); font-weight: 600; }

/* ── Toast + modal ─────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: #111827;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  z-index: 50;
  max-width: 420px;
}
.toast.error { background: var(--danger); }

.modal { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45); display: grid; place-items: center; z-index: 60; }
.modal-box { background: #fff; border-radius: 12px; padding: 18px; width: min(520px, 92vw); }
.modal-box h3 { margin: 0 0 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

code { background: #eef2f9; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
