:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --border: #e4e4e7;
  --text: #18181b;
  --muted: #71717a;
  --accent: #3f3f46;
  --link: #1d4ed8;
  --focus: #18181b;
  --danger: #b91c1c;
  font-size: 15px;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 70rem;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.main { padding-bottom: 3rem; }

.top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3rem;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.025em;
  color: var(--text);
  text-decoration: none;
}
.brand:hover { text-decoration: underline; text-underline-offset: 3px; }

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  font-size: 0.875rem;
}
.nav a {
  color: var(--muted);
  text-decoration: none;
}
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--text); font-weight: 600; }

h1.page-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 1.75rem 0 0.75rem;
}
h2.section {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  margin: 2rem 0 0.75rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.flash {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  padding: 0.65rem 0.85rem;
  border-radius: 6px;
  font-size: 0.875rem;
  margin: 1rem 0;
}
.flash.error {
  background: #fef2f2;
  border-color: #fecaca;
  color: var(--danger);
}

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.86rem; }
.small { font-size: 0.8125rem; }

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.35rem;
}
.progress-label {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  width: 5.75rem;
  flex-shrink: 0;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}
.progress-num {
  font-size: 0.75rem;
  color: var(--muted);
  width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

.table-scroll { overflow-x: auto; margin: 0 -0.15rem; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th,
.table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.table th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: linear-gradient(#fafafa, #fafafa);
}
.table tbody tr:last-child td { border-bottom: none; }
.table th.th-narrow { width: 3.5rem; }
.table a { color: var(--link); text-decoration: none; }
.table a:hover { text-decoration: underline; }

.job-row-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--bg); }
.btn-primary {
  background: var(--accent);
  color: #fafafa;
  border-color: var(--accent);
}
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.small { padding: 0.3rem 0.55rem; font-size: 0.76rem; }
.btn.danger { border-color: #fecaca; color: var(--danger); background: #fff; }
.btn.danger:hover { background: #fef2f2; }

form.inline-actions { display: inline; margin: 0; }
form.inline-actions button { vertical-align: middle; }

fieldset.form-grid {
  border: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

@media (min-width: 600px) {
  fieldset.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
}

.label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.055em;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  background: var(--surface);
  color: var(--text);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgb(63 63 70 / 0.12);
}
textarea { min-height: 4rem; resize: vertical; }

.row-actions form { margin-right: 0.35rem; display: inline; }

kbd {
  font-family: inherit;
  font-size: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}
.login-card {
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem 1.35rem;
}
.login-card h1 { margin-top: 0; font-size: 1.1rem; font-weight: 600; }

.pill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--muted);
}

.pill.hardware { border-color: #d4d4d8; }
.pill.material { border-color: #d4d4d8; }

.job-header-flex {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: space-between;
  align-items: baseline;
}

.job-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

/* —— Dashboard jobs board —— */
.dash-intro {
  margin-bottom: 1.25rem;
}

.dash-subtitle {
  margin: 0;
  max-width: 46rem;
  font-size: 0.9375rem;
  color: var(--muted);
  line-height: 1.5;
}

.dash-table-wrap {
  padding: 0;
  overflow: hidden;
}

.table-jobs {
  font-size: 0.875rem;
}

.table-jobs thead th {
  background: #f4f4f5;
  border-bottom: 1px solid var(--border);
  padding: 0.65rem 0.85rem;
  white-space: nowrap;
}

.table-jobs tbody td {
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table-jobs tbody tr:last-child td {
  border-bottom: none;
}

.table-jobs tbody tr:hover td {
  background: #fafafa;
}

.th-rn,
.cell-rn {
  width: 2rem;
  text-align: center;
}

.th-progress {
  min-width: 8.5rem;
}

.th-action {
  width: 4.5rem;
  text-align: center;
}

.cell-num strong {
  font-weight: 600;
}

.cell-name {
  max-width: 14rem;
  font-weight: 500;
}

.link-materials {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.35rem 0;
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
}

.link-materials:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.link-materials-label {
  font-size: 0.8125rem;
}

.badge-lines {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.badge-lines-empty {
  color: var(--muted);
  font-weight: 500;
}

.badge-lines-detail {
  font-size: 0.6875rem;
  color: var(--muted);
  font-weight: 500;
}

.mini-bar {
  height: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
  max-width: 11rem;
}

.mini-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.mini-bar-delivered .mini-bar-fill {
  background: #52525b;
}

.mini-bar-meta {
  margin-top: 0.3rem;
  font-size: 0.6875rem;
  color: var(--text);
}

.cell-print {
  text-align: center;
}

.btn-ghost {
  border-color: var(--border);
  background: transparent;
  color: var(--text);
}

.api-log-pre {
  margin: 0;
  padding: 1rem 1.1rem;
  font-size: 0.75rem;
  line-height: 1.45;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  background: #fafafa;
  border-radius: 0 0 8px 8px;
  max-height: 70vh;
  overflow-y: auto;
}
