:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --ink: #101214;
  --muted: #69717d;
  --line: #dfe3e8;
  --line-strong: #c6ccd4;
  --accent: #5c4ee5;
  --accent-dark: #3f35b8;
  --success: #0d7f56;
  --warning: #a05a00;
  --danger: #b42318;
  --shadow: 0 12px 32px rgba(16, 18, 20, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.auth-body {
  background:
    linear-gradient(180deg, rgba(16, 18, 20, 0.04), rgba(16, 18, 20, 0) 280px),
    #f7f8fa;
}

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

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  border-right: 1px solid #252a31;
  background: #101214;
  color: #fff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 750;
  letter-spacing: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  font-size: 16px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav a,
.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-weight: 650;
  cursor: pointer;
  line-height: 1.2;
}

.nav a {
  justify-content: flex-start;
  color: #d8dee7;
}

.nav a:hover {
  background: #1c2128;
  color: #fff;
}

.account {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid #252a31;
}

.cash {
  color: #b9b2ff;
  font-weight: 700;
}

.sidebar .muted {
  color: #9aa4b2;
}

.sidebar .button.ghost {
  color: #fff;
  background: #171b21;
  border-color: #303742;
}

.main {
  width: min(1240px, 100%);
  padding: 32px;
}

.public-main {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  max-width: 46ch;
  color: var(--muted);
  font-size: 17px;
}

