:root {
  color-scheme: light;
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-strong: #eef3f2;
  --text: #172026;
  --muted: #61717a;
  --border: #d9e1e5;
  --accent: #0f6b57;
  --accent-strong: #0a5545;
  --accent-soft: #e2f3ed;
  --blue: #285b89;
  --amber: #b7791f;
  --amber-soft: #fff4db;
  --red: #b42318;
  --red-soft: #ffe4df;
  --gray-soft: #edf0f2;
  --shadow: 0 10px 24px rgba(23, 32, 38, 0.07);
  --shadow-soft: 0 4px 14px rgba(23, 32, 38, 0.05);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.45;
}

a {
  color: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 16px;
  background: var(--accent-strong);
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(12px);
}

.brand {
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
  color: #fff;
}

.user-chip {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  color: #d8eee7;
  font-size: 13px;
}

.user-chip strong {
  color: #fff;
}

.logout {
  grid-column: 2;
  grid-row: 1;
  color: #d8eee7;
  font-size: 14px;
  text-decoration: none;
}

.navrail {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 8px 12px 10px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

.navrail::-webkit-scrollbar {
  display: none;
}

.navrail a {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.navrail a.active {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--accent-soft);
}

.page {
  width: min(1160px, 100%);
  margin: 0 auto;
  padding: 22px 14px 64px;
}

.intro {
  margin: 4px 0 20px;
}

.intro h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.08;
  letter-spacing: 0;
}

.intro p {
  margin: 8px 0 0;
  max-width: 720px;
  color: var(--muted);
}

.tile-grid {
  display: grid;
  gap: 12px;
}

.home-section {
  display: grid;
  gap: 12px;
  margin: 28px 0 0;
}

.home-section h2,
.panel h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
}

.draft-status,
.cart-source {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 8px;
  padding: 10px 12px;
  border: 1px solid #b6e2d1;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 700;
}

.cart-source {
  display: flex;
  width: fit-content;
  max-width: 100%;
  margin-bottom: 16px;
  color: var(--text);
}

.action-tile {
  display: grid;
  gap: 6px;
  min-height: 100px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  text-decoration: none;
}

.action-tile--primary {
  border-color: #b6e2d1;
  background: #f4fbf8;
  box-shadow: var(--shadow);
}

.action-tile--hero {
  min-height: 126px;
  border-color: var(--accent-strong);
  background: var(--accent);
  color: #fff;
  box-shadow: var(--shadow);
}

.action-tile span {
  font-size: 19px;
  line-height: 1.2;
  font-weight: 800;
}

.action-tile small,
.muted,
td span {
  color: var(--muted);
}

.action-tile--hero small {
  color: #d8eee7;
}

.login-panel {
  min-height: calc(100vh - 80px);
  display: grid;
  align-content: center;
  gap: 18px;
  max-width: 760px;
  margin: 0 auto;
}

.login-panel h1 {
  margin: 0;
  font-size: 42px;
  color: var(--accent-strong);
}

.login-panel p {
  margin: 0;
  color: var(--muted);
}

.login-list {
  display: grid;
  gap: 10px;
}

.login-card {
  margin: 0;
}

.login-card button {
  width: 100%;
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.login-card span {
  font-size: 18px;
  font-weight: 800;
}

.login-card strong,
.login-card em {
  color: var(--muted);
  font-style: normal;
  font-size: 14px;
}

.panel {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.focus-panel {
  display: grid;
  gap: 18px;
}

.stack {
  display: grid;
  gap: 12px;
}

.form-grid,
.filters {
  display: grid;
  gap: 12px;
}

.filters {
  margin-bottom: 16px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.field input,
.field select,
.field textarea,
.searchbar input,
.count-input,
.small-input,
.qty-form input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
  font-size: 16px;
}

.field textarea,
.email-preview {
  resize: vertical;
}

.searchbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(15, 107, 87, 0.14);
}

.button.secondary {
  border-color: var(--border);
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: none;
}

.button.warning {
  border-color: #d6a650;
  background: var(--amber-soft);
  color: #7a4d0b;
  box-shadow: none;
}

.button.small {
  min-height: 42px;
  padding: 7px 10px;
  font-size: 14px;
}

.button.wide {
  width: 100%;
}

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

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0 18px;
}

.home-overview {
  display: grid;
  gap: 10px;
  margin: 18px 0 6px;
}

.pilot-info {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid #bdd5eb;
  border-radius: var(--radius);
  background: #f5f9fd;
  color: var(--text);
}

.pilot-info span {
  color: var(--muted);
}

.pilot-info a,
.feedback-link a {
  color: var(--accent-strong);
  font-weight: 800;
}

.feedback-link {
  margin: 20px 0 0;
  color: var(--muted);
}

