/* 仕入れメモ ウェブ版
   配色・角丸・フロスト感は iPhoneアプリ版 AppTheme.swift の値をそのまま写している。 */

:root {
  --off-white: #EFEFF1;
  --pink: #ECD4D4;
  --blue-gray: #CCDBE2;
  --lavender: #C9CBE0;

  --text-primary: #4A3F58;
  --text-secondary: #6B5A5A;
  --text-tertiary: #8B7A7A;
  --button-text: #2D2F48;
  --pink-text: #6B3F3F;

  --focus: #534AB7;

  --card-radius: 22px;
  --small-radius: 12px;

  --tabbar-bg: #F7F2E6;
  --tabbar-border: rgba(180, 150, 120, 0.2);

  --profit-green: #085041;
  --profit-green-mid: #2F6B4A;
  --loss-red: #A32D2D;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --tabbar-h: 56px;
  --syncbar-h: 30px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overscroll-behavior-y: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Helvetica Neue", sans-serif;
  color: var(--text-primary);
  background: var(--off-white);
  -webkit-text-size-adjust: 100%;
}

button, input, textarea {
  font-family: inherit;
  font-size: 16px; /* iOSの自動ズーム防止 */
  color: inherit;
}
button { border: none; background: none; padding: 0; cursor: pointer; }

.hidden { display: none !important; }

/* ── 画面コンテナ ────────────────────────────────────────────────── */

.screen {
  position: fixed;
  inset: 0;
  top: 0;
  padding-top: calc(var(--safe-top) + var(--syncbar-h));
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 背景グラデーション（homeGradient / inputGradient / detailGradient の再現） */
.screen.grad-home {
  background: linear-gradient(135deg, rgba(236,212,212,0.7) 0%, var(--off-white) 50%, rgba(201,203,224,0.7) 100%);
}
.screen.grad-input {
  background: linear-gradient(135deg, rgba(201,203,224,0.7) 0%, var(--off-white) 50%, rgba(236,212,212,0.7) 100%);
}
.screen.grad-detail {
  background: linear-gradient(135deg, rgba(236,212,212,0.7) 0%, rgba(201,203,224,0.5) 50%, rgba(204,219,226,0.7) 100%);
}

.page { padding: 16px 20px 40px; }

/* ── 同期状態バー ────────────────────────────────────────────────── */

.syncbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  height: calc(var(--safe-top) + var(--syncbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: rgba(247, 242, 230, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--tabbar-border);
  color: var(--text-secondary);
}
.syncbar.pending { background: rgba(201, 203, 224, 0.92); color: var(--button-text); }
.syncbar.error   { background: rgba(236, 212, 212, 0.95); color: var(--pink-text); }
.syncbar .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.syncbar.syncing .dot { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.25 } }

/* ── 下部タブバー ────────────────────────────────────────────────── */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--tabbar-bg);
  border-top: 1px solid var(--tabbar-border);
}
.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 44px;
  color: var(--text-secondary);
  font-size: 11px;
  opacity: 0.75;
}
.tab img { width: 26px; height: 26px; object-fit: contain; }
.tab.active { color: var(--pink-text); font-weight: 500; opacity: 1; }

/* ── カード（frostedCard の再現） ──────────────────────────────────── */