.muted {
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

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

.detail-grid {
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
}

.print-grid {
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.compact {
  display: grid;
  align-content: start;
  gap: 12px;
}

.auth-panel {
  width: min(1120px, 100%);
  min-height: 640px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  align-items: center;
  gap: 48px;
}

.auth-copy {
  display: grid;
  align-content: center;
  gap: 16px;
}

.public-brand {
  width: fit-content;
  margin-bottom: 28px;
  font-size: 18px;
}

.auth-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.auth-facts span {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  color: #2d333a;
  font-size: 13px;
  font-weight: 750;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.auth-panel .form-panel {
  border-top: 4px solid var(--accent);
}

.form-panel p {
  display: grid;
  gap: 6px;
  margin: 0;
}

.form-panel-field {
  display: grid;
  gap: 6px;
}

label {
  color: #2d333a;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}

select[multiple] {
  min-height: 96px;
}

textarea {
  min-height: 92px;
  resize: vertical;
}

.button.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.button.primary:hover {
  background: var(--accent-dark);
}

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

.button.primary:disabled:hover {
  background: var(--accent);
}

.button.ghost {
  background: #fff;
  border-color: var(--line-strong);
}

.button.danger {
  color: var(--danger);
  background: #fff;
  border-color: #f0b8b2;
}

.button.full {
  width: 100%;
}

.button.small {
  min-height: 30px;
  padding: 6px 10px;
  font-size: 13px;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.message {
  padding: 11px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.message.success {
  border-color: #b9e6d4;
  color: var(--success);
}

.message.error {
  border-color: #f0b8b2;
  color: var(--danger);
}

.message.info {
  border-color: #c9d6ff;
  color: #30459f;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status,
.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7f8fa;
  color: #2d333a;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status.ready,
.status.active,
.status.completed {
  color: var(--success);
  background: #ecfdf5;
  border-color: #b9e6d4;
}

.status.processing,
.status.uploaded,
.status.held,
.status.maintenance {
  color: var(--warning);
  background: #fff8ed;
  border-color: #ffd89c;
}

.status.error,
.status.failed,
.status.paused,
.tag.danger {
  color: var(--danger);
  background: #fff5f4;
  border-color: #f0b8b2;
}

.status.needs_review {
  color: #30459f;
  background: #f0f3ff;
  border-color: #c9d6ff;
}

.filters {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 18px;
}

.filters label {
  min-width: 180px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td a {
  font-weight: 700;
}

.empty {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.metric {
  font-size: 44px;
  line-height: 1;
  font-weight: 800;
}

.small-metric {
  font-size: 28px;
  min-width: 90px;
  text-align: right;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.preview-grid img {
  width: 100%;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.preview-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.preview-strip img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.paper-preview {
  position: relative;
  width: min(100%, 920px);
  overflow: hidden;
  border: 2px solid #252a31;
  border-radius: 6px;
  background:
    linear-gradient(to right, rgba(16, 18, 20, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(16, 18, 20, 0.08) 1px, transparent 1px),
    #fff;
  background-size: 8.333% 8.333%;
}

.paper-preview.has-overflow::before,
.paper-preview.has-overflow::after {
  content: "";
  position: absolute;
  inset: -8%;
  z-index: 8;
  pointer-events: none;
}

.paper-preview.has-overflow::before {
  inset: 0;
  background: rgba(180, 35, 24, 0.16);
}

.paper-preview.has-overflow::after {
  inset: 8%;
  background:
    linear-gradient(42deg, transparent calc(50% - 6px), var(--danger) calc(50% - 6px), var(--danger) calc(50% + 6px), transparent calc(50% + 6px)),
    linear-gradient(-42deg, transparent calc(50% - 6px), var(--danger) calc(50% - 6px), var(--danger) calc(50% + 6px), transparent calc(50% + 6px)),
    linear-gradient(42deg, transparent calc(50% - 9px), rgba(255, 255, 255, 0.78) calc(50% - 9px), rgba(255, 255, 255, 0.78) calc(50% + 9px), transparent calc(50% + 9px)),
    linear-gradient(-42deg, transparent calc(50% - 9px), rgba(255, 255, 255, 0.78) calc(50% - 9px), rgba(255, 255, 255, 0.78) calc(50% + 9px), transparent calc(50% + 9px));
}

.pdf-placement {
  position: absolute;
  top: 0;
  left: 0;
  min-width: 16px;
  min-height: 16px;
  border: 0;
  background: transparent;
  overflow: visible;
}

.pdf-placement img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform-origin: center;
  display: block;
  max-width: none;
  pointer-events: none;
}

.placement-warning {
  margin: 12px 0 0;
  border: 1px solid rgba(180, 35, 24, 0.32);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
  font-weight: 700;
}

.roll-note {
  margin: 12px 0 0;
  border: 1px solid rgba(13, 127, 86, 0.24);
  border-radius: 6px;
  padding: 10px 12px;
  background: rgba(13, 127, 86, 0.08);
  color: var(--success);
  font-weight: 700;
}

.paper-ruler {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  background: rgba(16, 18, 20, 0.18);
}

.paper-ruler.horizontal {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
}

.paper-ruler.vertical {
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
}

.facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.facts div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.facts dt {
  color: var(--muted);
  font-weight: 650;
}

.facts dd {
  margin: 0;
  font-weight: 750;
}

.tile-form {
  display: grid;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.print-commit-form {
  display: grid;
  gap: 16px;
  margin-top: 4px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.orientation-field {
  margin-bottom: 6px;
}

.orientation-field select {
  margin-top: 2px;
}

.print-commit-form .range-row:first-of-type {
  margin-top: 2px;
}

.print-commit-form .check-row {
  margin-top: 4px;
}

.tile-form.is-submitting,
.print-commit-form.is-submitting {
  opacity: 0.62;
  pointer-events: none;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, 1.4fr) 58px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.range-row input[type="range"] {
  min-height: 28px;
  padding: 0;
  accent-color: var(--accent);
}

.range-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
}

.check-row input {
  width: auto;
  min-height: 0;
}

.wide-form {
  max-width: 720px;
}

.progress-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid #c9d6ff;
  border-radius: 8px;
  background: #f7f9ff;
}

.progress-head,
.progress-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.progress-head span {
  color: var(--accent-dark);
  font-weight: 800;
}

.progress-track {
  height: 12px;
  overflow: hidden;
  border: 1px solid #c9d6ff;
  border-radius: 999px;
  background: #e8edff;
}

.progress-bar {
  height: 100%;
  min-width: 8px;
  border-radius: inherit;
  background: var(--accent);
  transition: width 260ms ease;
}

.progress-meta {
  color: var(--muted);
  font-size: 13px;
}

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

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

  .sidebar {
    position: static;
    height: auto;
  }

  .main {
    padding: 20px;
  }

  .grid.two,
  .detail-grid,
  .auth-panel {
    grid-template-columns: 1fr;
  }
}
