:root {
  --brand: #b5613a;
  --brand-dark: #97492a;
  --ink: #2c2420;
  --muted: #8a7d74;
  --bg: #faf6f0;
  --card: #ffffff;
  --soft: #f3ece3;
  --border: #ece2d6;
  --accent: #5b7a6a;
  --danger: #c2410c;
  /* admin（管理画面）系 */
  --navy: #142036;
  --navy-2: #1f3258;
  --blue: #2563eb;
  --up: #16a34a;
  --down: #e11d48;
  --c1: #2563eb; --c2: #0ea5e9; --c3: #22c55e; --c4: #f59e0b; --c5: #a855f7; --c6: #ec4899;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(44,36,32,.07), 0 1px 2px rgba(44,36,32,.05);
  --shadow-lg: 0 18px 44px rgba(44,36,32,.18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
/* hidden属性を確実に効かせる（.login-screen / .adm-app / .cart-badge 等の display 指定に勝たせる） */
[hidden] { display: none !important; }
body { font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.65; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-dark); }
.yen::before { content: "¥"; }

/* ===== 共通ボタン・トースト ===== */
.btn { border: none; border-radius: 10px; padding: 11px 18px; font-size: 14px; font-weight: 700; cursor: pointer; transition: filter .15s, transform .05s; text-decoration: none; display: inline-block; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.06); }
.btn-block { width: 100%; }
.btn-ghost { background: var(--card); color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--brand); }
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(16px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== 上部バー（ストア⇄管理の切替リンク） ===== */
.mode-switch { background: var(--navy); color: #fff; font-size: 12.5px; }
.mode-switch .ms-wrap { max-width: 1100px; margin: 0 auto; padding: 7px 18px; display: flex; align-items: center; gap: 10px; }
.mode-switch .ms-tag { opacity: .8; }
.mode-switch a { color: #fff; text-decoration: none; margin-left: auto; background: rgba(255,255,255,.14); padding: 5px 13px; border-radius: 999px; font-weight: 700; }
.mode-switch a:hover { background: rgba(255,255,255,.26); }

/* =========================================================================
 * ストア（販売）側
 * =======================================================================*/
.shop-header { background: var(--card); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.hwrap { max-width: 1100px; margin: 0 auto; padding: 14px 18px; display: flex; align-items: center; gap: 14px; }
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink); }
.brand-mark { font-size: 24px; }
.brand-name { font-family: "Hiragino Mincho ProN", "Yu Mincho", serif; font-size: 21px; font-weight: 600; letter-spacing: .04em; }
.brand-tag { font-size: 12px; color: var(--muted); }
.cart-btn { margin-left: auto; position: relative; background: var(--soft); border: 1px solid var(--border); border-radius: 11px; padding: 9px 14px; font-size: 16px; cursor: pointer; }
.cart-btn:hover { border-color: var(--brand); }
.cart-badge { position: absolute; top: -7px; right: -7px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; min-width: 19px; height: 19px; border-radius: 999px; display: grid; place-items: center; padding: 0 5px; }

.hero { background: linear-gradient(120deg, #f0e4d6, #e8d6c4); }
.hero-inner { max-width: 1100px; margin: 0 auto; padding: 38px 18px; }
.hero h1 { font-family: "Hiragino Mincho ProN", serif; font-size: 26px; margin-bottom: 8px; }
.hero p { font-size: 14px; color: #6b5a4d; max-width: 560px; }

.shop-bar { max-width: 1100px; margin: 0 auto; padding: 18px 18px 4px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }
.chip { background: var(--card); border: 1px solid var(--border); border-radius: 999px; padding: 7px 15px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.chip:hover { border-color: var(--brand); color: var(--ink); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.sort { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.sort select { font: inherit; padding: 7px 10px; border-radius: 9px; border: 1px solid var(--border); background: var(--card); color: var(--ink); }

.product-grid { max-width: 1100px; margin: 0 auto; padding: 18px 18px 50px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.product { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow); transition: transform .12s, box-shadow .15s; }
.product:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.p-thumb { aspect-ratio: 1/1; display: grid; place-items: center; font-size: 58px; position: relative; }
.p-stocktag { position: absolute; top: 9px; left: 9px; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.p-stocktag.low { background: #fef3c7; color: #b45309; }
.p-stocktag.out { background: #fee2e2; color: #b91c1c; }
.p-body { padding: 13px 14px 15px; display: flex; flex-direction: column; flex: 1; }
.p-cat { font-size: 11px; color: var(--accent); font-weight: 700; }
.p-name { font-size: 15px; font-weight: 600; margin: 3px 0 4px; }
.p-desc { font-size: 12px; color: var(--muted); flex: 1; }
.p-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; gap: 8px; }
.p-price { font-size: 17px; font-weight: 800; }
.p-price small { font-size: 11px; font-weight: 600; color: var(--muted); }
.add-btn { background: var(--brand); color: #fff; border: none; border-radius: 9px; padding: 8px 12px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.add-btn:hover { filter: brightness(1.06); }
.add-btn:disabled { background: #cdbfb2; cursor: not-allowed; }

/* カートドロワー */
.cart-drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 380px; max-width: 92vw; background: var(--card); box-shadow: var(--shadow-lg); z-index: 60; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.cart-drawer.open { transform: translateX(0); }
.cd-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.cd-head h2 { font-size: 18px; font-family: "Hiragino Mincho ProN", serif; }
.cd-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--muted); }
.cd-items { flex: 1; overflow-y: auto; padding: 8px 18px; }
.cd-empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; }
.cd-item { display: grid; grid-template-columns: 48px 1fr auto; gap: 11px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); }
.cd-thumb { width: 48px; height: 48px; border-radius: 10px; display: grid; place-items: center; font-size: 26px; }
.cd-name { font-size: 13.5px; font-weight: 600; }
.cd-unit { font-size: 11.5px; color: var(--muted); }
.cd-qty { display: inline-flex; align-items: center; gap: 8px; margin-top: 5px; }
.qbtn { width: 24px; height: 24px; border-radius: 7px; border: 1px solid var(--border); background: var(--soft); cursor: pointer; font-size: 14px; line-height: 1; }
.qbtn:hover { border-color: var(--brand); }
.cd-line { text-align: right; font-weight: 700; font-size: 14px; }
.cd-remove { display: block; background: none; border: none; color: var(--muted); font-size: 11px; cursor: pointer; margin-top: 4px; text-decoration: underline; }
.cd-foot { border-top: 1px solid var(--border); padding: 16px 18px 20px; }
.cd-row { display: flex; justify-content: space-between; font-size: 13.5px; margin-bottom: 6px; color: var(--muted); }
.cd-row.total { color: var(--ink); font-weight: 800; font-size: 17px; margin: 10px 0 14px; }
.cd-free { font-size: 12px; color: var(--accent); margin-bottom: 10px; }
.scrim { position: fixed; inset: 0; background: rgba(44,36,32,.45); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .22s; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* チェックアウト・完了（ストア） */
.view { max-width: 1000px; margin: 0 auto; padding: 26px 18px 60px; }
.back-link { background: none; border: none; color: var(--brand-dark); font-size: 14px; cursor: pointer; margin-bottom: 12px; }
.ck-title { font-size: 23px; font-family: "Hiragino Mincho ProN", serif; margin-bottom: 18px; }
.ck-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 22px; align-items: start; }
.ck-form, .ck-summary { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.ck-form h3, .ck-summary h3 { font-size: 15px; margin-bottom: 12px; }
.fld { display: block; margin-bottom: 13px; }
.fld > span { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; }
.fld em { font-style: normal; font-size: 10.5px; color: #fff; background: var(--brand); padding: 1px 7px; border-radius: 999px; margin-left: 6px; }
.fld input, .fld textarea, .fld select { width: 100%; font: inherit; background: var(--soft); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; color: var(--ink); }
.fld input:focus, .fld textarea:focus, .fld select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #f3e2d7; }
.fld input.invalid, .fld textarea.invalid { border-color: var(--danger); }
.fld-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pay-opts { display: flex; flex-direction: column; gap: 8px; }
.pay { display: flex; align-items: center; gap: 9px; background: var(--soft); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 14px; cursor: pointer; }
.pay:has(input:checked) { border-color: var(--brand); background: #f7ece3; }
.ck-item { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.ck-totals { margin: 10px 0 16px; }
.ck-totals div { display: flex; justify-content: space-between; font-size: 13.5px; padding: 4px 0; color: var(--muted); }
.ck-totals div.grand { color: var(--ink); font-weight: 800; font-size: 18px; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 10px; }
.ck-note { font-size: 11.5px; color: var(--muted); margin-top: 10px; text-align: center; }
.done-card { background: var(--card); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); padding: 46px 28px; text-align: center; max-width: 520px; margin: 30px auto; }
.done-ico { width: 64px; height: 64px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 32px; display: grid; place-items: center; margin: 0 auto 18px; }
.done-card h2 { font-size: 22px; font-family: "Hiragino Mincho ProN", serif; margin-bottom: 10px; }
.done-card p { color: var(--muted); font-size: 14px; }
.order-no { margin: 16px 0 22px; color: var(--ink) !important; font-size: 15px; }
.order-no strong { color: var(--brand-dark); letter-spacing: .04em; }

.shop-foot { border-top: 1px solid var(--border); padding: 22px 18px; text-align: center; color: var(--muted); font-size: 12px; }

/* =========================================================================
 * 管理画面（admin）側
 * =======================================================================*/
.adm-body { background: #eef2f7; }
/* ログイン */
.login-screen { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--navy), var(--navy-2)); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px 30px; width: 360px; max-width: 100%; }
.login-card h1 { font-size: 20px; margin-bottom: 4px; }
.login-card .lc-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }
.login-card .fld input { background: #f5f8fc; }
.login-demo { font-size: 12px; background: #eef4ff; border: 1px solid #d6e4ff; color: #1d4ed8; border-radius: 9px; padding: 9px 11px; margin-bottom: 16px; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 18px; }

.adm-app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.adm-side { background: linear-gradient(180deg, var(--navy), var(--navy-2)); color: #aebbd0; padding: 18px 14px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.adm-brand { display: flex; align-items: center; gap: 9px; color: #fff; padding: 6px 8px 18px; }
.adm-brand b { color: #6f9bff; }
.adm-nav { display: flex; flex-direction: column; gap: 3px; }
.adm-nav button { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; font-size: 14px; cursor: pointer; color: #aebbd0; background: none; border: none; text-align: left; width: 100%; }
.adm-nav button:hover { background: rgba(255,255,255,.06); color: #fff; }
.adm-nav button.active { background: var(--blue); color: #fff; }
.adm-side .side-foot { margin-top: auto; }
.adm-logout { background: rgba(255,255,255,.08); border: none; color: #cfd9e8; border-radius: 9px; padding: 9px; width: 100%; cursor: pointer; font-size: 13px; }
.adm-logout:hover { background: rgba(255,255,255,.16); color: #fff; }

.adm-main { min-width: 0; display: flex; flex-direction: column; }
.adm-top { background: #fff; border-bottom: 1px solid #e4eaf2; padding: 14px 22px; display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 5; }
.adm-top h1 { font-size: 18px; color: var(--ink); }
.adm-top .at-actions { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.seg { display: flex; background: #f5f8fc; border: 1px solid #e4eaf2; border-radius: 9px; padding: 3px; }
.seg button { border: none; background: none; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; color: #6a7a90; }
.seg button.active { background: #fff; color: var(--blue); box-shadow: var(--shadow); }
.adm-content { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.adm-menu-btn { display: none; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.kpi { background: #fff; border: 1px solid #e4eaf2; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-label { font-size: 12.5px; color: #6a7a90; font-weight: 600; }
.kpi-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; }
.kpi-val { font-size: 24px; font-weight: 800; margin-top: 8px; color: var(--ink); }
.kpi-delta { font-size: 12px; font-weight: 700; margin-top: 5px; }
.kpi-delta.up { color: var(--up); } .kpi-delta.down { color: var(--down); }
.kpi-delta .vs { color: #6a7a90; font-weight: 500; }
.kpi-delta.flat { color: #6a7a90; }

.acard { background: #fff; border: 1px solid #e4eaf2; border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.acard .card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.acard .card-head h2 { font-size: 15px; color: var(--ink); }
.acard .card-meta { font-size: 12px; color: #6a7a90; }
.agrid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
.agrid-2.b { grid-template-columns: 1fr 1.1fr; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.grid-line { stroke: #e4eaf2; stroke-dasharray: 3 4; }
.axis-text { fill: #6a7a90; font-size: 11px; }
#aLineArea .g0 { stop-color: var(--blue); stop-opacity: .26; }
#aLineArea .g1 { stop-color: var(--blue); stop-opacity: 0; }
.line-path { fill: none; stroke: var(--blue); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.dot { fill: #fff; stroke: var(--blue); stroke-width: 2; }
.donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut-wrap svg { width: 168px; height: 168px; flex: 0 0 auto; }
.donut-center-num { fill: var(--ink); font-size: 20px; font-weight: 800; }
.donut-center-lbl { fill: #6a7a90; font-size: 10px; }
.legend { list-style: none; display: flex; flex-direction: column; gap: 8px; flex: 1; min-width: 130px; }
.legend li { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); }
.legend .sw { width: 11px; height: 11px; border-radius: 3px; }
.legend .lg-name { flex: 1; }
.legend .lg-pct { font-weight: 700; color: #6a7a90; }
.bar-label { fill: var(--ink); font-size: 11.5px; }
.bar-val { fill: #6a7a90; font-size: 11px; }

.atable-wrap { overflow-x: auto; }
.atable { width: 100%; border-collapse: collapse; font-size: 13px; }
.atable th { text-align: left; color: #6a7a90; font-weight: 600; font-size: 11.5px; padding: 9px 10px; border-bottom: 1px solid #e4eaf2; white-space: nowrap; }
.atable td { padding: 10px 10px; border-bottom: 1px solid #eef2f7; white-space: nowrap; color: var(--ink); }
.atable tr:last-child td { border-bottom: none; }
.atable .num { text-align: right; }
.status-sel { font: inherit; font-size: 12px; padding: 4px 8px; border-radius: 7px; border: 1px solid #e4eaf2; background: #fff; }
/* 状態変更：ワンクリックの横並びボタン */
.st-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.st-btn { font: inherit; font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 7px; border: 1px solid #e4eaf2; background: #fff; cursor: pointer; white-space: nowrap; transition: all .12s; }
.st-btn.new { color: #b45309; } .st-btn.shipped { color: #1d4ed8; } .st-btn.done { color: #15803d; } .st-btn.returned { color: #7c3aed; } .st-btn.canceled { color: #b91c1c; }
.st-btn:not(.active):hover { border-color: currentColor; background: #f7faff; }
.st-btn.active { color: #fff; border-color: transparent; cursor: default; }
.st-btn.new.active { background: #d97706; } .st-btn.shipped.active { background: #2563eb; } .st-btn.done.active { background: #16a34a; } .st-btn.returned.active { background: #7c3aed; } .st-btn.canceled.active { background: #dc2626; }
.pill.returned { background: #ede9fe; color: #6d28d9; }
html[data-theme="dark"] .pill.returned { background: #2a2150; color: #c4b5fd; }
.pill { font-size: 11px; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.pill.new { background: #fef3c7; color: #b45309; }
.pill.shipped { background: #dbeafe; color: #1d4ed8; }
.pill.done { background: #dcfce7; color: #15803d; }
.pill.canceled { background: #fee2e2; color: #b91c1c; }
.stock-cell { display: inline-flex; align-items: center; gap: 7px; }
.stock-num { font-weight: 800; min-width: 30px; text-align: center; }
.stock-num.low { color: #b45309; } .stock-num.out { color: #b91c1c; }
.sbtn { width: 26px; height: 26px; border-radius: 7px; border: 1px solid #e4eaf2; background: #f5f8fc; cursor: pointer; font-size: 15px; line-height: 1; }
.sbtn:hover { border-color: var(--blue); }
.filter-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.fbtn { background: #fff; border: 1px solid #e4eaf2; border-radius: 999px; padding: 6px 13px; font-size: 12.5px; font-weight: 600; color: #6a7a90; cursor: pointer; }
.fbtn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.alert-banner { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; border-radius: 10px; padding: 11px 14px; font-size: 13px; }
.adm-foot { padding: 14px 22px 28px; color: #6a7a90; font-size: 12px; text-align: center; }

/* ===== レスポンシブ ===== */
@media (max-width: 980px) { .product-grid { grid-template-columns: repeat(3, 1fr); } .kpi-row { grid-template-columns: repeat(2,1fr); } .agrid-2, .agrid-2.b { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .ck-layout { grid-template-columns: 1fr; }
  .adm-app { grid-template-columns: 1fr; }
  .adm-side { position: fixed; z-index: 40; width: 220px; transform: translateX(-100%); transition: transform .25s; }
  .adm-side.open { transform: translateX(0); }
  .adm-menu-btn { display: grid; place-items: center; background: #f5f8fc; border: 1px solid #e4eaf2; border-radius: 9px; width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
}
@media (max-width: 600px) { .product-grid { grid-template-columns: repeat(2, 1fr); } .brand-tag { display: none; } .fld-row { grid-template-columns: 1fr; } }
