/* ===== リセット・変数 ===== */
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent}
:root{
  --primary:#9b6d8f;--primary-light:#c4a0b8;--primary-dark:#7a5370;
  --accent:#e8956d;--bg:#f8f5f2;--card:#ffffff;
  --text:#2d2d2d;--sub:#888;--border:#ece8e5;--nav:80px;
}
body{font-family:-apple-system,BlinkMacSystemFont,'Noto Sans JP',sans-serif;background:#e8e8e8;display:flex;justify-content:center;min-height:100vh}

/* ===== アプリ枠 ===== */
.app{width:100%;max-width:430px;background:var(--card);min-height:100vh;position:relative;overflow-x:hidden}

/* ===== 画面共通 ===== */
.screen{display:none;flex-direction:column;height:100vh;overflow:hidden}
.screen.active{display:flex}

/* ===== ログイン ===== */
#loginScreen{
  background:
    radial-gradient(ellipse at 20% 80%,rgba(255,182,193,.5) 0%,transparent 50%),
    radial-gradient(ellipse at 80% 20%,rgba(173,216,230,.6) 0%,transparent 50%),
    linear-gradient(170deg,#a8d8ea 0%,#c9e8f0 25%,#f8e1e7 60%,#fde8ec 100%);
  justify-content:center;align-items:center;padding:40px 28px;gap:0;overflow:hidden;position:relative
}
#loginScreen::before{
  content:'';position:absolute;inset:0;pointer-events:none;
  background-image:
    radial-gradient(ellipse 12px 8px at 15% 20%,rgba(255,192,203,.7) 0%,transparent 100%),
    radial-gradient(ellipse 8px 12px at 75% 10%,rgba(255,182,193,.6) 0%,transparent 100%),
    radial-gradient(ellipse 10px 7px at 85% 35%,rgba(255,209,220,.7) 0%,transparent 100%),
    radial-gradient(ellipse 14px 9px at 10% 55%,rgba(255,192,203,.5) 0%,transparent 100%),
    radial-gradient(ellipse 9px 13px at 60% 75%,rgba(255,182,193,.6) 0%,transparent 100%);
  animation:petalDrift 8s ease-in-out infinite alternate
}
@keyframes petalDrift{0%{transform:translateY(0) rotate(0);opacity:.8}100%{transform:translateY(-8px) rotate(3deg);opacity:1}}
#loginScreen>*{position:relative;z-index:1}
.login-logo{width:80px;height:80px;background:rgba(255,255,255,.15);border-radius:24px;display:flex;align-items:center;justify-content:center;font-size:36px;margin-bottom:16px;backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.3)}
.login-title{color:#5a3a6b;font-size:22px;font-weight:700;margin-bottom:4px;text-shadow:0 1px 4px rgba(255,255,255,.8)}
.login-subtitle{color:#7a5a8a;font-size:12px;margin-bottom:32px;text-shadow:0 1px 3px rgba(255,255,255,.8)}
.login-card{background:rgba(255,255,255,.95);border-radius:24px;padding:28px 24px;width:100%;backdrop-filter:blur(20px);box-shadow:0 8px 32px rgba(0,0,0,.15)}
.login-card label{font-size:12px;font-weight:600;color:var(--sub);letter-spacing:.5px;text-transform:uppercase;display:block;margin-bottom:6px}
.login-input{width:100%;padding:14px 16px;border:2px solid var(--border);border-radius:12px;font-size:16px;font-family:inherit;background:var(--bg);color:var(--text);margin-bottom:16px;outline:none;transition:border-color .2s}
.login-input:focus{border-color:var(--primary)}
.login-btn{width:100%;padding:16px;background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff;border:none;border-radius:14px;font-size:16px;font-weight:700;font-family:inherit;cursor:pointer;box-shadow:0 4px 15px rgba(155,109,143,.4)}
.login-forgot{display:flex;gap:10px;margin-top:16px}
.login-forgot button{flex:1;padding:11px;border:1.5px solid var(--border);border-radius:10px;background:#fff;font-size:12px;font-family:inherit;color:var(--sub);cursor:pointer}
.login-error{background:rgba(230,126,126,.15);border:1px solid rgba(230,126,126,.4);border-radius:10px;padding:10px 14px;font-size:13px;color:#a83a3a;margin-bottom:12px}
.login-admin{color:rgba(90,58,107,.4);font-size:11px;margin-top:20px;text-align:center;cursor:pointer}

/* ===== ホーム ===== */
#homeScreen{background:var(--bg)}
.home-header{background:linear-gradient(135deg,var(--primary),var(--primary-dark));padding:52px 20px 24px;color:#fff;flex-shrink:0}
.home-header-top{display:flex;justify-content:space-between;align-items:center;margin-bottom:20px}
.home-store{font-size:13px;opacity:.8}
.home-title{font-size:20px;font-weight:700}
.logout-btn{background:rgba(255,255,255,.2);border:none;color:#fff;padding:8px 14px;border-radius:20px;font-size:12px;font-family:inherit;cursor:pointer}
.quick-actions{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}
.quick-btn{background:rgba(255,255,255,.15);border:1.5px solid rgba(255,255,255,.3);border-radius:16px;padding:14px 12px;color:#fff;display:flex;align-items:center;gap:8px;cursor:pointer;font-family:inherit;backdrop-filter:blur(10px)}
.quick-btn-icon{font-size:20px}
.quick-btn-label{font-size:12px;font-weight:600;line-height:1.3;text-align:left}
.home-body{flex:1;overflow-y:auto;padding:20px 16px var(--nav)}
.section-title{font-size:15px;font-weight:700;color:var(--text);margin-bottom:12px;display:flex;align-items:center;gap:6px}

/* ===== Top5 ===== */
.top5-list{display:flex;flex-direction:column;gap:8px;margin-bottom:24px}
.top5-item{background:var(--card);border-radius:14px;padding:14px 16px;display:flex;align-items:center;gap:12px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.top5-rank{width:28px;height:28px;background:var(--primary);color:#fff;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;flex-shrink:0}
.top5-rank.gold{background:#d4a017}.top5-rank.silver{background:#9e9e9e}.top5-rank.bronze{background:#c47c3a}
.top5-info{flex:1;min-width:0}
.top5-name{font-size:14px;font-weight:600;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.top5-sub{font-size:11px;color:var(--sub);margin-top:2px}

/* ===== お気に入り ===== */
.fav-scroll{display:flex;gap:10px;overflow-x:auto;padding-bottom:4px;margin-bottom:24px}
.fav-scroll::-webkit-scrollbar{display:none}
.fav-card{background:var(--card);border-radius:14px;padding:14px;min-width:130px;box-shadow:0 2px 8px rgba(0,0,0,.06);flex-shrink:0}
.fav-card-icon{font-size:28px;margin-bottom:8px}
.fav-card-name{font-size:12px;font-weight:600;color:var(--text);margin-bottom:4px}
.fav-card-price{font-size:13px;color:var(--primary);font-weight:700;margin-bottom:10px}
.fav-add-btn{width:100%;padding:8px;background:var(--primary);color:#fff;border:none;border-radius:8px;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer;touch-action:manipulation}
.fav-remove-btn{width:100%;padding:6px;background:none;color:#c47c7c;border:1.5px solid #c47c7c;border-radius:8px;font-size:11px;font-weight:600;font-family:inherit;cursor:pointer;touch-action:manipulation;margin-top:6px}

/* ===== 汎用ボタン ===== */
.add-btn{width:36px;height:36px;background:var(--primary);color:#fff;border:none;border-radius:10px;font-size:20px;display:flex;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;font-family:inherit;touch-action:manipulation}

/* ===== 商品一覧 ===== */
#productsScreen{background:var(--bg)}
.products-header{background:var(--card);padding:16px 16px 12px;box-shadow:0 2px 8px rgba(0,0,0,.06);flex-shrink:0}
.search-bar{display:flex;align-items:center;background:var(--bg);border-radius:14px;padding:12px 16px;gap:10px;margin-bottom:12px;border:2px solid var(--border)}
.search-bar input{flex:1;border:none;background:none;font-size:15px;font-family:inherit;color:var(--text);outline:none}
.search-icon{font-size:18px;color:var(--sub)}
.category-tabs{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px}
.category-tabs::-webkit-scrollbar{display:none}
.cat-tab{padding:8px 16px;border-radius:20px;font-size:13px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;border:none;background:var(--bg);color:var(--sub)}
.cat-tab.active{background:var(--primary);color:#fff}
.products-list{flex:1;overflow-y:auto;padding:14px 16px var(--nav);display:flex;flex-direction:column;gap:10px}
.product-card{background:var(--card);border-radius:16px;padding:16px;display:flex;align-items:center;gap:14px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.product-img{width:56px;height:56px;background:var(--bg);border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:28px;flex-shrink:0}
.product-info{flex:1;min-width:0}
.product-code{font-size:11px;color:var(--sub);margin-bottom:2px}
.product-name{font-size:14px;font-weight:700;color:var(--text);margin-bottom:4px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.product-meta{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.product-price{font-size:15px;font-weight:700;color:var(--primary)}
.product-delivery{font-size:11px;color:#4caf50;background:#e8f5e9;padding:2px 8px;border-radius:10px}
.product-actions{display:flex;flex-direction:column;align-items:center;gap:8px}
.heart-btn{background:none;border:none;font-size:20px;cursor:pointer;line-height:1}

/* ===== スキャン ===== */
#scanScreen{background:#1a1a1a;align-items:center}
.scan-header{width:100%;padding:52px 20px 20px;display:flex;align-items:center;gap:12px;flex-shrink:0}
.scan-back{background:rgba(255,255,255,.15);border:none;color:#fff;width:36px;height:36px;border-radius:10px;font-size:18px;cursor:pointer;font-family:inherit}
.scan-title{color:#fff;font-size:18px;font-weight:700}
.scan-viewport{width:280px;height:280px;border-radius:20px;overflow:hidden;position:relative;background:#333;margin:0 auto 16px}
#barcodeVideo{width:100%;height:100%;object-fit:cover}
.scan-overlay{position:absolute;inset:0;display:flex;align-items:center;justify-content:center}
.scan-frame{width:200px;height:200px;border:3px solid var(--primary);border-radius:16px;box-shadow:0 0 0 9999px rgba(0,0,0,.4);position:relative}
.scan-line{position:absolute;left:0;right:0;height:2px;background:var(--primary);box-shadow:0 0 10px var(--primary);animation:scanMove 2s ease-in-out infinite}
@keyframes scanMove{0%,100%{top:20%}50%{top:80%}}
.scan-msg{color:rgba(255,255,255,.9);font-size:14px;text-align:center;padding:0 40px;min-height:20px;margin-bottom:8px}
.scan-guide{color:rgba(255,255,255,.7);font-size:14px;text-align:center;padding:0 40px;margin-bottom:24px;line-height:1.6}
.scan-manual-btn{padding:14px 32px;border:2px solid rgba(255,255,255,.3);border-radius:14px;background:transparent;color:#fff;font-size:14px;font-weight:600;font-family:inherit;cursor:pointer}

/* ===== カート ===== */
#cartScreen{background:var(--bg)}
.cart-header{background:var(--card);padding:52px 20px 16px;box-shadow:0 2px 8px rgba(0,0,0,.06);flex-shrink:0}
.cart-header h2{font-size:20px;font-weight:700;color:var(--text)}
.cart-list{flex:1;overflow-y:auto;padding:14px 16px var(--nav);display:flex;flex-direction:column;gap:10px}
.cart-item{background:var(--card);border-radius:16px;padding:16px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.cart-item-top{display:flex;align-items:flex-start;gap:12px;margin-bottom:12px}
.cart-item-img{width:48px;height:48px;background:var(--bg);border-radius:10px;display:flex;align-items:center;justify-content:center;font-size:24px;flex-shrink:0}
.cart-item-info{flex:1}
.cart-item-name{font-size:14px;font-weight:700;color:var(--text);margin-bottom:2px}
.cart-item-code{font-size:11px;color:var(--sub)}
.cart-item-delete{background:none;border:none;font-size:18px;color:#ccc;cursor:pointer;font-family:inherit}
.cart-item-bottom{display:flex;align-items:center;justify-content:space-between}
.qty-control{display:flex;align-items:center;gap:12px;background:var(--bg);border-radius:12px;padding:6px 12px}
.qty-btn{width:32px;height:32px;border:none;background:var(--card);border-radius:8px;font-size:18px;color:var(--primary);cursor:pointer;font-weight:700;font-family:inherit;box-shadow:0 1px 4px rgba(0,0,0,.1);touch-action:manipulation}
.qty-num{font-size:18px;font-weight:700;color:var(--text);min-width:28px;text-align:center}
.cart-item-subtotal{font-size:16px;font-weight:700;color:var(--primary)}
.cart-delivery-tag{font-size:11px;color:#4caf50;margin-top:8px}
.cart-footer{background:var(--card);padding:16px 20px 24px;box-shadow:0 -4px 16px rgba(0,0,0,.08);flex-shrink:0;margin-bottom:var(--nav)}
.cart-total-row{display:flex;justify-content:space-between;align-items:center;margin-bottom:14px}
.cart-total-label{font-size:15px;color:var(--sub)}
.cart-total-price{font-size:24px;font-weight:700;color:var(--text)}
.order-btn{width:100%;padding:18px;background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff;border:none;border-radius:16px;font-size:17px;font-weight:700;font-family:inherit;cursor:pointer;box-shadow:0 4px 15px rgba(155,109,143,.4)}
.order-btn:disabled{background:#ccc;box-shadow:none;cursor:not-allowed}
.cart-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--sub);gap:12px;font-size:14px}
.cart-empty-icon{font-size:64px}

/* ===== 注文履歴 ===== */
#historyScreen{background:var(--bg)}
.history-header{background:var(--card);padding:52px 16px 12px;box-shadow:0 2px 8px rgba(0,0,0,.06);flex-shrink:0}
.history-header h2{font-size:20px;font-weight:700;color:var(--text);margin-bottom:14px}
.period-tabs{display:flex;gap:6px;overflow-x:auto}
.period-tabs::-webkit-scrollbar{display:none}
.period-tab{padding:7px 14px;border-radius:20px;font-size:12px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;border:1.5px solid var(--border);background:var(--bg);color:var(--sub)}
.period-tab.active{background:var(--primary);color:#fff;border-color:var(--primary)}
.history-list{flex:1;overflow-y:auto;padding:14px 16px var(--nav);display:flex;flex-direction:column;gap:10px}
.history-card{background:var(--card);border-radius:16px;padding:16px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.history-card-top{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:10px}
.history-date{font-size:12px;color:var(--sub)}
.history-order-no{font-size:13px;font-weight:700;color:var(--text)}
.history-total{font-size:17px;font-weight:700;color:var(--primary)}
.history-total.cancel{color:#c47c7c}
.history-items{font-size:12px;color:var(--sub);margin-bottom:12px;line-height:1.6}
.reorder-btn{width:100%;padding:12px;background:var(--bg);border:2px solid var(--primary);border-radius:12px;color:var(--primary);font-size:14px;font-weight:700;font-family:inherit;cursor:pointer}
.status-badge{font-size:11px;font-weight:700;padding:3px 8px;border-radius:20px;white-space:nowrap}
.status-pending{background:#f0f0f0;color:#888}
.status-accepted{background:#e6f4ea;color:#2e7d32}
.history-accepted-at{font-size:11px;color:#2e7d32;margin-bottom:8px}

/* ===== 取り消し ===== */
#cancelScreen{background:var(--bg)}
.cancel-card{background:var(--card);border-radius:16px;padding:16px;display:flex;align-items:center;gap:12px;box-shadow:0 2px 8px rgba(0,0,0,.06);margin-bottom:10px}

/* ===== ボトムナビ ===== */
.bottom-nav{position:fixed;bottom:0;width:100%;max-width:430px;background:var(--card);display:flex;padding:10px 0 16px;box-shadow:0 -2px 12px rgba(0,0,0,.08);z-index:100}
.nav-item{flex:1;display:flex;flex-direction:column;align-items:center;gap:3px;cursor:pointer;position:relative}
.nav-icon{font-size:22px}
.nav-label{font-size:10px;color:var(--sub);font-weight:500}
.nav-item.active .nav-label{color:var(--primary);font-weight:700}
.cart-badge{position:absolute;top:-2px;right:14px;background:var(--accent);color:#fff;border-radius:10px;font-size:10px;font-weight:700;padding:1px 6px;min-width:18px;text-align:center;display:none}

/* ===== モーダル（ボトムシート） ===== */
.modal-overlay{display:none;position:fixed;inset:0;background:rgba(0,0,0,.5);z-index:200;justify-content:flex-end;flex-direction:column}
.modal-overlay.open{display:flex}
.modal-sheet{background:var(--card);border-radius:24px 24px 0 0;padding:24px 20px 40px;max-height:80vh;overflow-y:auto}
.modal-handle{width:40px;height:4px;background:var(--border);border-radius:2px;margin:0 auto 20px}
.modal-title{font-size:18px;font-weight:700;color:var(--text);margin-bottom:16px}
.modal-row{display:flex;justify-content:space-between;align-items:center;padding:10px 0;border-bottom:1px solid var(--border);font-size:14px}
.modal-row-name{color:var(--text);flex:1}
.modal-row-price{color:var(--primary);font-weight:700}
.modal-total-row{display:flex;justify-content:space-between;align-items:center;padding:16px 0 20px;font-size:18px;font-weight:700}
.modal-actions{display:flex;flex-direction:column;gap:10px}
.mbtn{width:100%;padding:16px;border:none;border-radius:14px;font-size:15px;font-weight:700;font-family:inherit;cursor:pointer}
.mbtn-primary{background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff}
.mbtn-primary:disabled{background:#ccc;cursor:not-allowed}
.mbtn-outline{background:var(--bg);color:var(--primary);border:2px solid var(--primary)}
.mbtn-ghost{background:var(--bg);color:var(--sub)}

/* ===== 管理者 ===== */
#adminLoginScreen,#adminDashboard,#userManagementScreen,#dataConfirmationScreen,#settingsScreen{background:var(--bg)}
.admin-header{background:linear-gradient(135deg,#6b7a8f,#5a6878);padding:52px 20px 20px;color:#fff;flex-shrink:0;display:flex;align-items:flex-end;justify-content:space-between}
.admin-header h1{font-size:18px;font-weight:700}
.admin-back{background:rgba(255,255,255,.2);border:none;color:#fff;padding:8px 14px;border-radius:20px;font-size:12px;font-family:inherit;cursor:pointer}
.admin-body{flex:1;overflow-y:auto;padding:20px 16px}
.acard{background:var(--card);border-radius:16px;padding:16px;margin-bottom:12px;box-shadow:0 2px 8px rgba(0,0,0,.06)}
.alabel{font-size:12px;font-weight:600;color:var(--sub);text-transform:uppercase;letter-spacing:.5px;display:block;margin:14px 0 6px}
.alabel:first-child{margin-top:0}
.ainput{width:100%;padding:12px 14px;border:2px solid var(--border);border-radius:10px;font-size:15px;font-family:inherit;background:var(--bg);color:var(--text);outline:none;transition:border-color .2s}
.ainput:focus{border-color:var(--primary)}
.abtn{width:100%;padding:14px;background:linear-gradient(135deg,var(--primary),var(--primary-dark));color:#fff;border:none;border-radius:12px;font-size:15px;font-weight:700;font-family:inherit;cursor:pointer;margin-top:14px}
.abtn-danger{background:linear-gradient(135deg,#e67e7e,#d67070)}
.abtn-green{background:linear-gradient(135deg,#7aa88f,#6a9880)}
.abtn-blue{background:linear-gradient(135deg,#7a9ba8,#6b8fa2)}
.admin-nav-btn{width:100%;padding:18px 16px;border-radius:14px;border:none;color:#fff;font-size:16px;font-weight:600;font-family:inherit;cursor:pointer;margin-bottom:12px;text-align:left}
.amsg{padding:12px 14px;border-radius:10px;font-size:13px;margin-bottom:12px}
.amsg-ok{background:#e8f5e9;color:#2e7d32}
.amsg-err{background:#fce8e8;color:#a83a3a}
.user-row{display:flex;align-items:center;padding:14px;border-bottom:1px solid var(--border)}
.user-row:last-child{border-bottom:none}
.user-info{flex:1}
.user-id{font-weight:700;color:var(--text);font-size:15px}
.user-name{font-size:12px;color:var(--sub);margin-top:2px}
.del-btn{padding:8px 14px;background:var(--bg);border:1.5px solid #e67e7e;color:#e67e7e;border-radius:8px;font-size:12px;font-weight:600;font-family:inherit;cursor:pointer}

/* ===== 改変履歴 ===== */
.cl-entry{margin-bottom:16px}
.cl-ver{font-size:15px;font-weight:700;color:var(--text)}
.cl-date{font-size:12px;color:var(--sub);margin-left:8px}
.cl-items{margin-top:8px;padding-left:4px;list-style:none}
.cl-items li{font-size:13px;color:#5a5a5a;padding:3px 0 3px 14px;position:relative;line-height:1.5}
.cl-items li::before{content:'・';position:absolute;left:0;color:var(--primary)}

/* ===== ホーム セクションナビボタン ===== */
.home-store-name{font-size:13px;opacity:.9;font-weight:600}
.section-nav-btn{width:100%;padding:18px 20px;background:var(--card);border:none;border-radius:16px;font-size:15px;font-weight:700;color:var(--text);text-align:left;display:flex;justify-content:space-between;align-items:center;cursor:pointer;box-shadow:0 2px 8px rgba(0,0,0,.06);margin-bottom:12px;font-family:inherit}
.section-nav-btn span{color:var(--sub);font-size:18px}
.home-cat-tabs{display:flex;gap:8px;overflow-x:auto;padding-bottom:4px;margin-bottom:12px}
.home-cat-tabs::-webkit-scrollbar{display:none}

/* ===== 共通ヘッダー行・戻るボタン ===== */
.header-row{display:flex;justify-content:space-between;align-items:center}
.back-btn{padding:8px 14px;border-radius:20px;font-size:12px;font-weight:600;font-family:inherit;white-space:nowrap;cursor:pointer;border:1.5px solid var(--border);background:var(--bg);color:var(--sub)}

/* ===== Top5・お気に入り画面 ===== */
#top5Screen,#favScreen{background:var(--bg)}
.fav-grid{display:grid;grid-template-columns:1fr 1fr;gap:10px}

/* ===== ユーティリティ ===== */
.hidden{display:none!important}
