:root {
  color-scheme: light dark;
  --bg: #f6f7f9;
  --surface: #fff;
  --ink: #172033;
  --muted: #586174;
  --line: #d9dee8;
  --brand: #1c5bbf;
  --on-brand: #fff;
  --danger: #a51d2d;
  font: 16px/1.5 system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

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

button,
.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: .4rem;
  background: var(--brand);
  color: var(--on-brand);
  padding: .55rem .85rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

input,
select {
  min-height: 2.75rem;
  color: inherit;
  font: inherit;
}

.secondary {
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid #f6b73c;
  outline-offset: 2px;
}

.skip {
  position: fixed;
  left: -999px;
}

.skip:focus {
  top: .5rem;
  left: .5rem;
  z-index: 10;
  border-radius: .3rem;
  background: var(--surface);
  padding: .5rem;
}

.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}

.login-card {
  width: min(100%, 26rem);
  border: 1px solid var(--line);
  border-radius: .65rem;
  background: var(--surface);
  padding: clamp(1.25rem, 5vw, 2rem);
}

.login-card h1 {
  margin-top: 0;
}

.login-card label,
.login-card input {
  display: block;
  width: 100%;
}

.login-card input {
  margin: .25rem 0 1rem;
  border: 1px solid var(--line);
  border-radius: .4rem;
  padding: .55rem;
}

.captcha {
  display: block;
  max-width: 100%;
  margin: 0 0 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: 3.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
  background: #13213b;
  color: #fff;
}

.topbar a {
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

.topbar form {
  margin: 0;
}

.topbar .link {
  min-height: 2.75rem;
  background: transparent;
  color: #fff;
  padding: .25rem;
}

.shell {
  display: grid;
  grid-template-columns: 13rem minmax(0, 1fr);
  align-content: start;
  min-height: calc(100vh - 3.5rem);
}

.admin-nav {
  position: sticky;
  top: 3.5rem;
  align-self: start;
  height: calc(100vh - 3.5rem);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  padding: 1rem;
}

.admin-nav a {
  display: block;
  border-radius: .4rem;
  padding: .55rem .65rem;
  text-decoration: none;
}

.admin-nav a:hover {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
}

.admin-nav a[aria-current="page"] {
  background: color-mix(in srgb, var(--brand) 16%, transparent);
  color: var(--ink);
  font-weight: 700;
}

main {
  min-width: 0;
  width: 100%;
  max-width: 80rem;
  margin-inline: auto;
  padding: clamp(1rem, 3vw, 2rem);
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  line-height: 1.2;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
  gap: 1rem;
}

.cards article,
.notice,
.empty {
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
  padding: 1rem;
}

.cards strong,
.cards span {
  display: block;
}

.cards strong {
  font-size: 2rem;
}

.cards span,
.notice {
  color: var(--muted);
}

.notice.error {
  border-color: var(--danger);
  color: var(--danger);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: .75rem;
  margin-bottom: 1rem;
}

.filters label {
  display: grid;
  gap: .25rem;
}

.filters label:first-child {
  min-width: min(100%, 18rem);
  flex: 1;
}

.filters input,
.filters select {
  border: 1px solid var(--line);
  border-radius: .4rem;
  background: var(--surface);
  padding: .5rem;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  overscroll-behavior-inline: contain;
  border: 1px solid var(--line);
  border-radius: .5rem;
  background: var(--surface);
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: .7rem;
  text-align: left;
  white-space: nowrap;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
}

tbody tr:last-child td {
  border-bottom: 0;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-top: 1rem;
  color: var(--muted);
}

.pagination span {
  margin-right: auto;
}

.pagination a {
  min-height: 2.75rem;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--brand);
  border-radius: .4rem;
  padding: .45rem .75rem;
  font-weight: 600;
  text-decoration: none;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline;
}

@media (max-width: 767px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-nav {
    z-index: 2;
    width: 100%;
    height: auto;
    min-height: 3.25rem;
    display: flex;
    align-items: center;
    gap: .125rem;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-padding-inline: .5rem;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    background: var(--bg);
    padding: .25rem max(.5rem, env(safe-area-inset-right)) .25rem max(.5rem, env(safe-area-inset-left));
    scrollbar-width: thin;
  }

  .admin-nav::-webkit-scrollbar {
    height: .4rem;
  }

  .admin-nav a {
    flex: 0 0 auto;
    min-height: 2.75rem;
    display: inline-flex;
    align-items: center;
    padding: .5rem .65rem;
    white-space: nowrap;
  }

  .page-header {
    align-items: flex-start;
    margin-bottom: 1.25rem;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filters button {
    width: 100%;
  }

  th,
  td {
    padding: .625rem;
  }
}

@media (max-width: 420px) {
  .page-header {
    flex-direction: column;
  }

  .page-header .button {
    width: 100%;
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101622;
    --surface: #182131;
    --ink: #edf2fa;
    --muted: #b3bed0;
    --line: #334157;
    --brand: #79aaff;
    --on-brand: #101622;
  }
}
