/* こぐま顧客カード — 部屋カルテのデザインシステム（docs/DESIGN_SYSTEM.md）に合わせる */
:root {
  --color-brand-brown: #6a3a07;
  --color-brand-brown-dark: #4c2905;
  --color-brand-orange: #f18d00;
  --color-brand-green: #6fba2c;
  --color-green-700: #3b7818;
  --color-red-700: #b42318;
  --color-amber-800: #824600;
  --color-neutral-950: #2e241b;
  --color-neutral-700: #6b6158;
  --color-neutral-500: #958b82;
  --color-neutral-300: #ded7cd;
  --color-neutral-100: #f1eee8;
  --color-neutral-50: #f7f4ee;
  --font-sans: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  --radius-sm: 9px; --radius-md: 13px; --radius-lg: 18px; --radius-xl: 24px;
  --shadow-sm: 0 2px 10px rgba(76, 41, 5, .06);
  --shadow-md: 0 12px 34px rgba(76, 41, 5, .12);
  --tap: 48px;

  --bg: var(--color-neutral-50);
  --card: #fff;
  --muted-bg: var(--color-neutral-100);
  --brand-soft: #fff3df;
  --ink: var(--color-neutral-950);
  --ink-2: var(--color-neutral-700);
  --ink-3: var(--color-neutral-500);
  --line: var(--color-neutral-300);
  --navy: var(--color-brand-brown);
  --navy-dark: var(--color-brand-brown-dark);
  --accent: var(--color-brand-orange);
  --ok: var(--color-green-700); --ok-bg: #edf7e4;
  --warn: var(--color-amber-800); --warn-bg: #fff4df;
  --bad: var(--color-red-700); --bad-bg: #fff0ed;
  --focus-ring: rgba(111, 186, 44, .44);
  --card-border: rgba(106, 58, 7, .13);
  --stage: var(--color-brand-green);
  --stage-ink: #2f6b13;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font-family: var(--font-sans); font-size: 16px; line-height: 1.5; overscroll-behavior-y: none; }
a { color: var(--navy); }
button { font-family: inherit; }
.hidden { display: none !important; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.error { color: var(--bad); font-size: 14px; }
.spacer { flex: 1; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------------- ログイン ---------------- */
.login { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: var(--navy); padding: 24px; }
.login-card { background: #fff; border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 360px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.25); }
.login-brand-logo { width: 150px; max-width: 70%; display: block; margin: 0 auto 10px; }
.login-logo { font-size: 22px; font-weight: 700; letter-spacing: .04em; }
.login-lead { color: var(--ink-2); font-size: 14px; margin: 6px 0 4px; }
.login-field { display: block; text-align: left; font-size: 13px; color: var(--ink-2); margin-top: 14px; }
.login-card input { width: 100%; height: var(--tap); margin: 6px 0 12px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font-size: 17px; text-align: center; }

/* ---------------- ヘッダー ---------------- */
#topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 6px; min-height: 56px; padding: max(6px, env(safe-area-inset-top)) 10px 6px; background: var(--navy); color: #fff; }
.topbar-brand img { height: 30px; width: auto; display: block; background: #fff; border-radius: 8px; padding: 2px 6px; }
#title-wrap { flex: 1; min-width: 0; }
#title { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subtitle { font-size: 12px; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#topbar-actions { display: flex; gap: 6px; }
#topbar-actions button { height: 36px; padding: 0 12px; border: 1px solid rgba(255,255,255,.55); background: transparent; color: #fff; border-radius: 9px; font-size: 14px; font-weight: 700; white-space: nowrap; }
#topbar-actions button.primary { background: var(--accent); border-color: var(--accent); }
.icon-btn { width: 40px; height: 40px; border: 0; background: transparent; color: inherit; font-size: 28px; line-height: 1; border-radius: 10px; cursor: pointer; }
.icon-btn.small { width: 32px; height: 32px; font-size: 16px; color: var(--ink-3); }

/* ---------------- 本体・タブ ---------------- */
#view { padding: 12px 12px calc(84px + env(safe-area-inset-bottom)); max-width: 820px; margin: 0 auto; }
#tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; justify-content: center; gap: 2px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); padding: 4px 6px calc(4px + env(safe-area-inset-bottom)); backdrop-filter: blur(8px); }
#tabbar a { flex: 1; max-width: 160px; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 6px 4px; text-decoration: none; color: var(--ink-2); font-size: 11.5px; border-radius: 10px; }
#tabbar a .ti { font-size: 18px; line-height: 1.1; }
#tabbar a.active { color: var(--navy); background: var(--brand-soft); font-weight: 700; }

/* ---------------- 共通部品 ---------------- */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow-sm); }
.sec-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: var(--radius-md); font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-danger { background: var(--bad-bg); border-color: rgba(180,35,24,.35); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-lg { min-height: var(--tap); font-size: 16px; }
.btn-sm { min-height: 34px; padding: 0 11px; font-size: 13.5px; font-weight: 600; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--muted-bg); color: var(--ink-2); white-space: nowrap; }
.pill.acc { background: var(--ok-bg); color: var(--ok); font-weight: 700; }
.pill.warn { background: var(--warn-bg); color: var(--warn); font-weight: 700; }
.pill.bad { background: var(--bad-bg); color: var(--bad); font-weight: 700; }
.small-pill { font-size: 11px; padding: 1px 7px; margin-left: 6px; vertical-align: middle; }
.chev { color: var(--ink-3); font-size: 22px; }
.alert-strip { background: var(--bad-bg); color: var(--bad); border: 1px solid rgba(180,35,24,.25); border-radius: var(--radius-md); padding: 10px 14px; font-weight: 700; margin-bottom: 12px; }
.alert-strip.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(130,70,0,.25); }
.loading, .empty { text-align: center; color: var(--ink-2); padding: 28px 12px; white-space: pre-wrap; line-height: 1.7; }
.foot-note { text-align: center; color: var(--ink-3); font-size: 12px; margin: 26px 0 10px; }
.foot-link { color: var(--navy); }
.chiprow { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 15px; font-weight: 700; }
.filter-bar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 4px 0 12px; }
.filter-chip { min-height: 34px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--ink-2); font-size: 13.5px; font-weight: 700; }
.filter-chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.inline-select { min-height: 34px; border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; font-size: 13.5px; background: #fff; }
.search { width: 100%; height: 44px; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; font-size: 16px; margin-bottom: 8px; background: #fff; }

/* 入力欄 */
.field { display: block; margin-bottom: 10px; }
.field-label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 3px; }
.field-hint { display: block; font-size: 12px; color: var(--ink-3); margin-top: 3px; }
.field input, .field select, .field textarea { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 16px; font-family: inherit; background: #fff; color: var(--ink); }
.field textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .span2 { grid-column: 1 / -1; }
@media (max-width: 520px) { .grid2 { grid-template-columns: 1fr; } }
.sticky-foot { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); background: rgba(247,244,238,.95); padding: 8px 0; display: flex; gap: 8px; justify-content: center; }
.sticky-foot .btn { flex: 1; max-width: 420px; }

/* モーダル */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(46,36,27,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: var(--radius-xl) var(--radius-xl) 0 0; padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.modal h3 { margin: 0 0 12px; font-size: 17px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 14px; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: var(--radius-xl); } }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 60; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 700; box-shadow: var(--shadow-md); max-width: 90vw; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.update-banner { position: fixed; top: 0; left: 0; right: 0; z-index: 70; background: var(--accent); color: #fff; text-align: center; padding: 10px; font-weight: 700; cursor: pointer; }

/* ---------------- 追いかけ・一覧の行 ---------------- */
.grp { font-size: 12px; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; margin: 14px 0 6px; display: flex; align-items: center; gap: 8px; }
.grp::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fu-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 6px; cursor: pointer; }
.fu-row:active { background: var(--muted-bg); }
.days { text-align: center; border-radius: 9px; padding: 5px 0 3px; font-size: 19px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; background: var(--muted-bg); color: var(--ink-2); min-width: 50px; }
.days span { display: block; font-size: 10px; font-weight: 500; margin-top: 2px; opacity: .8; }
.days.warn { background: var(--warn-bg); color: var(--warn); }
.days.crit { background: var(--bad-bg); color: var(--bad); }
.days.ok { background: var(--muted-bg); }
.fu-main { min-width: 0; }
.fu-name { font-weight: 700; font-size: 15.5px; }
.fu-name i { font-style: normal; font-weight: 400; color: var(--ink-2); font-size: 13px; margin-left: 6px; }
.fu-need { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fu-last { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fu-last b { color: var(--ink); margin-right: 5px; font-variant-numeric: tabular-nums; }
.fu-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.list-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 6px; font: inherit; color: inherit; cursor: pointer; }
.list-row:active { background: var(--muted-bg); }
.card-row .fu-main { flex: 1; }
.deal-brief { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; white-space: nowrap; }

/* 段階・記号 */
.stage-pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.stage-pill b { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--stage); color: #fff; font-size: 12px; }
.stage-pill.closed b { background: var(--ink-3); }
.stage-pill.dead b { background: var(--ink-3); }
.code-circle { width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--muted-bg); color: var(--ink); font-weight: 700; font-size: 12.5px; flex: none; }
.code-circle.stage { background: var(--stage); color: #fff; }
.code-circle.dead { background: var(--ink-3); color: #fff; }
.code-circle.note { background: transparent; border: 1px dashed var(--line); color: var(--ink-3); }
.code-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.code-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; min-width: 52px; min-height: 48px; padding: 4px 6px; border: 1px solid var(--line); background: #fff; border-radius: 12px; cursor: pointer; }
.code-btn b { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--muted-bg); font-size: 12.5px; }
.code-btn span { font-size: 10.5px; color: var(--ink-2); }
.code-btn.stage b { background: var(--stage); color: #fff; }
.code-btn.dead b { background: var(--ink-3); color: #fff; }
.code-btn.on { border-color: var(--navy); background: var(--brand-soft); box-shadow: 0 0 0 2px var(--brand-soft); }
.sticky-foot.codes { justify-content: flex-start; overflow-x: auto; gap: 6px; scrollbar-width: none; }
.sticky-foot.codes .code-btn { flex: none; }

/* ---------------- 顧客カード ---------------- */
.summary { display: flex; align-items: center; gap: 12px; }
.kv { display: grid; grid-template-columns: 64px 1fr; gap: 3px 10px; margin: 0; font-size: 14px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.tel { font-size: 17px; font-weight: 700; color: var(--navy); }
.memo { white-space: pre-wrap; background: var(--muted-bg); border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 8px 0 0; }
.deal.closed { opacity: .72; }
.deal-kind { font-size: 13px; color: var(--ink-2); }
.deal-title { font-size: 15px; }
.props { display: grid; gap: 6px; margin-top: 10px; }
.prop { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.prop-main { flex: 1; min-width: 0; font-size: 14px; }
.prop-status { min-height: 32px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; }
.picker-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
.modal input[type=text]:not(.field input) { width: 100%; min-height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 16px; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px solid var(--muted-bg); cursor: pointer; }
.tl li:last-child { border-bottom: 0; }
.tl-body { min-width: 0; flex: 1; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.tl-head .d { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tl-head .c { font-weight: 700; }
.tl-head .by { color: var(--ink-3); font-size: 12px; }
.tl-head .auto { font-size: 11px; color: #355f8c; background: #e1eaf4; padding: 0 6px; border-radius: 4px; }
.tl-note { font-size: 14.5px; white-space: pre-wrap; margin-top: 2px; }
.audit-row { display: grid; grid-template-columns: 110px 70px 1fr; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--muted-bg); font-size: 14px; }
@media (max-width: 520px) { .audit-row { grid-template-columns: 1fr; gap: 0; } }
.guide ol, .guide p { font-size: 15px; line-height: 1.8; margin: 0; }
.guide ol { padding-left: 20px; }
.guide-codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 6px 10px; font-size: 14px; margin-bottom: 8px; }
.guide-codes b { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--stage); color: #fff; font-size: 12px; margin-right: 4px; }

/* ---------------- 音声入力 ---------------- */
.mic-wrap { position: relative; display: block; }
.mic-wrap > input, .mic-wrap > textarea { padding-right: 46px; }
.mic-btn { position: absolute; top: 5px; right: 5px; width: 36px; height: 36px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 17px; line-height: 1; cursor: pointer; }
.mic-wrap > input + .mic-btn { top: 50%; transform: translateY(-50%); }
.mic-btn.on { background: var(--bad); border-color: var(--bad); animation: mic-pulse 1.1s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.mic-hint { font-size: 12px; color: var(--navy); font-weight: 600; padding: 3px 2px 0; }
@media (prefers-reduced-motion: reduce) { .mic-btn.on { animation: none; } }

/* ---------------- 話すだけ記録 ---------------- */
.voice-stage { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.voice-stage textarea { width: 100%; min-height: 80px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font: inherit; font-size: 16px; }
.voice-stage .modal-actions { width: 100%; }
.voice-mic { width: 84px; height: 84px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-size: 36px; cursor: pointer; }
.voice-mic.on { background: var(--bad); border-color: var(--bad); animation: mic-pulse 1.1s ease-in-out infinite; }
.voice-status { font-size: 13.5px; color: var(--ink-2); text-align: center; min-height: 1.5em; }
@media (prefers-reduced-motion: reduce) { .voice-mic.on { animation: none; } }
