:root {
  color-scheme: light;
  --ink: #222520;
  --muted: #5b635d;
  --paper: #f8f7f1;
  --panel: #ffffff;
  --line: #d8ddd3;
  --green: #2f6f5e;
  --blue: #365f87;
  --gold: #a96f1c;
  --plum: #7b526f;
  --danger: #9f3f40;
  --ok: #2e7250;
  --shadow: 0 18px 44px rgba(35, 39, 35, 0.12);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(54, 95, 135, 0.08), transparent 32%),
    linear-gradient(180deg, #eef5f2 0, var(--paper) 44%, #eef1f6 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  cursor: pointer;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px;
  border: 1px solid rgba(34, 37, 32, 0.12);
  border-radius: 8px;
  background: rgba(248, 247, 241, 0.94);
  box-shadow: 0 12px 32px rgba(34, 37, 32, 0.08);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: white;
  background: var(--green);
}

.brand-mark svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.3;
}

.eyebrow {
  display: block;
  margin: 0 0 5px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 820;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-title {
  display: block;
  font-size: 1.14rem;
  font-weight: 860;
}

.top-actions,
.command-actions,
.form-actions,
.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.top-actions {
  justify-content: flex-end;
}

.top-actions a,
.primary-button,
.secondary-button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 13px;
  font-weight: 790;
}

.top-actions a,
.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: white;
}

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

.inline-link {
  display: inline-flex;
  width: fit-content;
  color: var(--blue);
  font-weight: 790;
  text-decoration: underline;
  text-underline-offset: 3px;
}

main {
  padding: 16px 0 34px;
}

.command-band,
.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 0;
}

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

h1 {
  max-width: 980px;
  margin-bottom: 0;
  font-size: clamp(2rem, 4.4vw, 4.8rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2vw, 2rem);
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.12rem;
}

.data-boundary,
.boundary-note {
  border: 1px solid rgba(169, 111, 28, 0.28);
  border-radius: 8px;
  background: #fff8e8;
}

.data-boundary {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 14px;
  color: #5a431a;
}

.boundary-note {
  margin: 0 0 16px;
  padding: 12px;
  color: #604916;
  line-height: 1.5;
}

.tool-grid,
.signal-grid,
.operations-grid,
.viewer-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(410px, 0.95fr);
  gap: 16px;
  align-items: start;
}

.signal-grid,
.operations-grid {
  margin-top: 16px;
}

.operations-grid {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 0.75fr) minmax(280px, 0.85fr);
}

.editor-panel,
.preview-panel,
.family-panel,
.queue-panel,
.utility-panel,
.dignity-card {
  border: 1px solid rgba(34, 37, 32, 0.12);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.editor-panel,
.preview-panel,
.family-panel,
.queue-panel,
.utility-panel {
  padding: 16px;
}

.panel-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.compact-field {
  min-width: 180px;
}

.form-grid,
.role-note-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.role-note-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 780;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  color: var(--ink);
  background: white;
}

textarea {
  min-height: 76px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(54, 95, 135, 0.28);
  outline-offset: 2px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.check-row input {
  width: auto;
  margin-top: 3px;
}

.dignity-card {
  overflow: hidden;
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
  color: white;
  background: #284b45;
}

.card-head h2 {
  color: white;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
  align-content: start;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 8px;
  color: #f8f7f1;
  background: rgba(255, 255, 255, 0.16);
  font-size: 0.76rem;
  font-weight: 820;
}

.pill.warning {
  color: #381d1d;
  background: #ffd8d8;
}

.pill.ok {
  color: #0f3221;
  background: #cdeed8;
}

.card-body {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.card-line {
  display: grid;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
  background: #fcfcf9;
}

.card-line span {
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.card-line strong,
.card-line p {
  margin: 0;
  line-height: 1.45;
}

.qr-panel {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.copy-row {
  flex-wrap: nowrap;
}

.copy-row input {
  min-width: 0;
}

.queue-count {
  border-radius: 999px;
  padding: 5px 9px;
  color: white;
  background: var(--plum);
  font-size: 0.8rem;
  font-weight: 830;
}

.queue-list {
  display: grid;
  gap: 10px;
}

.queue-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfcf9;
}

.queue-item.flagged {
  border-color: rgba(159, 63, 64, 0.44);
  background: #fff5f4;
}

.queue-item p {
  color: var(--muted);
  line-height: 1.5;
}

.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tiny-button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: white;
  font-weight: 790;
}

.danger-text {
  color: var(--danger);
  font-weight: 820;
}

.check-list,
.step-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.check-list li,
.step-list li {
  margin-bottom: 9px;
}

.viewer-mode {
  padding-top: 4px;
}

@media (max-width: 980px) {
  .topbar,
  .command-band,
  .section-heading,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .command-actions {
    justify-content: flex-start;
  }

  .tool-grid,
  .signal-grid,
  .operations-grid,
  .viewer-grid,
  .form-grid,
  .role-note-grid {
    grid-template-columns: 1fr;
  }

  .compact-field {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    position: static;
  }

  .data-boundary {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: clamp(2rem, 12vw, 3rem);
  }

  .copy-row {
    flex-wrap: wrap;
  }
}

@media print {
  body {
    background: white;
  }

  .topbar,
  .command-band,
  .data-boundary,
  .editor-panel,
  .family-panel,
  .queue-panel,
  .operations-grid,
  .qr-panel,
  .preview-panel > .panel-heading,
  .utility-panel,
  .secondary-button,
  .primary-button,
  .inline-link {
    display: none !important;
  }

  .app-shell,
  main,
  .workspace,
  .tool-grid,
  .viewer-grid {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .preview-panel,
  .dignity-card {
    border: 0;
    box-shadow: none;
  }

  .dignity-card {
    page-break-inside: avoid;
  }
}
