:root {
  color-scheme: light;
  --ink: #242936;
  --muted: #687280;
  --soft: #8a93a1;
  --line: #d9dee7;
  --paper: #ffffff;
  --stripe: #f4f5f7;
  --panel: #f7f8fb;
  --shell: #eef1f5;
  --accent: #804b9a;
  --accent-dark: #6f3f87;
  --danger: #cf3f35;
  --shadow: 0 18px 52px rgba(24, 31, 43, 0.12);
  --sheet-width: 1800px;
  --table-width: 1700px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 240px),
    var(--shell);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid #ccd3df;
  border-radius: 8px;
  padding: 0 15px;
  color: var(--ink);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

button:hover {
  border-color: #9fa9ba;
  background: #fafbfc;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  border-color: var(--accent);
  color: #fff;
  background: var(--accent);
}

button.primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

button.danger {
  border-color: var(--danger);
  color: #fff;
  background: var(--danger);
}

button.ghost {
  border-color: transparent;
  background: transparent;
}

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

input:focus,
select:focus {
  outline: 2px solid rgba(128, 75, 154, 0.18);
  border-color: var(--accent);
}

input[readonly] {
  color: var(--muted);
  background: #f5f6f8;
}

.hidden {
  display: none !important;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  padding: 34px;
  border: 1px solid rgba(128, 75, 154, 0.16);
  border-radius: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.login-logo {
  width: min(260px, 100%);
  height: auto;
  display: block;
}

.login-panel h1 {
  margin: 18px 0 24px;
  font-size: 30px;
  letter-spacing: 0;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
}

.app-shell {
  width: 100%;
  max-width: 100vw;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  overflow-x: hidden;
}

.sidebar {
  min-height: 100vh;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(18px);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 18px;
  border-right: 1px solid var(--line);
}

.brand-block {
  display: grid;
  gap: 12px;
  padding: 12px 0 18px;
}

.brand-block img {
  width: 158px;
  height: auto;
  display: block;
}

.brand-block strong {
  display: block;
  font-size: 20px;
}

.brand-block span,
.side-head span,
.search-box,
.panel-kicker {
  color: var(--muted);
  font-size: 13px;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.side-head strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.side-actions {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.side-actions button {
  width: 100%;
}

.nav-button.active {
  border-color: rgba(128, 75, 154, 0.36);
  color: var(--accent);
  background: #f7f0fa;
}

.search-box {
  display: grid;
  gap: 8px;
  margin: 16px 0 12px;
}

.order-list {
  display: grid;
  gap: 8px;
}

.order-card {
  width: 100%;
  min-height: 78px;
  display: grid;
  gap: 5px;
  text-align: left;
  border-radius: 10px;
  padding: 11px 12px;
  background: #fff;
}

.order-card.active {
  border-color: rgba(128, 75, 154, 0.48);
  background: #f5eef8;
}

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

.workspace {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  padding: 18px 20px 22px;
}

.app-page {
  min-width: 0;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1180px;
  margin: 0 auto 16px;
  padding: 18px 20px;
  border: 1px solid rgba(217, 222, 231, 0.88);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 10px 32px rgba(24, 31, 43, 0.06);
}

.page-head span {
  color: var(--muted);
  font-size: 13px;
}

.page-head h2 {
  margin: 4px 0 0;
  font-size: 24px;
  letter-spacing: 0;
}

.stats-layout,
.settings-page-panel {
  max-width: 1180px;
  margin: 0 auto;
}

.stats-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 16px;
}

.settings-page-panel {
  padding: 20px;
  border: 1px solid #dde2ea;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(24, 31, 43, 0.05);
}

.settings-page-panel.compact {
  max-width: 720px;
}

.toolbar {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(217, 222, 231, 0.88);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 10px 32px rgba(24, 31, 43, 0.06);
}

.toolbar strong {
  display: block;
  font-size: 18px;
}

.toolbar span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.order-header-picker {
  width: min(280px, 30vw);
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.receipt-stage {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid #d5dbe5;
  border-radius: 16px;
  padding: 18px;
  background: #dfe4ec;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65), 0 18px 52px rgba(24, 31, 43, 0.08);
}

.receipt {
  width: var(--sheet-width);
  margin: 0 auto;
  padding: 68px 50px 52px;
  background: var(--paper);
  box-shadow: 0 12px 36px rgba(24, 31, 43, 0.08);
}

.receipt-header {
  display: flex;
  align-items: center;
  gap: 44px;
  padding: 0 0 34px;
}

.logo {
  width: 140px;
  height: 140px;
  display: grid;
  place-items: center;
  flex: 0 0 140px;
  color: #e95c43;
  font-size: 96px;
  line-height: 0.9;
  font-weight: 300;
  letter-spacing: 0;
}

.logo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.logo.empty-logo {
  width: 140px;
  color: transparent;
}

.company-title-logo {
  width: min(430px, 100%);
  height: auto;
  display: block;
}

.company h1 {
  margin: 0 0 14px;
  font-size: 38px;
  font-weight: 600;
}

.company p {
  margin: 8px 0;
  font-size: 18px;
}

.meta-row {
  display: grid;
  grid-template-columns: 1fr 260px 520px;
  align-items: center;
  gap: 34px;
  padding: 0 0 10px;
  font-size: 18px;
}

.top-meta {
  grid-template-columns: 1fr 520px;
  padding-bottom: 10px;
  font-size: 20px;
}

.top-meta span:last-child,
.meta-row > span:last-child {
  white-space: nowrap;
}

.customer-label,
.opener-label {
  display: flex;
  align-items: center;
  gap: 8px;
}

.opener-label {
  white-space: nowrap;
}

.opener-label input {
  width: 120px;
  border: 0;
  border-bottom: 1px solid #cfd5de;
  border-radius: 0;
  padding: 2px 4px;
  font-weight: 700;
  background: transparent;
}

.customer-label input {
  width: 340px;
  border: 0;
  border-bottom: 1px solid #cfd5de;
  border-radius: 0;
  font-size: 25px;
  background: transparent;
}

.lines-table {
  width: calc(var(--table-width) + 92px);
  min-width: calc(var(--table-width) + 92px);
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 17px;
}

.lines-table th,
.lines-table td {
  height: 42px;
  border: 1px solid var(--line);
  text-align: center;
}

.lines-table th {
  color: #4b5566;
  background: #fafafa;
  font-weight: 700;
}

.lines-table tbody tr:nth-child(even) {
  background: var(--stripe);
}

.lines-table input {
  height: 100%;
  border: 0;
  border-radius: 0;
  text-align: center;
  background: transparent;
}

.lines-table input:focus {
  outline: 2px solid rgba(128, 75, 154, 0.14);
  outline-offset: -2px;
}

.product-col {
  width: 380px;
}

.color-col {
  width: 150px;
}

.batch-col {
  width: 180px;
}

.size-col {
  width: 108px;
}

.unit-col {
  width: 80px;
}

.qty-col {
  width: 130px;
}

.price-col {
  width: 90px;
}

.amount-col {
  width: 150px;
}

.action-col {
  width: 92px;
}

.row-actions {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.row-actions button {
  min-width: 34px;
  width: 34px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: 44px;
  row-gap: 16px;
  padding: 34px 0 14px;
  font-size: 23px;
}

.summary-grid p,
.summary-grid label {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  margin: 0;
  white-space: nowrap;
}

.summary-grid input {
  width: 118px;
  border: 0;
  border-bottom: 1px solid #cfd5de;
  border-radius: 0;
  padding: 2px 4px;
  font-size: 23px;
  font-weight: 700;
  background: transparent;
}

.note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 16px;
  color: #737985;
  font-size: 21px;
}

.note-row input {
  width: min(760px, 80%);
  border: 0;
  color: var(--accent);
  font-size: 24px;
  font-weight: 700;
  background: transparent;
}

.footer-note {
  margin: 36px 0 0;
  color: #8a8f99;
  font-size: 20px;
}

.panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid #dde2ea;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(24, 31, 43, 0.05);
}

.panel > strong {
  overflow-wrap: anywhere;
  font-size: 17px;
}

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

.panel-kicker {
  text-transform: uppercase;
}

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

.metric {
  min-height: 76px;
  display: grid;
  align-content: space-between;
  padding: 12px;
  border: 1px solid #e1e6ee;
  border-radius: 12px;
  background: var(--panel);
}

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

.metric strong {
  font-size: 24px;
  letter-spacing: 0;
}

.metric.accent {
  border-color: rgba(128, 75, 154, 0.24);
  background: #f7f0fa;
}

.metric.accent strong {
  color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(17, 24, 39, 0.48);
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  border-radius: 14px;
  padding: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.24);
}

.modal-head,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-head {
  margin-bottom: 18px;
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 18px;
}

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

.settings-grid label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.settings-grid label:nth-child(5),
.settings-grid label:nth-child(6) {
  grid-column: 1 / -1;
}

.preview-panel {
  width: min(980px, 100%);
}

.preview-panel img {
  width: 100%;
  display: block;
  border: 1px solid var(--line);
  background: #fff;
}

@media (max-width: 1260px) {
  .app-shell {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .panel {
    margin-bottom: 0;
  }
}

@media (max-width: 900px) {
  body {
    background: #f5f6f8;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .login-shell {
    align-items: start;
    padding: 18px;
  }

  .login-panel {
    margin-top: 36px;
    padding: 24px;
  }

  .login-logo {
    width: min(220px, 100%);
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    width: 100%;
    max-width: 100vw;
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 12px;
  }

  .brand-block {
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 0 0 12px;
  }

  .brand-block img {
    width: 120px;
  }

  .side-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }

  .side-actions button {
    padding: 0 8px;
  }

  .order-list {
    display: flex;
    gap: 8px;
    padding-bottom: 4px;
    overflow-x: auto;
  }

  .order-card {
    min-width: 220px;
  }

  .workspace {
    padding: 10px;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
  }

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

  .toolbar-actions button {
    padding: 0 8px;
  }

  .order-header-picker {
    width: 100%;
  }

  .receipt-stage {
    padding: 10px;
    border-radius: 12px;
  }

  .receipt {
    padding-top: 24px;
    box-shadow: none;
    border: 1px solid var(--line);
  }

  .receipt-header {
    gap: 14px;
    padding: 0 12px 18px;
  }

  .logo,
  .logo.empty-logo {
    width: 74px;
    height: 74px;
    flex-basis: 74px;
    font-size: 48px;
  }

  .company h1 {
    margin-bottom: 8px;
    font-size: 24px;
  }

  .company p {
    margin: 5px 0;
    font-size: 14px;
  }

  .company-title-logo {
    width: min(250px, 100%);
  }

  .meta-row,
  .top-meta {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0 10px 8px;
    font-size: 15px;
  }

  .top-meta span:first-child {
    display: none;
  }

  .customer-label,
  .opener-label {
    align-items: stretch;
    flex-direction: column;
    gap: 4px;
  }

  .customer-label input,
  .opener-label input {
    width: 100%;
    font-size: 18px;
  }

  .lines-table {
    min-width: 1080px;
    font-size: 16px;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px 16px;
    padding: 16px 10px 10px;
    font-size: 18px;
  }

  .summary-grid label {
    align-items: stretch;
    flex-direction: column;
  }

  .summary-grid input {
    width: 100%;
    font-size: 18px;
  }

  .note-row {
    align-items: stretch;
    flex-direction: column;
    padding: 12px 10px 0;
    font-size: 18px;
  }

  .note-row input {
    width: 100%;
    font-size: 20px;
  }

  .footer-note {
    margin: 24px 10px 0;
    font-size: 15px;
    line-height: 1.6;
  }

  .page-head,
  .stats-layout,
  .settings-page-panel {
    max-width: none;
  }

  .page-head,
  .stats-layout {
    margin-bottom: 10px;
  }

  .page-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-layout {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: 10px;
    place-items: end center;
  }

  .modal-panel {
    width: 100%;
    max-height: 92vh;
    border-radius: 12px 12px 0 0;
  }

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

  .settings-grid label:nth-child(5),
  .settings-grid label:nth-child(6) {
    grid-column: auto;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

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

  .sidebar,
  .toolbar,
  .no-print {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .workspace,
  .receipt-stage {
    padding: 0;
    border: 0;
    background: #fff;
    box-shadow: none;
  }

  .receipt {
    width: 100%;
    box-shadow: none;
  }
}
