:root {
  --bg: #0d1117;
  --bg-soft: #161b22;
  --bg-panel: #111827;
  --bg-elevated: #192231;
  --border: #2f3845;
  --border-strong: #465465;
  --text: #e6edf3;
  --text-soft: #c7d1db;
  --text-muted: #93a1b3;
  --accent: #5eead4;
  --accent-soft: rgba(94, 234, 212, 0.16);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.14);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.14);
  --topbar-bg: rgba(13, 17, 23, 0.78);
  --radius: 18px;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f8fb;
    --bg-soft: #ffffff;
    --bg-panel: #ffffff;
    --bg-elevated: #eef4f8;
    --border: #d5dee8;
    --border-strong: #aab8c7;
    --text: #152335;
    --text-soft: #30465c;
    --text-muted: #59687a;
    --accent: #00796b;
    --accent-soft: rgba(0, 121, 107, 0.12);
    --danger: #b42318;
    --danger-soft: rgba(180, 35, 24, 0.12);
    --warning: #9a6700;
    --warning-soft: rgba(154, 103, 0, 0.12);
    --success: #137333;
    --success-soft: rgba(19, 115, 51, 0.12);
    --topbar-bg: rgba(245, 248, 251, 0.94);
    --shadow: 0 14px 28px rgba(15, 23, 42, 0.08);
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 17px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(94, 234, 212, 0.12), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family: 'JetBrains Mono', 'SFMono-Regular', 'Consolas', monospace;
  line-height: 1.55;
}

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

a {
  color: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
}

.back-link {
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  padding: 0.48rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 1.4rem;
  max-width: 1520px;
  margin: 0 auto;
  padding: 1.4rem;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 5.4rem;
  display: grid;
  gap: 1rem;
}

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 100%),
    var(--bg-panel);
  box-shadow: var(--shadow);
}

.brand-panel,
.nav-panel,
.summary-panel,
.checklist-panel,
.section-card,
.stat-card {
  padding: 1.08rem;
}

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.brand-panel h1,
.section-card h3 {
  margin: 0;
}

.lede {
  margin: 0.6rem 0 0;
  color: var(--text-soft);
}

.nav-panel {
  display: grid;
  gap: 0.55rem;
}

.nav-link {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-soft);
  text-align: left;
  padding: 0.85rem 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.nav-link strong {
  display: block;
  margin-bottom: 0.18rem;
  color: var(--text);
  font-size: 0.92rem;
}

.nav-link span {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.nav-link:hover,
.nav-link:focus-visible {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.nav-link.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.checklist {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.8rem;
}

.checklist-item {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  border-radius: 14px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.03);
}

.checklist-item.ok {
  border-color: rgba(74, 222, 128, 0.3);
  background: var(--success-soft);
}

.checklist-item.warn {
  border-color: rgba(251, 191, 36, 0.3);
  background: var(--warning-soft);
}

.checklist-dot {
  width: 0.78rem;
  height: 0.78rem;
  border-radius: 999px;
  margin-top: 0.18rem;
  background: var(--warning);
  flex: 0 0 auto;
}

.checklist-item.ok .checklist-dot {
  background: var(--success);
}

.workspace {
  display: grid;
  gap: 1rem;
}

.banner {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
}

.banner__content {
  display: grid;
  gap: 0.8rem;
}

.banner__message {
  color: var(--text);
}

.banner.warning {
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.35);
}

.banner.error {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.35);
}

.banner.success {
  background: var(--success-soft);
  border-color: rgba(74, 222, 128, 0.35);
}

.view {
  display: none;
  gap: 1rem;
}

.view.is-active {
  display: grid;
}

.overview-actions-card {
  display: grid;
  gap: 1rem;
}

.first-run-card {
  display: grid;
  gap: 1rem;
}

.csv-example-card {
  display: grid;
  gap: 1rem;
}

.csv-example-card h3,
.csv-example-card p {
  margin: 0;
}

.csv-example-card .sample-preview-card h4 {
  font-size: 0.84rem;
}

.csv-example-card .sample-preview-card p {
  margin-bottom: 0.55rem;
  font-size: 0.76rem;
}

.csv-example-card table th,
.csv-example-card table td {
  font-size: 0.72rem;
  padding: 0.25rem 0.35rem;
}

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

.sample-preview-grid table {
  min-width: 0;
}

.sample-preview-card h4 {
  margin: 0 0 0.55rem;
}

.sample-preview-card p {
  margin: 0 0 0.75rem;
}

.stats-grid,
.three-up,
.two-up {
  display: grid;
  gap: 1rem;
}

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

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

.two-up {
  grid-template-columns: minmax(320px, 0.95fr) minmax(0, 1.05fr);
}

