:root {
  color-scheme: light;
  --canvas: #f4f5f0;
  --surface: #fff;
  --ink: #192722;
  --muted: #52665c;
  --line: #dfe6df;
  --accent: #1f5948;
  --accent-hover: #174637;
  --accent-soft: #e8f2eb;
  --warm: #faf0db;
  --danger: #9b332c;
  --radius: 14px;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--canvas);
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
a, button, input, select, textarea, summary { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid #28775e; outline-offset: 3px; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(27px, 4vw, 41px); letter-spacing: -.045em; line-height: 1.18; }
h2 { font-size: 18px; line-height: 1.4; }
h3 { font-size: 15px; }
small { font-size: 12px; }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
button { appearance: none; }
input, select, textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #bdcdc3;
  border-radius: 8px;
  color: var(--ink);
  background: #fff;
  padding: 9px 11px;
  min-height: 44px;
}
input:disabled, select:disabled, input:read-only:not([type="checkbox"]) { background: var(--canvas); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; margin: 0; accent-color: var(--accent); }
label, .field-value { display: grid; gap: 5px; color: var(--muted); font-size: 13px; font-weight: 600; min-width: 0; }
input, select, textarea { font-size: 16px; font-weight: 400; }
.field-value strong { font-size: 16px; color: var(--ink); padding: 8px 0; }
textarea { resize: vertical; }
summary { color: var(--accent); font-weight: 650; }
code { font-family: ui-monospace, monospace; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1264px; margin: auto; padding: 12px 32px; display: flex; align-items: center; gap: 46px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 18px; font-weight: 800; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 39px; height: 39px; border-radius: 10px; color: #e4f2e7; background: var(--accent); }
nav { display: flex; gap: 5px; }
nav a { text-decoration: none; color: var(--muted); padding: 8px 14px; white-space: nowrap; font-weight: 650; border-radius: 8px; }
nav a[aria-current], nav a:hover { color: var(--accent); background: var(--accent-soft); }
.identity { display: flex; margin-left: auto; align-items: center; gap: 10px; }
.avatar { background: #e2ece4; color: var(--accent); display: grid; place-items: center; border-radius: 50%; min-width: 36px; height: 36px; font-weight: 700; }
.identity-name { font-size: 13px; font-weight: 700; white-space: nowrap; }
.identity-name small { color: var(--muted); font-weight: 500; display: block; }
.signout { position: relative; }
.signout .form-error { position: absolute; right: 0; width: 180px; z-index: 1; }

.main { width: min(100% - 48px, 1200px); margin: 0 auto; padding: 35px 0 60px; display: grid; align-content: start; gap: 20px; }
.page-heading { display: flex; gap: 16px; align-items: end; justify-content: space-between; min-width: 0; padding: 4px 0 5px; }
.page-heading h1 { overflow-wrap: anywhere; }
.context { color: var(--muted); font-size: 14px; font-weight: 650; margin-bottom: 5px; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 8px 15px;
  border: 1px solid transparent; border-radius: 8px; text-align: center; font-weight: 650; text-decoration: none;
  white-space: nowrap; font-size: 14px; line-height: 1.35;
}
.primary { color: #fff; background: var(--accent); }
.primary:hover { background: var(--accent-hover); }
.secondary { background: var(--surface); color: var(--accent); border-color: #c9d7cd; }
.secondary:hover { background: var(--accent-soft); }
.text { background: transparent; color: var(--accent); padding-inline: 9px; }
.text:hover { background: var(--accent-soft); }
.icon-button { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--muted); font-size: 23px; }
.panel { background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); min-width: 0; }
.padded { padding: 22px; }
.padded-title { padding: 17px 22px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-heading span, .muted { color: var(--muted); }
.padded > .panel-heading { margin-bottom: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.stat { min-height: 105px; padding: 17px 20px; display: grid; gap: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat span { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat strong { align-self: end; font-size: clamp(18px, 3.5vw, 29px); line-height: 1.2; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat small { color: var(--muted); }
.filters { display: flex; align-items: end; flex-wrap: wrap; gap: 12px; }
.records > .filters { padding: 20px; border-bottom: 1px solid var(--line); }
.filters label { min-width: 140px; flex: 0 1 172px; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; font-size: 14px; }
td, th { padding: 12px 18px; }
td:first-child, th:first-child { padding-left: 22px; }
th { font-size: 12px; color: var(--muted); background: #f7f9f5; white-space: nowrap; }
td { border-top: 1px solid #edf1ed; overflow-wrap: anywhere; }
tr:hover td { background: #fafbf8; }
.record-link { font-weight: 750; color: var(--accent); text-underline-offset: 3px; white-space: nowrap; }
.record-note { display: block; color: var(--muted); }
.amount { white-space: nowrap; font-variant-numeric: tabular-nums; }
.status { display: inline-block; padding: 4px 9px; font-size: 12px; border-radius: 20px; font-weight: 700; white-space: nowrap; background: #eef1ec; color: #43544a; }
.status-review, .status-confirmation { background: var(--warm); color: #735221; }
.status-approved, .status-settled { background: var(--accent-soft); color: var(--accent); }
.status-return_customer, .status-return_supervisor { background: #f7e9e6; color: #8e3b33; }
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.stack { display: grid; gap: 13px; justify-items: start; }
.stack > label, .stack > .fields, .stack > .price-fields, .stack > .form-error { width: 100%; }
.fields, .price-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; align-items: end; }
.price-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { margin-top: 16px; }
.form-error { margin-top: 10px; color: var(--danger); background: #fbefec; padding: 10px 12px; border-radius: 8px; overflow-wrap: anywhere; }
.notice { background: var(--warm); color: #5c4520; padding: 11px 14px; border-radius: 8px; overflow-wrap: anywhere; }
.margin-bottom { margin-bottom: 14px; }
.order-lines-panel { margin-top: 14px; }
.order-line { display: grid; grid-template-columns: 26px minmax(110px, 1fr) minmax(135px, 1.4fr) minmax(80px, .65fr) minmax(80px, .5fr) 44px; gap: 12px; align-items: end; border-bottom: 1px solid var(--line); padding: 12px 0; }
.line-num { display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); width: 26px; height: 26px; border-radius: 8px; font-size: 12px; font-weight: 750; }
.line-sequence { align-self: center; }
.line-charge { display: grid; gap: 5px; }
.line-charge span { font-size: 13px; color: var(--muted); }
.line-charge output { display: grid; align-items: center; min-height: 44px; font-weight: 750; }
.amount-footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 18px; }
.amount-footer strong { color: var(--accent); font-size: 25px; }
.detail-summary { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(140px, 2fr); gap: 16px; align-items: center; }
.detail-money { color: var(--accent); font-size: clamp(25px, 4vw, 40px); font-weight: 800; letter-spacing: -.045em; }
.detail-facts { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 7px; color: var(--muted); font-size: 13px; }
.detail-facts strong { color: var(--ink); }
.review-grid, .ledger-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.review-grid div { display: grid; gap: 7px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); }
.review-grid strong { color: var(--ink); }
.inline-form { margin-top: 14px; }
.inline-fields { margin-top: 12px; max-width: 540px; }
.assignment-row { padding: 15px 0; border-top: 1px solid var(--line); }
.assignment-group { display: grid; grid-template-columns: 130px minmax(0, 1fr) 44px; gap: 12px; align-items: end; background: #f7f9f6; padding: 11px; border-radius: 8px; margin-top: 10px; }
.workers { min-width: 0; border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 3px 12px; }
.workers legend { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.workers label { cursor: pointer; display: flex; align-items: center; min-height: 34px; gap: 6px; }
.period-description { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 14px; color: var(--muted); font-size: 13px; }
.period-list a { display: inline-block; padding: 4px 8px; }
.timeline ol { margin: 13px 0 0; padding-left: 22px; }
.timeline li { margin: 8px 0; }
.timeline li span { margin-left: 8px; color: var(--muted); font-size: 13px; }
.timeline li p { overflow-wrap: anywhere; }
.account-actions { min-width: 120px; }
.account-actions summary { margin-bottom: 4px; }
.standalone { text-align: center; padding: 35px 20px; }
.standalone h1 { margin: 10px 0 20px; font-size: 26px; }
.error-code { color: var(--accent); font-size: 14px; font-weight: 750; }

.login-page { min-height: 100vh; display: grid; place-items: center; }
.login-shell { width: min(100% - 40px, 900px); margin: 24px auto; display: grid; grid-template-columns: 1.08fr 1fr; border: 1px solid var(--line); border-radius: 22px; overflow: hidden; box-shadow: 0 18px 60px #233d2d16; }
.login-intro { display: grid; align-content: start; gap: 54px; padding: 40px; background: #173b31; color: #f2f6ed; position: relative; overflow: hidden; min-height: 400px; }
.login-intro .brand { position: relative; z-index: 1; }
.login-intro .brand-mark { background: #2a5747; }
.login-heading { position: relative; z-index: 1; }
.login-heading p { margin-top: 14px; color: #d1e3d6; }
.warehouse-art { position: absolute; bottom: -42px; right: -15px; width: 67%; height: 195px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; transform: rotate(-10deg); opacity: .75; }
.warehouse-art i { background: repeating-linear-gradient(90deg, #2a5446 0 4px, #305f4e 4px 6px); border-radius: 6px; border: 1px solid #52806b; }
.warehouse-art i:nth-child(2n) { background: repeating-linear-gradient(90deg, #376552 0 4px, #416f5a 4px 6px); }
.login-form { background: #fff; padding: 42px 40px; display: grid; align-content: center; gap: 18px; }
.login-form h2 { font-size: 25px; }
.login-form .button { width: 100%; margin-top: 4px; }
.demo { border-top: 1px solid var(--line); padding-top: 13px; font-size: 13px; color: var(--muted); }
.demo p { margin-top: 6px; }
.demo ul { margin: 8px 0; padding-left: 19px; }
.demo-entry { display: flex; gap: 8px 12px; flex-wrap: wrap; }

@media (max-width: 740px) {
  .top-inner { gap: 8px 14px; flex-wrap: wrap; padding: 8px 14px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 36px; height: 36px; }
  nav { order: 3; width: 100%; overflow: auto; }
  nav a { padding: 7px 10px; font-size: 14px; }
  .identity { gap: 4px; }
  .avatar { display: none; }
  .main { width: calc(100% - 24px); padding: 20px 0 40px; gap: 14px; }
  .page-heading { align-items: start; flex-direction: column; gap: 10px; }
  .padded { padding: 14px; }
  .padded-title { padding: 13px 14px; }
  .stat { padding: 10px; min-height: 86px; }
  .stats { gap: 6px; }
  .stat span { font-size: 12px; }
  .stat strong { font-size: clamp(14px, 4.3vw, 22px); }
  .filters { gap: 8px; }
  .records > .filters { padding: 12px; }
  .filters label { flex: 1 1 130px; min-width: 0; }
  .ledger-grid { grid-template-columns: 1fr; }
  .price-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 7px; }
  .line-sequence { grid-column: 1 / -1; }
  .order-line label:nth-child(2) { grid-column: 1 / 2; }
  .order-line label:nth-child(3) { grid-column: 2 / -1; }
  .assignment-group { grid-template-columns: 1fr 44px; gap: 8px; }
  .assignment-group .workers { grid-row: 2; grid-column: 1 / -1; }
  .assignment-group .icon-button { grid-column: 2; grid-row: 1; }
  .review-grid { gap: 6px; }
  .detail-summary { grid-template-columns: 1fr; gap: 4px; }
  .login-shell { width: min(100% - 24px, 520px); grid-template-columns: 1fr; }
  .login-intro { padding: 22px; min-height: 150px; gap: 18px; }
  .login-intro h1 { font-size: 27px; }
  .login-heading p { margin-top: 5px; font-size: 13px; }
  .warehouse-art { right: -40px; height: 115px; width: 47%; opacity: .45; }
  .login-form { padding: 20px; }
  td, th { padding: 9px 12px; }
  td:first-child, th:first-child { padding-left: 14px; }
  .table-scroll table, .table-scroll tbody { display: block; }
  .table-scroll thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .table-scroll tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; border-bottom: 1px solid var(--line); gap: 4px; }
  .table-scroll tr:last-child { border-bottom: 0; }
  .table-scroll td { display: block; border: 0; padding: 4px 6px; }
  .table-scroll td::before { content: attr(data-label); display: block; color: var(--muted); font-size: 11px; font-weight: 600; }
}

.full-credit { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-top: 10px; }

.bill-tabs { width: fit-content; padding: 3px; background: var(--canvas); border-radius: 10px; }
.bill-tabs a[aria-current] { background: var(--surface); box-shadow: 0 1px 3px #19272225; }
.bill-filter { margin-top: 14px; }
.stats:has(> :nth-child(2):last-child) { grid-template-columns: repeat(2, minmax(0, 1fr)); }

@media (max-width: 740px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .button, nav a, .workers label { min-height: 44px; }
  nav a { display: inline-flex; align-items: center; justify-content: center; }
  .workers label { padding-inline: 6px; }
  .table-scroll tr { padding: 12px; gap: 6px 10px; }
  .table-scroll tr + tr { border-top: 4px solid var(--canvas); }
  .table-scroll td:first-child:has(.record-link) { grid-column: 1 / -1; }
  .record-link { display: inline-flex; align-items: center; min-height: 44px; white-space: normal; }
  .table-scroll td { min-width: 0; }
  .bill-tabs { width: 100%; }
  .bill-tabs a { flex: 1; }
  .page-heading .actions, .form-actions { width: 100%; }
  .page-heading .button, .form-actions > *, .form-actions form .button { flex: 1; }
  .form-actions form .button { width: 100%; }
  .order-line { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 10px; }
  .line-sequence { grid-column: 1; grid-row: 1; }
  .order-line .icon-button { grid-column: 2; grid-row: 1; justify-self: end; }
  .order-line label:nth-child(2) { grid-column: 1; grid-row: 2; }
  .order-line label:nth-child(4) { grid-column: 2; grid-row: 2; }
  .order-line label:nth-child(3) { grid-column: 1; grid-row: 3; }
  .line-charge { grid-column: 2; grid-row: 3; }
  .bill-filter .button { flex-basis: 100%; }
  .fields input[type=date], .filters input[type=date], .filters input[type=month] { max-width: 100%; }
}

@media (max-width: 480px) {
  [data-order-form] .fields > label:first-child { grid-column: 1 / -1; }
  .filters label:has(input[type=date]) { flex-basis: 155px; }
}

.registration { width: min(100% - 24px, 480px); }
.login-alternative { margin-top: 8px; }
.add-line { margin-top: 12px; }
.order-footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 18px; margin-top: 14px; }
.order-footer .amount-footer { margin: 0; }
#rate-editor { scroll-margin-top: 16px; }
.table-scroll .stack .button { white-space: normal; }

@media (max-width: 740px) {
  .add-line { width: 100%; }
  .order-footer { position: sticky; bottom: 0; z-index: 1; box-shadow: 0 -4px 16px #19272214; padding-inline: 12px; }
  .order-footer .amount-footer { gap: 5px; flex-direction: column; align-items: start; }
  .order-footer .amount-footer strong { font-size: 21px; }
  .order-footer button { margin-left: auto; }
  .table-scroll td:has([data-account-form]) { grid-column: 1 / -1; }
}

@media (max-width: 480px) {
  .order-line label:nth-child(2) { grid-column: 1 / -1; }
  .order-line label:nth-child(4) { grid-column: 1; grid-row: 3; }
  .order-line label:nth-child(3) { grid-column: 1 / -1; grid-row: 4; }
}
