:root { color-scheme: light; --ink:#1b211c; --muted:#687068; --paper:#fbfaf6; --panel:#fff; --line:#dfe3dc; --brand:#3d6046; --brand-dark:#294331; --soft:#edf3ed; --danger:#a43636; --shadow:0 12px 32px rgba(31,48,34,.09); font-family:Inter,"Noto Sans JP",system-ui,sans-serif; }
  * { box-sizing:border-box; }
  html, body { margin:0; min-width:0; min-height:100%; background:var(--paper); color:var(--ink); }
  body { overflow-x:hidden; }
  button, input, select { font:inherit; }
  button { min-height:44px; border:0; border-radius:12px; padding:.7rem 1rem; background:var(--brand); color:#fff; font-weight:700; cursor:pointer; }
  button:hover { background:var(--brand-dark); }
  button:focus-visible, input:focus-visible, select:focus-visible { outline:3px solid rgba(61,96,70,.3); outline-offset:2px; }
  button:disabled { opacity:.55; cursor:not-allowed; }
  .hidden { display:none !important; }
  .app { width:100%; min-width:0; }
  .login-view { min-height:100dvh; display:grid; place-items:center; padding:20px; background:linear-gradient(145deg,#e9efe8,#faf8f0 55%,#e8ddd1); }
  .login-card { width:min(100%,420px); padding:32px 24px; border:1px solid var(--line); border-radius:24px; background:rgba(255,255,255,.94); box-shadow:var(--shadow); text-align:center; }
  h1,h2,h3,p { margin-top:0; }
  .eyebrow { margin-bottom:6px; color:var(--brand); font-size:.75rem; font-weight:800; letter-spacing:.14em; }
  .message,.form-error { min-height:1.4em; margin:10px 0 0; color:var(--danger); font-size:.9rem; }
  .topbar { display:flex; justify-content:space-between; gap:12px; align-items:center; padding:16px; background:#182119; color:#fff; }
  .topbar h1 { margin:0; font-size:1.35rem; }
  .topbar .eyebrow { color:#b8ccb9; }
  .user-tools { display:flex; gap:8px; align-items:center; min-width:0; }
  #currentUserName { max-width:120px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .nav { position:sticky; top:0; z-index:10; display:flex; gap:6px; overflow-x:auto; padding:8px 12px; background:#fff; border-bottom:1px solid var(--line); scrollbar-width:none; }
  .nav button { flex:0 0 auto; min-height:40px; padding:.55rem .85rem; background:transparent; color:var(--muted); }
  .nav button.active { background:var(--soft); color:var(--brand-dark); }
  main { width:min(100%,1100px); margin:0 auto; padding:18px 14px 72px; }
  .screen { min-width:0; }
  .hero-card,.detail-card,.receipt-preview,.editor-form,.item-card,.category-group,.category-admin { border:1px solid var(--line); border-radius:18px; background:var(--panel); box-shadow:0 5px 18px rgba(31,48,34,.04); }
  .hero-card { padding:24px 20px; background:linear-gradient(135deg,#fff,#f0f4ed); }
  .home-actions { display:grid; grid-template-columns:1fr; gap:12px; margin-top:16px; }
  .home-action { padding:20px; text-align:left; }
  .home-action small { display:block; margin-top:5px; font-weight:400; opacity:.85; }
  .screen-heading { display:flex; flex-direction:column; gap:10px; margin-bottom:16px; }
  .screen-heading h2 { margin-bottom:4px; }
  .screen-heading p { margin:0; color:var(--muted); }
  .button-secondary { background:#eef1ed; color:var(--ink); }
  .button-secondary:hover { background:#dfe6df; }
  .text-button { padding:0; min-height:36px; background:transparent; color:var(--brand); }
  .notice { margin-bottom:14px; padding:14px; border:1px solid #dcae69; border-radius:12px; background:#fff6e8; }
  #checkoutForm { display:grid; gap:16px; min-width:0; }
  .catalog { display:grid; gap:14px; min-width:0; }
  .category-group { padding:16px; }
  .category-group h3 { margin-bottom:12px; }
  .product-row { display:grid; grid-template-columns:minmax(0,1fr) 92px; gap:10px; align-items:center; padding:12px 0; border-top:1px solid var(--line); }
  .product-row:first-of-type { border-top:0; }
  .product-meta { min-width:0; }
  .product-meta strong { display:block; overflow-wrap:anywhere; }
  .product-meta span { color:var(--muted); font-size:.9rem; }
  input, select { width:100%; min-width:0; min-height:44px; padding:.65rem .75rem; border:1px solid #bbc3ba; border-radius:10px; background:#fff; color:var(--ink); }
  input[aria-invalid="true"],select[aria-invalid="true"] { border-color:var(--danger); }
  .qty-input { text-align:right; }
  .receipt-preview { padding:18px; align-self:start; }
  .receipt-lines { display:grid; gap:10px; }
  .receipt-line { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px; align-items:center; font-size:.92rem; }
  .receipt-product { display:flex; min-width:0; gap:6px; align-items:center; }
  .receipt-product strong { min-width:0; overflow-wrap:anywhere; }
  .receipt-subtotal { white-space:nowrap; text-align:right; }
  .quantity-badge { display:inline-flex; flex:0 0 auto; align-items:center; justify-content:center; min-width:2.25em; padding:.18em .5em; border-radius:999px; background:var(--soft); color:var(--brand-dark); font-size:.82em; font-weight:800; white-space:nowrap; }
  .receipt-empty { color:var(--muted); }
  .receipt-total { display:flex; justify-content:space-between; margin:16px 0; padding-top:14px; border-top:2px solid var(--ink); font-size:1.2rem; }
  #submitReceiptButton { width:100%; }
  .category-group-heading,.receipt-heading { display:flex; justify-content:space-between; gap:8px; align-items:center; min-width:0; }
  .category-group-heading h3,.receipt-heading h3 { margin:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .selection-count,.receipt-heading span { flex:0 0 auto; color:var(--muted); font-size:.78rem; }
  .checkout-pagination { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); gap:8px; align-items:center; text-align:center; }
  .checkout-pagination button:last-child { justify-self:stretch; }
  .checkout-pagination button:first-child { justify-self:stretch; }
  #receiptPagination:empty { display:none; }
  .main-view.checkout-active { height:100dvh; display:grid; grid-template-rows:auto auto minmax(0,1fr); overflow:hidden; }
  .main-view.checkout-active main { width:min(100%,1100px); height:100%; min-height:0; padding:8px 10px; overflow:hidden; }
  #checkoutScreen:not(.hidden) { height:100%; min-height:0; display:grid; grid-template-rows:auto minmax(0,1fr); position:relative; }
  #checkoutScreen .screen-heading { min-height:0; margin-bottom:7px; align-items:center; }
  #checkoutScreen .screen-heading h2 { margin:0; font-size:1.12rem; }
  #checkoutScreen .screen-heading p { display:none; }
  #checkoutScreen .screen-heading button { min-height:38px; padding:.45rem .7rem; }
  #checkoutScreen .notice { position:absolute; z-index:5; top:48px; left:0; right:0; margin:0; padding:9px 11px; font-size:.82rem; box-shadow:var(--shadow); }
  #checkoutForm { height:100%; min-height:0; grid-template-rows:minmax(0,1fr) minmax(210px,auto); gap:8px; }
  #productCatalog { height:100%; min-height:0; display:grid; gap:7px; align-content:start; overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
  #productCatalog > .item-card { align-self:start; }
  #productCatalog > .category-group { align-self:start; }
  .category-group { min-width:0; padding:7px 9px; overflow:hidden; }
  .category-group-heading { margin-bottom:2px; }
  #productCatalog .category-group-heading { align-items:flex-start; gap:4px; }
  #productCatalog .category-group-heading h3 { overflow:visible; text-overflow:clip; white-space:normal; overflow-wrap:anywhere; font-size:.78rem; line-height:1.2; }
  #productCatalog .selection-count { font-size:.66rem; line-height:1.2; }
  .category-products { display:grid; grid-template-columns:minmax(0,1fr); min-width:0; }
  #productCatalog .product-row { grid-template-columns:minmax(0,1fr) 54px; gap:5px; min-height:0; padding:3px 0; }
  #productCatalog .product-meta strong { overflow:visible; text-overflow:clip; white-space:normal; overflow-wrap:anywhere; font-size:.72rem; line-height:1.2; }
  #productCatalog .product-meta span { font-size:.66rem; line-height:1.15; }
  #productCatalog .qty-input { min-height:34px; padding:.25rem .35rem; font-size:.74rem; }
  .receipt-preview { height:100%; min-height:210px; padding:9px 12px; align-self:stretch; display:grid; grid-template-rows:auto minmax(0,1fr) auto auto auto auto; gap:5px; overflow:hidden; }
  .receipt-lines { min-height:0; align-content:start; gap:4px; overflow-x:hidden; overflow-y:auto; overscroll-behavior:contain; }
  .receipt-line { gap:6px; font-size:.82rem; }
  .receipt-product strong { display:-webkit-box; overflow:hidden; -webkit-box-orient:vertical; -webkit-line-clamp:2; line-height:1.2; }
  .receipt-empty { margin:5px 0; font-size:.84rem; }
  .receipt-total { margin:0; padding-top:5px; font-size:1.05rem; }
  #checkoutError { min-height:1.1em; max-height:2.4em; margin:0; overflow:hidden; font-size:.76rem; }
  #submitReceiptButton { min-height:40px; padding:.5rem .8rem; }
  .card-list { display:grid; gap:12px; }
  .receipt-filter { display:grid; gap:10px; margin-bottom:8px; padding:14px; border:1px solid var(--line); border-radius:16px; background:var(--panel); }
  .receipt-filter-actions { display:flex; flex-wrap:wrap; gap:8px; }
  .receipt-filter-actions button { flex:1 1 140px; }
  .receipt-filter .form-error { margin:0; }
  .history-status { min-height:1.4em; margin:8px 0; color:var(--muted); font-size:.86rem; }
  .load-more { display:block; width:100%; margin-top:14px; }
  .receipt-card-summary { display:grid; gap:7px; margin-top:13px; padding:11px 12px; border-radius:12px; background:var(--soft); }
  .receipt-summary-row { display:flex; min-width:0; justify-content:space-between; gap:10px; align-items:center; }
  .receipt-summary-row strong { min-width:0; overflow-wrap:anywhere; }
  .receipt-summary-omitted,.receipt-summary-totals { margin:7px 0 0; color:var(--muted); font-size:.84rem; }
  .receipt-summary-omitted { margin:0; }
  .item-card { padding:16px; min-width:0; }
  .item-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
  .item-head h3 { margin-bottom:4px; overflow-wrap:anywhere; }
  .meta { color:var(--muted); font-size:.88rem; overflow-wrap:anywhere; }
  .item-actions,.form-actions,.dialog-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:14px; }
  .danger { background:#fff0f0; color:var(--danger); }
  .danger:hover { background:#f7dede; }
  .editor-form { display:grid; grid-template-columns:1fr; gap:14px; margin-bottom:16px; padding:16px; }
  .category-admin { margin-bottom:16px; padding:16px; }
  .inline-form { margin-top:12px; }
  .category-admin-list { display:grid; gap:8px; margin-top:12px; }
  .category-admin-row { display:flex; justify-content:space-between; gap:8px; align-items:center; padding:9px 0; border-top:1px solid var(--line); }
  .category-admin-row strong { min-width:0; overflow-wrap:anywhere; }
  .compact { min-height:38px; padding:.45rem .65rem; }
  label span { display:block; margin-bottom:6px; font-size:.86rem; font-weight:700; }
  .check-label { display:flex; align-items:center; gap:9px; }
  .check-label input { width:22px; min-height:22px; }
  .check-label span { margin:0; }
  .detail-card { overflow:hidden; padding:18px; }
  .detail-grid { display:grid; gap:8px; margin-bottom:18px; }
  .detail-row { display:flex; justify-content:space-between; gap:12px; padding:9px 0; border-bottom:1px solid var(--line); }
  .detail-row span:last-child { text-align:right; overflow-wrap:anywhere; }
  .detail-items { width:100%; table-layout:fixed; border-collapse:collapse; font-size:.9rem; }
  .detail-items th,.detail-items td { padding:10px 5px; border-bottom:1px solid var(--line); text-align:right; overflow-wrap:anywhere; }
  .detail-items th:first-child,.detail-items td:first-child { text-align:left; overflow-wrap:anywhere; }
  .detail-items th:first-child { width:40%; }
  .detail-items th:nth-child(2) { width:21%; }
  .detail-items th:nth-child(3) { width:16%; }
  .detail-items th:nth-child(4) { width:23%; }
  .detail-items .detail-product-name { font-weight:800; }
  .detail-total { margin-top:16px; text-align:right; font-size:1.25rem; }
  .dialog-backdrop { position:fixed; inset:0; z-index:100; display:grid; place-items:center; padding:18px; background:rgba(10,15,11,.65); }
  .dialog-card { width:min(100%,440px); padding:22px; border-radius:18px; background:#fff; box-shadow:var(--shadow); }
  .toast { position:fixed; right:14px; bottom:14px; z-index:120; max-width:calc(100% - 28px); padding:13px 16px; border-radius:12px; background:#182119; color:#fff; box-shadow:var(--shadow); }
  @media (max-height:650px) {
    .main-view.checkout-active .topbar { padding:6px 10px; }
    .main-view.checkout-active .topbar .eyebrow { display:none; }
    .main-view.checkout-active .topbar h1 { font-size:1rem; }
    .main-view.checkout-active .topbar button { min-height:34px; padding:.35rem .6rem; }
    .main-view.checkout-active .nav { padding:3px 8px; }
    .main-view.checkout-active .nav button { min-height:34px; padding:.35rem .65rem; }
  }
  @media (min-width:700px) {
    .topbar { padding:18px 28px; }
    main { padding:28px 24px 80px; }
    .screen-heading { flex-direction:row; justify-content:space-between; align-items:center; }
    .receipt-filter { grid-template-columns:minmax(180px,1.4fr) repeat(2,minmax(150px,1fr)); align-items:end; }
    .receipt-filter-actions { flex-wrap:nowrap; }
    .receipt-filter .form-error { grid-column:1/-1; }
    .home-actions { grid-template-columns:repeat(3,1fr); }
    #checkoutForm { grid-template-columns:minmax(0,1fr) 340px; grid-template-rows:minmax(0,1fr); gap:14px; }
    .receipt-preview { position:static; min-height:0; }
    .main-view.checkout-active main { padding:12px 24px; }
    #checkoutScreen .screen-heading { margin-bottom:10px; }
    #checkoutScreen .screen-heading p { display:block; font-size:.86rem; }
    #productCatalog { grid-template-columns:repeat(3,minmax(0,1fr)); gap:7px; }
    #productCatalog .category-group { padding:6px 7px; }
    #productCatalog .product-row { grid-template-columns:minmax(0,1fr) 48px; gap:4px; padding:2px 0; }
    #productCatalog .category-group-heading h3 { font-size:.74rem; }
    #productCatalog .selection-count { font-size:.62rem; }
    #productCatalog .product-meta strong { font-size:.68rem; }
    #productCatalog .product-meta span { font-size:.62rem; }
    #productCatalog .qty-input { min-height:32px; padding:.2rem .25rem; font-size:.7rem; }
    .receipt-preview { padding:14px 16px; gap:8px; }
    .receipt-line { font-size:.9rem; }
    .editor-form { grid-template-columns:repeat(2,minmax(0,1fr)); padding:20px; }
    .wide { grid-column:1/-1; }
  }