:root {
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #17231f;
  background: #f2f5f2;
  font-synthesis: none;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { min-width: 320px; min-height: 100vh; margin: 0; background: radial-gradient(circle at 20% -10%, #e5f2eb 0, transparent 34%), #f2f5f2; }
button, input, select { font: inherit; }
button { cursor: pointer; }
input, select { min-width: 0; border: 1px solid #d8dfda; border-radius: 11px; padding: 12px 13px; color: #17231f; background: #fff; outline: none; }
input:focus, select:focus { border-color: #08775e; box-shadow: 0 0 0 3px #08775e1c; }
button:disabled { cursor: not-allowed; opacity: .58; }
.eyebrow { margin: 0 0 6px; color: #08775e; font-size: 12px; font-weight: 900; letter-spacing: .17em; }
.muted { color: #6d7873; }
.error { color: #c93f30 !important; }
.success { color: #08775e !important; }
.form-message { min-height: 22px; margin: 13px 0 0; font-size: 14px; line-height: 1.5; }

.login-view { min-height: 100vh; display: grid; grid-template-columns: 1fr minmax(380px, 560px); align-items: center; gap: 7vw; padding: 7vw; background: linear-gradient(120deg, #0b342c 0 48%, transparent 48%), radial-gradient(circle at 85% 20%, #d8f04f45, transparent 30%), #eef3ef; }
.login-brand { align-self: start; display: flex; align-items: center; gap: 14px; color: #fff; }
.login-brand strong, .app-brand strong { display: block; font-size: 20px; }
.login-brand small, .app-brand small { display: block; margin-top: 2px; font-size: 9px; letter-spacing: .17em; opacity: .64; }
.brand-mark { display: grid; place-items: center; width: 50px; height: 50px; border-radius: 16px; color: #17342e; background: #d8f04f; font-weight: 950; letter-spacing: -.06em; }
.login-card { width: 100%; padding: 44px; border: 1px solid #e0e7e2; border-radius: 26px; background: #fffffffff2; box-shadow: 0 30px 90px #13251f1c; backdrop-filter: blur(8px); }
.login-card h1 { margin: 4px 0 8px; font-size: 38px; letter-spacing: -.045em; }
.login-card > label { display: grid; gap: 7px; margin: 19px 0; color: #45504b; font-size: 14px; font-weight: 650; }
.login-card button, .checkout-card > button, .create-user-form button[type="submit"] { width: 100%; min-height: 50px; border: 0; border-radius: 12px; color: #17342e; background: #d8f04f; font-weight: 900; }

.app-header { position: sticky; z-index: 20; top: 0; display: grid; grid-template-columns: 270px 1fr auto; align-items: center; gap: 28px; min-height: 78px; padding: 0 max(24px, calc((100vw - 1720px) / 2)); border-bottom: 1px solid #dce3de; background: #ffffffed; backdrop-filter: blur(16px); }
.app-brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; }
.app-brand .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
nav { justify-self: center; display: flex; gap: 6px; padding: 5px; border-radius: 13px; background: #eef2ef; }
nav button { border: 0; border-radius: 9px; padding: 9px 17px; color: #68736e; background: transparent; font-weight: 750; }
nav button.active { color: #fff; background: #0d493d; box-shadow: 0 5px 14px #0d493d24; }
.account-area { display: flex; align-items: center; justify-content: flex-end; gap: 13px; }
.account-area > div:first-child { text-align: right; }
.account-area strong, .account-area small { display: block; }
.account-area small { color: #7a847f; font-size: 11px; }
.balance-pill { padding: 9px 13px; border-radius: 10px; color: #0a654f; background: #e7f5ef; font-weight: 850; }
.icon-button { border: 1px solid #dce3de; border-radius: 10px; padding: 9px 12px; color: #55605b; background: #fff; }

main { width: min(1720px, calc(100% - 48px)); margin: 0 auto; padding: 42px 0 80px; }
.page-view > .page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading h1 { margin: 5px 0; font-size: clamp(30px, 4vw, 52px); line-height: 1.08; letter-spacing: -.045em; }
.page-heading p:last-child { margin: 8px 0 0; }
.secondary, .primary-small, .danger-small { border-radius: 10px; padding: 10px 15px; font-weight: 800; }
.secondary { border: 1px solid #d8dfda; color: #08775e; background: #fff; }
.primary-small { border: 0; color: #fff; background: #08775e; }
.danger-small { border: 1px solid #efc4be; color: #b93629; background: #fff5f3; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.summary-grid article { padding: 17px 19px; border: 1px solid #dfe5e0; border-radius: 15px; background: #fff; }
.summary-grid span, .summary-grid small, .summary-grid strong { display: block; }
.summary-grid span { color: #6d7873; font-size: 13px; }
.summary-grid strong { margin: 7px 0 3px; font-size: 25px; }
.summary-grid small { color: #89928e; }

.toolbar { display: grid; grid-template-columns: 1fr 190px auto; gap: 12px; margin-bottom: 16px; }
.toolbar input, .toolbar select { min-height: 48px; }
#count { align-self: center; min-width: 58px; color: #69736f; text-align: right; }
.shop-layout { display: grid; grid-template-columns: minmax(0, 1fr) 430px; align-items: start; gap: 28px; }
.products { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.product-card { position: relative; display: grid; gap: 8px; min-height: 185px; padding: 18px 18px 18px 50px; border: 1px solid #dfe5e0; border-radius: 16px; color: inherit; background: #fff; text-align: left; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease; }
.product-card:not(:disabled):hover { transform: translateY(-2px); border-color: #9ab7ad; }
.product-card.active { border-color: #08775e; box-shadow: 0 0 0 2px #08775e; }
.product-card:disabled { cursor: default; opacity: 1; padding-left: 18px; }
.product-card strong { align-self: start; min-height: 44px; line-height: 1.45; }
.product-card small { padding-right: 48px; color: #76807b; }
.check { position: absolute; left: 16px; top: 17px; display: grid; place-items: center; width: 22px; height: 22px; border: 1px solid #b8c4bf; border-radius: 6px; color: #08775e; font-weight: 900; }
.product-card.active .check { color: #fff; border-color: #08775e; background: #08775e; }
.tag { position: absolute; right: 14px; top: 14px; padding: 4px 8px; border-radius: 999px; color: #08775e; background: #e6f5ef; font-size: 12px; }
.meta { color: #68736e; }
.prices { align-self: end; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.price { color: #c44a26; font-size: 23px; font-weight: 900; }
.prices del { color: #8b9590; font-size: 13px; }
aside { position: sticky; top: 98px; }
.checkout-card { padding: 25px; border-radius: 20px; color: #fff; background: #123a32; box-shadow: 0 20px 50px #17352e24; }
.checkout-card h2 { margin: 0 0 17px; font-size: 25px; }
.checkout-card > label { display: grid; gap: 7px; margin: 16px 0; color: #d8e2de; font-size: 14px; }
.input-suffix { position: relative; display: block; }
.input-suffix input { width: 100%; padding-right: 82px; }
.input-suffix b { position: absolute; right: 13px; top: 13px; color: #71807a; font-weight: 500; }
.selected { min-height: 72px; display: grid; gap: 12px; padding: 14px; border-radius: 12px; color: #d8e0dd; background: #ffffff0d; }
.empty-selection { display: block; }
.selected-list { display: grid; gap: 10px; }
.selected-list div, .selected-total { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; min-width: 0; }
.selected-list span { min-width: 0; line-height: 1.45; overflow-wrap: anywhere; }
.selected-list b { flex: none; }
.selected-total { padding-top: 12px; border-top: 1px solid #ffffff25; color: #fff; }

.panel { margin-bottom: 18px; padding: 22px; border: 1px solid #dde4df; border-radius: 17px; background: #fff; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.panel-heading h2 { margin: 0 0 4px; }
.panel-heading p { margin: 0; color: #737d78; }
.form-grid { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr 1fr 150px; align-items: end; gap: 12px; }
.form-grid label { display: grid; gap: 7px; color: #4d5853; font-size: 13px; font-weight: 700; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-heading { padding: 21px 22px 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 15px 16px; border-bottom: 1px solid #e4e9e5; text-align: left; vertical-align: top; }
th { color: #69736f; background: #f6f8f6; font-size: 12px; letter-spacing: .04em; white-space: nowrap; }
td { font-size: 14px; }
td small { display: block; margin-top: 5px; color: #7b8580; }
td input { width: 150px; padding: 9px 10px; }
.user-actions { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.user-actions .secondary { min-height: 38px; padding: 8px 12px; }
.switch { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
.switch input { width: auto; }
.order-filters { display: grid; grid-template-columns: 1fr 220px 220px auto; gap: 12px; }
.orders-table code { display: block; color: #0a654f; font-weight: 800; }
.order-products { display: grid; gap: 4px; max-width: 430px; }
.status { display: inline-block; padding: 5px 8px; border-radius: 999px; font-size: 12px; font-weight: 850; white-space: nowrap; }
.status-succeeded { color: #08775e; background: #e3f3ed; }
.status-processing, .status-cancelling { color: #765315; background: #fff1c9; }
.status-needs_review, .status-cancel_review { color: #a54828; background: #ffebe2; }
.status-failed { color: #9c3025; background: #f9e3df; }
.status-cancelled { color: #66716c; background: #e9eeeb; }
.empty { padding: 30px; color: #6b7671; text-align: center; }

.ledger-dialog { width: min(820px, calc(100% - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 22px; color: #18202a; background: #f5f7f5; box-shadow: 0 30px 100px #071c1845; overflow: hidden; }
.ledger-dialog::backdrop { background: #102924a6; backdrop-filter: blur(6px); }
.ledger-dialog-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 25px 28px 18px; background: #fff; }
.ledger-dialog-header h2 { margin: 3px 0 0; font-size: 25px; }
.ledger-dialog-header .eyebrow { margin: 0; }
.dialog-close { display: grid; place-items: center; width: 42px; height: 42px; padding: 0; border: 0; border-radius: 50%; color: #52605a; background: #edf1ee; font-size: 26px; line-height: 1; }
.ledger-summary { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 28px 18px; background: #fff; }
.ledger-summary span { padding: 9px 12px; border-radius: 10px; color: #64706b; background: #f1f5f2; font-size: 13px; }
.ledger-summary strong { margin-left: 5px; color: #12372f; }
.ledger-timeline { position: relative; display: grid; gap: 14px; max-height: calc(100vh - 205px); padding: 22px 28px 30px 50px; overflow-y: auto; }
.ledger-timeline::before { position: absolute; top: 24px; bottom: 30px; left: 33px; width: 2px; background: #d6e0db; content: ""; }
.ledger-entry { position: relative; padding: 18px; border: 1px solid #dfe6e2; border-radius: 15px; background: #fff; box-shadow: 0 5px 16px #17372e0a; }
.ledger-dot { position: absolute; top: 22px; left: -24px; width: 12px; height: 12px; border: 3px solid #f5f7f5; border-radius: 50%; background: #08775e; box-shadow: 0 0 0 2px #08775e; }
.ledger-debit .ledger-dot { background: #c44a26; box-shadow: 0 0 0 2px #c44a26; }
.ledger-entry-head, .ledger-entry-head > div { display: flex; align-items: center; gap: 12px; }
.ledger-entry-head { justify-content: space-between; }
.ledger-entry-head time { color: #7b8580; font-size: 12px; }
.ledger-amount { color: #08775e; font-size: 20px; white-space: nowrap; }
.ledger-debit .ledger-amount { color: #c44a26; }
.ledger-balances { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 13px; }
.ledger-balances span { padding: 7px 9px; border-radius: 8px; color: #6d7873; background: #f3f6f4; font-size: 12px; }
.ledger-note { margin: 11px 0 0; color: #64706b; font-size: 13px; }
.ledger-order-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; margin-top: 13px; padding-top: 12px; border-top: 1px dashed #dce3df; color: #65716c; font-size: 12px; }
.ledger-products { display: grid; gap: 7px; margin-top: 10px; }
.ledger-products > div { display: flex; justify-content: space-between; gap: 18px; padding: 10px 12px; border-radius: 9px; background: #f7f9f7; }
.ledger-products span { min-width: 0; }
.ledger-products span:last-child { flex: none; text-align: right; }
.ledger-products strong, .ledger-products b { display: block; font-size: 13px; }
.ledger-products small { display: block; margin-top: 3px; color: #7b8580; font-size: 11px; }

.confirm-dialog { width: min(540px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 24px; color: #18202a; background: #fff; box-shadow: 0 30px 100px #071c1845; overflow: hidden; }
.confirm-dialog::backdrop { background: #102924a6; backdrop-filter: blur(6px); }
.confirm-dialog[data-mode="cancel"] .confirm-accent { background: linear-gradient(90deg, #b4372a, #ea745d); }
.confirm-dialog[data-mode="cancel"] .confirm-icon { color: #fff; background: #c94c3b; }
.confirm-dialog[data-mode="cancel"] .confirm-submit { background: #b93e30; box-shadow: 0 8px 20px #b93e3035; }
.confirm-accent { height: 7px; background: linear-gradient(90deg, #08775e, #50b88f 58%, #d8f04f); }
.confirm-content { padding: 30px; }
.confirm-heading { display: flex; align-items: center; gap: 16px; }
.confirm-icon { display: grid; place-items: center; flex: 0 0 48px; height: 48px; border-radius: 15px; color: #17342e; background: #d8f04f; font-size: 24px; font-weight: 900; }
.confirm-eyebrow { margin: 0 0 3px; color: #08775e; font-size: 11px; font-weight: 900; letter-spacing: .14em; }
.confirm-heading h2 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.confirm-warning { margin: 22px 0 18px; padding: 13px 15px; border-radius: 12px; color: #75511a; background: #fff5d9; font-size: 14px; line-height: 1.55; }
.confirm-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 0 0 15px; }
.confirm-facts div { padding: 12px; border: 1px solid #e3e8e4; border-radius: 11px; background: #f7f9f7; }
.confirm-facts dt { margin-bottom: 5px; color: #78817d; font-size: 11px; }
.confirm-facts dd { margin: 0; font-size: 13px; font-weight: 800; overflow-wrap: anywhere; }
.confirm-items { display: grid; gap: 9px; max-height: 220px; padding: 14px; overflow-y: auto; border: 1px solid #e3e8e4; border-radius: 13px; }
.confirm-items div { display: flex; justify-content: space-between; gap: 18px; font-size: 14px; }
.confirm-items b { flex: none; }
.confirm-total { display: flex; align-items: baseline; justify-content: space-between; margin: 18px 0; }
.confirm-total span { color: #69736f; }
.confirm-total strong { color: #c44a26; font-size: 30px; }
.confirm-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px; }
.confirm-actions button { min-height: 50px; border: 0; border-radius: 13px; font-weight: 850; }
.confirm-cancel { color: #46504c; background: #edf1ee; }
.confirm-submit { color: #fff; background: #08775e; box-shadow: 0 8px 20px #08775e35; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100% - 48px)); padding: 14px 18px; border-radius: 12px; color: #fff; background: #08775e; box-shadow: 0 14px 40px #152b2538; font-weight: 700; }
.toast-error { background: #b84133; }

@media (max-width: 1300px) {
  .products { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid button { align-self: end; }
}

@media (max-width: 1050px) {
  .app-header { grid-template-columns: 1fr auto; padding: 12px 20px; }
  .app-header nav { grid-row: 2; grid-column: 1 / -1; justify-self: stretch; justify-content: center; }
  .shop-layout { grid-template-columns: 1fr; }
  aside { position: static; }
  .order-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .login-view { display: block; padding: 24px 16px; background: #eef3ef; }
  .login-brand { margin-bottom: 40px; color: #17342e; }
  .login-card { padding: 28px 22px; }
  main { width: min(100% - 28px, 720px); padding-top: 28px; }
  .account-area > div:first-child { display: none; }
  .balance-pill { font-size: 12px; }
  nav { overflow-x: auto; justify-content: flex-start !important; }
  nav button { white-space: nowrap; }
  .page-heading, .panel-heading { align-items: flex-start !important; }
  .summary-grid, .products, .form-grid, .order-filters { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: 1fr; }
  #count { text-align: left; }
  .confirm-content { padding: 22px; }
  .confirm-facts, .confirm-actions { grid-template-columns: 1fr; }
  .ledger-dialog-header { padding: 21px 20px 16px; }
  .ledger-summary { padding: 0 20px 16px; }
  .ledger-timeline { padding: 18px 18px 24px 40px; }
  .ledger-timeline::before { left: 26px; }
  .ledger-entry-head, .ledger-entry-head > div, .ledger-products > div { align-items: flex-start; flex-direction: column; }
  .ledger-products span:last-child { text-align: left; }
}
