/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --primary:        #0f2451;
  --primary-light:  #1a3a7c;
  --accent:         #2563eb;
  --accent-hover:   #1d4ed8;
  --success:        #059669;
  --danger:         #dc2626;
  --danger-hover:   #b91c1c;
  --warning:        #d97706;
  --bg:             #f1f5f9;
  --card:           #ffffff;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --border:         #e2e8f0;
  --shadow-sm:      0 1px 3px rgba(0,0,0,0.08);
  --shadow-md:      0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg:      0 10px 30px rgba(0,0,0,0.12);
  --radius:         8px;
  --radius-lg:      12px;
}

/* ── Reset & Base ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ────────────────────────────────────────────────────────────── */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 32px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.3px;
}

.navbar-brand .brand-dot {
  width: 8px; height: 8px;
  background: #60a5fa;
  border-radius: 50%;
  display: inline-block;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.navbar-nav a {
  color: rgba(255,255,255,0.80);
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}

.navbar-nav a:hover, .navbar-nav a.active {
  background: rgba(255,255,255,0.12);
  color: #fff;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: rgba(255,255,255,0.80);
}

.navbar-user strong { color: #fff; }

/* ── Page Layout ───────────────────────────────────────────────────────────── */
.page-wrapper { max-width: 1200px; margin: 0 auto; padding: 40px 24px; }
.page-header { margin-bottom: 32px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.4px; }
.page-header p  { color: var(--text-muted); margin-top: 4px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h2 { font-size: 16px; font-weight: 600; color: var(--text); }
.card-body { padding: 24px; }

/* ── Stat Cards ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.stat-card .stat-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 2px 8px rgba(37,99,235,0.4); }

.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: var(--danger-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { padding: 5px 12px; font-size: 13px; }

.btn-logout {
  background: rgba(255,255,255,0.10);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.20);
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.btn-logout:hover { background: rgba(255,255,255,0.20); }

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: #f8fafc;
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }

.user-name { font-weight: 600; color: var(--text); }
.user-email { color: var(--text-muted); font-size: 13px; }

/* ── Role Badges ────────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-platform-admin { background: #ede9fe; color: #6d28d9; }
.badge-admin          { background: #dbeafe; color: #1d4ed8; }
.badge-user           { background: #f0fdf4; color: #166534; }

/* ── Action Buttons in Table ────────────────────────────────────────────────── */
.actions { display: flex; gap: 8px; }

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,36,81,0.5);
  backdrop-filter: blur(2px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  padding: 32px;
  transform: translateY(12px);
  transition: transform 0.2s;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}

.modal-header h3 { font-size: 18px; font-weight: 700; color: var(--text); }

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

.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* ── Alert / Toast ──────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  display: none;
}
.alert.show { display: block; }
.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }

/* ── Landing Page ───────────────────────────────────────────────────────────── */
.landing {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--primary) 0%, #1e3a8a 50%, #1d4ed8 100%);
}

.landing-header {
  padding: 24px 48px;
  display: flex;
  align-items: center;
}

.landing-brand {
  display: flex; align-items: center; gap: 10px;
  color: #fff; font-size: 20px; font-weight: 700; letter-spacing: -0.3px;
}

.landing-main {
  flex: 1;
  display: flex;
  align-items: flex-start;          /* card sits at the top, not vertical centre */
  justify-content: center;
  padding: 48px 24px;
}

.landing-card {
  background: rgba(255,255,255,0.97);
  border-radius: 20px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.25);
  padding: 52px 48px;
  max-width: 440px;
  width: 100%;
  text-align: center;
}

.landing-card .logo-mark {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 16px;
  margin: 0 auto 24px;
  display: flex; align-items: center; justify-content: center;
}

.landing-card .logo-mark svg { width: 32px; height: 32px; color: #fff; }

.landing-card h1 {
  font-size: 24px; font-weight: 700;
  color: var(--text); margin-bottom: 8px;
  letter-spacing: -0.4px;
}

.landing-card p {
  color: var(--text-muted); font-size: 15px; margin-bottom: 32px;
  line-height: 1.6;
}

.btn-miracl {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 2px 8px rgba(15,36,81,0.3);
}

.btn-miracl:hover {
  background: var(--primary-light);
  box-shadow: 0 4px 16px rgba(15,36,81,0.4);
  color: #fff;
  text-decoration: none;
}

.error-box {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 20px;
  text-align: left;
  display: none;
}

.error-box.show { display: block; }

.landing-footer {
  padding: 24px;
  text-align: center;
  color: rgba(255,255,255,0.45);
  font-size: 13px;
}

/* ── Role info strip ────────────────────────────────────────────────────────── */
.role-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--primary);
  color: rgba(255,255,255,0.85);
  padding: 10px 24px;
  font-size: 13px;
}
.role-strip strong { color: #fff; }

/* ── Dashboard Info Grid ────────────────────────────────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.info-card h3 { font-size: 14px; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.info-card p  { font-size: 15px; color: var(--text); font-weight: 500; }

/* ── Loading ─────────────────────────────────────────────────────────────────── */
.loading { color: var(--text-muted); font-size: 14px; padding: 24px; text-align: center; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .page-wrapper { padding: 24px 16px; }
  .landing-card  { padding: 36px 24px; }
  .form-row      { grid-template-columns: 1fr; }
  .navbar        { padding: 0 16px; }
  .stats-grid    { grid-template-columns: 1fr 1fr; }
}