.card {
  background: rgba(255, 255, 255, 0.42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 0.5px solid rgba(255, 255, 255, 0.5);
  border-radius: var(--card-radius);
  padding: 16px;
}
.card.tight { padding: 14px; }
.card.tighter { padding: 12px; }
.card.tappable:active { transform: scale(0.99); }

/* ── 見出し ─────────────────────────────────────────────────────── */

.h1 { font-size: 28px; font-weight: 700; margin: 0; }
.h2 { font-size: 22px; font-weight: 700; margin: 0; }
.sub { font-size: 15px; color: var(--text-secondary); margin: 4px 0 0; }
.section-title { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin: 4px 0 0; }
.caption { font-size: 12px; color: var(--text-tertiary); margin: 0; }
.caption2 { font-size: 11px; color: var(--text-tertiary); margin: 0; }

.stack { display: flex; flex-direction: column; gap: 20px; }
.stack-sm { display: flex; flex-direction: column; gap: 12px; }
.stack-xs { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }

/* ナビゲーションヘッダー（プッシュ画面用） */
.navbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px 0;
  min-height: 44px;
}
.navbar .back {
  display: flex; align-items: center; gap: 2px;
  min-height: 44px; padding: 0 8px 0 0;
  color: var(--button-text); font-size: 16px; font-weight: 500;
}
.navbar .nav-title {
  flex: 1; text-align: center; font-size: 17px; font-weight: 600;
  color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  padding-right: 44px;
}

/* ── ボタン（PrimaryButton / SubButton） ───────────────────────────── */

.btn-primary {
  display: block; width: 100%;
  padding: 16px;
  border-radius: var(--small-radius);
  background: rgba(201, 203, 224, 0.85);
  color: var(--button-text);
  font-size: 17px; font-weight: 600;
  text-align: center;
}
.btn-primary:disabled { background: rgba(201, 203, 224, 0.4); opacity: 0.7; }
.btn-sub {
  display: block; width: 100%;
  padding: 13px;
  border-radius: var(--small-radius);
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid var(--lavender);
  color: var(--text-primary);
  font-size: 15px; font-weight: 500;
  text-align: center;
}
.btn-sub.danger { color: var(--pink-text); }
.btn-small {
  padding: 8px 14px;
  border-radius: var(--small-radius);
  background: rgba(201, 203, 224, 0.85);
  color: var(--button-text);
  font-size: 13px; font-weight: 600;
  min-height: 44px;
}

/* ── バッジ ─────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-progress { background: rgba(236, 212, 212, 0.6); color: var(--pink-text); }
.badge-store    { background: rgba(236, 212, 212, 0.7); color: var(--pink-text); }
.badge-online   { background: rgba(201, 203, 224, 0.7); color: var(--button-text); }
.badge-plain    { background: rgba(204, 219, 226, 0.5); color: var(--text-tertiary); }

/* ── 進行中ブロックカード ──────────────────────────────────────────── */

.active-card { border: 1px solid rgba(236, 212, 212, 0.6); }
.active-place { font-size: 19px; font-weight: 700; margin: 0; }
.warn-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 14px;
  border-radius: var(--small-radius);
  background: rgba(236, 212, 212, 0.7);
  border: 1px solid rgba(107, 63, 63, 0.5);
  color: var(--pink-text);
  text-align: left;
  width: 100%;
}
.warn-banner strong { font-size: 15px; }

/* ── 入力フィールド ──────────────────────────────────────────────── */

