:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f1f3f7;
  --surface-sunken: #e7ebf1;
  --ink: #171c24;
  --ink-soft: #333b47;
  --muted: #5a6472;
  --line: #dce1e8;
  --line-strong: #c3cbd6;
  --grid-line: #ccd4df;
  --grid-line-strong: #adb9c8;
  --accent: #17408c;
  --accent-hover: #102f68;
  --accent-soft: #e9eff9;
  --accent-line: #c2d0e8;
  --danger: #a12b22;
  --danger-soft: #fbeeec;
  --danger-line: #ebc7c3;
  --warning: #855100;
  --warning-soft: #fdf3e1;
  --info: #1e4a8c;
  --info-soft: #eef3fb;
  --focus: #17408c;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(18, 28, 45, 0.06);
  --shadow: 0 1px 2px rgba(18, 28, 45, 0.05), 0 12px 32px rgba(18, 28, 45, 0.07);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.015em; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -56px;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 650;
  transition: top 0.15s ease;
}

.skip-link:focus { top: 12px; color: #fff; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  min-height: var(--topbar-h);
  padding: 10px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.brand > span:last-child { min-width: 0; }

.brand-logo {
  height: 44px;
  width: auto;
  flex: none;
  display: block;
}

.brand-rule {
  width: 1px;
  height: 30px;
  background: var(--line-strong);
  flex: none;
  margin: 0 2px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title {
  display: block;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  display: block;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.topbar-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.topbar-link:hover {
  border-color: var(--line);
  color: var(--ink);
  background: var(--surface);
}

.shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 36px 24px 80px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}

.page-head h1 {
  font-size: clamp(27px, 3.4vw, 36px);
  line-height: 1.1;
  letter-spacing: -0.025em;
  margin: 0 0 7px;
}

.lede {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
  max-width: 68ch;
}

.page-meta {
  font-size: 12px;
  color: var(--muted);
  padding-bottom: 5px;
  white-space: nowrap;
}

.input, .select, .textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px;
  line-height: 1.4;
  min-height: 44px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.input:hover, .select:hover, .textarea:hover { border-color: #a8b8ad; }

.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 64, 140, 0.16);
}

.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger);
  background: #fffbfa;
}

.textarea {
  min-height: 110px;
  resize: vertical;
  font-size: 15px;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 44px;
  padding: 10px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-primary:disabled { background: #9fafcb; cursor: default; }

.btn-ghost {
  background: var(--surface);
  border-color: var(--line-strong);
  color: var(--ink);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-hover); }

.btn-danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }

.btn-sm {
  min-height: 36px;
  padding: 7px 11px;
  font-size: 12.5px;
  border-radius: var(--radius-sm);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 34px 0 14px;
  flex-wrap: wrap;
}

.section-heading h2 {
  font-size: 20px;
  margin: 0;
  letter-spacing: -0.015em;
}

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

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

.card-grid:focus { outline: none; }

.start-msg {
  color: var(--danger);
  font-size: 13px;
  margin: 12px 0 0;
}

.start-msg:empty { display: none; }

