:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --line: #dbe4ef;
  --text: #102033;
  --muted: #65758b;
  --brand: #008f72;
  --brand-strong: #00705a;
  --danger: #d93025;
  --warning: #b7791f;
  --success: #057a55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

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

.app-shell {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #101923;
  color: #dce6f3;
  padding: 24px 18px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-weight: 800;
  font-size: 18px;
}

.brand-subtitle {
  color: #9fb0c4;
  font-size: 12px;
}

.role-link {
  display: block;
  margin: 8px 0;
  padding: 12px 14px;
  border-radius: 10px;
  color: #cbd8e6;
}

.role-link.active,
.role-link:hover {
  background: rgba(0, 143, 114, 0.18);
  color: #fff;
}

.sidebar-note {
  margin-top: 28px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  color: #9fb0c4;
  font-size: 12px;
  line-height: 1.7;
}

.sidebar-logout {
  width: 100%;
  margin-top: 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: transparent;
  color: #dce6f3;
}

.sidebar-logout:hover {
  border-color: rgba(255, 255, 255, 0.4);
  background: rgba(255, 255, 255, 0.08);
}

.main {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 28px;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-link {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.secondary-button { background: #fff; color: var(--brand); }
.button-link:hover, .secondary-button:hover { background: #e7f5f1; color: var(--brand-strong); }

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(17, 31, 48, 0.05);
}

.metric {
  padding: 16px;
}

.metric span,
.metric em {
  display: block;
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.metric strong {
  display: block;
  margin: 8px 0;
  font-size: 28px;
}

.merchant-code-banner {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 20px 22px;
  margin-bottom: 18px;
  border: 1px solid rgba(0, 143, 114, .32);
  border-radius: 14px;
  background: linear-gradient(105deg, #e4f8ef, #f8fffc);
}

.merchant-code-banner span, .merchant-code-banner p { color: var(--muted); font-size: 13px; }
.merchant-code-banner strong { display: block; margin: 4px 0; color: var(--brand-strong); font-size: 30px; letter-spacing: .08em; }
.merchant-code-banner p { margin: 0; line-height: 1.7; }
.merchant-code-banner button { flex: 0 0 auto; }
.attention-list, .notification-list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.attention-list li { padding: 11px 12px; border-radius: 9px; background: #f7f9fc; line-height: 1.6; }
.attention-list a, .table-link { color: var(--brand-strong); font-weight: 700; }
.attention-ok { border-left: 3px solid var(--success); }
.attention-danger { border-left: 3px solid var(--danger); }
.notification-list li { display: grid; gap: 3px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.notification-list span, .notification-list time { color: var(--muted); font-size: 13px; line-height: 1.55; }
.warehouse-address-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.warehouse-address-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfe; }
.warehouse-address-card div { display: flex; justify-content: space-between; gap: 8px; }
.warehouse-address-card span { color: var(--muted); font-size: 13px; }
.warehouse-address-card p { margin: 6px 0; color: #30445c; line-height: 1.65; font-size: 13px; word-break: break-all; }
.warehouse-address-card button { margin-top: 8px; }

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

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

.card {
  padding: 18px;
  margin-bottom: 18px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 17px;
}

.primary-card {
  border-color: rgba(0, 143, 114, 0.35);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-weight: 700;
  background: #f7f9fc;
}

.badge {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e8eef7;
  color: #40546d;
  font-size: 12px;
}

.badge-printed,
.badge-valid {
  background: #dff7ed;
  color: var(--success);
}

.badge-print_queued {
  background: #e5f2ff;
  color: #2164a6;
}

.badge-exception,
.badge-expired {
  background: #fde8e7;
  color: var(--danger);
}

.badge-bound,
.badge-expires_soon {
  background: #fff3d6;
  color: var(--warning);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #30445c;
  font-size: 13px;
}

.field-label { display: inline-flex; align-items: center; gap: 3px; }
.required-mark { color: var(--danger); font-size: 15px; line-height: 1; }

input,
select,
button {
  height: 38px;
  border: 1px solid #c8d4e3;
  border-radius: 8px;
  padding: 0 12px;
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(0, 143, 114, 0.18);
  border-color: var(--brand);
}

button {
  cursor: pointer;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

button:hover {
  background: var(--brand-strong);
}

.table-button {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.table-checkbox {
  width: 16px;
  height: 16px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--brand);
  vertical-align: middle;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.wide {
  grid-column: span 2;
}

.warehouse-address-field {
  align-content: start;
  padding: 11px 12px;
  border: 1px solid #d8e0e8;
  border-radius: 10px;
  background: #f5f7f9;
}

.warehouse-address-field .field-label {
  justify-content: flex-start;
  color: #405166;
}

.auto-fill-tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: #e4e9ee;
  color: #647486;
  font-size: 11px;
  font-style: normal;
  font-weight: 600;
  line-height: 1.25;
}

.warehouse-address-field .readonly-field {
  border-color: #d5dde5;
  background: #e9edf1;
  color: #526274;
  cursor: not-allowed;
  box-shadow: none;
}

.warehouse-address-field .readonly-field:focus {
  outline: none;
  border-color: #d5dde5;
  box-shadow: none;
}

.warehouse-address-field .input-hint {
  margin: 0;
  color: #718093;
}

.auth-panel,
.process-list {
  line-height: 1.8;
  color: #30445c;
}

.scan-form {
  display: block;
}

.scan-row {
  display: grid;
  grid-template-columns: 1fr 148px;
  gap: 10px;
  margin: 8px 0 10px;
}

.device-status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.device-status-grid > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fbfe;
}

.device-status-grid span,
.device-status-grid strong { display: block; }
.device-status-grid span { color: var(--muted); font-size: 13px; }
.device-status-grid strong { margin-top: 6px; color: var(--ink); }

.agent-token-row { display: flex; align-items: end; gap: 10px; margin-top: 16px; }
.agent-token-row label { flex: 1; color: var(--muted); font-size: 13px; }
.agent-token-row input { display: block; width: 100%; margin-top: 5px; font-family: ui-monospace, Consolas, monospace; }
.printer-selection-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 10px; margin-top: 16px; }
.printer-selection-form select { width: 100%; background: #fff; }
.printer-selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-message { min-height: 20px; margin-top: 6px; color: var(--brand-dark); font-size: 13px; }

.scan-row input {
  height: 48px;
  font-size: 18px;
}

.notice {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #edf4ff;
  color: #27476d;
}

.notice.success {
  background: #e4f8ef;
  color: var(--success);
}

.notice.danger {
  background: #fde8e7;
  color: var(--danger);
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(0, 143, 114, 0.16), transparent 34%),
    var(--bg);
}

.auth-card {
  width: min(460px, 100%);
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 70px rgba(17, 31, 48, 0.12);
}

.auth-brand {
  color: var(--text);
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 0 0 8px;
}

.auth-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
  color: var(--brand);
  font-size: 13px;
}

.inline-form {
  display: grid;
  grid-template-columns: 180px 120px 1fr 90px;
  gap: 10px;
}

.compact-action-form {
  display: grid;
  grid-template-columns: minmax(90px, 0.65fr) minmax(160px, 1.35fr) auto;
  gap: 6px;
  min-width: 390px;
  align-items: center;
}

.compact-action-form input {
  min-width: 0;
  padding: 8px 10px;
}

@media (max-width: 760px) {
  .compact-action-form {
    grid-template-columns: 1fr;
    min-width: 240px;
  }

  body {
    overflow-x: hidden;
  }

  .sidebar {
    min-width: 0;
    padding: 14px 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .sidebar nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .role-link {
    flex: 0 0 auto;
    margin: 0;
    padding: 9px 11px;
  }

  .sidebar-note {
    display: none;
  }

  .sidebar-logout {
    margin-top: 10px;
  }

  .main {
    padding: 16px 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .topbar h1 {
    font-size: 24px;
  }

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

  .card {
    padding: 14px;
  }

  .scan-row,
  .device-status-grid,
  .printer-selection-form {
    grid-template-columns: 1fr;
  }

  .printer-selection-actions button {
    flex: 1;
  }
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.order-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.order-filter-bar input { flex: 1 1 280px; }
.order-filter-bar select { flex: 0 1 180px; }
.order-filter-bar button { min-height: 40px; }
.filter-summary { margin: 0 0 12px; color: var(--muted); font-size: 13px; }
.danger-button { border-color: var(--danger); color: var(--danger); background: #fff; }
.input-hint { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.toolbar-actions { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.import-guide { margin-top: 14px; padding: 12px 14px; border: 1px solid #d8e4ef; border-radius: 9px; background: #f7fafc; color: #516274; font-size: 13px; line-height: 1.6; }
.import-guide p { margin: 4px 0 0; }

.modal-backdrop {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(9, 22, 35, .55);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
  width: min(720px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.modal-heading h2 { margin: 0; }

.icon-button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  grid-column: 1 / -1;
}

@media (max-width: 1100px) {
  .app-shell,
  .content-grid.two {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

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

  .inline-form {
    grid-template-columns: 1fr;
  }

  .toolbar { align-items: flex-start; flex-direction: column; }

  .merchant-code-banner { align-items: flex-start; flex-direction: column; }

  .warehouse-address-grid { grid-template-columns: 1fr; }

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

  .wide {
    grid-column: auto;
  }
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 16px;
}

.pagination .button-link {
  min-width: 88px;
  text-align: center;
}
