*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --primary:   #2563eb;
  --primary-h: #1d4ed8;
  --danger:    #dc2626;
  --text:      #111827;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Auth layout ── */
.auth-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.auth-card p.subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 1.75rem;
}

/* ── Form ── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1.1rem;
}

.form-group label {
  font-size: .875rem;
  font-weight: 500;
}

.form-group input,
.form-group select {
  padding: .6rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  outline: none;
  transition: border-color .15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--primary);
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.2rem;
  border: none;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}

.btn-primary  { background: var(--primary); color: #fff; width: 100%; padding: .7rem; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover   { opacity: .85; }
.btn-ghost    { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-ghost:hover    { background: var(--bg); }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Alert ── */
.alert {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: none;
}
.alert.show   { display: block; }
.alert-error  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success{ background: #dcfce7; color: #166534; border: 1px solid #86efac; }

/* ── Dashboard layout ── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  gap: .25rem;
  flex-shrink: 0;
}

.sidebar .logo {
  font-size: 1.1rem;
  font-weight: 700;
  padding: .5rem .75rem 1.25rem;
  color: var(--primary);
}

.sidebar a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .55rem .75rem;
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: .9rem;
  transition: background .15s;
}

.sidebar a:hover,
.sidebar a.active { background: var(--bg); color: var(--primary); font-weight: 500; }

.sidebar .spacer { flex: 1; }

.sidebar .user-info {
  padding: .75rem;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  color: var(--muted);
}

.sidebar .user-info strong { display: block; color: var(--text); font-size: .875rem; }

.main {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
}

.page-header h2 { font-size: 1.35rem; font-weight: 700; }

/* ── Cards / stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
}

.stat-card .label { font-size: .8rem; color: var(--muted); margin-bottom: .3rem; }
.stat-card .value { font-size: 1.75rem; font-weight: 700; }

/* ── Table ── */
.table-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead { background: var(--bg); }
th, td { padding: .75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; font-size: .8rem; text-transform: uppercase; color: var(--muted); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-admin  { background: #ede9fe; color: #5b21b6; }
.badge-user   { background: #dbeafe; color: #1e40af; }
.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }

/* ── Modal ── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  display: flex; align-items: center; justify-content: center;
  z-index: 50;
  display: none;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  padding: 2rem;
  width: 100%;
  max-width: 460px;
}

.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 1.25rem; }
.modal-footer { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.25rem; }
