:root {
  --teal-900: #0b3d3a;
  --teal-700: #0f6b64;
  --teal-600: #13807a;
  --teal-100: #dcefed;
  --teal-50: #eef7f6;
  --ink: #1f2a2e;
  --muted: #5a6a70;
  --line: #d5e0e2;
  --bg: #f4f7f8;
  --white: #fff;
  --amber: #a15c00;
  --amber-bg: #fff3dc;
  --red: #a8322d;
  --red-bg: #fde8e6;
  --violet: #5b3fa0;
  --violet-bg: #efeafb;
  --slate: #3f5560;
  --slate-bg: #e6ecef;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  min-width: 1280px;
}
button { font: inherit; cursor: pointer; }
h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 14px; }

/* ===== top bar ===== */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  height: 68px; padding: 0 24px;
  background: var(--teal-900); color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 300px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #5fc4b8, #13807a); }
.brand-name { font-weight: 700; font-size: 16px; }
.brand-sub { font-size: 12px; opacity: .8; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  background: transparent; color: #cfe5e2; border: 0;
  padding: 10px 16px; border-radius: 8px; font-size: 16px; font-weight: 600;
  position: relative;
}
.tab:hover { background: rgba(255,255,255,.08); }
.tab.active { background: #fff; color: var(--teal-900); }
.tab-badge {
  display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px;
  background: #f2b84b; color: #3b2600; font-size: 12px; vertical-align: 2px;
}
.reset {
  background: transparent; color: #cfe5e2; border: 1px solid rgba(255,255,255,.35);
  border-radius: 6px; padding: 4px 10px; font-size: 13px;
}
.reset:hover { background: rgba(255,255,255,.1); }

main { padding: 24px 32px 40px; max-width: 1280px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.page-head { margin-bottom: 16px; }

/* ===== badges / flags ===== */
.badge {
  display: inline-block; font-size: 12px; font-weight: 700; line-height: 1.6;
  padding: 0 8px; border-radius: 4px; white-space: nowrap;
}
.badge.draft { background: var(--slate-bg); color: var(--slate); border: 1px dashed #8aa0aa; }
.badge.human-b { background: var(--teal-100); color: var(--teal-700); }
.badge.new { background: #f2b84b; color: #3b2600; }
.badge.ok { background: var(--teal-100); color: var(--teal-700); }
.flag {
  display: inline-block; font-size: 13px; font-weight: 600;
  padding: 1px 8px; border-radius: 999px; margin: 1px 2px 1px 0; white-space: nowrap;
}
.f-amount { background: var(--amber-bg); color: var(--amber); }
.f-date { background: var(--red-bg); color: var(--red); }
.f-project { background: var(--violet-bg); color: var(--violet); }
.f-dup { background: #e3eefc; color: #2c5a99; }
.f-none { color: #8a999e; font-size: 14px; }

/* ===== screen 1 ===== */
.capture-layout { display: flex; gap: 48px; align-items: flex-start; justify-content: center; }
.phone {
  width: 370px; height: 680px; flex: none;
  border: 10px solid #22343a; border-radius: 36px; background: #e9f0f1;
  display: flex; flex-direction: column; overflow: hidden; position: relative;
  box-shadow: 0 10px 30px rgba(11,61,58,.18);
}
.phone-notch { position: absolute; top: 0; left: 50%; transform: translateX(-50%); width: 110px; height: 18px; background: #22343a; border-radius: 0 0 12px 12px; z-index: 2; }
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 24px 14px 10px; background: #fff; border-bottom: 1px solid var(--line);
}
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--teal-600); color: #fff;
  display: grid; place-items: center; font-weight: 700;
}
.chat-title { font-weight: 700; font-size: 16px; line-height: 1.3; }
.chat-sub { font-size: 12px; color: var(--muted); }
.chat-body { flex: 1; overflow-y: auto; padding: 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.chat-foot { padding: 10px; background: #fff; border-top: 1px solid var(--line); }
.shoot {
  width: 100%; padding: 10px; border: 0; border-radius: 10px;
  background: var(--teal-700); color: #fff; font-weight: 700; font-size: 16px;
}
.shoot:disabled { background: #a9bcbf; cursor: default; }

.msg { max-width: 86%; font-size: 16px; line-height: 1.5; animation: pop .25s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg.bot { align-self: flex-start; background: #fff; border-radius: 4px 14px 14px 14px; padding: 8px 12px; }
.msg.me { align-self: flex-end; background: #c9e8e3; border-radius: 14px 4px 14px 14px; padding: 8px 12px; }
.msg.photo { padding: 4px; background: #c9e8e3; }
.msg .time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.msg.typing { color: var(--muted); font-style: italic; }

.receipt-img {
  width: 120px; background: #fffef8; border: 1px solid #ddd6c4; padding: 8px 8px 10px;
  font-family: "Osaka-Mono", "MS Gothic", monospace; font-size: 10px; line-height: 1.35; color: #333;
  transform: rotate(-2deg); box-shadow: 0 2px 4px rgba(0,0,0,.12);
}
.receipt-img .r-shop { text-align: center; font-weight: 700; font-size: 11px; }
.receipt-img .r-row { display: flex; justify-content: space-between; }
.receipt-img .r-total { border-top: 1px dashed #999; margin-top: 3px; padding-top: 2px; font-weight: 700; }

.result-card { width: 100%; max-width: 92%; }
.result-card .rc-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; font-weight: 700; }
.result-card dl { display: grid; grid-template-columns: 52px 1fr; gap: 0 8px; margin: 0 0 8px; font-size: 16px; }
.result-card dt { color: var(--muted); }
.result-card dd { margin: 0; font-weight: 600; }
.rc-actions { display: flex; gap: 6px; }
.rc-actions button { flex: 1; border-radius: 8px; padding: 6px 4px; font-size: 16px; font-weight: 700; }
.btn-primary { background: var(--teal-700); color: #fff; border: 0; }
.btn-ghost { background: #fff; color: var(--teal-700); border: 1px solid var(--teal-600); }
.rc-actions button:disabled { opacity: .45; cursor: default; }
.done { border-left: 4px solid var(--teal-600); }

.capture-side { width: 520px; padding-top: 8px; }
.capture-side .lead { font-size: 17px; margin: 8px 0 16px; }
.steps { padding-left: 1.4em; margin: 0 0 16px; }
.steps li { margin-bottom: 6px; }
.note { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.after-send {
  margin-top: 16px; padding: 12px 16px; border-radius: 10px;
  background: var(--teal-50); border: 1px solid var(--teal-100); font-weight: 600;
}
.link {
  background: none; border: 0; color: var(--teal-700); text-decoration: underline; font-weight: 700; padding: 0 6px;
}

/* ===== stats ===== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.stat .k { font-size: 14px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 700; color: var(--teal-900); }
.stat .v small { font-size: 14px; font-weight: 600; color: var(--muted); margin-left: 4px; }
.stat.bump { animation: bump 1.2s ease-out; }
@keyframes bump { 0% { background: #fff1c9; } 100% { background: #fff; } }

/* ===== screen 2 ===== */
.journal-layout { display: grid; grid-template-columns: 1fr 280px; gap: 20px; align-items: start; }
.journal-main .stats { grid-template-columns: repeat(4, 1fr); }
.table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: 16px; }
.list th {
  text-align: left; font-size: 15px; color: var(--muted); font-weight: 600;
  background: var(--teal-50); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.list td { padding: 7px 10px; border-bottom: 1px solid #e8eef0; vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.list .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.list tr.is-new td { background: #fff8e3; }
.list tr.is-new td:first-child { box-shadow: inset 4px 0 0 #f2b84b; }
.list tr.is-confirmed td { color: #6c7b80; }
.acct { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.acct .name { font-weight: 600; }
.confirm-btn {
  background: #fff; color: var(--teal-700); border: 1px solid var(--teal-600);
  border-radius: 6px; padding: 3px 10px; font-size: 14px; font-weight: 700; white-space: nowrap;
}
.confirm-btn:hover { background: var(--teal-50); }
.confirmed { color: var(--teal-700); font-weight: 700; font-size: 14px; white-space: nowrap; }
.unknown { color: var(--violet); font-weight: 600; }

.rules {
  position: sticky; top: 88px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.rule { border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.rule.ai { background: var(--slate-bg); }
.rule.human { background: var(--teal-50); border: 2px solid var(--teal-600); }
.rule-title { font-weight: 700; margin-bottom: 4px; }
.rule ul { margin: 0; padding-left: 1.2em; font-size: 16px; }
.rule p { margin: 6px 0 0; color: var(--muted); }
.legend div { margin: 2px 0; }

/* ===== screen 3 ===== */
.projects { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.pcard.bump { animation: bump 1.6s ease-out; }
.pcard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcard-name { font-size: 18px; font-weight: 700; }
.pcard-meta { font-size: 14px; color: var(--muted); }
.bar { height: 12px; background: #e3ebec; border-radius: 6px; overflow: hidden; margin: 10px 0 4px; position: relative; }
.bar .fill-confirmed { position: absolute; left: 0; top: 0; bottom: 0; background: var(--teal-600); }
.bar .fill-pending { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(45deg, #8fcfc6 0 6px, #b5e0da 6px 12px); }
.bar-legend { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.bar-legend b { color: var(--ink); }
.pnums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 10px; }
.pnum { background: var(--teal-50); border-radius: 8px; padding: 6px 10px; }
.pnum .k { font-size: 13px; color: var(--muted); }
.pnum .v { font-size: 18px; font-weight: 700; }
.pnum .delta { font-size: 13px; color: #8a5a00; font-weight: 700; margin-left: 4px; }
.pflags { display: flex; flex-direction: column; gap: 6px; }
.pflag { display: flex; gap: 8px; align-items: flex-start; font-size: 16px; }
.pflag .flag { flex: none; }
.pflag.ok { color: var(--muted); }

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--teal-900); color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 15px; z-index: 20;
}
