:root {
  color-scheme: light;
  --ink: #15171a;
  --muted: #626a73;
  --line: #d9dee4;
  --surface: #ffffff;
  --panel: #f6f8fa;
  --nav: #20252b;
  --blue: #2468c9;
  --green: #237a44;
  --red: #b83a30;
  --amber: #a96705;
  --shadow: 0 14px 40px rgba(22, 28, 36, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f5;
  color: var(--ink);
}

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

button,
.button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 8px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
  white-space: nowrap;
}

button.secondary,
.button.secondary {
  background: white;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: var(--nav);
  color: white;
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 72px;
  padding: 14px 24px;
}

.topbar h1 {
  font-size: 1.2rem;
  letter-spacing: 0;
  margin: 0;
}

.topbar p {
  color: #c5ccd5;
  font-size: 0.9rem;
  margin: 4px 0 0;
}

.mode-pill {
  background: #f4c542;
  border-radius: 8px;
  color: #201b07;
  font-weight: 800;
  padding: 8px 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.control-panel {
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
}

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

.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title h2 {
  font-size: 0.9rem;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

.section-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.test-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 12px;
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.82rem;
  gap: 5px;
}

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

textarea {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  min-height: 280px;
  resize: vertical;
}

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

#message {
  border-left: 4px solid var(--blue);
  color: var(--muted);
  margin: 12px 0 0;
  padding: 6px 0 6px 10px;
}

#message[data-kind="error"] {
  border-color: var(--red);
  color: var(--red);
}

#message[data-kind="success"] {
  border-color: var(--green);
}

.stat-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-grid div,
.validation-stats div {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.stat-grid span,
.validation-stats span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.stat-grid strong,
.validation-stats strong {
  font-size: 1.15rem;
}

.tabs {
  background: white;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  padding: 12px 18px;
}

.tabs button {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.tabs button[data-active="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.panel-body {
  overflow: auto;
  padding: 18px;
}

.preview-toolbar,
.validation-toolbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.preview-toolbar div,
.validation-toolbar div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pdf-frame {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  height: calc(100vh - 170px);
  min-height: 520px;
  width: 100%;
}

.batch-list {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.batch-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.batch-card h3,
.paper-heading h3 {
  font-size: 1rem;
  margin: 0;
}

.batch-card p,
.paper-heading span {
  color: var(--muted);
  margin: 4px 0 0;
}

.batch-card ol {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}

.batch-card li {
  align-items: center;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(46px, 0.6fr) minmax(70px, 1fr) minmax(90px, 1fr);
  padding-top: 6px;
}

.batch-card small {
  color: var(--muted);
}

.validation-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(95px, 1fr));
  margin-bottom: 14px;
}

.validation-stats [data-status="ok"] {
  border-color: rgba(35, 122, 68, 0.35);
}

.validation-stats [data-status="issue"] {
  border-color: rgba(184, 58, 48, 0.35);
}

.validation-stats [data-status="reprint"] {
  border-color: rgba(169, 103, 5, 0.35);
}

.sheet-validation {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(360px, 1fr));
  overflow-x: auto;
}

.paper-side {
  min-width: 360px;
}

.paper-heading {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.paper {
  aspect-ratio: 530 / 750;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  position: relative;
}

.page-slot {
  background: #edf4fb;
  border: 2px solid #323840;
  border-radius: 3px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
  overflow: hidden;
  padding: 8px;
  position: absolute;
  white-space: normal;
}

.page-slot span {
  display: block;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.page-slot small {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
}

.page-slot[data-status="ok"] {
  background: #e5f3ea;
  border-color: var(--green);
}

.page-slot[data-status="issue"] {
  background: #fdebea;
  border-color: var(--red);
}

.page-slot[data-status="reprint"] {
  background: #fff3d8;
  border-color: var(--amber);
}

.page-slot[data-status="blank"] {
  background: #f1f2f4;
  border-color: #c9ced6;
  color: #7a828c;
}

.data-view {
  background: #111418;
  border-radius: 8px;
  color: #dfe7ef;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  margin: 0;
  min-height: calc(100vh - 160px);
  overflow: auto;
  padding: 16px;
  white-space: pre-wrap;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .control-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sheet-validation {
    grid-template-columns: minmax(360px, 1fr);
  }
}

@media print {
  .topbar,
  .control-panel,
  .tabs,
  .preview-toolbar,
  .validation-toolbar {
    display: none;
  }

  .layout,
  .workspace {
    display: block;
  }
}
