:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #172033;
  --muted: #647083;
  --line: #d9e1ea;
  --primary: #0b6bcb;
  --primary-dark: #07559f;
  --danger: #b42318;
  --danger-bg: #fff1f0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 48px);
}

.brand {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
}

.site-nav {
  align-items: center;
  display: flex;
  gap: 18px;
}

.account-pill {
  background: #eef5fc;
  border: 1px solid #c9def2;
  border-radius: 999px;
  color: #24415f;
  font-size: 13px;
  font-weight: 700;
  padding: 5px 10px;
}

.site-nav form {
  margin: 0;
}

.page-shell {
  margin: 0 auto;
  max-width: 1180px;
  padding: 32px clamp(16px, 4vw, 48px);
}

.messages {
  margin-bottom: 20px;
}

.message {
  background: #eaf6ef;
  border: 1px solid #b9dec8;
  border-radius: 8px;
  margin: 0 0 10px;
  padding: 10px 12px;
}

.auth-panel,
.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 auto;
  max-width: 480px;
  padding: 28px;
}

.auth-panel.wide {
  max-width: 760px;
}

.page-heading {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-bottom: 24px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.muted,
.help-text {
  color: var(--muted);
  font-size: 14px;
}

.form-stack,
.form-grid,
.form-sections {
  display: grid;
  gap: 18px;
}

.form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

input,
textarea,
select {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  width: 100%;
}

textarea {
  resize: vertical;
}

.full-width {
  grid-column: 1 / -1;
}

.errorlist {
  color: var(--danger);
  font-size: 14px;
  margin: 0;
  padding-left: 18px;
}

.primary-button,
.secondary-button,
.danger-button,
.link-button {
  align-items: center;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
}

.primary-button {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.secondary-button {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--text);
}

.danger-button {
  background: var(--danger-bg);
  border: 1px solid #f3b5af;
  color: var(--danger);
}

.danger-button.small {
  min-height: 34px;
  padding: 6px 10px;
}

.secondary-button.small {
  min-height: 34px;
  padding: 6px 10px;
}

.link-button {
  background: transparent;
  border: 0;
  color: var(--primary);
  min-height: auto;
  padding: 0;
}

.form-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.record-list {
  display: grid;
  gap: 14px;
}

.filter-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 18px;
}

.filter-form {
  align-items: end;
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(260px, 1fr) 170px 170px auto;
}

.filter-actions {
  display: flex;
  gap: 10px;
}

.record-card {
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 260px) auto;
  padding: 18px;
}

.record-main h2 {
  margin-bottom: 4px;
}

dl {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 16px 0 0;
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

dd {
  margin: 0;
}

.attachment-summary {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.attachment-summary strong {
  font-size: 24px;
}

.attachment-summary span {
  color: var(--muted);
  font-size: 13px;
}

.attachment-list {
  display: grid;
  gap: 4px;
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
}

.attachment-list a {
  display: block;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.record-actions {
  display: flex;
  gap: 10px;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.details-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.3fr) minmax(280px, 0.7fr);
}

.detail-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.panel-heading {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.panel-heading h2 {
  margin-bottom: 0;
}

.detail-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

.stat-row div {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat-row strong {
  display: block;
  font-size: 28px;
}

.stat-row span {
  color: var(--muted);
  font-size: 13px;
}

.file-drop {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
}

.selected-files {
  color: var(--primary);
  font-size: 14px;
  font-weight: 400;
}

.existing-files {
  margin-top: 20px;
}

.file-row {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px 0;
}

@media (max-width: 800px) {
  .site-header,
  .page-heading,
  .record-card {
    align-items: stretch;
    flex-direction: column;
  }

  .site-header,
  .page-heading {
    display: flex;
  }

  .form-grid,
  .filter-form,
  .record-card,
  dl,
  .details-grid,
  .detail-list,
  .stat-row {
    grid-template-columns: 1fr;
  }

  .record-actions,
  .form-actions,
  .filter-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
