:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #64716b;
  --line: #dce3df;
  --paper: #ffffff;
  --wash: #f4f7f5;
  --brand: #176b4d;
  --brand-dark: #0f5039;
  --accent: #e3a32b;
  --danger: #b53b35;
  --danger-bg: #fff2f1;
  --shadow: 0 10px 32px rgba(22, 56, 44, 0.08);
  font-family: Inter, "Microsoft YaHei", system-ui, sans-serif;
  font-size: 16px;
  color: var(--ink);
  background: var(--wash);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 0; overflow-x: hidden; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); }
.topbar-inner { width: min(1120px, calc(100% - 32px)); height: 64px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--brand-dark); }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 7px; color: white; background: var(--brand); font-size: 14px; }
.nav { display: flex; align-items: center; gap: 6px; }
.nav button { border: 0; background: transparent; color: var(--muted); padding: 9px 11px; border-radius: 6px; }
.nav button.active { color: var(--brand-dark); background: #eaf3ef; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: 9px; margin-left: 8px; padding-left: 14px; border-left: 1px solid var(--line); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: white; background: #315d78; font-weight: 800; }
.page { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 64px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: 0; }
.page-head p { margin: 0; color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 9px; }
.btn { min-height: 40px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 14px; background: white; color: var(--ink); font-weight: 650; }
.btn:hover { border-color: #9cafb7; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: white; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #e6b7b4; background: var(--danger-bg); }
.btn.small { min-height: 32px; padding: 5px 9px; font-size: 14px; }
.btn.link { border: 0; background: transparent; color: var(--brand); padding-inline: 6px; }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.product-card { padding: 19px; display: flex; flex-direction: column; min-height: 210px; }
.product-card h2 { margin: 13px 0 6px; font-size: 19px; }
.product-card p { color: var(--muted); margin: 0; line-height: 1.55; }
.product-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; padding-top: 15px; border-top: 1px solid var(--line); }
.product-meta strong { display: block; font-size: 17px; }
.product-meta span { color: var(--muted); font-size: 13px; }
.product-card .btn { margin-top: auto; width: 100%; }
.badge { width: fit-content; display: inline-flex; align-items: center; min-height: 25px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 750; background: #e9f4ef; color: var(--brand-dark); }
.badge.finalized { background: #eceef0; color: #59636a; }
.badge.locked { background: #fff3d9; color: #805300; }
.badge.void { background: #f1f1f1; color: #707070; }
.empty { padding: 64px 20px; text-align: center; border: 1px dashed #bbc8c1; border-radius: 8px; color: var(--muted); }
.empty h2 { color: var(--ink); margin: 0 0 8px; font-size: 20px; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: #e9f0ec; }
.auth-panel { width: min(430px, 100%); padding: 30px; background: white; border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.auth-panel .brand { margin-bottom: 25px; }
.auth-panel h1 { font-size: 25px; margin: 0 0 8px; }
.auth-panel > p { color: var(--muted); line-height: 1.6; margin: 0 0 24px; }
.field { display: grid; gap: 7px; margin-bottom: 15px; }
.field label { font-size: 14px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; min-height: 42px; border: 1px solid #bac6c0; border-radius: 6px; padding: 9px 11px; color: var(--ink); background: white; }
.field textarea { min-height: 82px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid rgba(23,107,77,.15); border-color: var(--brand); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 22px; }
.auth-panel .btn.primary { width: 100%; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }

.back { border: 0; color: var(--brand); background: transparent; padding: 0; margin-bottom: 18px; font-weight: 700; }
.summary-band { background: #16382c; color: white; padding: 24px; border-radius: 8px; margin-bottom: 18px; }
.summary-band h1 { margin: 8px 0 8px; font-size: 27px; }
.summary-band p { color: #cbded6; margin: 0; }
.summary-stats { display: flex; flex-wrap: wrap; gap: 24px; margin-top: 20px; }
.summary-stats strong { display: block; font-size: 21px; color: white; }
.summary-stats span { color: #bdd2c9; font-size: 13px; }
.section { margin-top: 26px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 20px; }
.price-table { width: 100%; border-collapse: collapse; background: white; border: 1px solid var(--line); }
.price-table th, .price-table td { text-align: left; padding: 11px 13px; border-bottom: 1px solid var(--line); }
.price-table th { color: var(--muted); font-size: 13px; background: #fafcfb; }
.price-table tr:last-child td { border-bottom: 0; }
.money { font-variant-numeric: tabular-nums; font-weight: 750; }
.rides { display: grid; gap: 14px; }
.ride { overflow: hidden; }
.ride-head { display: flex; justify-content: space-between; align-items: center; padding: 15px 17px; background: #fafcfb; border-bottom: 1px solid var(--line); }
.ride-head h3 { margin: 0; font-size: 17px; }
.ride-head p { margin: 3px 0 0; color: var(--muted); font-size: 13px; }
.slot-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.slot { min-height: 67px; display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 11px 15px; border-bottom: 1px solid var(--line); }
.slot:nth-child(odd) { border-right: 1px solid var(--line); }
.slot-name { min-width: 0; }
.slot-name strong { display: block; overflow-wrap: anywhere; }
.slot-name span { color: var(--muted); font-size: 13px; }
.owner { color: #315d78; font-weight: 750; }
.vacant { color: var(--muted); }
.settlements { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.settlement { padding: 18px; }
.settlement-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 13px; }
.settlement-head h3 { margin: 0; }
.settlement ul { list-style: none; padding: 0; margin: 0; }
.settlement li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(17, 28, 23, .55); }
.modal { width: min(620px, 100%); max-height: calc(100vh - 40px); overflow: auto; background: white; border-radius: 8px; box-shadow: 0 24px 80px rgba(0,0,0,.24); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); background: white; }
.modal-head h2 { margin: 0; font-size: 20px; }
.icon-btn { width: 36px; height: 36px; border: 0; background: transparent; border-radius: 6px; font-size: 22px; }
.icon-btn:hover { background: var(--wash); }
.modal-body { padding: 20px; }
.item-editor { display: grid; gap: 8px; margin: 10px 0; }
.item-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 38px; gap: 8px; }
.item-row input { min-width: 0; min-height: 40px; border: 1px solid #bac6c0; border-radius: 6px; padding: 8px 10px; }
.item-row button { border: 1px solid #e6b7b4; border-radius: 6px; background: var(--danger-bg); color: var(--danger); }
.template-row, .member-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.template-row:last-child, .member-row:last-child { border-bottom: 0; }
.template-row h3, .member-row h3 { margin: 0 0 3px; font-size: 16px; }
.template-row p, .member-row p { margin: 0; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs button { padding: 10px 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--muted); }
.tabs button.active { border-color: var(--brand); color: var(--brand); font-weight: 750; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 20px); padding: 11px 16px; border-radius: 6px; color: white; background: #1e2b25; opacity: 0; pointer-events: none; transition: .2s; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--danger); }

@media (max-width: 780px) {
  .topbar-inner { width: calc(100% - 20px); height: auto; min-height: 60px; flex-wrap: wrap; padding: 9px 0; }
  .nav { width: 100%; order: 2; overflow-x: auto; border-top: 1px solid var(--line); padding-top: 6px; }
  .user-chip span { display: none; }
  .page { width: calc(100% - 24px); padding-top: 24px; }
  .page-head { align-items: flex-start; flex-direction: column; }
  .grid, .settlements { grid-template-columns: 1fr; }
  .slot-list { grid-template-columns: 1fr; }
  .slot:nth-child(odd) { border-right: 0; }
  .summary-band { padding: 19px; }
  .summary-band h1 { font-size: 23px; }
  .price-table th, .price-table td { padding: 9px; }
}