.instrument-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.instrument-card:hover {
  border-color: var(--accent-line);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.instrument-card .meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.instrument-card .meta .code {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border: 1px solid var(--accent-line);
  padding: 2px 7px;
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: 10.5px;
}

.instrument-card h3 {
  font-size: 17px;
  line-height: 1.32;
  margin: 0;
}

.instrument-card .audience {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
  min-height: 36px;
}

.instrument-card .purpose {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.instrument-card .footer {
  margin-top: auto;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.instrument-card .footer .small {
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.footer-note {
  margin-top: 48px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12.5px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 26, 19, 0.55);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  padding: 26px;
  box-shadow: 0 24px 70px rgba(8, 20, 13, 0.28);
}

.modal h3 { margin: 0 0 6px; font-size: 19px; }

.modal p {
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 0 18px;
  line-height: 1.5;
}

.modal .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.modal-lg { max-width: 720px; max-height: 88vh; overflow: auto; }

.paste-area {
  min-height: 190px;
  font-family: var(--font-mono);
  font-size: 13px;
  white-space: pre;
}

.field-label {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  margin-bottom: 6px;
  color: var(--ink);
}

.field-hint {
  font-size: 12.5px;
  color: var(--muted);
  margin: 5px 0 0;
  line-height: 1.45;
}

.hidden { display: none !important; }
[hidden] { display: none !important; }

.form-shell {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 100px;
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  gap: 30px;
  align-items: start;
}

.form-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 18px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.side-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}

.side-card h4 {
  margin: 0 0 10px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 52vh;
  overflow: auto;
  margin: 0 -6px;
  padding: 0 6px;
}

.toc a {
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 7px 8px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 2px solid transparent;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 9px;
  gap: 8px;
  align-items: start;
  line-height: 1.35;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.toc a:hover { background: var(--accent-soft); color: var(--accent-hover); }

.toc a.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
  border-left-color: var(--accent);
  font-weight: 650;
}

.toc a .toc-id {
  font-size: 10px;
  font-weight: 700;
  color: #7f8c9f;
  min-width: 26px;
  font-variant-numeric: tabular-nums;
  padding-top: 1px;
}

.toc a.active .toc-id { color: var(--accent); }

.toc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  margin-top: 5px;
  justify-self: end;
}

.toc a[data-state="partial"] .toc-dot { background: var(--warning); }
.toc a[data-state="complete"] .toc-dot { background: var(--accent); }

.progress-track {
  height: 8px;
  background: var(--surface-sunken);
  border-radius: 999px;
  overflow: hidden;
  margin: 10px 0 7px;
}

.progress-fill {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.progress-text {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  line-height: 1.5;
}

.form-main { min-width: 0; }
.form-main:focus { outline: none; }

.form-head {
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.form-head > div > .sub:first-child {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.form-head h1 {
  font-size: clamp(24px, 2.8vw, 32px);
  line-height: 1.15;
  margin: 0 0 10px;
}

.form-head .sub { color: var(--muted); font-size: 13px; }

.status-line {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.status-pill {
  font-size: 10.5px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--warning-soft);
  color: var(--warning);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

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

.save-state {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.save-state.saving { color: var(--warning); }
.save-state.error { color: var(--danger); }

.intro-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 15px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.intro-card summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 14px;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  list-style: none;
}

.intro-card summary::-webkit-details-marker { display: none; }

.intro-card summary::after {
  content: "+";
  font-size: 18px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1;
}

.intro-card[open] summary::after { content: "−"; }

.intro-card p {
  font-size: 13.5px;
  color: var(--muted);
  margin: 12px 0 0;
  max-width: 80ch;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 24px 24px;
  margin-bottom: 16px;
  scroll-margin-top: calc(var(--topbar-h) + 18px);
  box-shadow: var(--shadow-sm);
}

.form-section h2 {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16.5px;
  margin: 0;
  line-height: 1.3;
}

.section-id {
  flex: none;
  min-width: 32px;
  height: 32px;
  padding: 0 7px;
  border-radius: 7px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent-hover);
  display: inline-grid;
  place-items: center;
  font-size: 11.5px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.section-note {
  font-size: 12.5px;
  color: var(--muted);
  margin: 10px 0 0;
  max-width: 92ch;
  line-height: 1.5;
}

.fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  margin-top: 20px;
}

.field { min-width: 0; }
.field.span-2 { grid-column: auto; }

.field:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
  border-radius: 4px;
}

.field > label, .field > .group-label {
  display: block;
  font-size: 13.5px;
  font-weight: 650;
  margin-bottom: 6px;
  line-height: 1.4;
  color: var(--ink);
}

.req { color: var(--accent); margin-left: 3px; font-weight: 800; }

.field-static {
  background: var(--surface-muted);
  border-left: 3px solid var(--line-strong);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.choices {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.choice {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  border-radius: 8px;
  min-height: 44px;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.12s, background 0.12s;
}

.choice:hover { border-color: var(--accent-line); background: #fbfdfb; }

.choice input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
  flex: none;
}

.choice.checked {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
  font-weight: 600;
}

.field-invalid > .input,
.field-invalid > .select,
.field-invalid > .textarea {
  border-color: var(--danger);
}

.field-invalid > label,
.field-invalid > .group-label { color: var(--danger); }

.field-invalid .choice { border-color: var(--danger-line); }

.field-error {
  color: var(--danger) !important;
  font-weight: 550;
}

.grid-tools {
  display: flex;
  justify-content: flex-end;
  margin: 2px 0 7px;
}

.grid-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
  max-height: 600px;
  background: var(--surface);
}

table.data-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 760px;
  font-size: 12.5px;
}

table.data-grid th {
  position: sticky;
  top: 0;
  background: #eef2f8;
  color: #465264;
  font-weight: 700;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--grid-line-strong);
  border-right: 1px solid var(--grid-line);
  white-space: nowrap;
  z-index: 2;
}

table.data-grid th:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: #e5eaf2;
  min-width: 230px;
  border-right: 1px solid var(--grid-line-strong);
}

table.data-grid th:last-child,
table.data-grid td:last-child { border-right: 0; }

table.data-grid td {
  border-bottom: 1px solid var(--grid-line);
  border-right: 1px solid var(--grid-line);
  padding: 0;
  background: var(--surface);
  vertical-align: middle;
}

table.data-grid td:first-child {
  position: sticky;
  left: 0;
  background: var(--surface);
  padding: 9px 10px;
  color: var(--ink-soft);
  font-weight: 500;
  z-index: 1;
  min-width: 230px;
  max-width: 300px;
  line-height: 1.4;
  border-right: 1px solid var(--grid-line-strong);
}

table.data-grid tbody tr:not(.total-row):hover td { background: #fafbfd; }

table.data-grid tr.total-row td {
  background: #eaf0fa;
  font-weight: 700;
  color: var(--accent-hover);
  border-top: 1px solid var(--accent-line);
  border-bottom: 1px solid var(--accent-line);
}

table.data-grid tr.total-row td:first-child { background: #e1e9f7; }

.cell-input {
  width: 100%;
  min-width: 88px;
  min-height: 40px;
  border: 0;
  background: transparent;
  padding: 9px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  font-variant-numeric: tabular-nums;
}

.cell-input:hover:not([readonly]) { background: #fafbfd; }

.cell-input.num { text-align: right; }

.cell-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  padding: 8px 10px;
  min-width: 160px;
}

.cell-checks label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-soft);
  white-space: nowrap;
}

.cell-checks input { accent-color: var(--accent); margin: 0; }

.cell-input.text { text-align: left; min-width: 160px; }

.cell-input:focus {
  background: #f2f6fd;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cell-input[readonly] { color: var(--accent-hover); font-weight: 650; }
.cell-input.invalid { background: var(--danger-soft); }

table.data-grid td select.cell-input,
table.data-grid td select {
  min-width: 165px;
  min-height: 40px;
  appearance: none;
  background-color: #f7f9fc;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%235b6b62' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 11px 7px;
  border: 0;
  padding: 9px 30px 9px 10px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
}

table.data-grid td select.cell-input:hover,
table.data-grid td select:hover { background-color: #f0f4fb; }

table.data-grid td select.cell-input:focus,
table.data-grid td select:focus {
  background-color: #ecf2fc;
  box-shadow: inset 0 0 0 2px var(--accent);
}

.grid-hint {
  font-size: 11.5px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.45;
}

.repeat-actions { display: flex; gap: 8px; margin-top: 10px; }

td.row-actions { text-align: center; padding: 4px 8px; }

.icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.icon-btn:hover { border-color: var(--danger-line); color: var(--danger); background: var(--danger-soft); }

.file-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.file-row input[type=file] { font-size: 13px; color: var(--muted); max-width: 100%; }
.file-link { font-size: 13px; font-weight: 600; }

.checks-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.checks-card h3 { margin: 0 0 10px; font-size: 13px; }

.check-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  font-size: 12.5px;
  padding: 8px 0;
  border-top: 1px dashed var(--line);
  line-height: 1.45;
}

.check-row:first-of-type { border-top: 0; }

.check-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #9cabc0;
  margin-top: 5px;
  flex: none;
}

.check-row.ok .check-dot { background: var(--accent); }
.check-row.bad .check-dot { background: var(--danger); }
.check-row.bad { color: var(--danger); }

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-top: 20px;
  box-shadow: var(--shadow-sm);
}

