:root {
  --ink: #22244b;
  --mist: #c6cfc7;
  --paper: #ffffff;
  --line: #dfe5e0;
  --soft: #f5f7f5;
  --danger: #a8272f;
  --ok: #236a3a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: var(--ink); }

button,
.button {
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

button:hover,
.button:hover { filter: brightness(1.08); }

.secondary,
.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--mist);
  text-decoration: none;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--mist);
  border-radius: 6px;
  min-height: 40px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

textarea { resize: vertical; }

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.topbar {
  height: 68px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, .96);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand,
.nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 32px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  display: grid;
  place-items: center;
  letter-spacing: 0;
  font-size: 13px;
}

.nav a { text-decoration: none; font-weight: 700; }
.nav form { margin: 0; }

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(198, 207, 199, .45), rgba(255, 255, 255, .9) 44%),
    var(--paper);
}

.login-panel {
  width: min(430px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 34px;
  box-shadow: 0 20px 70px rgba(34, 36, 75, .12);
}

.login-panel h1,
.page-title h1,
.result h1 {
  margin: 0;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.03;
}

.eyebrow {
  margin: 0 0 8px;
  color: #526050;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 800;
}

.muted { color: #59605a; }

.form-stack {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.page {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 34px clamp(16px, 4vw, 42px) 60px;
}

.narrow { width: min(780px, 100%); }

.page-title {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 20px;
  margin-bottom: 24px;
}

.user-chip {
  border: 1px solid var(--mist);
  border-radius: 999px;
  padding: 8px 12px;
  font-weight: 700;
  background: var(--soft);
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.align-start { align-items: start; }

.band,
.panel,
.result {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 22px;
  margin-bottom: 18px;
}

.band { background: var(--soft); }

.panel h2 {
  margin: 0 0 16px;
  font-size: 22px;
}

.check-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 12px;
  align-items: center;
  min-height: 46px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.check-row:last-child { border-bottom: 0; }

.small-input { width: 140px; }

.segmented {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--mist);
  border-radius: 6px;
  overflow: hidden;
  min-width: 260px;
  background: #fff;
}

.segmented.compact { min-width: 150px; }

.segmented label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 750;
}

.segmented label + label { border-left: 1px solid var(--mist); }
.segmented input { width: auto; min-height: auto; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  vertical-align: middle;
}

th {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #526050;
}

td input,
td select { min-width: 130px; }

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 18px;
}

.admin-form {
  display: grid;
  grid-template-columns: 1.2fr 1.3fr 1fr .8fr auto auto;
  gap: 10px;
  align-items: center;
}

.user-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.4fr .8fr .7fr 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.user-grid-head {
  color: #526050;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding-top: 0;
}

.user-list .user-grid:last-child { border-bottom: 0; }

.check-inline {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.check-inline input { width: auto; min-height: auto; }

.flash {
  width: min(1240px, calc(100% - 32px));
  margin: 16px auto 0;
  border-radius: 6px;
  padding: 12px 14px;
  border: 1px solid var(--mist);
  background: var(--soft);
  font-weight: 700;
}

.login-panel .flash { width: 100%; margin: 18px 0 0; }
.flash.error { border-color: #e3a4a8; color: var(--danger); background: #fff5f6; }
.flash.success { border-color: #add5b9; color: var(--ok); background: #f3fbf5; }

dl {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px;
}

dt { font-weight: 800; }
dd { margin: 0; }

@media (max-width: 860px) {
  .topbar { height: auto; min-height: 68px; align-items: flex-start; flex-direction: column; padding-top: 14px; padding-bottom: 14px; }
  .nav { flex-wrap: wrap; }
  .grid.two { grid-template-columns: 1fr; }
  .page-title { align-items: flex-start; flex-direction: column; }
  .check-row { grid-template-columns: 1fr; }
  .segmented { width: 100%; min-width: 0; }
  .admin-form { grid-template-columns: 1fr; }
  .user-grid,
  .user-grid-head { grid-template-columns: 1fr; }
  .user-grid-head { display: none; }
  .actions { justify-content: stretch; flex-direction: column; align-items: stretch; }
  .button, .secondary, button { width: 100%; }
}
