:root {
  --bg: #f3efe6;
  --ink: #1c2420;
  --muted: #5f6b64;
  --line: #e2d9cb;
  --card: #fffdf8;
  --brand: #0e6b4f;
  --brand-dark: #0a4d39;
  --brand-soft: #e7f3ec;
  --accent: #a35b2d;
  --danger: #9d342c;
  --warn: #8a6412;
  --info: #1d5c86;
  --sidebar: #12261f;
  --shadow: 0 12px 32px rgba(48, 38, 18, 0.06);
  --radius: 16px;
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -10%, rgba(14, 107, 79, 0.1), transparent 55%),
    radial-gradient(700px 360px at 110% 0%, rgba(163, 91, 45, 0.1), transparent 50%),
    var(--bg);
  min-height: 100vh;
}
a { color: var(--brand-dark); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3 { font-weight: 680; letter-spacing: -0.02em; margin: 0; }
.muted { color: var(--muted); }
.money, .readonly, .stat strong, .grand strong { font-variant-numeric: tabular-nums; }

.brand { display: flex; gap: 10px; align-items: center; color: inherit; min-width: 0; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: #f4e2c4; color: #6d3a16; font-weight: 720; flex: none;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; line-height: 1.3; }
.brand-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.public-wrap { width: min(920px, calc(100% - 32px)); margin: 0 auto; padding: 36px 0 64px; }
.public-foot { color: var(--muted); font-size: 13px; margin-top: 28px; }
.auth-card, .portal-card, .section-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.auth-card { width: min(460px, 100%); margin: 18px auto 0; padding: 26px; }
.auth-card .region-grid { grid-template-columns: 1fr; }
.auth-card h1, .portal-head h1 { font-size: 28px; margin-bottom: 8px; }
.portal-head { margin: 22px 0 16px; }
.portal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.portal-card { padding: 20px; display: flex; flex-direction: column; gap: 8px; min-height: 180px; }
.portal-card strong { font-size: 18px; }
.portal-card span { color: var(--muted); flex: 1; line-height: 1.55; }

.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--sidebar);
  color: #d7e6de;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { color: white; padding: 0 8px 18px; }
.sidebar .brand-text small { color: #9db5a8; }
.side-nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  color: #d7e6de;
  padding: 10px 12px;
  border-radius: 10px;
  border-left: 3px solid transparent;
}
.nav-link.is-active, .nav-link:hover { background: rgba(255,255,255,.07); }
.nav-link.is-active { border-left-color: #e3b07a; color: white; }
.nav-group { margin-top: 0; }
.nav-group summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  margin-right: 6px;
  margin-bottom: 3px;
}
.nav-group[open] summary::after { transform: rotate(-135deg); margin-bottom: -3px; }
.nav-group:not([open]) .nav-sub { display: none; }
.nav-group[open] .nav-sub { display: flex; flex-direction: column; gap: 2px; padding: 4px 0 2px 12px; }
.sidebar-foot { margin-top: auto; padding: 16px 8px 0; display: flex; justify-content: space-between; gap: 8px; font-size: 13px; }
.sidebar-foot a { color: #e3b07a; }
.who { color: #9db5a8; }
.admin-main { min-width: 0; }
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 22px 28px 0;
}
.topbar h1 { font-size: 26px; }
.page { padding: 18px 28px 48px; }

.phone-app { width: min(480px, 100%); margin: 0 auto; min-height: 100vh; background: transparent; }
.store-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 0; position: sticky; top: 0; background: rgba(243,239,230,.92); backdrop-filter: blur(8px); z-index: 2;
}
.text-link { color: var(--accent); font-size: 14px; }
.store-main { padding: 8px 16px 108px; }
.store-title { font-size: 24px; margin: 12px 0; }
.tabbar {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: #fffdf8; border-top: 1px solid var(--line);
}
.tab { text-align: center; padding: 12px 8px 16px; color: var(--muted); }
.tab.is-active { color: var(--brand); font-weight: 680; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 12px; border: 1px solid transparent; padding: 10px 14px;
  background: white; cursor: pointer; min-height: 40px; text-decoration: none;
}
.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: transparent; border-color: #eccfcb; color: var(--danger); }
.btn-small { min-height: 34px; padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.store-body .btn, .store-body input, .store-body select, .store-body textarea { min-height: 44px; font-size: 16px; }
.store-body .btn-small { min-height: 40px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span, .section-card h2, .filters label { font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); background: white; border-radius: 12px; padding: 10px 12px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(14,107,79,.25); border-color: var(--brand); }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 6px 0; }
.notice, .flash { border-radius: 12px; padding: 12px 14px; margin: 0 0 14px; line-height: 1.5; }
.notice { background: var(--brand-soft); color: var(--brand-dark); }
.notice-warn { background: #fff4df; color: #6d5310; }
.flash-ok { background: var(--brand-soft); color: var(--brand-dark); }
.flash-error { background: #fdeceb; color: var(--danger); }
.flash ul { margin: 0; padding-left: 18px; }
.checkline { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin-top: 8px; }
.checkline input { width: auto; margin-top: 3px; }

.region-grid, .split, .stat-grid, .queue-grid, .form-grid { display: grid; gap: 12px; }
.region-grid, .form-grid { grid-template-columns: repeat(3, 1fr); }
.form-grid .wide { grid-column: 1 / -1; }
.section-card { padding: 16px; margin-bottom: 16px; }
.section-card h2 { margin-bottom: 12px; font-size: 16px; color: var(--ink); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 14px; }
.filters .field { margin: 0; min-width: 140px; }
.filters input, .filters select { min-width: 140px; }

.table-wrap { overflow-x: auto; }
.data { width: 100%; border-collapse: collapse; }
.data td.nowrap, .data th.nowrap { white-space: nowrap; }
.data th, .data td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: 14px; }
.data th { color: var(--muted); font-weight: 600; font-size: 12px; }
.data tr:hover td { background: rgba(14,107,79,.03); }
.inline-logistics { display: flex; gap: 6px; min-width: 180px; }
.inline-logistics select { min-height: 34px; min-width: 120px; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 12px; line-height: 20px; }
.badge-ok { background: var(--brand-soft); color: var(--brand-dark); }
.badge-muted { background: #eeeae3; color: #5c574e; }
.badge-info { background: #e5f1f8; color: var(--info); }
.badge-warn { background: #fff1d6; color: var(--warn); }

.pager { display: flex; gap: 6px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.pager a, .pager .is-current, .pager-gap {
  min-width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; padding: 0 8px;
}
.pager a { border: 1px solid var(--line); background: white; }
.pager .is-current { background: var(--brand); color: white; }

.stat-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.stat, .queue-card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.stat span, .queue-card span { display: block; color: var(--muted); font-size: 13px; }
.stat strong, .queue-card strong { display: block; margin-top: 6px; font-size: 22px; }
.queue-grid { grid-template-columns: 1fr 1fr; margin-bottom: 20px; }
.queue-card { color: inherit; }
.queue-card.is-hot { border-color: #efd3a4; background: #fff8ee; }
.queue-card.is-risk { border-color: #f0c9c4; background: #fff6f5; }
.queue-card.is-active { outline: 2px solid var(--brand); }

.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr 140px; gap: 8px; align-items: center; font-size: 13px; }
.bar-track { height: 8px; background: #efe8dc; border-radius: 99px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand); border-radius: 99px; }
.bar-row.is-today .bar-fill { background: var(--accent); }

.item-list { display: flex; flex-direction: column; gap: 10px; }
.item-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.6fr) .7fr .6fr .6fr .7fr auto;
  gap: 8px;
  align-items: end;
  padding-bottom: 8px;
  border-bottom: 1px dashed var(--line);
}
.item-row .field { margin: 0; }
.readonly {
  min-height: 42px; display: flex; align-items: center; padding: 8px 10px;
  background: #f7f3eb; border-radius: 12px; border: 1px solid transparent;
}
.grand {
  margin: 14px 0;
  display: flex; justify-content: space-between; align-items: center;
  background: var(--brand-soft); border-radius: 14px; padding: 14px 16px;
}
.grand strong { font-size: 26px; color: var(--brand-dark); }

.paste-zone {
  border: 1.5px dashed #c9bba6; border-radius: 16px; padding: 14px; background: #fff;
  margin: 8px 0 14px;
}
.paste-zone.is-drag, .paste-zone:focus { border-color: var(--brand); outline: none; background: #f4fbf7; }
.preview img { max-height: 280px; border-radius: 12px; margin-bottom: 8px; }

.order-card {
  display: block; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; margin-bottom: 10px; color: inherit;
}
.order-card-top, .order-card-foot, .kv { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.order-card p { margin: 8px 0; line-height: 1.5; overflow-wrap: anywhere; }
.kv div { overflow-wrap: anywhere; }
.store-body .item-row { grid-template-columns: 1fr 1fr; }
.store-body .item-row .grow { grid-column: 1 / -1; }
.kv { padding: 8px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.kv span { color: var(--muted); flex: none; }
.line {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.empty { padding: 28px 10px; text-align: center; color: var(--muted); }
.goods-line { min-height: 22px; line-height: 22px; white-space: nowrap; }
.goods-line + .goods-line { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }

.print-sheet {
  background: white; border: 1px solid var(--line); border-radius: 16px; padding: 28px 24px 36px;
  min-height: calc(100vh - 150px);
  display: flex; flex-direction: column;
}
.sheet-main { flex: 1 0 auto; }
.sheet-date { font-size: 16px; margin: 0 0 8px; }
.sheet-title { text-align: center; font-size: 28px; margin: 0 0 6px; }
.sheet-note { text-align: center; color: var(--muted); margin: 0 0 16px; }
.sheet-table { width: 100%; border-collapse: collapse; }
.sheet-table th, .sheet-table td { border: 1px solid #2a2a2a; padding: 8px 6px; text-align: left; vertical-align: top; font-size: 14px; }
.sheet-table th { background: #f4f1ea; font-weight: 650; }
.sheet-summary { margin-top: 18px; }
.sheet-summary h3 { margin: 0 0 8px; font-size: 16px; }
.sheet-summary-table { width: auto; min-width: 420px; }
.sheet-money { display: flex; flex-wrap: wrap; gap: 18px 32px; margin-top: 12px; font-size: 15px; }
.sheet-signs { display: flex; justify-content: space-between; gap: 32px; margin-top: auto; padding-top: 36px; font-size: 16px; }
.sheet-signs div { flex: 1; }
.sign-line { display: inline-block; min-width: 160px; border-bottom: 1px solid #222; height: 22px; vertical-align: bottom; }

@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body.admin-body { background: white !important; }
  .sidebar, .topbar, .no-print { display: none !important; }
  .admin-shell, .admin-main { display: block !important; min-height: 0 !important; height: auto !important; }
  .page { padding: 0 !important; }
  .print-sheet { border: none; border-radius: 0; padding: 0; box-shadow: none; min-height: 250mm; }
  .sheet-table th { background: white; }
  .sheet-table tr, .sheet-signs { break-inside: avoid; }
  .sheet-table thead { display: table-header-group; }
}

@media (max-width: 900px) {
  .admin-shell { display: block; }
  .sidebar { position: sticky; top: 0; height: auto; z-index: 3; }
  .side-nav { flex-direction: row; overflow-x: auto; }
  .nav-link { white-space: nowrap; }
  .nav-group { margin-top: 0; }
  .nav-group[open] .nav-sub { flex-direction: row; overflow-x: auto; padding-left: 0; }
  .sidebar-foot { display: none; }
  .portal-grid, .region-grid, .form-grid, .queue-grid { grid-template-columns: 1fr; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
  .item-row { grid-template-columns: 1fr 1fr; }
  .item-row .grow { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: 72px 1fr; }
  .bar-row .bar-meta { grid-column: 2; }
}
