:root {
  color-scheme: light;
  --ink: #2b1719;
  --muted: #7d6367;
  --line: #ead5d7;
  --soft: #fff6f6;
  --brand: #b4232f;
  --brand-dark: #8f1823;
  --accent: #d04545;
  --warn: #fff0f0;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #fff6f6;
}
.login-body {
  background:
    linear-gradient(135deg, rgba(180,35,47,.08), rgba(255,255,255,.86) 45%),
    #fff6f6;
}
.topbar {
  min-height: 64px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: linear-gradient(90deg, #8f1823, #c72e3b);
  color: #fff;
  border-bottom: 1px solid #7f1720;
  position: sticky;
  top: 0;
  z-index: 4;
}
.topbar strong { display: block; font-size: 20px; }
.topbar span { color: #ffe4e7; font-size: 13px; }
nav { display: flex; gap: 8px; flex-wrap: wrap; }
button, .button {
  border: 0;
  background: var(--brand);
  color: #fff;
  min-height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 650;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
button:hover, .button:hover { background: var(--brand-dark); }
button.secondary { background: #7f6367; }
button.ghost { background: rgba(255,255,255,.16); color: #fff; border: 1px solid rgba(255,255,255,.24); }
button.danger { background: #8f1823; }
main { padding: 24px; max-width: 1440px; margin: 0 auto; }
.login-panel { min-height: calc(100vh - 90px); display: grid; place-items: center; }
.login-card, .panel, .sheet-head, .history {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}
.login-card { width: min(420px, 100%); }
h1, h2 { margin: 0 0 12px; letter-spacing: 0; }
p { color: var(--muted); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}
input:focus, select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(180,35,47,.14);
}
form { display: grid; gap: 12px; }
.sheet-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 16px;
}
.period-bar, .filters, .user-form { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 10px; }
.period-bar { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0 16px;
}
.stat {
  background: #fff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px;
}
.stat span { display:block; color: var(--muted); font-size: 12px; }
.stat strong { font-size: 22px; }
.table-wrap {
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 62vh;
}
.table-wrap.short { max-height: 420px; margin-top: 14px; }
table { border-collapse: collapse; width: 100%; min-width: 980px; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: middle; font-size: 14px; }
th { position: sticky; top: 0; background: #eaf3f8; z-index: 2; }
th { background: #f8e5e7; color: #65101a; }
tr.group-row td { background: var(--warn); font-weight: 700; color: #8f1823; }
td input { width: 100%; min-width: 86px; }
td.qty input { max-width: 110px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin: 14px 0; }
.msg { min-height: 24px; color: var(--brand); font-weight: 650; }
.msg.error { color: #b64242; }
.admin-grid { display: grid; gap: 18px; }
.filters { grid-template-columns: repeat(8, minmax(120px, 1fr)); align-items: end; }
.order-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 12px 0;
  background: #fff;
}
.order-card h3 { margin: 0 0 8px; }
.order-card small { color: var(--muted); }
.line-list { margin: 8px 0 0; padding-left: 18px; color: var(--ink); }
.preview-panel {
  border: 1px solid #e7b7bd;
  background: #fff7f7;
  border-radius: 8px;
  padding: 14px 16px;
  margin-top: 12px;
}
.preview-panel h3 { margin: 0 0 8px; color: var(--brand-dark); }
.preview-panel p { margin: 0 0 8px; }
.preview-list {
  display: grid;
  gap: 6px;
  max-height: 260px;
  overflow: auto;
}
.row-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.order-actions { margin-top: 12px; }
.row-actions button {
  min-height: 32px;
  padding: 0 12px;
}
@media (max-width: 860px) {
  .topbar { align-items: flex-start; gap: 12px; flex-direction: column; }
  main { padding: 14px; }
  .sheet-head { display: grid; }
  .period-bar, .filters, .user-form { grid-template-columns: 1fr; }
  table { min-width: 920px; }
}