.stat-label {
  margin-bottom: 0.45rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.stat-value {
  font-size: 1.52rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 0.2rem;
}

.stat-note {
  color: var(--text-soft);
  font-size: 0.84rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head p {
  margin: 0.22rem 0 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.button-row {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 1rem;
}

.toolbar {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.field {
  display: grid;
  gap: 0.34rem;
}

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

.field span {
  color: var(--text-soft);
  font-size: 0.82rem;
}

.field--checkbox {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 100%;
}

.field--checkbox span {
  font-size: 0.88rem;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 2.7rem;
  padding: 0.75rem 0.82rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
}

textarea {
  min-height: 7rem;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button {
  min-height: 2.7rem;
  padding: 0.72rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.button--primary {
  border-color: transparent;
  background: var(--accent);
  color: #05221c;
  font-weight: 700;
}

.button--danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.35);
  color: var(--danger);
}

.button--small {
  min-height: 2.2rem;
  padding: 0.54rem 0.82rem;
  font-size: 0.82rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.84rem;
}

.logo-preview-wrap {
  min-height: 4rem;
  padding: 0.75rem;
  border-radius: 12px;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
}

.logo-preview-wrap img {
  max-width: 180px;
  max-height: 90px;
  border-radius: 10px;
  display: block;
  background: white;
}

.issue-list,
.note-list,
.search-results,
#winnerList {
  display: grid;
  gap: 0.75rem;
}

.issue-card,
.note-card,
.search-card,
.winner-card {
  padding: 0.9rem 1rem;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.issue-card.warning {
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.3);
}

.issue-card.success {
  background: var(--success-soft);
  border-color: rgba(74, 222, 128, 0.3);
}

.issue-card.error,
.note-card--danger {
  background: var(--danger-soft);
  border-color: rgba(248, 113, 113, 0.3);
}

.search-card,
.winner-card {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 74px minmax(0, 1fr) auto;
  align-items: center;
}

.winner-card.paid {
  background: var(--success-soft);
  border-color: rgba(74, 222, 128, 0.32);
}

.lot-pill {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 3rem;
  padding: 0.5rem 0.7rem;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.status-chip,
.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.75rem;
  white-space: nowrap;
}

.status-chip.available {
  color: var(--success);
  background: var(--success-soft);
  border-color: rgba(74, 222, 128, 0.28);
}

.status-chip.sold {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: rgba(251, 191, 36, 0.28);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 0.82rem 0.88rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  font-size: 0.85rem;
}

th {
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
}

tr:last-child td {
  border-bottom: none;
}

.empty-state,
.inspector-empty {
  padding: 1.1rem;
  border-radius: 14px;
  border: 1px dashed var(--border-strong);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-soft);
}

.layout-canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
}

.layout-canvas {
  position: relative;
  width: 100%;
  aspect-ratio: 8.5 / 11;
  border-radius: 14px;
  background:
    linear-gradient(to right, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.04) 1px, transparent 1px),
    white;
  background-size: 8.333% 4.166%;
  overflow: hidden;
  color: black;
}

.layout-block {
  position: absolute;
  border: 1px solid rgba(0, 121, 107, 0.18);
  background: rgba(0, 121, 107, 0.08);
  border-radius: 10px;
  padding: 0.35rem 0.45rem;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.layout-block.is-selected {
  border-color: #00796b;
  box-shadow: 0 0 0 2px rgba(0, 121, 107, 0.18);
}

.layout-block__meta {
  font-size: 0.58rem;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.2rem;
}

.layout-block__content {
  font-size: 0.8rem;
  line-height: 1.35;
  white-space: pre-wrap;
  overflow: hidden;
}

.layout-block--table {
  background: rgba(14, 116, 144, 0.08);
  border-style: dashed;
}

.layout-table-placeholder {
  width: 100%;
  height: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background:
    linear-gradient(to bottom, rgba(15, 23, 42, 0.1) 0 1px, transparent 1px 100%),
    linear-gradient(to right, rgba(15, 23, 42, 0.1) 0 1px, transparent 1px 100%);
  background-size: 100% 20%, 25% 100%;
  border-radius: 6px;
}

.document-preview {
  min-height: 20rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.03);
  overflow: auto;
}

.preview-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.preview-page,
.print-page {
  position: relative;
  width: min(100%, 740px);
  aspect-ratio: 8.5 / 11;
  margin: 0 auto 1rem;
  border-radius: 14px;
  border: 1px solid #cbd5e1;
  background: white;
  color: black;
  font-family: Georgia, 'Times New Roman', serif;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.preview-block,
.print-block {
  position: absolute;
  padding: 0.18rem 0.28rem;
  overflow: hidden;
  white-space: pre-wrap;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-family: Georgia, 'Times New Roman', serif;
}

.preview-table th,
.preview-table td {
  border: 1px solid #cbd5e1;
  padding: 0.32rem 0.42rem;
  color: black;
  font-size: 0.77rem;
}

.preview-table th {
  background: #edf2f7;
  font-size: 0.72rem;
}

.print-root {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(6px);
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal__card {
  width: min(720px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  box-shadow: var(--shadow);
}

.modal__card--wide {
  width: min(980px, 100%);
}

.modal-error {
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--text);
  font-size: 0.85rem;
}

.modal__head,
.modal__body,
.modal__foot {
  padding: 1rem 1.05rem;
}

.modal__head,
.modal__foot {
  border-bottom: 1px solid var(--border);
}

.modal__foot {
  border-top: 1px solid var(--border);
  border-bottom: none;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

@media (max-width: 1120px) {
  .app-shell,
  .stats-grid,
  .three-up,
  .two-up,
  .sample-preview-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }
}

@media (max-width: 760px) {
  html {
    font-size: 16px;
  }

  .app-shell,
  .topbar {
    padding: 1rem;
  }

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

  .search-card,
  .winner-card {
    grid-template-columns: 1fr;
  }
}

@media print {
  .topbar,
  .sidebar,
  .workspace > *,
  .banner {
    display: none !important;
  }

  body {
    background: white;
  }

  .app-shell {
    display: block;
    padding: 0;
    margin: 0;
    max-width: none;
  }

  .print-root {
    display: block !important;
  }

  .print-page {
    width: 100%;
    aspect-ratio: auto;
    min-height: 10.6in;
    margin: 0;
    border: none;
    border-radius: 0;
    box-shadow: none;
    page-break-after: always;
  }

  .print-page:last-child {
    page-break-after: auto;
  }
}
