:root {
  --ink: #1f2933;
  --muted: #61717d;
  --line: #d8dee4;
  --page: #f5f7f8;
  --panel: #ffffff;
  --blue: #1f6fb2;
  --blue-soft: #e6f1fb;
  --green: #24785a;
  --green-soft: #e7f4ed;
  --amber: #9a6116;
  --amber-soft: #fff1d6;
  --red: #b94a48;
  --red-soft: #fce8e6;
  --slate-soft: #eef1f4;
  --shadow: 0 10px 28px rgba(30, 44, 56, 0.08);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-size: 15px;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  font-weight: 800;
}

h2 {
  font-size: 18px;
  font-weight: 800;
}

.header-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(82px, 1fr));
  gap: 10px;
  min-width: 420px;
}

.role-box {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.role-box span {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0 12px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.header-stats div,
.metric {
  background: var(--slate-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.header-stats span,
.metric strong {
  display: block;
  font-size: 22px;
  line-height: 1;
  font-weight: 800;
}

.header-stats small,
.metric span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 28px;
  overflow-x: auto;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  white-space: nowrap;
}

.tab.is-active {
  background: var(--blue-soft);
  border-color: #9cc5e8;
  color: var(--blue);
  font-weight: 800;
}

.admin-only.is-hidden,
.staff-hidden {
  display: none !important;
}

main {
  padding: 18px 28px 28px;
}

.tab-panel {
  display: none;
}

.tab-panel.is-active {
  display: block;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.flow-strip span {
  min-height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  border: 1px solid #bed8c9;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.order-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(420px, 1.35fr);
  gap: 16px;
}

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

.catalog-panel,
.cart-panel {
  grid-column: 2;
}

.cart-panel {
  margin-top: -1px;
}

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

.panel-title p {
  color: var(--muted);
  margin-top: 6px;
  font-size: 13px;
}

.with-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

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

.filters {
  margin-bottom: 12px;
}

.filters.compact {
  grid-template-columns: minmax(240px, 420px);
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
}

textarea {
  resize: vertical;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.catalog-wrap {
  max-height: 422px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafb;
  color: #46545f;
  font-size: 13px;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.item-name {
  min-width: 180px;
  white-space: normal;
  font-weight: 800;
}

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

.qty-input {
  width: 76px;
}

.primary,
.secondary,
.danger,
.ghost {
  min-height: 36px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
}

.primary {
  background: var(--blue);
  color: #fff;
}

.secondary {
  background: var(--slate-soft);
  color: #34424d;
  border: 1px solid var(--line);
}

.danger {
  background: var(--red-soft);
  color: var(--red);
}

.ghost {
  background: #fff;
  color: var(--blue);
  border: 1px solid #acd0ec;
}

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

.record-list {
  display: grid;
  gap: 12px;
}

.record {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
}

.record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.record-title {
  display: grid;
  gap: 5px;
}

.record-title strong {
  font-size: 16px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

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

.status.rpa {
  background: var(--blue-soft);
  color: var(--blue);
}

.status.done {
  background: var(--green-soft);
  color: var(--green);
}

.status.error {
  background: var(--red-soft);
  color: var(--red);
}

.line-table {
  margin: 8px 0 12px;
  border-radius: 8px;
}

.empty {
  min-height: 112px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.metric-grid,
.report-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.report-grid {
  grid-template-columns: minmax(300px, 0.7fr) minmax(420px, 1.3fr);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #1f2933;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1040px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .role-box {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }

  .header-stats {
    width: 100%;
    min-width: 0;
  }

  .order-layout,
  .report-grid {
    grid-template-columns: 1fr;
  }

  .catalog-panel,
  .cart-panel {
    grid-column: 1;
  }
}

@media (max-width: 720px) {
  .app-header,
  main,
  .tabs {
    padding-left: 14px;
    padding-right: 14px;
  }

  .header-stats,
  .metric-grid,
  .flow-strip,
  .form-grid,
  .filters {
    grid-template-columns: 1fr;
  }

  .with-actions,
  .record-head {
    flex-direction: column;
  }

  .primary,
  .secondary,
  .danger,
  .ghost {
    width: 100%;
  }
}
