:root {
  /* 公式サイト（casaflor.vercel.app/design/css/tokens.css）・お客様フォームと同じ色 */
  --bg: #F6F5F1;          /* 画面の地（公式 --color-surface） */
  --panel: #FFFFFF;
  --ink: #2E312F;         /* 公式 --color-text */
  --ink-soft: #5F645F;    /* 補足の文字（公式 --color-text-muted を少し濃く） */
  --line: #DDDDD6;        /* 公式 --color-border */
  --terra: #4E664D;       /* 主役の緑（公式 --color-brand-deep） */
  --terra-dark: #3E523E;  /* 公式 --color-brand-deeper */
  /* 状況ごとの色（公式の配色の中で見分けがつくように選んだもの。白地で文字が読める濃さ） */
  --s-new: #944A31;       /* 新規受付: テラコッタ（公式 --color-accent） */
  --s-sent: #85692F;      /* イメージ送付済: 黄土 */
  --s-survey: #4E664D;    /* 現地調査 調整中: 緑 */
  --s-quoted: #4D6A80;    /* 見積提出済: 灰青 */
  --s-won: #4F7349;       /* 成約: 若い緑 */
  --s-lost: #70766F;      /* 失注: グレー（白地で 4.5:1 以上） */
  --radius: 12px;
  --shadow: 0 1px 2px rgba(46,49,47,.06), 0 4px 14px -6px rgba(46,49,47,.12);
  --font-sans: "Zen Kaku Gothic New", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --font-latin: "EB Garamond", Georgia, "Times New Roman", serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-sans); font-size: 14px; line-height: 1.6; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; }
h2, h3 { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--ink-soft); font-size: 12.5px; }

