:root {
  --ink: #1b2127;
  --ink-2: #3f4a54;
  --muted: #66717c;
  --line: #d6dce1;
  --line-2: #e7eaed;
  --bg: #f3f4f5;
  --surface: #ffffff;
  --surface-2: #f8f9fa;
  --top: #1f2a33;
  --accent: #1c5d86;
  --accent-hover: #154a6c;
  --accent-soft: #e7f0f6;
  --ok: #1d6b39;
  --ok-bg: #e5f2e9;
  --warn: #7f5300;
  --warn-bg: #fcf2da;
  --bad: #a3261c;
  --bad-bg: #fbe8e6;
  --late: #8a4a12;
  --late-bg: #fcefe2;
  --radius: 4px;
  --focus: 0 0 0 3px rgba(28, 93, 134, 0.25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--font);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-underline-offset: 2px;
}

a:hover {
  color: var(--accent-hover);
}

h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 650;
}

h2 {
  font-size: 16px;
  font-weight: 650;
}

p {
  margin: 0 0 10px;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ------------------------------------------------------------ Header */

.topbar {
  background: var(--top);
  color: #fff;
}

.topbar-inner,
.mainnav-inner,
.footer-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
  font-size: 16px;
}

.brand:hover {
  color: #fff;
}

.brand-mark {
  width: 26px;
  height: 26px;
  display: inline-grid;
  place-items: center;
  background: #fff;
  color: var(--top);
  border-radius: 3px;
  font-weight: 800;
  font-size: 15px;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.user-name {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
}

.user-name:hover {
  color: #fff;
  text-decoration: underline;
}

.user-role {
  color: #aab6c0;
}

.signout {
  margin: 0;
}

.topbar .btn-link {
  color: #d5dde3;
}

.topbar .btn-link:hover {
  color: #fff;
}

.mainnav {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.mainnav-inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.mainnav a {
  display: block;
  padding: 12px 12px 10px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  border-bottom: 3px solid transparent;
}

.mainnav a:hover {
  color: var(--ink);
  border-bottom-color: var(--line);
}

.mainnav a.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ------------------------------------------------------------ Page */

.page {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 24px 16px 40px;
}

.page-narrow {
  max-width: 780px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head h1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.page-sub {
  color: var(--muted);
  margin: 4px 0 0;
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.panel > h2 {
  margin-bottom: 12px;
}

.panel-action {
  border-left: 4px solid var(--accent);
}

.panel-danger {
  border-color: #e6c3bf;
}

.split {
  display: grid;
  gap: 20px;
  align-items: start;
}

@media (min-width: 960px) {
  .split {
    grid-template-columns: 1fr 1fr;
  }
}

.split > .panel {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.nowrap {
  white-space: nowrap;
}

.note {
  color: var(--muted);
  font-size: 13px;
  margin: 12px 0 0;
}

.empty {
  color: var(--muted);
  padding: 16px 0;
  margin: 0;
}

/* ------------------------------------------------------------ Notices and tags */

.notice {
  border: 1px solid;
  border-left-width: 4px;
  border-radius: var(--radius);
  padding: 11px 14px;
  margin-bottom: 18px;
}

.notice p:last-child,
.notice ul {
  margin-bottom: 0;
}

.notice ul {
  padding-left: 20px;
  margin-top: 4px;
}

.notice-ok {
  background: var(--ok-bg);
  border-color: #b6d7c1;
  border-left-color: var(--ok);
}

.notice-error {
  background: var(--bad-bg);
  border-color: #eec4bf;
  border-left-color: var(--bad);
}

.notice-warn {
  background: var(--warn-bg);
  border-color: #ecd49a;
  border-left-color: var(--warn);
}

.tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 3px;
  font-size: 12.5px;
  font-weight: 650;
  line-height: 1.6;
  white-space: nowrap;
  vertical-align: middle;
  border: 1px solid transparent;
}

h1 .tag {
  font-size: 13px;
}

.tag-pending {
  background: #eef1f4;
  color: #36424d;
  border-color: #dde2e7;
}

.tag-overdue {
  background: var(--bad-bg);
  color: var(--bad);
  border-color: #efc9c4;
}

.tag-paused {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: #ecd49a;
}

.tag-done {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: #bfdcc8;
}

.tag-late {
  background: var(--late-bg);
  color: var(--late);
  border-color: #efd2b5;
}

.tag-void,
.tag-muted {
  background: #eceff1;
  color: var(--muted);
  border-color: #dfe3e6;
}

/* ------------------------------------------------------------ Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font: 600 14px/1 var(--font);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: #c3cad1;
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: #aab3bb;
}

.btn-danger {
  background: var(--bad);
  color: #fff;
}

.btn-danger:hover {
  background: #86201a;
}

.btn[disabled],
.btn.is-busy {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.btn-link-danger {
  color: var(--bad);
}

/* Step action controls: stacked so the open form never pushes the other button sideways. */
.action-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action > summary {
  list-style: none;
  width: 100%;
}

.action > summary::-webkit-details-marker {
  display: none;
}

.action[open] > summary.btn-primary {
  background: var(--accent-hover);
}

.action[open] > summary.btn-secondary {
  background: #eef1f4;
}

.action-form {
  display: grid;
  gap: 10px;
  margin-top: 8px;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* ------------------------------------------------------------ Forms */

.form label,
.filters label,
.action-form label {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

label > input:not([type="checkbox"]),
label > select,
label > textarea,
label > .hint {
  display: block;
  margin-top: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid #bcc4cc;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: 400 15px/1.35 var(--font);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

input[readonly] {
  background: var(--surface-2);
  color: var(--muted);
}

input[type="file"] {
  font: 400 14px var(--font);
  padding: 8px 0;
}

input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
  flex: none;
}

.form .check,
.check {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  font-weight: 400;
}

.hint,
.optional {
  font-weight: 400;
  font-size: 13px;
  color: var(--muted);
}

.form {
  margin: 0;
}

.form:not(.form-grid) > label + label,
.form:not(.form-grid) > label + button {
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px 20px;
}

.form-grid-3 {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.form-inline {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.form-inline label {
  flex: 1 1 240px;
}

.input-narrow {
  max-width: 110px;
}

fieldset {
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 14px 16px 16px;
  margin: 0 0 16px;
}

legend {
  font-weight: 650;
  padding: 0 6px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px 20px;
  margin-bottom: 8px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 18px;
}

.filters label {
  flex: 0 1 220px;
}

.filters input[type="search"] {
  min-width: 220px;
}

.presets {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-self: center;
  font-size: 14px;
}

.presets a.is-active {
  color: var(--ink);
  font-weight: 650;
  text-decoration: none;
}

/* ------------------------------------------------------------ Tables */

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel .table-wrap {
  border-color: var(--line-2);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.table th,
.table td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line-2);
}

.table thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 650;
  border-bottom-color: var(--line);
  white-space: nowrap;
}

.table thead th.group {
  text-align: center;
  border-bottom: 1px solid var(--line-2);
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tfoot th,
.table tfoot td {
  background: var(--surface-2);
  font-weight: 650;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table tr.is-current td {
  background: var(--accent-soft);
}

.table tr.is-inactive td {
  color: var(--muted);
}

.table td.is-alert {
  color: var(--bad);
  font-weight: 650;
}

.table-compact th,
.table-compact td {
  padding: 7px 9px;
  font-size: 13px;
}

.table-form td {
  padding: 6px 8px;
  vertical-align: middle;
}

.table-form input {
  min-width: 90px;
}

/* ------------------------------------------------------------ Work queue */

.step-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 16px;
}

.step-tabs a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 14px;
  white-space: nowrap;
}

.step-tabs a:hover {
  border-color: #aab3bb;
  color: var(--ink);
}

.step-tabs a.is-mine .step-tab-name {
  font-weight: 650;
}

.step-tabs a.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.step-tab-count {
  min-width: 26px;
  padding: 0 6px;
  text-align: center;
  background: #eef1f4;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--ink-2);
}

.step-tabs a.is-active .step-tab-count {
  background: #fff;
  color: var(--accent);
}

.step-info {
  margin-bottom: 16px;
}

.step-info h2 {
  margin-bottom: 4px;
}

.step-info p {
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 4px;
}

.qlist {
  display: grid;
  gap: 10px;
}

.qitem {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
}

@media (min-width: 860px) {
  .qitem {
    grid-template-columns: 1fr 280px;
    align-items: start;
  }
}

.qitem-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.entry-link {
  font-weight: 700;
  font-size: 16px;
}

.qitem-bill {
  font-weight: 600;
  color: var(--ink-2);
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 26px;
  margin: 0;
}

.meta dt,
.details dt {
  font-size: 12.5px;
  color: var(--muted);
}

.meta dd,
.details dd {
  margin: 0;
  font-weight: 600;
}

.meta dd.num,
.details dd.num {
  font-variant-numeric: tabular-nums;
}

.hold-line {
  margin: 10px 0 0;
  padding: 8px 10px;
  background: var(--warn-bg);
  border-radius: var(--radius);
  font-size: 14px;
  color: #5a3b00;
}

/* ------------------------------------------------------------ Entry detail */

.details {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px 24px;
  margin: 0;
}

.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 14px;
}

.log li {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 2px 16px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-2);
}

.log li:last-child {
  border-bottom: 0;
}

.log-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.log-what {
  font-weight: 600;
}

.log-who {
  grid-column: 2;
  color: var(--ink-2);
}

.log-detail {
  grid-column: 2;
  color: var(--muted);
}

@media (max-width: 560px) {
  .log li {
    grid-template-columns: 1fr;
  }

  .log-who,
  .log-detail {
    grid-column: 1;
  }
}

/* ------------------------------------------------------------ Dashboard */

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.summary-label {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.summary-value {
  display: block;
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.definitions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px 24px;
  margin: 14px 0 0;
  font-size: 13px;
}

.definitions dt {
  font-weight: 650;
}

.definitions dd {
  margin: 0;
  color: var(--muted);
}

.pager {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
}

/* ------------------------------------------------------------ Admin */

.link-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.link-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
}

.link-list li:last-child {
  border-bottom: 0;
}

.link-list a {
  font-weight: 650;
}

.link-list span {
  color: var(--muted);
  font-size: 14px;
}

.master-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 560px;
  overflow-y: auto;
  border-top: 1px solid var(--line-2);
}

.master-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 2px;
  border-bottom: 1px solid var(--line-2);
  font-size: 14px;
}

.master-list li.is-inactive > span {
  color: var(--muted);
}

.master-list form {
  margin: 0;
  flex: none;
}

/* ------------------------------------------------------------ Sign in and legal */

.signin {
  max-width: 400px;
  margin: 32px auto 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 26px 18px;
}

.signin h1 {
  margin-bottom: 6px;
}

.signin .page-sub {
  margin-bottom: 20px;
}

.signin .form {
  margin-bottom: 16px;
}

.prose {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px 28px;
  line-height: 1.6;
}

.prose h1 {
  margin-bottom: 4px;
}

.prose h2 {
  font-size: 17px;
  margin: 26px 0 8px;
}

.prose ul {
  padding-left: 22px;
  margin: 0 0 10px;
}

.prose li {
  margin-bottom: 6px;
}

/* ------------------------------------------------------------ Footer */

.footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding-top: 16px;
  padding-bottom: 16px;
}

.footer a {
  color: var(--muted);
}

.footer a:hover {
  color: var(--ink);
}

.demo-banner {
  background: var(--warn-bg);
  border-bottom: 1px solid #ecd49a;
  color: #5a3b00;
  font-size: 14px;
  text-align: center;
  padding: 6px 16px;
}

@media (max-width: 640px) {
  .user-role {
    display: none;
  }

  .page {
    padding-top: 18px;
  }

  .panel,
  .prose {
    padding: 16px;
  }

  .signin {
    margin-top: 8px;
    padding: 20px 18px 12px;
  }

  .filters label,
  .filters input[type="search"] {
    flex: 1 1 100%;
    min-width: 0;
  }
}

@media print {
  .topbar,
  .footer,
  .qitem-actions,
  .panel-action,
  .panel-danger,
  .filters,
  .barcode-form {
    display: none;
  }

  body {
    background: #fff;
  }

  .panel,
  .table-wrap {
    border: 0;
  }
}

/* ------------------------------------------------------------ Layout refinements */

.panel-action .action-row,
.panel-action > .action {
  max-width: 380px;
}

.panel-action .hold-line {
  margin: 0 0 12px;
}

.table .col-step {
  min-width: 200px;
}

.brand-name,
.user-name,
.topbar .btn-link {
  white-space: nowrap;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 480px) {
  .brand-name {
    display: none;
  }
}