.form-actions .note { font-size: 12.5px; color: var(--muted); max-width: 56ch; line-height: 1.5; }

.action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.action-row.centered { justify-content: center; }

.error-box {
  background: var(--danger-soft);
  border: 1px solid var(--danger-line);
  border-left: 4px solid var(--danger);
  color: #741b15;
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}

.error-box:focus { outline: none; }
.error-box strong { font-size: 14px; }
.error-box ul { margin: 8px 0 0; padding-left: 18px; }
.error-box li { margin: 5px 0; }
.error-box a { color: #741b15; font-weight: 650; }
.error-box a:focus-visible { outline-color: var(--danger); }

.notice-box {
  background: var(--info-soft);
  border: 1px solid #cdddf3;
  color: var(--info);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  font-size: 13px;
  margin-bottom: 16px;
}

.submitted .repeat-actions,
.submitted td.row-actions,
.submitted .file-row input[type=file],
.submitted .grid-hint,
.submitted .grid-tools {
  display: none !important;
}

.success-wrap {
  max-width: 640px;
  margin: 64px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 38px;
  text-align: center;
  box-shadow: var(--shadow);
}

.success-mark {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 27px;
  margin: 0 auto 18px;
}

.success-wrap h1 { font-size: 25px; margin: 0 0 8px; }
.success-wrap p { color: var(--muted); font-size: 14px; }

.success-meta {
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0;
}

.admin-gate {
  max-width: 430px;
  margin: 76px auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.admin-gate h1 { font-size: 22px; margin: 0 0 8px; }
.admin-gate p { color: var(--muted); font-size: 13.5px; margin: 0 0 18px; }

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

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}

.stat .num {
  font-size: 25px;
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .lbl {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.toolbar .select { width: auto; min-width: 175px; }
.toolbar .input { width: auto; }

.admin-table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  box-shadow: var(--shadow-sm);
}

table.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }

table.admin-table th {
  text-align: left;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: #f1f4f9;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.admin-table td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf0f5;
  vertical-align: top;
}

table.admin-table tr:last-child td { border-bottom: 0; }
table.admin-table tbody tr:hover td { background: #fafbfd; }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
}

.badge.submitted { background: var(--info-soft); color: var(--info); }
.badge.draft { background: var(--warning-soft); color: var(--warning); }

.mono { font-family: var(--font-mono); font-size: 11.5px; }

.detail-section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.detail-section h4 { margin: 0 0 8px; font-size: 13px; display: flex; align-items: center; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 5px 16px; font-size: 12.5px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; word-break: break-word; }
.detail-grid .full { grid-column: 1 / -1; }

.detail-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; }
.detail-table th, .detail-table td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
.detail-table th { background: #f1f4f9; font-weight: 650; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 44px 20px;
}

