:root {
  color-scheme: light;
  --slate-950: #162536;
  --slate-800: #263b4f;
  --slate-600: #526b80;
  --slate-500: #6d8294;
  --blue-700: #1557a6;
  --blue-800: #104681;
  --blue-100: #e8f1fb;
  --blue-050: #f4f8fc;
  --line: #d3dee8;
  --surface: #ffffff;
  --page: #edf3f8;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --success: #176b45;
  --radius: 0.75rem;
  --shadow: 0 0.5rem 1.5rem rgb(22 37 54 / 0.09);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--page);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--slate-950);
  background: var(--page);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
summary,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--blue-700);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--blue-800);
}

:focus-visible {
  outline: 3px solid #f0a500;
  outline-offset: 3px;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: clamp(1rem, 4vw, 3rem);
}

.auth-card {
  width: 100%;
  max-width: 28rem;
  padding: clamp(1.25rem, 5vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand,
.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.auth-brand {
  flex-direction: column;
  align-items: flex-start;
  margin-bottom: 1.75rem;
}

.auth-brand-mark,
.brand-mark {
  display: grid;
  flex: 0 0 2.75rem;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 0.6rem;
  color: #fff;
  background: var(--blue-700);
  font-weight: 800;
  letter-spacing: 0.04em;
}

.auth-brand-mark {
  flex: none;
  width: auto;
  min-height: 44px;
  padding: 0 0.875rem;
  white-space: nowrap;
  overflow-wrap: normal;
}

.auth-brand-label,
.brand-name {
  color: var(--slate-950);
  font-size: 1.1rem;
  font-weight: 750;
  line-height: 1.2;
}

.auth-brand-label {
  white-space: nowrap;
  overflow-wrap: normal;
}

.auth-brand .auth-notice {
  width: 100%;
  margin: 0;
}

.brand-subtitle {
  display: block;
  color: var(--slate-600);
  font-size: 0.875rem;
  font-weight: 400;
}

.auth-heading,
.page-header h1 {
  margin: 0 0 1.25rem;
  color: var(--slate-950);
  font-size: clamp(1.5rem, 3vw, 2rem);
  line-height: 1.2;
}

.auth-heading h1 {
  margin: 0 0 0.75rem;
  font-size: inherit;
  line-height: 1.2;
}

.auth-heading p {
  margin: 0;
  color: var(--slate-600);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.5;
}

.auth-content {
  min-width: 0;
}

.auth-notice,
.auth-message,
.messages,
.message {
  margin: 0 0 1rem;
  padding: 0.75rem 0.875rem;
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  color: var(--slate-800);
  background: var(--blue-050);
}

.auth-message-error,
.message.error,
.errorlist {
  border-color: #e7aaa5;
  color: var(--danger);
  background: var(--danger-bg);
}

.auth-errors,
.errorlist {
  margin: 0.4rem 0 0;
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.auth-field,
.field {
  min-width: 0;
  margin-bottom: 1rem;
}

.auth-field label,
.field label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--slate-800);
  font-weight: 650;
}

.auth-field input,
.auth-field select,
.auth-field textarea,
.field input,
.field select,
.field textarea,
.auth-content input,
.auth-content select,
.auth-content textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0.6rem 0.75rem;
  border: 1px solid #9eb1c2;
  border-radius: 0.45rem;
  color: var(--slate-950);
  background: #fff;
  font-size: 16px;
  line-height: 1.35;
}

.auth-field textarea,
.field textarea,
.auth-content textarea {
  min-height: 7rem;
  resize: vertical;
}

.auth-field input:focus,
.auth-field select:focus,
.auth-field textarea:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue-700);
}

.auth-help,
.helptext,
.field-help {
  display: block;
  margin-top: 0.35rem;
  color: var(--slate-600);
  font-size: 0.875rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.auth-actions,
.actions,
.action-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

button,
.button,
.auth-submit {
  display: inline-flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1rem;
  border: 1px solid var(--blue-700);
  border-radius: 0.45rem;
  color: #fff;
  background: var(--blue-700);
  cursor: pointer;
  font-weight: 700;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

button:hover,
.button:hover,
.auth-submit:hover {
  border-color: var(--blue-800);
  background: var(--blue-800);
  color: #fff;
}

.button-secondary,
button.button-secondary {
  border-color: #9eb1c2;
  color: var(--slate-800);
  background: #fff;
}

.button-secondary:hover,
button.button-secondary:hover {
  color: var(--slate-950);
  background: var(--blue-050);
}

.button-danger,
button.button-danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

.auth-account-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.5rem;
  font-size: 0.9375rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(13rem, 16rem) minmax(0, 1fr);
  min-height: 100vh;
}

.app-nav {
  padding: 1.25rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.nav-links {
  display: grid;
  gap: 0.25rem;
  margin-top: 2rem;
}

.nav-links a {
  display: block;
  padding: 0.65rem 0.75rem;
  border-radius: 0.4rem;
  color: var(--slate-800);
  text-decoration: none;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] {
  color: var(--blue-800);
  background: var(--blue-100);
}

.page-content {
  width: 100%;
  max-width: 90rem;
  min-width: 0;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.page-header p {
  margin: 0;
  color: var(--slate-600);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(12rem, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card,
.panel {
  min-width: 0;
  padding: clamp(1rem, 2.5vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 0.25rem 0.75rem rgb(22 37 54 / 0.04);
}

.stat-card strong {
  display: block;
  margin-top: 0.25rem;
  color: var(--slate-950);
  font-size: clamp(1.5rem, 4vw, 2.25rem);
  line-height: 1.1;
}

.muted {
  color: var(--slate-600);
}

.record-list {
  display: grid;
  gap: 0.75rem;
}

.record-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.record-row:last-child {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  max-width: 100%;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: var(--blue-800);
  background: var(--blue-100);
  font-size: 0.8125rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.form-errors {
  margin-bottom: 1rem;
  color: var(--danger);
}

.empty-state {
  padding: 2rem 1rem;
  color: var(--slate-600);
  text-align: center;
}

.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 36rem;
  border-collapse: collapse;
}

th,
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  text-align: left;
  overflow-wrap: anywhere;
}

th {
  color: var(--slate-800);
  background: var(--blue-050);
  font-size: 0.875rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.details-list {
  display: grid;
  grid-template-columns: minmax(8rem, 0.75fr) minmax(0, 1.5fr);
  gap: 0.65rem 1rem;
  margin: 0;
}

.details-list dt {
  color: var(--slate-600);
  font-weight: 650;
}

.details-list dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .app-shell {
    display: block;
  }

  .app-nav {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .app-nav .nav-links {
    display: none;
  }

  .app-nav details[open] .nav-links,
  .app-nav details .nav-links {
    display: grid;
  }

  .app-nav summary {
    min-height: 44px;
    padding: 0.6rem 0;
    cursor: pointer;
    font-weight: 700;
  }

  .field-grid,
  .details-list {
    grid-template-columns: 1fr;
  }

  .auth-actions > *,
  .actions > *,
  .action-group > * {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
