:root {
  color-scheme: light;
  --navy: #061738;
  --navy-2: #102a58;
  --blue: #1c72e8;
  --green: #27b778;
  --red: #d83b4b;
  --ink: #14233b;
  --muted: #68758a;
  --line: #dfe6ef;
  --surface: rgba(255, 255, 255, .94);
  --shadow: 0 20px 60px rgba(20, 43, 78, .11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 0%, rgba(43, 119, 232, .15), transparent 29rem),
    radial-gradient(circle at 96% 12%, rgba(39, 183, 120, .12), transparent 28rem),
    #f4f7fb;
}

button, input, select { font: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(22px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  box-shadow: 0 10px 30px rgba(6, 23, 56, .18);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand img { width: 43px; height: 43px; border-radius: 12px; box-shadow: 0 6px 18px rgba(0,0,0,.24); }
.brand span { display: grid; line-height: 1.12; }
.brand b { letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: rgba(255,255,255,.67); }
.back-link { padding: 10px 15px; border: 1px solid rgba(255,255,255,.22); border-radius: 12px; font-weight: 700; }

main { width: min(1180px, calc(100% - 36px)); margin: 44px auto 80px; }

.panel {
  background: var(--surface);
  border: 1px solid rgba(219, 227, 239, .9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.centered, .auth-panel { width: min(500px, 100%); margin: 9vh auto 0; padding: 38px; }
.centered { text-align: center; color: var(--muted); }

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid #dce7f5;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(30px, 5vw, 48px); line-height: 1.04; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 25px; letter-spacing: -.025em; }
.lead { color: var(--muted); font-size: 16px; line-height: 1.55; }

.stack { display: grid; gap: 16px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #3e4c62; font-size: 13px; font-weight: 750; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: none;
  transition: border .2s, box-shadow .2s;
}
input:focus, select:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(28, 114, 232, .1); }
input[type="checkbox"] { width: 20px; min-height: 20px; accent-color: var(--blue); }

.button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border: 0;
  border-radius: 12px;
  font-weight: 800;
  cursor: pointer;
  transition: transform .16s, opacity .16s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .55; transform: none; }
.button.primary { color: #fff; background: linear-gradient(135deg, var(--blue), #2862d4); box-shadow: 0 9px 20px rgba(28, 114, 232, .2); }
.button.secondary { color: var(--ink); background: #edf2f8; }
.button.danger { color: var(--red); background: #fff0f2; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.5; }

.message { margin: 5px 0 0; padding: 11px 13px; border-radius: 10px; font-size: 13px; }
.message.error { color: #a82435; background: #fff0f2; border: 1px solid #f4cbd1; }
.message.success { color: #147049; background: #ecfbf4; border: 1px solid #bfe9d6; }

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 28px;
}
.hero .lead { margin-bottom: 0; }
.hero-actions { display: flex; align-items: center; gap: 10px; }
.user-chip { padding: 10px 13px; color: var(--navy); background: #fff; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; font-weight: 750; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.summary-grid article {
  padding: 22px;
  background: linear-gradient(145deg, #fff, #f7faff);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 8px 24px rgba(20,43,78,.06);
}
.summary-grid span { display: block; margin-bottom: 5px; color: var(--navy); font-size: 32px; font-weight: 850; letter-spacing: -.04em; }
.summary-grid small { color: var(--muted); font-weight: 650; }

.create-panel { padding: 28px; margin-bottom: 34px; }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading > p { max-width: 410px; margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

.form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.35fr 1.15fr .9fr auto;
  gap: 12px;
  align-items: end;
}
.form-action { display: flex; }
.form-action .button { white-space: nowrap; }

.user-list { display: grid; gap: 13px; }
.user-card {
  padding: 21px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 7px 22px rgba(20,43,78,.05);
}
.user-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 17px; }
.identity { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), #65a7ff);
  border-radius: 13px;
  font-weight: 850;
}
.identity b { display: block; }
.identity small { display: block; margin-top: 3px; color: var(--muted); }
.identity small + small { margin-top: 1px; font-size: 11px; }
.badges { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.badge { padding: 5px 8px; color: #4f5e72; background: #eef2f7; border-radius: 999px; font-size: 11px; font-weight: 800; }
.badge.admin { color: #175cb6; background: #e9f2ff; }
.badge.active { color: #147049; background: #e8f8f0; }
.badge.inactive { color: #a82435; background: #fff0f2; }

.user-form {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.35fr .9fr auto auto;
  gap: 11px;
  align-items: end;
}
.toggle-label { min-height: 48px; display: flex; align-items: center; gap: 8px; padding: 0 12px; background: #f7f9fc; border-radius: 12px; }
.user-actions { display: flex; gap: 8px; }
.reset-box { display: none; grid-template-columns: 1fr auto; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.reset-box.open { display: grid; }
.empty { padding: 32px; color: var(--muted); text-align: center; background: #fff; border: 1px dashed #cad5e3; border-radius: 18px; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(390px, calc(100vw - 48px));
  padding: 13px 16px;
  color: #fff;
  background: var(--navy);
  border-radius: 12px;
  box-shadow: 0 16px 40px rgba(6,23,56,.24);
  font-weight: 700;
}

@media (max-width: 950px) {
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .form-action { grid-column: 1 / -1; }
  .form-action .button { width: 100%; }
  .user-form { grid-template-columns: repeat(2, 1fr); }
  .user-actions { grid-column: 1 / -1; }
}

@media (max-width: 650px) {
  .topbar { height: 68px; padding: 0 17px; }
  .brand small { display: none; }
  main { width: min(100% - 24px, 1180px); margin-top: 27px; }
  .centered, .auth-panel { margin-top: 5vh; padding: 26px 21px; }
  .hero { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; justify-content: space-between; }
  .summary-grid { grid-template-columns: 1fr; gap: 10px; }
  .summary-grid article { padding: 17px 20px; }
  .create-panel { padding: 20px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 7px; }
  .form-grid, .user-form { grid-template-columns: 1fr; }
  .user-actions { grid-column: auto; }
  .user-actions .button { flex: 1; }
  .user-head { align-items: flex-start; }
  .reset-box { grid-template-columns: 1fr; }
}