@media (max-width: 1080px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-shell { grid-template-columns: 1fr; }
  .form-sidebar { position: static; order: 2; }
  .form-sidebar .side-card.toc-card { display: none; }
  .stats-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .topbar-inner, .shell, .form-shell { padding-left: 16px; padding-right: 16px; }
  .brand-logo { height: 36px; }
  .brand-rule { height: 26px; }
  .brand-title { font-size: 13px; }
  .brand-sub { font-size: 11px; }
  .topbar-actions { gap: 6px; }
  .save-state { display: none; }
  .card-grid { grid-template-columns: 1fr; }
  .section-heading { margin-top: 28px; }
  .form-section { padding: 18px 16px; }
  .form-head { padding-bottom: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt { margin-top: 6px; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .success-wrap { margin: 32px 16px; padding: 26px 20px; }
  .topbar-link { padding: 8px; }
}

@media (max-width: 520px) {
  #top-save-draft { display: none; }
  .brand-rule { display: none; }
  .back-label { display: none; }
  .back-link { padding: 8px 10px; }
}

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

@media print {
  .topbar, .form-sidebar, .form-actions, .checks-card, .skip-link, .grid-tools { display: none !important; }
  body { background: #fff; }
  .form-shell { grid-template-columns: 1fr; padding: 0; max-width: none; }
  .form-section, .intro-card { break-inside: avoid; box-shadow: none; border-color: #ccc; }
  .form-main { width: 100%; }
}
