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

:root {
  --bg:        #f7f8fa;
  --surface:   #ffffff;
  --border:    #e2e5ea;
  --primary:   #4f46e5;
  --primary-h: #4338ca;
  --text:      #111827;
  --muted:     #6b7280;
  --danger:    #ef4444;
  --success:   #10b981;
  --radius:    10px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
  --font:      'Inter', system-ui, sans-serif;
  --admin:     #0f172a;
  --admin-h:   #1e293b;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ── Auth pages ── */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 2.5rem;
  width: 100%;
  max-width: 480px;
}

.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: .25rem;
}

.auth-card .subtitle {
  color: var(--muted);
  font-size: .9rem;
  margin-bottom: 2rem;
}

/* ── Form elements ── */
.field { margin-bottom: 1.1rem; }

label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select {
  width: 100%;
  padding: .65rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.12);
  background: #fff;
}

select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }

/* radio / checkbox row */
.radio-group, .check-group {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
  margin-top: .25rem;
}

.radio-group label, .check-group label {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-weight: 400;
  cursor: pointer;
}

input[type="radio"], input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .7rem 1.4rem;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 600;
  font-family: var(--font);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}
.btn-primary:hover { background: var(--primary-h); text-decoration: none; color: #fff; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: var(--bg); text-decoration: none; }

.btn-sm { padding: .4rem .9rem; font-size: .85rem; width: auto; }
.btn-xs { padding: .3rem .7rem; font-size: .78rem; width: auto; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; text-decoration: none; color: #fff; }

.btn-admin {
  background: var(--admin);
  color: #fff;
  width: 100%;
}
.btn-admin:hover { background: var(--admin-h); text-decoration: none; color: #fff; }

/* ── Messages ── */
.messages { list-style: none; margin-bottom: 1.2rem; }
.messages li {
  padding: .7rem 1rem;
  border-radius: var(--radius);
  font-size: .9rem;
  margin-bottom: .5rem;
}
.messages .error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.messages .success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.errorlist { color: var(--danger); font-size: .82rem; margin-top: .25rem; list-style: none; }

/* ── Navbar ── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.nav-brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--primary);
  letter-spacing: -.3px;
}

/* ── Profile dropdown ── */
.nav-user { position: relative; }

.nav-user-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .9rem;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  font-family: var(--font);
  color: var(--text);
  transition: background .15s;
}

.nav-user-btn:hover { background: #eef0f5; }

.nav-avatar {
  width: 30px; height: 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem;
  font-weight: 700;
}

.chevron { font-size: .7rem; color: var(--muted); transition: transform .2s; }
.nav-user-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
  min-width: 170px;
  display: none;
  overflow: hidden;
}

.dropdown-menu.open { display: block; }

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
  font-size: .9rem;
  color: var(--text);
  transition: background .12s;
}
.dropdown-menu a:hover { background: var(--bg); text-decoration: none; }
.dropdown-menu a.logout-link { color: var(--danger); }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); margin: 0; }

/* ── Page content ── */
.page-content {
  max-width: 900px;
  margin: 2.5rem auto;
  padding: 0 1.5rem;
}

/* ── Dashboard card ── */
.dashboard-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
  border-radius: 16px;
  padding: 2.5rem;
  color: #fff;
  margin-bottom: 2rem;
}
.dashboard-hero h2 { font-size: 1.8rem; font-weight: 700; }
.dashboard-hero p { opacity: .85; margin-top: .4rem; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: .5rem; }
.card p { color: var(--muted); font-size: .88rem; }

/* ── Profile page ── */
.profile-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.8rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
}

.profile-avatar-lg {
  width: 72px; height: 72px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-meta h2 { font-size: 1.3rem; font-weight: 700; }
.profile-meta p { color: var(--muted); font-size: .9rem; }

.detail-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.6rem;
  margin-bottom: 1.2rem;
  box-shadow: var(--shadow);
}

.detail-section h3 {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .8rem 1.5rem;
}

.detail-item label { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.detail-item p { font-size: .95rem; color: var(--text); margin-top: .1rem; font-weight: 500; }
.detail-item p.empty { color: #ccc; font-style: italic; font-weight: 400; }

/* badge */
.badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-yes { background: #ecfdf5; color: #065f46; }
.badge-no  { background: #fef2f2; color: #b91c1c; }

/* ── Complete profile form page ── */
.form-page {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 2rem;
  box-shadow: var(--shadow);
}

.form-page h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: .25rem; }
.form-page .subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 2rem; }

.form-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.btn-row {
  display: flex;
  gap: .75rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* 2-column form grid */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 1.2rem;
}

/* ── Admin panel ── */
.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: #f1f5f9;
  color: var(--admin);
  border: 1px solid #cbd5e1;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: .25rem .75rem;
  margin-bottom: 1rem;
}

.field-hint {
  font-size: .78rem;
  color: var(--muted);
  margin-top: .3rem;
}
.field-hint code {
  background: #f1f5f9;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-size: .75rem;
}

.admin-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.admin-topbar h2 {
  font-size: 1.4rem;
  font-weight: 700;
}

.admin-sub {
  color: var(--muted);
  font-size: .88rem;
  margin-top: .2rem;
}

.admin-back {
  font-size: .85rem;
  color: var(--muted);
  display: inline-block;
  margin-bottom: .1rem;
}
.admin-back:hover { color: var(--primary); }

.admin-search-form {
  margin-bottom: 1.2rem;
}

.admin-search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: .9rem;
  font-size: 1rem;
  pointer-events: none;
  color: var(--muted);
}

.admin-search-input {
  width: 100%;
  padding: .7rem 2.8rem .7rem 2.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: .95rem;
  font-family: var(--font);
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

.admin-search-input:focus {
  border-color: var(--admin);
  box-shadow: 0 0 0 3px rgba(15,23,42,.08);
}

.search-clear {
  position: absolute;
  right: .9rem;
  font-size: .85rem;
  color: var(--muted);
  line-height: 1;
  padding: .2rem .4rem;
  border-radius: 4px;
  text-decoration: none;
}
.search-clear:hover { background: var(--bg); color: var(--danger); }

.search-result-info {
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: .9rem;
}

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}

.admin-table thead {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

.admin-table td {
  padding: .85rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.admin-table tbody tr:last-child td {
  border-bottom: none;
}

.admin-table tbody tr:hover {
  background: #fafafa;
}

.td-num {
  color: var(--muted);
  font-size: .8rem;
  width: 2.5rem;
}

.td-name {
  display: flex;
  align-items: center;
  gap: .6rem;
  font-weight: 500;
}

.td-avatar {
  width: 30px;
  height: 30px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.td-code {
  background: #f1f5f9;
  padding: .15rem .45rem;
  border-radius: 4px;
  font-size: .82rem;
  color: var(--admin);
}

.td-muted {
  color: var(--muted);
}

.td-actions {
  display: flex;
  gap: .4rem;
  align-items: center;
}

.admin-empty {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--muted);
  box-shadow: var(--shadow);
}

.form-section-title {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 1.2rem 0 .8rem;
}

/* ── Responsive ── */
@media (max-width: 700px) {
  .admin-table th:nth-child(4),
  .admin-table td:nth-child(4),
  .admin-table th:nth-child(5),
  .admin-table td:nth-child(5) {
    display: none;
  }
}

@media (max-width: 600px) {
  .auth-card { padding: 1.8rem 1.2rem; }
  .navbar { padding: 0 1rem; }
  .page-content { padding: 0 1rem; }
  .profile-header { flex-direction: column; text-align: center; }
  .form-grid-2 { grid-template-columns: 1fr; }
}