:root {
  color-scheme: light;
  --background: #f2f5f3;
  --surface: #ffffff;
  --surface-muted: #f7f9f8;
  --ink: #16201d;
  --muted: #5e6d68;
  --line: #d9e1de;
  --brand: #0b6b57;
  --brand-dark: #074b3e;
  --brand-soft: #dff1eb;
  --info: #2563a9;
  --info-soft: #e8f1fb;
  --success: #18734e;
  --success-soft: #e4f5ec;
  --warning: #94600a;
  --warning-soft: #fff2d3;
  --danger: #a12c35;
  --danger-soft: #fdebed;
  --shadow: 0 16px 40px rgb(23 48 41 / 8%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 5% 0%, rgb(104 190 162 / 14%), transparent 28rem),
    var(--background);
}

button,
input,
select {
  font: inherit;
}

button,
summary,
select,
input[type="file"] {
  cursor: pointer;
}

button {
  min-height: 2.6rem;
  padding: 0.65rem 1rem;
  border: 1px solid var(--brand);
  border-radius: 0.55rem;
  color: #fff;
  font-weight: 700;
  background: var(--brand);
}

button:hover:not(:disabled) {
  background: var(--brand-dark);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgb(11 107 87 / 25%);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.button-secondary {
  color: var(--brand-dark);
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.button-danger {
  color: var(--danger);
  border-color: #e8bfc3;
  background: var(--danger-soft);
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.65rem 1rem;
  color: #fff;
  background: var(--brand-dark);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
  padding: 2rem max(1.25rem, calc((100vw - 1280px) / 2));
  color: #f7fffc;
  background: linear-gradient(120deg, #073f35, #0c705b 58%, #14846a);
  box-shadow: var(--shadow);
}

.site-header h1,
.site-header p {
  margin: 0;
}

.site-header h1 {
  margin-top: 0.35rem;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
}

.eyebrow,
.section-kicker {
  color: #bce8d9;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.subtitle {
  margin-top: 0.6rem !important;
  color: #d9eee7;
}

.token-panel {
  width: min(28rem, 100%);
  padding: 0.75rem 1rem;
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 0.75rem;
  background: rgb(255 255 255 / 9%);
}

.token-panel summary {
  font-weight: 750;
}

.token-form {
  margin-top: 1rem;
}

.token-form label,
.field-hint {
  font-size: 0.84rem;
}

.token-form input {
  flex: 1 1 12rem;
}

.token-form .field-hint {
  color: #d9eee7;
}

.inline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.notice {
  position: fixed;
  z-index: 50;
  top: 1rem;
  left: 50%;
  width: min(90vw, 44rem);
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -1rem);
  transition: 150ms ease;
}

.notice.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.notice.notice-error {
  color: var(--danger);
  border-color: #e8bfc3;
  background: var(--danger-soft);
}

.notice.notice-success {
  color: var(--success);
  border-color: #b8dec9;
  background: var(--success-soft);
}

.page-shell {
  width: min(1280px, calc(100% - 2rem));
  margin: 1.5rem auto 3rem;
}

.panel {
  padding: clamp(1rem, 2.5vw, 1.6rem);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel + .panel,
.task-grid + .panel {
  margin-top: 1.25rem;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.task-grid .panel + .panel {
  margin-top: 0;
}

.panel h2,
.section-kicker {
  margin: 0;
}

.panel h2 {
  margin-top: 0.25rem;
  font-size: 1.28rem;
}

.panel .section-kicker {
  color: var(--brand);
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.2rem;
}

.summary-card {
  min-height: 7rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--surface-muted);
}

.summary-card span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.summary-card strong {
  display: block;
  margin-top: 0.65rem;
  font-size: 1.85rem;
}

.summary-info {
  background: var(--info-soft);
}

.summary-success {
  background: var(--success-soft);
}

.summary-warning {
  background: var(--warning-soft);
}

.summary-danger {
  border-color: #e8bfc3;
  background: var(--danger-soft);
}

.stacked-form {
  display: grid;
  gap: 0.65rem;
  margin-top: 1.2rem;
}

.stacked-form label,
.filter-form label {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

input,
select {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid #bdc9c5;
  border-radius: 0.55rem;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  padding: 0.45rem;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.batch-preview,
.batch-progress {
  padding: 0.85rem;
  border: 1px dashed #b8c7c1;
  border-radius: 0.6rem;
  color: var(--muted);
  background: var(--surface-muted);
}

.batch-preview p,
.batch-progress p {
  margin: 0.25rem 0;
}

.batch-progress {
  margin-top: 1rem;
  border-style: solid;
}

.batch-count-hint {
  margin-top: 0.8rem;
}

.records-heading {
  align-items: end;
}

.filter-form {
  display: grid;
  grid-template-columns: auto minmax(9rem, 13rem) auto;
  align-items: center;
  gap: 0.55rem;
}

.table-wrap {
  margin-top: 1.25rem;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.8rem 0.65rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  background: var(--surface-muted);
}

.empty-cell,
.loading-cell {
  padding: 2rem;
  color: var(--muted);
  text-align: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  background: #edf1ef;
  white-space: nowrap;
}

.status-info {
  color: var(--info);
  background: var(--info-soft);
}

.status-success {
  color: var(--success);
  background: var(--success-soft);
}

.status-warning {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.row-warning {
  max-width: 17rem;
  margin: 0.45rem 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.4;
}

.action-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.action-group button {
  min-height: 2rem;
  padding: 0.35rem 0.55rem;
  font-size: 0.78rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

dialog {
  width: min(760px, calc(100% - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 1.4rem;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 70px rgb(10 32 25 / 25%);
  overflow: auto;
}

.batch-detail-dialog {
  width: min(1180px, calc(100% - 2rem));
}

dialog::backdrop {
  background: rgb(5 24 19 / 48%);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  margin: 0.25rem 0 0;
}

.batch-append-section,
.batch-records-section {
  margin-top: 1.25rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
}

.batch-append-section h3,
.batch-records-section h3 {
  margin: 0;
}

.batch-append-section .stacked-form {
  margin-top: 0.85rem;
}

.detail-code {
  margin: 1rem 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.1rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}

.detail-item {
  padding: 0.7rem;
  border-radius: 0.55rem;
  background: var(--surface-muted);
}

.detail-item dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 750;
}

.detail-item dd {
  margin: 0.3rem 0 0;
  overflow-wrap: anywhere;
}

.danger-callout,
.warning-callout {
  padding: 0.9rem;
  border: 1px solid #e8bfc3;
  border-radius: 0.6rem;
  color: var(--danger);
  font-weight: 750;
  background: var(--danger-soft);
}

.warning-callout {
  color: var(--warning);
  border-color: #ecd18e;
  background: var(--warning-soft);
}

.attempt-list {
  display: grid;
  gap: 0.65rem;
  padding: 0;
  list-style: none;
}

.attempt-card {
  padding: 0.75rem;
  border-left: 3px solid var(--line);
  background: var(--surface-muted);
}

.attempt-card p {
  margin: 0.25rem 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .site-header {
    flex-direction: column;
  }

  .token-panel {
    width: 100%;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100% - 1rem, 1280px);
    margin-top: 0.5rem;
  }

  .site-header {
    padding: 1.25rem 1rem;
  }

  .task-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-top: 0.75rem;
  }

  .task-grid .panel + .panel {
    margin-top: 0;
  }

  .panel + .panel,
  .task-grid + .panel {
    margin-top: 0.75rem;
  }

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

  .summary-card {
    min-height: 5.7rem;
  }

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

  .filter-form {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
