/* 幡中POS スタイル */

/* ========== View Transitions ========== */
::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 0.22s;
  animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}
::view-transition-old(root) {
  animation-name: vt-fade-out;
}
::view-transition-new(root) {
  animation-name: vt-fade-slide-in;
}
@keyframes vt-fade-out {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes vt-fade-slide-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* prefers-reduced-motion の人にはアニメ無効 */
@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation: none; }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Kaku Gothic ProN', 'Helvetica Neue', sans-serif; background: #f4f5f3; color: #222; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
a { color: #2e7d32; }
.hidden { display: none !important; }

.boot, .loading-inline { padding: 64px; text-align: center; color: #888; }

/* ========== グローバル ========== */
.loading {
  position: fixed; inset: 0; background: rgba(255,255,255,0.5); display: flex; align-items: center; justify-content: center; z-index: 9999;
}
.spinner { width: 40px; height: 40px; border: 4px solid #ddd; border-top-color: #2e7d32; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; top: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: white; padding: 10px 20px; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  z-index: 10000; max-width: 90vw;
}
.toast.success { background: #2e7d32; }
.toast.error { background: #c62828; }

/* ========== ボタン共通 ========== */
.btn-primary { background: #2e7d32; color: white; border: none; padding: 10px 18px; border-radius: 6px; font-size: 15px; }
.btn-primary:disabled { background: #aaa; cursor: not-allowed; }
.btn-secondary { background: #eee; color: #333; border: 1px solid #ccc; padding: 10px 18px; border-radius: 6px; font-size: 15px; }
.btn-link { background: none; border: none; color: #2e7d32; padding: 4px 8px; cursor: pointer; font-size: 14px; }
.btn-link.danger { color: #c62828; }

/* ========== ログイン ========== */
.login-screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: white; border-radius: 12px; padding: 32px; max-width: 380px; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: #2e7d32; }
.login-sub { margin: 0 0 24px; color: #888; font-size: 13px; }
.login-card label { display: block; margin: 16px 0; font-size: 13px; color: #555; }
.login-card input { width: 100%; padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 16px; margin-top: 4px; }
.login-card .btn-primary { width: 100%; padding: 14px; font-size: 16px; margin-top: 12px; }
.error-text { color: #c62828; min-height: 1.2em; margin: 8px 0 0; font-size: 13px; }

/* ========== テナントピッカー ========== */
.tenant-picker { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f4f5f3; }
.picker-card { background: white; border-radius: 12px; padding: 32px; max-width: 480px; width: 100%; box-shadow: 0 2px 12px rgba(0,0,0,0.08); }
.picker-card.wide { max-width: 720px; }
.picker-card h1 { margin: 0 0 4px; color: #2e7d32; font-size: 22px; }
.picker-sub { color: #888; font-size: 13px; margin: 0 0 24px; }
.picker-card h3 { margin: 24px 0 8px; font-size: 15px; color: #555; }
.picker-card label { display: block; margin: 12px 0; font-size: 13px; color: #555; }
.picker-card label small { color: #999; font-weight: 400; }
.picker-card input[type=text], .picker-card select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px; margin-top: 4px; }
.picker-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.picker-actions .btn-primary { flex: 1; padding: 12px; }
.picker-actions .btn-secondary { padding: 12px 16px; }
.picker-foot { text-align: right; margin-top: 16px; }
.picker-group { margin: 16px 0; }
.picker-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.picker-tenant { background: #f9f9f9; border: 1px solid #e0e0e0; border-radius: 8px; padding: 14px 16px; text-align: left; cursor: pointer; transition: background 0.1s, border-color 0.1s; }
.picker-tenant:hover { background: #e8f5e9; border-color: #2e7d32; }
.picker-tenant .t-name { font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.picker-tenant code { font-size: 11px; color: #999; }

/* ========== POS ========== */
.pos { display: flex; flex-direction: column; height: 100vh; }
.pos-header { display: flex; justify-content: space-between; align-items: center; background: #2e7d32; color: white; padding: 8px 16px; }
.pos-header-left, .pos-header-right { display: flex; align-items: center; gap: 12px; }
.pos-mode-badge { background: rgba(255,255,255,0.2); padding: 4px 10px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.pos-mode-badge.return { background: #ef6c00; }
.pos-training-badge { background: #ffd54f; color: #5d4037; padding: 4px 10px; border-radius: 12px; font-size: 12px; }
.pos-header .btn-link { color: white; }
.pos-account { font-size: 13px; opacity: 0.9; }
.pos-breadcrumb { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.pos-breadcrumb .crumb { background: rgba(255,255,255,0.16); padding: 3px 10px; border-radius: 12px; }
.pos-breadcrumb .crumb.group { background: rgba(255,255,255,0.28); }
.pos-breadcrumb .crumb-sep { opacity: 0.6; font-size: 14px; }
.pos-header .btn-link { font-size: 13px; }

.summary-modal { max-width: 640px; }
.summary-modal h4 { margin: 16px 0 6px; font-size: 14px; color: #555; }
.pos-sum-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 8px; }
.pos-sum-cards .card { background: #f5f5f5; padding: 12px; border-radius: 8px; text-align: center; }
.pos-sum-cards .card-label { font-size: 11px; color: #777; }
.pos-sum-cards .card-val { font-size: 20px; font-weight: 700; color: #2e7d32; }
.data.compact th, .data.compact td { padding: 6px 8px; font-size: 13px; }

.pos-main { display: flex; flex: 1; overflow: hidden; }
.pos-products { flex: 1; overflow-y: auto; padding: 12px; }
.quick-h { margin: 16px 0 8px; font-size: 14px; color: #777; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.product-grid.quick { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.product-tile {
  background: white; border: 2px solid #ddd; border-radius: 8px; padding: 12px 8px; text-align: center;
  position: relative; transition: transform 0.05s, box-shadow 0.1s;
}
.product-tile:active { transform: scale(0.97); }
.product-tile.out-of-stock { opacity: 0.5; background: #f5f5f5; }
.product-tile.low-stock { border-color: #ef6c00; }
.tile-icon { font-size: 36px; line-height: 1; }
.tile-name { font-size: 14px; font-weight: 600; margin: 4px 0; word-break: break-word; }
.tile-price { color: #2e7d32; font-weight: 700; }
.tile-unit { font-weight: 400; font-size: 11px; color: #777; margin-left: 2px; }
.tile-stock { font-size: 11px; color: #777; margin-top: 4px; }
.product-tile.low-stock .tile-stock { color: #ef6c00; font-weight: 600; }
.tile-cart-qty {
  position: absolute; top: 4px; right: 4px; background: #2e7d32; color: white;
  min-width: 24px; height: 24px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
}
.tile-cart-qty:empty { display: none; }

.pos-cart { width: 320px; background: white; border-left: 1px solid #e0e0e0; display: flex; flex-direction: column; padding: 16px; }
.pos-cart h3 { margin: 0; font-size: 14px; color: #666; }
.pos-total { font-size: 36px; font-weight: 700; color: #2e7d32; margin: 8px 0 16px; }
.pos-cart-items { flex: 1; overflow-y: auto; }
.cart-line { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed #eee; font-size: 14px; }
.cart-empty { color: #aaa; text-align: center; padding: 32px; }
.pos-return-input { margin-top: 8px; padding: 8px; background: #fff3e0; border-radius: 6px; }
.pos-return-input label { font-size: 12px; }
.pos-return-input input { width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; }
.pos-actions { display: flex; gap: 8px; margin-top: 12px; }
.pos-actions button { flex: 1; padding: 14px; font-size: 15px; }

/* ========== POS 確認 ========== */
.pos-confirm { padding: 24px; max-width: 720px; margin: 0 auto; }
.confirm-items { background: white; border-radius: 8px; padding: 16px; margin: 16px 0; }
.confirm-line { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; padding: 6px 0; border-bottom: 1px dashed #eee; font-size: 16px; }
.confirm-total { font-size: 22px; text-align: right; margin: 16px 0; }
.payment-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 24px 0; }
.btn-payment { padding: 32px; font-size: 18px; font-weight: 700; border-radius: 12px; border: none; color: white; }
.btn-payment.cash { background: #43a047; }
.btn-payment.hachipay { background: #fb8c00; }
.confirm-back { display: flex; justify-content: space-between; gap: 8px; }
.confirm-back button { padding: 14px 28px; }

/* ========== お釣り画面 ========== */
.pos-cash { padding: 24px; max-width: 480px; margin: 0 auto; }
.cash-row { display: flex; justify-content: space-between; padding: 12px; background: white; margin: 4px 0; border-radius: 8px; font-size: 18px; }
.cash-row.received { background: #fff8e1; }
.cash-row.change { background: #e8f5e9; font-size: 28px; font-weight: 700; }
.cash-row.change.short { background: #ffebee; color: #c62828; }
.cash-val { font-weight: 700; color: #2e7d32; }
.preset-buttons { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.btn-preset { padding: 12px 18px; border-radius: 8px; background: white; border: 1px solid #ccc; font-size: 16px; }
.cash-numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 16px 0; }
.cash-numpad .num { padding: 18px; font-size: 20px; border-radius: 8px; background: white; border: 1px solid #ccc; }
.cash-numpad .num.back { background: #fff3e0; }
.cash-buttons { display: flex; justify-content: space-between; gap: 8px; }
.cash-buttons button { flex: 1; padding: 16px; font-size: 16px; }

/* ========== POS 結果 ========== */
.pos-result { padding: 48px 24px; max-width: 480px; margin: 0 auto; text-align: center; }
.result-emoji { font-size: 80px; }
.pos-result h2 { font-size: 24px; margin: 16px 0; }
.pos-result.success h2 { color: #2e7d32; }
.pos-result.return h2 { color: #ef6c00; }
.pos-result.offline h2 { color: #c62828; }
.result-change { background: #e8f5e9; padding: 20px; border-radius: 12px; font-size: 22px; margin: 24px 0; }
.result-change strong { color: #2e7d32; font-size: 36px; }
.result-tx-id { color: #999; font-size: 12px; }
.pos-result .btn-primary { width: 100%; padding: 18px; font-size: 16px; margin-top: 32px; }

/* ========== Admin ========== */
.admin { display: flex; flex-direction: column; min-height: 100vh; }
.admin-header { background: #1b5e20; color: white; padding: 12px 24px; display: flex; justify-content: space-between; align-items: center; }
.admin-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.admin-breadcrumb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 400; opacity: 0.9; }
.admin-breadcrumb .crumb { background: rgba(255,255,255,0.16); padding: 3px 10px; border-radius: 12px; }
.admin-breadcrumb .crumb.group { background: rgba(255,255,255,0.28); }
.admin-breadcrumb .crumb-sep { opacity: 0.6; font-size: 16px; }
.admin-user { display: flex; gap: 12px; align-items: center; font-size: 13px; }
.admin-user .btn-link { color: white; }
.admin-tabs { background: white; padding: 0 24px; border-bottom: 1px solid #e0e0e0; display: flex; gap: 4px; overflow-x: auto; }
.admin-tabs .tab { background: none; border: none; padding: 12px 18px; font-size: 14px; color: #555; border-bottom: 3px solid transparent; }
.admin-tabs .tab.active { color: #2e7d32; border-bottom-color: #2e7d32; font-weight: 600; }
.admin-body { padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; }
.admin-body .row { display: flex; gap: 16px; flex-wrap: wrap; }
.admin-body .row.align-end { align-items: center; justify-content: space-between; }
.admin-body h2 { margin: 0; }
.admin-body h3 { margin: 0 0 8px; font-size: 16px; }

.panel { background: white; padding: 16px; border-radius: 8px; margin: 16px 0; flex: 1; min-width: 280px; }
.summary-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.card { background: white; padding: 16px; border-radius: 8px; text-align: center; }
.card-label { font-size: 12px; color: #888; margin-bottom: 6px; }
.card-val { font-size: 24px; font-weight: 700; color: #2e7d32; }
.card.profit .card-val { color: #ef6c00; }

.data { width: 100%; border-collapse: collapse; background: white; border-radius: 8px; overflow: hidden; }
.data th { background: #f5f5f5; padding: 10px; text-align: left; font-size: 13px; color: #666; border-bottom: 1px solid #e0e0e0; }
.data td { padding: 10px; border-bottom: 1px solid #eee; font-size: 14px; }
.data tr.return-row td { background: #fff3e0; }
.data tr.training-row td { background: #fff8e1; color: #888; font-style: italic; }
.data td.stock-out { color: #c62828; font-weight: 700; }
.data td.stock-low { color: #ef6c00; font-weight: 700; }
.data td.icon { font-size: 24px; text-align: center; }
.data code { font-family: SFMono-Regular, monospace; font-size: 12px; color: #555; }
.ua { display: inline-block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.hint { color: #888; font-size: 13px; margin: 4px 0 16px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }

/* ========== モーダル ========== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-card { background: white; border-radius: 12px; padding: 24px; max-width: 480px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-card h3 { margin: 0 0 16px; }
.modal-card label { display: block; margin: 12px 0; font-size: 13px; color: #555; }
.modal-card input[type=text], .modal-card input[type=number], .modal-card input[type=password], .modal-card select { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 6px; font-size: 15px; margin-top: 4px; }
.modal-card input[readonly] { background: #f5f5f5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-actions button { padding: 10px 20px; }

/* ========== エラー ========== */
.error-screen { padding: 64px 24px; text-align: center; color: #c62828; }
.error-screen h2 { margin: 0 0 16px; }
.error-screen button { padding: 12px 24px; }

/* ========== レスポンシブ（タブレット縦） ========== */
@media (max-width: 720px) {
  .pos-main { flex-direction: column; }
  .pos-cart { width: 100%; border-left: none; border-top: 1px solid #e0e0e0; max-height: 40vh; }
  .product-grid { grid-template-columns: repeat(3, 1fr); }
  .product-grid.quick { grid-template-columns: repeat(4, 1fr); }
  .payment-buttons { grid-template-columns: 1fr; }
  .pos-header-left, .pos-header-right { font-size: 12px; gap: 6px; }
  .pos-mode-badge { font-size: 11px; padding: 3px 8px; }
}