/* ── 部品 ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px; }
.btn:hover { border-color: var(--terra); color: var(--terra); }
.btn:focus-visible, .tab:focus-visible, .card:focus-visible, .input:focus-visible, .icon-btn:focus-visible, .step:focus-visible, .pipe:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; }
.btn--primary { background: var(--terra); border-color: var(--terra); color: #fff; font-weight: 700; }
.btn--primary:hover { background: var(--terra-dark); border-color: var(--terra-dark); color: #fff; }
.btn--sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; line-height: 1; }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; min-height: 42px; }
textarea.input { resize: vertical; line-height: 1.7; }
.input--search { border-radius: 999px; max-width: 420px; }
.label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin: 10px 0 5px; }
.field { margin-bottom: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.actions--end { justify-content: flex-end; }

/* ── ログイン ── */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login__box { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px; box-shadow: var(--shadow); }
.login__brand { font-family: var(--font-latin); font-style: italic; color: var(--terra); font-size: 26px; font-weight: 700; text-align: center; }
.login__title { font-size: 15px; text-align: center; margin: 2px 0 20px; color: var(--ink-soft); font-weight: 600; letter-spacing: .1em; }
.login__label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.login__err { color: #B42318; font-size: 13px; font-weight: 700; margin: 10px 0 0; }
.login .btn--block { margin-top: 16px; }
.login__back { display: block; text-align: center; margin-top: 16px; font-size: 12.5px; color: var(--ink-soft); }

/* ── ヘッダー ── */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px; padding: 10px 20px;
  background: rgba(255,255,255,.94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand b { color: var(--terra); font-family: var(--font-latin); font-style: italic; font-size: 19px; margin-right: 6px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 8px 14px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--ink-soft); min-height: 40px; }
.tab:hover { background: #F0EFEA; }
.tab.is-active { background: var(--ink); color: #fff; }
.top__right { margin-left: auto; display: flex; gap: 8px; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 14px 20px 0; flex-wrap: wrap; }

/* ── パイプライン（状況の流れ） ── */
.pipeline { display: flex; gap: 6px; padding: 12px 20px 6px; overflow-x: auto; }
.pipe { position: relative; flex: 1 0 128px; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px 10px 22px; background: #fff;
  border: 0; cursor: pointer; text-align: left;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 12px 50%); }
.pipe:first-child { clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%); padding-left: 14px; }
.pipe--lost { flex: 0 0 104px; clip-path: none; border-radius: 10px; margin-left: 10px; padding-left: 14px; }
.pipe__name { font-size: 12px; font-weight: 700; color: var(--c); white-space: nowrap; }
.pipe__count { font-size: 22px; font-weight: 800; line-height: 1.1; }
.pipe__count small { font-size: 12px; font-weight: 500; color: var(--ink-soft); margin-left: 2px; }
.pipe__bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--c); }
.pipe.is-active { background: #EAEFE7; }

/* ── ボード ── */
.board { display: grid; grid-template-columns: repeat(6, minmax(250px, 1fr)); gap: 12px; padding: 10px 20px 40px; overflow-x: auto; align-items: start; }
.col { background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: var(--radius); min-height: 180px; display: flex; flex-direction: column; }
.col.is-over { outline: 2px dashed var(--c); outline-offset: -4px; background: #fff; }
.col__head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.col__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.col__name { font-weight: 700; font-size: 13px; }
.col__count { margin-left: auto; font-size: 12px; color: var(--ink-soft); }
.col__list { display: flex; flex-direction: column; gap: 10px; padding: 10px; }
.col__empty { color: var(--ink-soft); font-size: 12px; text-align: center; padding: 20px 8px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease; text-align: left; padding: 0; width: 100%; display: block; }
.card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px -10px rgba(46,49,47,.3); }
.card.is-dragging { opacity: .45; }
.card__thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; background: #ECEBE5; aspect-ratio: 2 / 1; }
.card__thumbs.one { grid-template-columns: 1fr; }
.thumb { width: 100%; height: 100%; object-fit: cover; display: block; background: #ECEBE5; }
.thumb-ph { display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--ink-soft);
  background: repeating-linear-gradient(45deg, #F0EFEA, #F0EFEA 8px, #E9E8E2 8px, #E9E8E2 16px); min-height: 60px; }
.card__body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 3px; }
.card__meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-soft); }
.card__name { font-weight: 700; font-size: 15px; }
.card__sub { font-size: 12px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card__price { font-weight: 700; color: var(--terra); font-size: 13px; margin-top: 2px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: #F0EFEA; color: #454A46; white-space: nowrap; }
.badge--todo { background: #FEE2E2; color: #991B1B; font-weight: 700; }
.badge--ok { background: #DCE5D9; color: #3E523E; }
.badge--wait { background: #F3E6DE; color: #944A31; }
.badge--date { background: #E3EAEE; color: #3B566B; }

/* ── 詳細パネル ── */
.scrim { position: fixed; inset: 0; background: rgba(46,49,47,.4); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: #fff; z-index: 50;
  box-shadow: -10px 0 40px -10px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.drawer__head { padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer__row { display: flex; align-items: center; gap: 10px; }
.drawer__id { font-size: 12px; color: var(--ink-soft); }
.drawer__title { font-size: 20px; font-weight: 800; margin: 2px 0 0; }
.drawer__row .icon-btn { margin-left: auto; flex: none; }
.drawer__body { overflow-y: auto; padding: 16px 20px 40px; display: flex; flex-direction: column; gap: 18px; }
.sec h3 { font-size: 12px; letter-spacing: .08em; color: var(--ink-soft); margin: 0 0 8px; font-weight: 700; }
.kv { display: grid; grid-template-columns: 104px 1fr; gap: 6px 12px; font-size: 13px; margin: 0; }
.kv dt { color: var(--ink-soft); }
.kv dd { margin: 0; word-break: break-word; }
.stepper { display: flex; gap: 4px; margin-top: 12px; }
.step { flex: 1; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 7px 4px; font-size: 11.5px; font-weight: 700;
  color: var(--ink-soft); cursor: pointer; line-height: 1.3; min-height: 40px; }
.step.is-done { background: #F6F5F1; color: var(--c); border-color: var(--c); }
.step.is-current { background: var(--c); border-color: var(--c); color: #fff; }
.step--lost { flex: 0 0 64px; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gallery button { display: block; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: #ECEBE5; padding: 0; cursor: zoom-in; text-align: left; }
.gallery .thumb, .gallery .thumb-ph { aspect-ratio: 4 / 3; height: auto; }
.gallery .cap { display: block; font-size: 11px; padding: 5px 7px; color: var(--ink-soft); background: #fff; }
.pre { white-space: pre-wrap; font-size: 13px; background: #FAFAF7; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin: 0; line-height: 1.7; font-family: inherit; }
.dates { display: flex; flex-direction: column; gap: 6px; }
.date-row { display: flex; gap: 8px; align-items: center; font-size: 13px; flex-wrap: wrap; }
.date-row b { color: var(--s-survey); font-size: 12px; min-width: 52px; }
.fixed-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.fixed-row .input { max-width: 240px; }
.quote-row { display: flex; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.quote-row b { min-width: 70px; }

/* ── ページ（見積書・一覧・設定） ── */
.page { max-width: 1000px; margin: 0 auto; padding: 20px 20px 60px; }
.page--narrow { max-width: 620px; }
.page__title { font-size: 20px; margin-bottom: 14px; }
.linked { background: #EEF2F4; border: 1px solid #C9D6DE; color: #3B566B; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span { display: inline-block; padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-size: 13px; }
.chips input:checked + span { background: var(--ink); color: #fff; border-color: var(--ink); }
.chips input:focus-visible + span { outline: 2px solid var(--terra); outline-offset: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 2fr; gap: 0 12px; }
.grid2__full { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
.items th, .list th { text-align: left; font-size: 12px; color: var(--ink-soft); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.items td { padding: 4px 6px; border-bottom: 1px solid #F0EFEA; }
.items input { width: 100%; padding: 7px 8px; border: 1px solid transparent; border-radius: 6px; background: #FAFAF7; min-width: 60px; }
.items input:focus { border-color: var(--terra); outline: none; background: #fff; }
.items .i-name { min-width: 220px; }
.num { text-align: right; }
.items .num input { text-align: right; }
.adders { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.totals { margin: 16px 0 16px auto; max-width: 340px; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; }
.totals > div { display: flex; justify-content: space-between; padding: 4px 0; }
.totals__grand { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 8px !important; font-size: 17px; color: var(--terra); }
.result { margin-top: 14px; padding: 12px 14px; border-radius: 10px; background: #EAEFE7; border: 1px solid #C9D6C5; color: #3E523E; }
.result.is-err { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }
.list td { padding: 9px 10px; border-bottom: 1px solid #F0EFEA; font-size: 13px; vertical-align: middle; }
.list tr:last-child td { border-bottom: 0; }
.link-btn { border: 0; background: none; color: #4E664D; text-decoration: underline; cursor: pointer; padding: 6px 2px; }
.card-box { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card-box h3 { font-size: 15px; margin-bottom: 4px; }

/* ── モーダル・ライトボックス・トースト ── */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(46,49,47,.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal__panel { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: 86vh; display: flex; flex-direction: column; padding: 16px; gap: 10px; }
.modal__head { display: flex; align-items: center; justify-content: space-between; }
.modal__list { overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; }
.pick { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 0; border-bottom: 1px solid #F0EFEA; background: #fff; width: 100%; text-align: left; cursor: pointer; }
.pick:hover { background: #FAFAF7; }
.pick__note { display: block; font-size: 11.5px; color: var(--ink-soft); }
.pick__price { white-space: nowrap; font-weight: 700; color: var(--terra); }
.empty { padding: 20px; text-align: center; color: var(--ink-soft); }
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; background: #2E312F; }
.lightbox__close { position: absolute; top: 14px; right: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2E312F; color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 90; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.toast--err { background: #991B1B; }
.dialog { position: fixed; inset: 0; z-index: 95; display: flex; align-items: center; justify-content: center; background: rgba(46,49,47,.45); padding: 16px; }
.dialog__box { background: #fff; border-radius: 14px; padding: 22px; width: min(440px, 100%); box-shadow: var(--shadow); line-height: 1.8; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.skeleton { height: 150px; border-radius: 10px; background: linear-gradient(90deg, #E9E8E2, #F6F5F1, #E9E8E2); background-size: 200% 100%; animation: sk 1.2s linear infinite; }
@keyframes sk { to { background-position: -200% 0; } }

@media (max-width: 760px) {
  .top { padding: 8px 12px; gap: 8px; }
  .top__right { margin-left: 0; }
  .toolbar { padding: 10px 12px 0; }
  .pipeline { padding: 10px 12px 4px; }
  .pipe { flex: 0 0 118px; }
  .board { grid-template-columns: 1fr; padding: 8px 12px 40px; }
  .board .col { display: none; }
  .board .col.is-shown { display: flex; }
  .kv { grid-template-columns: 88px 1fr; }
  .stepper { flex-wrap: wrap; }
  .step { flex: 1 0 30%; }
  .grid2 { grid-template-columns: 1fr; }
  .page { padding: 16px 12px 60px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* 見積書の添付 */
.attach { margin-top: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 10px; background: #FAFAF7; }
.attach__hint { margin: 8px 0 0; font-size: 12px; }
.attach__file { font-weight: 700; font-size: 13px; overflow-wrap: anywhere; }
.attach__fields { display: grid; gap: 4px; margin-top: 8px; }
.attach__fields .label { margin-top: 6px; }
.quote-row__subject { color: var(--ink-soft); flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.link-btn--danger { color: #B42318; }

/* 提出物: 写真ごとの操作 */
.gallery__cell { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.gallery__regen { font-size: 12px; text-align: left; padding: 6px 2px; }
.cap__src { display: block; color: var(--terra); font-size: 11px; }

/* 接続チェック */
.diag { margin-top: 12px; display: grid; gap: 8px; }
.diag__row { display: grid; gap: 2px; padding: 10px 12px; border-radius: 8px; border-left: 4px solid; font-size: 13px; }
.diag__row--ok { border-color: #4E664D; background: #EAEFE7; }
.diag__row--ng { border-color: #B42318; background: #FDECEA; }
.diag__name { font-weight: 700; }
.diag__detail { color: var(--ink-soft); overflow-wrap: anywhere; }

/* 未使用の状況（成約・失注）: 灰色の面をかける。面はクリックを通すので、開く・ドラッグで移すなどの操作はそのままできる */
.col--unused { position: relative; background: #E6E3DE; border-style: dashed; border-color: #BDB8B0; }
.col--unused::after, .pipe--unused::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: repeating-linear-gradient(135deg, rgba(90, 90, 90, .10) 0 8px, rgba(90, 90, 90, .03) 8px 16px);
}
.col--unused .col__dot { background: #9A958D; }
.col--unused .col__name, .col--unused .col__count, .col--unused .col__empty { color: #59544D; }
.col__unused { padding: 1px 8px; border-radius: 999px; background: #59544D; color: #fff; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.pipe--unused { background: #E6E3DE; }
.pipe--unused .pipe__name, .pipe--unused .pipe__count { color: #59544D; }
.pipe--unused .pipe__bar { background: #9A958D; }
.pipe--unused.is-active { background: #DAD6D0; }
.col--unused .card__meta, .col--unused .card__sub { color: #5F645F; }

/* メールの送り方を選ぶ */
.mail-addr { font-size: 13px; color: var(--ink-soft); overflow-wrap: anywhere; user-select: all; }
.mail-choices { display: grid; gap: 8px; margin-top: 14px; }
.mail-choices .btn { justify-content: center; text-align: center; text-decoration: none; }
.mail-note { margin: 10px 0 0; font-size: 12px; }
.mail-status { margin: 10px 0 0; font-size: 13px; font-weight: 700; color: #4E664D; min-height: 1.4em; }

/* 通知メールの宛先一覧 */
.notify-list { list-style: none; margin: 12px 0; padding: 0; border-top: 1px solid var(--line); }
.notify-list li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-size: 14px; }
.notify-list__addr { min-width: 0; overflow-wrap: anywhere; }
.notify-list__empty { color: var(--ink-soft); font-size: 13px; }
.notify-add .input { flex: 1 1 auto; min-width: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
