:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --ink: #1c2733;
  --muted: #68737f;
  --line: #dde3e9;
  --brand: #0f6cbf;
  --brand-dark: #0a4f8a;
  --ok: #178a4b;
  --bad: #c0392b;
  --radius: 8px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--brand);
  color: #fff;
}
.topbar .brand a { color: #fff; font-weight: 600; text-decoration: none; font-size: 18px; }
.topbar nav a { color: #eaf3fc; text-decoration: none; margin-left: 14px; }
.topbar nav a:hover { text-decoration: underline; }
.topbar .who { color: #cfe6fb; margin-left: 14px; font-size: 13px; }
main { max-width: 1240px; margin: 24px auto; padding: 0 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 18px;
  overflow-x: auto; /* wide tables scroll inside the white box instead of spilling out */
}
.card.narrow { max-width: 380px; margin: 48px auto; }
h1 { font-size: 18px; margin: 0 0 14px; }
form.upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
label { display: block; margin-bottom: 12px; }
input[type="text"], input[type="password"], input[type="email"], select, input[type="file"] {
  display: block; width: 100%;
  padding: 8px 10px; margin-top: 4px;
  border: 1px solid var(--line); border-radius: var(--radius); background: #fff;
  font: inherit;
}
form.upload input[type="file"] { flex: 1; min-width: 220px; width: auto; margin: 0; }
form.user-form { margin: 0 0 18px; }
.uform-row { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; }
.uform-row input[type="email"], .uform-row input[type="password"] { flex: 1; min-width: 180px; }
.uform-row select { width: auto; min-width: 140px; margin-top: 4px; }
.uform-shops {
  display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center;
  padding: 8px 10px; margin-top: 6px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fafafa;
}
.uform-shops label { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.uform-shops input[type="checkbox"] { margin: 0; }
button, a.btn {
  background: var(--brand); color: #fff; border: none; border-radius: var(--radius);
  padding: 8px 14px; cursor: pointer; text-decoration: none; font: inherit;
}
button:hover, a.btn:hover { background: var(--brand-dark); }
.hint { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; font-size: 14px; }
.flash.success { background: #e7f6ec; color: var(--ok); border: 1px solid #bfe6ce; }
.flash.error { background: #fdecea; color: var(--bad); border: 1px solid #f5c6c0; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }
td.actions { white-space: nowrap; }
td.actions a { margin-right: 10px; color: var(--brand); }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: #eef2f6; }
.badge.ok { background: #e7f6ec; color: var(--ok); }
.badge.bad { background: #fdecea; color: var(--bad); }
dl.facts { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 14px; }
dl.facts dt { color: var(--muted); }
form.user-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
form.user-form input, form.user-form select { width: auto; margin: 0; flex: 1; min-width: 130px; }
form.shop-edit { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
form.shop-edit input.hairline, form.shop-edit select.hairline {
  width: auto; margin: 0; padding: 4px 6px; font-size: 13px; min-width: 90px;
}
form.shop-edit input.hairline.num { min-width: 46px; width: 46px; }
form.shop-edit input.hairline.notes { min-width: 140px; }
.toggle-label { display: inline-flex; align-items: center; gap: 5px; margin: 0; font-size: 13px; }
.toggle-label input { margin: 0; }
button.link { background: none; color: var(--danger, var(--bad)); padding: 0; }
button.link.danger { color: var(--bad); }
button.link.danger:hover { background: none; color: var(--bad); text-decoration: underline; }
td.actions form { display: inline-block; margin: 0; }
td.actions form + form { margin-left: 8px; }
td.actions form:only-child { margin-left: 0; }
form.shop-edit label { margin: 0; }
form.shop-edit select.hairline { min-width: 120px; }
td input[name="password"].hairline { min-width: 150px; }
nav form.shopswitch { display: inline-flex; align-items: center; gap: 6px; margin-left: 14px; }
.shopswitch .switch-label { color: #cfe6fb; font-size: 12.5px; margin: 0; }
.shopswitch select {
  padding: 4px 6px; border-radius: var(--radius); border: none; font-size: 13px;
  max-width: 180px; background: #fff; color: var(--ink);
}
form.assign-shops { max-width: 460px; }
form.assign-shops label {
  display: inline-flex; align-items: center; gap: 5px; margin: 2px 14px 2px 0;
  font-size: 13px; white-space: nowrap;
}
form.assign-shops input { margin: 0; }
form.assign-shops .muted { color: var(--muted); }
form.assign-shops .full { color: var(--bad); font-size: 12px; }
form.assign-shops button { margin-top: 6px; padding: 4px 10px; font-size: 13px; }

/* Part converter */
.filter-row { display: flex; align-items: center; gap: 14px; }
.filter-row h1 { margin: 0; }
.filter-row .btn.back { white-space: nowrap; }
.btn.primary, button.primary { background: var(--brand); }
.btn.primary:hover, button.primary:hover { background: var(--brand-dark); }
.filters { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 12px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 4px 18px; }
.kv div { padding: 3px 0; border-bottom: 1px dashed var(--line); }
.kv span { display: inline-block; min-width: 110px; color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
.filters label { margin: 0; min-width: 150px; }
.filters label.inline-count { min-width: 0; color: var(--muted); font-size: 13px; padding-bottom: 8px; }
.filters input[type="text"] { display: block; width: 100%; }
.apply { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 14px; }
.apply label { margin: 0; min-width: 150px; }
.apply #a-type { display: block; width: 100%; margin-top: 4px; }
.apply #a-disc { display: block; width: 100%; margin-top: 4px; }
#a-msg { align-self: center; }
#parts td.mono { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; }
#parts tr.changed { background: #f0f7ff; }
#parts tr.changed td:last-child button { color: var(--bad); }
#parts tr.nopart { background: #fafafa; color: var(--muted); }
#parts tr.nopart .row-sel,
#parts tr.nopart .row-reset { display: none; }
#parts .codep { font-family: Consolas, "Courier New", monospace; font-size: 11px; color: var(--muted); }
#parts .arrow { color: var(--accent); }
#parts .row-reset { background: none; border: none; padding: 2px 6px; color: var(--muted); font-size: 13px; }
#parts .row-reset:hover { color: var(--bad); background: none; }
.totals { display: flex; gap: 24px; flex-wrap: wrap; }
.tot-block { flex: 1 1 300px; min-width: 0; }
.tot-block h3 { margin: 0 0 8px; font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tot-block table { font-size: 14px; margin-bottom: 6px; }
.tot-block td.mono { font-family: Consolas, "Courier New", monospace; font-size: 12.5px; text-align: right; }
.tot-block td:first-child { width: 100%; }
.tot-block tr.muted td { color: var(--muted); font-style: italic; }
.tot-foot { font-size: 13px; font-weight: 600; }
.cmp {
  display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap;
  margin: 4px 4px 10px; font-size: 14px;
}
.cmp .cmp-arrow { color: var(--muted); }
.cmp b { margin: 0 4px; }
.cmp em { font-style: normal; font-size: 13px; }
.cmp em.same { color: var(--muted); }
.cmp em.up { color: var(--ok); font-weight: 600; }
.cmp em.down { color: var(--bad); font-weight: 600; }
.gran { display: flex; gap: 28px; align-items: baseline; flex-wrap: wrap;
  border-top: 2px solid var(--line); margin-top: 14px; padding: 14px 4px 2px;
  font-size: 14px; }
.gran b { margin-left: 4px; }
.gran b::before { content: ''; }
.gran span:nth-child(3) { font-size: 16px; font-weight: 700;
  color: var(--accent); }
.gran span:nth-child(3) b { font-size: 18px; color: var(--accent); }
.gran #g-grand { font-size: 16px; font-weight: 700; color: var(--accent); }
.gran #g-grand b { font-size: 18px; color: var(--accent); }
.gran .note { font-size: 12px; font-weight: 400; color: var(--muted); }
#g-msg { margin-left: 10px; }
#g-msg a.btn { margin-left: 6px; }
#gen-form input[type="number"] { width: 110px; margin: 0; }
#gen-form select { width: auto; margin: 0; }

/* Searchable select: a small type-to-filter box beside the dropdown. */
.selsearch { display: inline-flex; gap: 6px; align-items: center; }
.selsearch input {
  width: auto; flex: 0 1 150px; margin: 0; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: var(--radius); font: inherit;
}
.filters .selsearch { display: flex; }
.filters .selsearch input { flex: 1 1 auto; margin-top: 4px; }

/* Labor-tax controls are hidden for now (uncomment to restore). */
.labtax { display: none; }