.status-card {
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

.status-card span,
.cart-summary span,
.location-card span,
.ongoing-withdrawal span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.status-card strong {
  font-size: 32px;
  line-height: 1;
}

.status-card small {
  color: var(--muted);
}

.status-card--ok {
  border-color: #cfe3dc;
}

.status-card--warning {
  border-color: #f2cf8f;
  background: #fffaf0;
}

.status-card--danger {
  border-color: #f0b8b0;
  background: #fff6f4;
}

.status-card--info {
  border-color: #bdd5eb;
  background: #f5f9fd;
}

.location-card,
.cart-summary,
.ongoing-withdrawal {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.location-card {
  margin: -4px 0 14px;
}

.location-card--compact {
  margin-top: 0;
}

.cart-summary {
  margin: 0 0 14px;
  border-color: #b6e2d1;
  background: #f4fbf8;
}

.cart-summary strong,
.location-card strong,
.ongoing-withdrawal strong {
  font-size: 18px;
  line-height: 1.2;
}

.take-choices {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.choice-card {
  display: grid;
  gap: 10px;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow-soft);
}

.choice-card--scan {
  align-content: center;
  border-color: #b6e2d1;
  background: #f4fbf8;
}

.choice-card--search {
  align-content: start;
}

.choice-card span {
  font-size: 22px;
  font-weight: 900;
}

.choice-card small {
  color: var(--muted);
}

.ongoing-withdrawal {
  margin: 0 0 18px;
  text-decoration: none;
}

.ongoing-withdrawal--active {
  border-color: #b6e2d1;
  background: var(--accent-soft);
}

.section-heading {
  margin: 18px 0 10px;
  font-size: 18px;
  line-height: 1.2;
}

.quick-actions .button,
.quick-actions form {
  min-width: min(100%, 150px);
}

.quick-actions form .button {
  width: 100%;
}

.list,
.cart-list {
  list-style: none;
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0 0 16px;
}

.item-row,
.cart-line,
.admin-row,
.readonly-row {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.item-row strong,
.cart-line strong,
td strong {
  display: block;
}

.row-action,
.qty-form {
  display: grid;
  grid-template-columns: 88px minmax(150px, 1fr);
  gap: 8px;
  align-items: center;
}

.qty-form {
  grid-template-columns: 42px 1fr 42px auto;
}

.qty-step {
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--gray-soft);
  color: var(--text);
  font-size: 20px;
  font-weight: 900;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--red);
  padding: 6px 0;
  font-weight: 700;
  cursor: pointer;
}

.empty-action {
  display: grid;
  gap: 12px;
  align-items: start;
}

.stock-preview {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.stock-preview span,
.balance-after {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.stock-preview strong,
.balance-after strong {
  color: var(--text);
}

.stock-preview--negative,
.balance-after.stock-preview--negative {
  border-color: #f0b8b0;
  background: #fff6f4;
}

.stock-preview--negative strong,
.balance-after.stock-preview--negative strong {
  color: var(--red);
}

.balance-after {
  display: block;
  margin-top: 6px;
}

.submit-panel {
  border-color: #b6e2d1;
}

.process-lock,
.process-note {
  display: grid;
  gap: 10px;
}

.process-note {
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid #f2cf8f;
  border-radius: var(--radius);
  background: #fffaf0;
}

.process-note span {
  color: var(--muted);
}

.submit-button {
  min-height: 54px;
  background: #067a5b;
  border-color: #067a5b;
  font-size: 17px;
}

.helper-text {
  margin: 10px 0 0;
  color: var(--muted);
}

.readonly-row {
  grid-template-columns: 1fr;
  background: var(--surface-strong);
}

.readonly-row span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.confirmation-panel {
  margin-bottom: 14px;
}

.registered-list,
.plain-list {
  list-style: none;
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
}

.registered-list li {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.registered-list li:last-child {
  border-bottom: 0;
}

.registered-list small {
  display: block;
  color: var(--muted);
}

.registered-list em {
  color: var(--text);
  font-style: normal;
  font-weight: 900;
  white-space: nowrap;
}

.plain-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.fact-grid {
  display: grid;
  gap: 10px;
}

.fact-grid div {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-strong);
}

.fact-grid span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 14px;
}

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

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

th {
  color: var(--muted);
  background: var(--surface-strong);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.status {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.status.ok {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status.low {
  background: var(--amber-soft);
  color: var(--amber);
}

.status.critical,
.status.empty {
  background: var(--red-soft);
  color: var(--red);
}

.email-preview {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 260px;
  color: var(--text);
  background: #fff;
}

.empty,
.notice,
.alert {
  padding: 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.empty {
  border: 1px dashed var(--border);
  color: var(--muted);
  background: var(--surface);
}

.notice {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid #b6e2d1;
}

.alert {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #ffc3ba;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-row {
  align-items: end;
}

.check {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.qr-grid {
  display: grid;
  gap: 12px;
}

.qr-card {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

.qr-card img {
  width: 120px;
  height: 120px;
}

.qr-card strong,
.qr-card span,
.qr-card small {
  display: block;
}

.qr-card small {
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 12px;
}

.print-actions {
  margin-bottom: 14px;
}

@media (min-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto auto;
    padding: 14px 24px;
  }

  .user-chip {
    grid-column: auto;
  }

  .logout {
    grid-column: auto;
    grid-row: auto;
  }

  .page {
    padding: 28px 24px 72px;
  }

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

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

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

  .take-choices {
    grid-template-columns: 0.8fr 1.2fr;
  }

  .form-grid,
  .filters {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: end;
  }

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

  .item-row,
  .cart-line,
  .admin-row {
    grid-template-columns: minmax(220px, 1fr) auto auto;
    align-items: center;
  }

  .admin-row {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
  }

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

@media (max-width: 520px) {
  .brand {
    font-size: 17px;
  }

  .intro h1 {
    font-size: 29px;
  }

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

  .row-action {
    grid-template-columns: 1fr;
  }

  .qty-form {
    grid-template-columns: 48px minmax(72px, 1fr) 48px;
  }

  .qty-form .button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .quick-actions .button,
  .quick-actions form {
    width: 100%;
  }

  .button {
    min-height: 52px;
  }

  .button.small {
    min-height: 46px;
  }

  .action-tile,
  .choice-card {
    min-height: 112px;
  }

  .qr-card {
    grid-template-columns: 92px 1fr;
  }

  .qr-card img {
    width: 92px;
    height: 92px;
  }
}

@media (min-width: 1040px) {
  .tile-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

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

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .navrail,
  .intro,
  .print-actions {
    display: none;
  }

  .page {
    width: 100%;
    padding: 0;
  }

  .qr-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8mm;
  }

  .qr-card {
    break-inside: avoid;
    box-shadow: none;
  }
}
