:root {
  color-scheme: light;
  --bg: #f3f1eb;
  --surface: #fffefb;
  --surface-2: #ebe8df;
  --ink: #1d2420;
  --muted: #69716c;
  --line: #d9d7cf;
  --green: #235f49;
  --green-soft: #e1eee7;
  --gold: #a8732b;
  --red: #a54136;
  --shadow: 0 18px 50px rgba(35, 43, 38, .11);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 85% 0, #fff 0, transparent 32%), var(--bg); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }

.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; min-height: 82px; padding: 13px clamp(16px, 3vw, 38px); border-bottom: 1px solid rgba(35, 43, 38, .1); background: rgba(255, 254, 251, .94); backdrop-filter: blur(16px); }
.brand-block { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-mark { width: 54px; height: 54px; object-fit: contain; }
.brand-block p, .eyebrow { margin: 0 0 3px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.brand-block h1 { margin: 0; font-size: clamp(18px, 2.5vw, 25px); letter-spacing: -.03em; }
.header-actions { display: flex; align-items: center; gap: 9px; }

.soft-button, .cart-button, .back-button, .primary-button, .danger-button { min-height: 44px; border-radius: 12px; border: 1px solid var(--line); padding: 10px 15px; cursor: pointer; font-weight: 750; }
.soft-button, .back-button { color: var(--ink); background: var(--surface); }
.cart-button, .primary-button { color: #fff; border-color: var(--green); background: var(--green); box-shadow: 0 8px 20px rgba(35, 95, 73, .18); }
.cart-button { display: flex; align-items: center; gap: 10px; }
.cart-button strong { display: grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; color: var(--green); background: #fff; }
.danger-button { color: var(--red); border-color: rgba(165, 65, 54, .25); background: #fff; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(35, 95, 73, .22); outline-offset: 2px; }

.workspace { width: min(1400px, 100%); margin: 0 auto; padding: clamp(18px, 3vw, 34px); }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.hero h2 { margin: 0; font-size: clamp(25px, 4vw, 42px); letter-spacing: -.045em; }
.hero p:last-child { margin: 7px 0 0; color: var(--muted); }
.search-panel { position: sticky; top: 96px; z-index: 10; margin-bottom: 22px; padding: 12px; border: 1px solid rgba(35, 43, 38, .09); border-radius: 17px; background: rgba(255, 254, 251, .92); box-shadow: 0 10px 32px rgba(35, 43, 38, .06); backdrop-filter: blur(12px); }
.search-box { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; }
.search-box > span { color: var(--green); font-size: 25px; }
.search-box input { width: 100%; height: 48px; padding: 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 17px; font-weight: 650; }
.search-box button { width: 34px; height: 34px; border: 0; border-radius: 999px; cursor: pointer; color: var(--muted); background: var(--surface-2); font-size: 20px; }
.alphabet { display: flex; gap: 5px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.alphabet::-webkit-scrollbar { display: none; }
.alphabet button { flex: 0 0 34px; height: 34px; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; color: var(--ink); background: var(--surface); font-weight: 750; }
.alphabet button.active { color: #fff; border-color: var(--green); background: var(--green); }

.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.category-card { min-height: 112px; padding: 17px; border: 1px solid var(--line); border-left: 5px solid var(--green); border-radius: 15px; cursor: pointer; text-align: left; color: var(--ink); background: var(--surface); box-shadow: 0 7px 20px rgba(35, 43, 38, .045); transition: transform .13s ease, border-color .13s ease; }
.category-card:nth-child(3n+2) { border-left-color: var(--gold); }
.category-card:nth-child(3n+3) { border-left-color: #56778a; }
.category-card:hover { transform: translateY(-2px); border-color: rgba(35, 95, 73, .4); }
.category-card strong { display: block; font-size: 18px; letter-spacing: -.02em; }
.category-card span { display: flex; justify-content: space-between; margin-top: 22px; color: var(--muted); font-size: 13px; font-weight: 650; }
.result-meta { margin-bottom: 10px; color: var(--muted); font-size: 13px; font-weight: 650; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(285px, 1fr)); gap: 11px; }
.product-card { display: flex; min-height: 168px; flex-direction: column; gap: 11px; padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.product-card.selected { border-color: rgba(35, 95, 73, .65); box-shadow: 0 0 0 3px rgba(35, 95, 73, .08); }
.product-card h3 { margin: 0; font-size: 16px; line-height: 1.28; }
.unit-chip { width: fit-content; padding: 5px 9px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.presentation-field { display: grid; gap: 5px; color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }
.presentation-field select { width: 100%; min-height: 42px; padding: 8px 34px 8px 10px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #fff; font-size: 12px; font-weight: 700; text-transform: none; }
.presentation-meta { display: grid; gap: 3px; padding: 10px; border-radius: 11px; background: #f5f3ed; }
.presentation-meta strong { color: var(--green); font-size: 13px; }
.presentation-meta span, .presentation-meta small { overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.35; text-overflow: ellipsis; }
.presentation-meta span { white-space: nowrap; }
.presentation-count-label { margin-top: -6px; text-align: center; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.stepper { display: grid; grid-template-columns: 46px minmax(68px, 1fr) 46px; gap: 8px; margin-top: auto; }
.stepper button { height: 46px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--green); background: #fff; font-size: 24px; font-weight: 800; }
.stepper button:first-child { color: var(--red); }
.stepper input { width: 100%; min-width: 0; height: 46px; border: 1px solid var(--line); border-radius: 12px; text-align: center; color: var(--ink); background: #f8f7f3; font-size: 18px; font-weight: 800; }

.loading-state, .error-state, .empty-state { padding: 60px 20px; text-align: center; color: var(--muted); font-weight: 650; }
.error-state { color: var(--red); }
.mobile-cart { position: fixed; right: 14px; bottom: max(14px, env(safe-area-inset-bottom)); left: 14px; z-index: 18; display: none; align-items: center; justify-content: space-between; min-height: 56px; padding: 10px 17px; border: 0; border-radius: 15px; cursor: pointer; color: #fff; background: var(--green); box-shadow: var(--shadow); }

.app-dialog { width: min(980px, calc(100vw - 28px)); max-height: min(850px, calc(100vh - 28px)); padding: 0; border: 1px solid var(--line); border-radius: 19px; color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgba(24, 31, 27, .57); backdrop-filter: blur(4px); }
.dialog-shell { display: flex; max-height: inherit; flex-direction: column; margin: 0; }
.dialog-head, .dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 16px 18px; }
.dialog-head { border-bottom: 1px solid var(--line); }
.dialog-head h2 { margin: 0; font-size: 23px; }
.dialog-head-actions, .dialog-primary-actions { display: flex; align-items: center; gap: 10px; }
.close-button { display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--muted); background: #fff; font-size: 25px; }
.dialog-body { flex: 1; overflow: auto; padding: 17px 18px; }
.dialog-foot { border-top: 1px solid var(--line); }
.request-meta { display: grid; grid-template-columns: .75fr 1.25fr; gap: 12px; margin-bottom: 18px; }
.request-meta label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.request-meta select, .request-meta textarea { width: 100%; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; color: var(--ink); background: #fff; }
.summary-list { display: grid; gap: 12px; }
.summary-group h3 { margin: 12px 0 7px; color: var(--green); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.summary-row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.summary-row p { margin: 0 0 4px; font-weight: 750; }
.summary-row small { display: block; color: var(--muted); }
.summary-row .stepper { width: 185px; margin: 0; }

.history-dialog { width: min(1120px, calc(100vw - 28px)); }
.history-layout { display: grid; grid-template-columns: 350px minmax(0, 1fr); min-height: 580px; overflow: hidden; }
.history-list { padding: 13px; overflow: auto; border-right: 1px solid var(--line); background: #f7f5ef; }
.history-card { width: 100%; margin-bottom: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; text-align: left; color: var(--ink); background: #fff; }
.history-card.active { border-color: var(--green); box-shadow: 0 0 0 2px rgba(35, 95, 73, .09); }
.history-card div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.history-card strong { font-size: 14px; }
.history-card p { margin: 8px 0 5px; font-weight: 700; }
.history-card small { color: var(--muted); }
.status-chip { display: inline-flex; width: fit-content; padding: 4px 8px; border: 1px solid rgba(35, 95, 73, .18); border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 800; }
.history-detail { overflow: auto; padding: 18px; }
.history-detail h3 { margin: 0; font-size: 23px; }
.history-detail-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 8px 0 18px; color: var(--muted); font-size: 13px; }
.email-status { width: fit-content; margin: -8px 0 15px; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.email-status.is-sent { color: var(--green); background: var(--green-soft); }
.email-status.is-pending { color: var(--red); background: #f8e6e2; }
.history-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-line p { margin: 0; font-weight: 700; }
.history-line small { display: block; color: var(--muted); }
.history-line strong { white-space: nowrap; color: var(--green); }
.toast { position: fixed; top: 96px; left: 50%; z-index: 80; transform: translateX(-50%); max-width: min(560px, calc(100vw - 28px)); padding: 13px 17px; border-radius: 13px; color: #fff; background: var(--green); box-shadow: var(--shadow); font-weight: 750; }
.toast.error { background: var(--red); }

@media (max-width: 760px) {
  .app-header { min-height: 72px; padding: 10px 13px; }
  .brand-mark { width: 44px; height: 44px; }
  .brand-block p { display: none; }
  .header-actions .soft-button { width: 45px; padding: 8px; overflow: hidden; color: transparent; white-space: nowrap; }
  .header-actions .soft-button span { color: var(--ink); }
  .cart-button > span { display: none; }
  .workspace { padding: 16px 13px 92px; }
  .hero { align-items: flex-start; }
  .hero h2 { font-size: 27px; }
  .search-panel { top: 80px; margin-inline: -4px; }
  .category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .category-card { min-height: 104px; padding: 13px; }
  .category-card strong { font-size: 15px; }
  .product-grid { grid-template-columns: 1fr; }
  .mobile-cart:not([hidden]) { display: flex; }
  .request-meta, .history-layout { grid-template-columns: 1fr; }
  .history-layout { min-height: 0; max-height: calc(100vh - 120px); overflow: auto; }
  .history-list { max-height: 260px; border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-row { grid-template-columns: 1fr; }
  .summary-row .stepper { width: 100%; }
  .dialog-foot { align-items: stretch; }
  .dialog-primary-actions { flex: 1; justify-content: flex-end; }
  .dialog-primary-actions span { display: none; }
}
