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

body {
  min-height: 100vh;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  height: var(--header-height);
  border-bottom: 1px solid var(--hairline);
  background: var(--canvas);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 16px;
}

.logo {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink-deep);
  text-decoration: none;
  letter-spacing: -0.5px;
  flex-shrink: 0;
}

.admin-badge {
  font-size: 0.7rem;
  color: var(--success);
  background: var(--tint-mint);
  border-radius: var(--r-xs);
  padding: 2px 7px;
  margin-left: 6px;
  font-weight: 600;
  vertical-align: middle;
}

/* ── Header nav ── */
.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}
.header-nav a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--steel);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: color 0.12s, background 0.12s;
}
.header-nav a:hover { color: var(--ink); background: var(--surface); }
.header-nav a.active { color: var(--ink); background: var(--surface); }
.header-nav a.admin-nav-link { color: var(--primary); font-weight: 600; }
.header-nav a.admin-nav-link:hover { background: #f0edfc; }
.header-nav a.admin-nav-link.active { background: #f0edfc; color: var(--primary); }

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Buttons ── */
.btn-primary {
  padding: 8px 16px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--r-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
  font-family: inherit;
}
.btn-primary:hover { background: var(--primary-pressed); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-sm {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  color: var(--charcoal);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  transition: border-color 0.12s, color 0.12s;
  font-family: inherit;
}
.btn-sm:hover { border-color: var(--slate); color: var(--ink); }
.btn-sm:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-logout {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  color: var(--steel);
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 500;
  transition: color 0.12s, border-color 0.12s;
  font-family: inherit;
}
.btn-logout:hover { color: var(--ink); border-color: var(--slate); }

.btn-danger {
  padding: 8px 14px;
  background: transparent;
  border: 1px solid #fca5a5;
  border-radius: var(--r-md);
  color: var(--error);
  cursor: pointer;
  font-size: 0.875rem;
  font-family: inherit;
  transition: background 0.15s;
}
.btn-danger:hover { background: #fff5f5; }

/* ── Section card ── */
.section {
  background: var(--canvas);
  border: 1px solid var(--hairline);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 16px;
}
.section-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--stone);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--hairline);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ── Form inputs (global) ── */
input[type=text],
input[type=number],
input[type=email],
input[type=password],
select,
textarea {
  background: var(--canvas);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-md);
  color: var(--ink);
  font-size: 0.9375rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
  appearance: none;
  height: 44px;
  font-family: inherit;
}
input[type=text]:focus,
input[type=number]:focus,
input[type=email]:focus,
input[type=password]:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(86,69,212,0.12);
}
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(86,69,212,0.12);
}
input::placeholder, textarea::placeholder { color: var(--stone); }
select { cursor: pointer; }
textarea { height: auto; }

/* ── Utilities ── */
.placeholder { font-size: 0.875rem; color: var(--stone); font-style: italic; }

.role-badge {
  font-size: 0.75rem;
  background: var(--surface);
  color: var(--steel);
  border-radius: var(--r-sm);
  padding: 2px 8px;
  font-weight: 500;
}
.role-badge.admin { background: var(--tint-mint); color: #166534; }

.result-msg { font-size: 0.8125rem; margin-top: 10px; color: var(--success); font-weight: 500; }
.result-msg.error { color: var(--error); }

/* ── Mobile menu button ── */
.mobile-menu-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-shrink: 0;
}
.mobile-menu-btn span {
  display: block;
  height: 2px;
  background: var(--ink);
  border-radius: 1px;
  transition: transform 0.2s, opacity 0.2s;
}
.mobile-menu-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.mobile-menu-btn.open span:nth-child(2) { opacity: 0; }
.mobile-menu-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Mobile ── */
@media (max-width: 640px) {
  header { padding: 0 16px; }
  .header-nav a { font-size: 0.8rem; padding: 5px 7px; }
  .btn-logout { padding: 5px 10px; font-size: 0.78rem; }
  .btn-sm { padding: 5px 10px; font-size: 0.78rem; }
  .section { padding: 16px; }
}

@media (max-width: 600px) {
  .mobile-menu-btn { display: flex; }
  .header-nav {
    display: none;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--canvas);
    border-bottom: 1px solid var(--hairline);
    box-shadow: 0 4px 12px rgba(0,0,0,0.07);
    padding: 8px 16px 14px;
    gap: 2px;
    z-index: 99;
  }
  .header-nav.open { display: flex; }
  .header-nav a { font-size: 0.9rem; padding: 10px 12px; }
}