.field-label { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.field-optional { font-size: 11px; color: var(--text-tertiary); margin-left: 4px; }

.input, .textarea {
  display: block; width: 100%;
  padding: 12px;
  border-radius: var(--small-radius);
  border: 0.5px solid rgba(201, 203, 224, 0.7);
  background: rgba(255, 255, 255, 0.3);
  color: var(--text-primary);
  outline: none;
  -webkit-appearance: none;
}
.input.filled, .textarea.filled { background: rgba(255, 255, 255, 0.5); }
.input.dashed { border-style: dashed; }
.input:focus, .textarea:focus {
  border-color: var(--focus);
  border-style: solid;
  border-width: 1.5px;
  background: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 6px rgba(83, 74, 183, 0.15);
}
.textarea { min-height: 76px; resize: none; line-height: 1.5; }

/* ── 利益カード（ProfitCard） ─────────────────────────────────────── */

.profit {
  position: relative;
  padding: 9px 11px 9px 14px;
  border-radius: var(--small-radius);
  background: rgba(255, 255, 255, 0.55);
  overflow: hidden;
}
.profit::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: #6BA68F;
}
.profit.net { background: rgba(225, 245, 238, 0.7); }
.profit.net::before { background: #1D9E75; }
.profit.loss { background: rgba(252, 235, 235, 0.8); }
.profit.loss::before { background: var(--loss-red); }
.profit-top { display: flex; align-items: baseline; justify-content: space-between; }
.profit-label { font-size: 11px; color: var(--text-secondary); }
.profit.net .profit-label { color: var(--profit-green-mid); font-weight: 500; }
.profit-value { font-size: 20px; font-weight: 500; color: var(--profit-green-mid); }
.profit.net .profit-value { color: var(--profit-green); }
.profit.loss .profit-value { color: var(--loss-red); }
.profit-break { font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.profit.net .profit-break { color: var(--profit-green-mid); }
.profit.loss .profit-break { color: #993556; }

/* ── 状態ピッカー ────────────────────────────────────────────────── */

.cond-btn {
  display: block; width: 100%;
  text-align: left;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--small-radius);
  background: rgba(255, 255, 255, 0.45);
  color: var(--button-text);
  font-size: 14px;
}
.cond-btn.selected { background: rgba(201, 203, 224, 0.85); }

/* ── 写真 ───────────────────────────────────────────────────────── */

.photo-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.photo-thumb {
  position: relative; flex: 0 0 auto;
  width: 80px; height: 80px;
  border-radius: 10px; overflow: hidden;
  background: rgba(204, 219, 226, 0.4);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-del {
  position: absolute; top: 2px; right: 2px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,0.45); color: #fff;
  font-size: 14px; line-height: 24px; text-align: center;
}
.photo-actions { display: flex; gap: 10px; }
.photo-btn {
  flex: 1;
  padding: 9px 12px;
  min-height: 44px;
  border-radius: var(--small-radius);
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--blue-gray);
  color: var(--text-primary);
  font-size: 14px;
}
.photo-btn:disabled { background: rgba(255,255,255,0.2); border-color: rgba(204,219,226,0.3); color: var(--text-tertiary); }

/* 一覧のサムネイル */
.item-thumb {
  position: relative; flex: 0 0 auto;
  width: 60px; height: 60px; border-radius: 10px; overflow: hidden;
  background: rgba(204, 219, 226, 0.4);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-tertiary); font-size: 18px;
}
.item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.item-thumb .count {
  position: absolute; right: 3px; bottom: 3px;
  padding: 2px 4px; border-radius: 999px;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 9px; font-weight: 700;
}

/* ── 追加中バナー ────────────────────────────────────────────────── */

.adding-banner {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(107, 63, 63, 0.25);
}
.adding-banner.store  { background: rgba(236, 212, 212, 0.85); }
.adding-banner.online { background: rgba(201, 203, 224, 0.85); }
.adding-banner .place { font-size: 20px; font-weight: 700; margin: 0; }
.adding-banner .kind { font-size: 13px; font-weight: 600; color: var(--text-secondary); margin: 1px 0 0; }
.adding-banner .icon { font-size: 20px; }

/* ── 場所サジェスト ──────────────────────────────────────────────── */

.suggest { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.suggest button {
  text-align: left;
  padding: 10px 14px;
  min-height: 44px;
  border-radius: var(--small-radius);
  background: rgba(201, 203, 224, 0.5);
  color: var(--text-primary);
  font-size: 14px;
}

/* 種別セグメント */
.seg { display: flex; border-radius: var(--small-radius); overflow: hidden; border: 1px solid rgba(201,203,224,0.6); }
.seg button {
  flex: 1; padding: 12px 0; min-height: 44px;
  font-size: 15px; font-weight: 600;
  background: rgba(255,255,255,0.2); color: var(--text-secondary);
}
.seg button.on { background: rgba(201, 203, 224, 0.85); color: var(--button-text); }

/* ── 空状態 ─────────────────────────────────────────────────────── */

.empty { text-align: center; padding: 60px 0; color: var(--text-tertiary); }
.empty .icon { font-size: 34px; }
.empty p { font-size: 15px; margin: 12px 0 0; }

/* ── 一覧行 ─────────────────────────────────────────────────────── */

.list-row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; }
.chev { color: var(--text-tertiary); font-size: 14px; }
.money-green { color: var(--profit-green); font-weight: 600; }
.money-red   { color: var(--pink-text); font-weight: 600; }

/* ── カメラ ─────────────────────────────────────────────────────── */

.camera { position: fixed; inset: 0; z-index: 100; background: #000; }
.camera video { width: 100%; height: 100%; object-fit: cover; }
.cam-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding-bottom: var(--safe-bottom); }
.cam-strip { display: flex; gap: 6px; padding: 7px 16px; overflow-x: auto; background: rgba(0,0,0,0.45); min-height: 0; }
.cam-strip:empty { display: none; }
.cam-strip .cell { position: relative; flex: 0 0 auto; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; }
.cam-strip .cell img { width: 100%; height: 100%; object-fit: cover; }
.cam-strip .cell button {
  position: absolute; top: 1px; right: 1px;
  width: 22px; height: 22px; border-radius: 50%;
  background: rgba(0,0,0,0.5); color: #fff; font-size: 13px; line-height: 22px;
}
.cam-bar {
  display: flex; align-items: center; justify-content: space-between;
  height: 100px; padding: 0 24px;
  background: rgba(0,0,0,0.5);
}
.cam-count { width: 60px; color: rgba(255,255,255,0.8); font-size: 13px; }
.cam-shutter {
  width: 72px; height: 72px; border-radius: 50%;
  background: #fff; border: 3px solid rgba(128,128,128,0.5);
}
.cam-shutter:disabled { background: rgba(255,255,255,0.3); }
.cam-done { width: 60px; color: #fff; font-size: 17px; font-weight: 600; text-align: right; }
.cam-denied {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  color: rgba(255,255,255,0.75); text-align: center; padding: 24px;
}
.cam-denied-icon { font-size: 44px; opacity: 0.6; }
.cam-close { color: #fff; font-size: 16px; padding: 12px 24px; }

/* ── 写真ビューア ────────────────────────────────────────────────── */

.viewer {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(0,0,0,0.94);
  display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x mandatory;
  align-items: center;
  padding-bottom: var(--safe-bottom);
}
.viewer img { width: 100vw; flex: 0 0 100vw; max-height: 100%; object-fit: contain; scroll-snap-align: center; }

/* ── トースト ───────────────────────────────────────────────────── */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  z-index: 120;
  padding: 10px 16px;
  border-radius: var(--small-radius);
  background: rgba(201, 203, 224, 0.95);
  color: var(--button-text);
  font-size: 15px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

/* ── 確認シート（ブラウザのconfirmの代わり） ─────────────────────────── */

.sheet-backdrop {
  position: fixed; inset: 0; z-index: 130;
  background: rgba(74, 63, 88, 0.35);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.sheet {
  width: 100%; max-width: 420px;
  display: flex; flex-direction: column; gap: 10px;
  padding: 20px;
  border-radius: var(--card-radius);
  background: rgba(247, 242, 230, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}
.sheet-title { font-size: 17px; font-weight: 700; }
.sheet-msg { font-size: 14px; color: var(--text-secondary); margin-bottom: 4px; line-height: 1.5; }
.sheet .btn-primary.danger { background: rgba(236, 212, 212, 0.95); color: var(--pink-text); }

/* 写真が読めなかったサムネイル */
.item-thumb.no-photo img, .photo-thumb.no-photo img { display: none; }
.item-thumb.no-photo::after { content: "🖼"; }

/* 「次へ」チップ（iOSの数字キーパッドには改行キーが無いので画面側に置く） */
.next-chip {
  padding: 6px 10px;
  min-height: 32px;
  border-radius: 999px;
  background: rgba(201, 203, 224, 0.75);
  color: var(--button-text);
  font-size: 12px; font-weight: 600;
}
.suggest:empty { display: none; }
