:root {
  --bg: #f4f2ee; --panel: #ffffff; --ink: #1d2433; --sub: #6a7180; --line: #e3e0d9;
  --brand: #1f3a5f; --brand-2: #2b4f7e; --sun: #f08a24; --sun-soft: #fff1e3;
  --ok: #1f8a5b; --ok-soft: #e4f4ec; --warn: #b7791f; --warn-soft: #fdf3dc; --ng: #c0392b; --ng-soft: #fbe6e3;
  --info: #2f6fb5; --info-soft: #e5eef9; --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .05);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.6 "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", "Meiryo", sans-serif; -webkit-text-size-adjust: 100%; }
a { color: var(--info); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* レイアウト */
.app { display: grid; grid-template-columns: 210px 1fr; min-height: 100vh; }
.side { background: var(--brand); color: #dfe7f2; padding: 16px 10px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 2px; }
.side .logo { color: #fff; font-weight: 700; font-size: 15px; padding: 4px 10px 16px; letter-spacing: .04em; }
.side .logo span { color: var(--sun); }
.side a { color: #dfe7f2; padding: 9px 12px; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.side a.on, .side a:hover { background: var(--brand-2); color: #fff; }
.side .me { margin-top: auto; font-size: 12px; padding: 10px; color: #aab7c9; }
.side .me button { background: none; border: 1px solid #50678a; color: #dfe7f2; border-radius: 6px; padding: 2px 8px; cursor: pointer; margin-left: 6px; }
.badge-n { background: var(--ng); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 7px; margin-left: auto; }
main { padding: 20px 24px 80px; max-width: 1280px; width: 100%; min-width: 0; }
.bottom { display: none; }
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .sp { flex: 1; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 12px 12px 90px; }
  .bottom { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--brand); z-index: 1000; padding-bottom: env(safe-area-inset-bottom); }
  .bottom a { flex: 1; color: #c9d5e5; text-align: center; font-size: 11px; padding: 8px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
  .bottom a.on { color: #fff; }
  .bottom a .ic { font-size: 18px; line-height: 1; }
  .bottom .badge-n { position: absolute; top: 3px; left: 55%; }
}

/* パネル */
.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.panel h2 { font-size: 15px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.panel h2 .sp { flex: 1; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .g2, .g3 { grid-template-columns: 1fr; } .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* フォーム */
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--sub); }
label.f.req > span::after { content: " *"; color: var(--ng); }
input[type=text], input[type=tel], input[type=email], input[type=number], input[type=date], input[type=datetime-local], input[type=password], input[type=search], select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: #fff; width: 100%; min-height: 40px; color: var(--ink); font-size: 15px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--sun); outline-offset: -1px; border-color: transparent; }
.btn { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; cursor: pointer; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: #c9c4b8; }
.btn.pri { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.sun { background: var(--sun); color: #fff; border-color: var(--sun); }
.btn.ng { color: var(--ng); border-color: #e9b9b3; }
.btn.sm { min-height: 30px; padding: 3px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: none; padding: 7px 12px; cursor: pointer; min-height: 36px; }
.seg button.on { background: var(--brand); color: #fff; }
.err { background: var(--ng-soft); color: var(--ng); border-radius: 8px; padding: 10px 12px; white-space: pre-line; margin-bottom: 10px; }
.note { font-size: 12px; color: var(--sub); }

/* チップ・ステータス */
.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: #eceae4; color: #444; white-space: nowrap; }
.st-新規流入 { background: var(--info-soft); color: var(--info); }
.st-催事アポ { background: var(--info-soft); color: var(--info); }
.st-架電中 { background: #eceae4; color: #555; }
.st-見込 { background: #e9e4f6; color: #5b3fa0; }
.st-現調昇格 { background: #e2f1f3; color: #1d6b78; }
.st-商談昇格 { background: var(--sun-soft); color: #b55e0b; }
.st-事前確認済 { background: #ffe7c4; color: #9a5300; }
.st-商談実施 { background: #fbe9d0; color: #8a4a00; }
.st-契約 { background: var(--ok-soft); color: var(--ok); }
.st-工事完了 { background: #d7efe2; color: #16683f; }
.st-入金済 { background: var(--ok); color: #fff; }
.st-NG, .st-失注, .st-商談キャンセル { background: var(--ng-soft); color: var(--ng); }
.lv-danger { border-left: 4px solid var(--ng); }
.lv-warn { border-left: 4px solid var(--warn); }
.lv-info { border-left: 4px solid var(--info); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.filters .chip { cursor: pointer; padding: 4px 11px; font-size: 13px; border: 1px solid transparent; }
.filters .chip.on { border-color: var(--ink); }

/* 一覧 */
table.t { width: 100%; border-collapse: collapse; background: #fff; }
table.t th, table.t td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.t th { font-size: 12px; color: var(--sub); font-weight: 600; background: #faf9f6; position: sticky; top: 0; white-space: nowrap; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #fbfaf7; }
table.t tr.total td { font-weight: 700; background: #faf9f6; }
.tablewrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
.cards { display: none; }
@media (max-width: 860px) {
  .tablewrap.listtable { display: none; }
  .cards { display: flex; flex-direction: column; gap: 8px; }
}
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; display: block; color: inherit; }
.card .top { display: flex; align-items: center; gap: 8px; }
.card .name { font-weight: 700; font-size: 15px; }
.card .meta { font-size: 12px; color: var(--sub); margin-top: 4px; }

/* 詳細 */
.head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.head .nm { font-size: 22px; font-weight: 700; }
.head .tel { font-size: 18px; font-weight: 700; color: var(--brand); }
.tabs { display: flex; gap: 4px; overflow-x: auto; margin: 12px 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 9px 12px; cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; color: var(--sub); }
.tabs button.on { border-color: var(--sun); color: var(--ink); font-weight: 700; }
.callbtns { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
@media (max-width: 860px) { .callbtns { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.callbtns button { min-height: 52px; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: pointer; font-weight: 600; }
.callbtns button.on { outline: 3px solid var(--sun); }
.callbtns .c-up { background: var(--sun-soft); border-color: #f6c896; color: #9a4f05; }
.callbtns .c-ng { background: var(--ng-soft); border-color: #eebbb4; color: var(--ng); }
.callbtns .c-ab { background: #f2f0eb; }
.callbtns .c-mi { background: #efeaf8; color: #5b3fa0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px dashed var(--line); display: grid; grid-template-columns: 120px 1fr; gap: 8px; }
.timeline .when { font-size: 12px; color: var(--sub); }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.item.off { background: #faf9f6; }
.item .ttl { display: flex; align-items: center; gap: 10px; font-weight: 700; margin-bottom: 8px; }
.sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.stat { background: #faf9f6; border-radius: 10px; padding: 10px 12px; }
.stat .l { font-size: 12px; color: var(--sub); }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--sub); }
#map, .map { height: 420px; border-radius: var(--radius); border: 1px solid var(--line); }
@media (max-width: 860px) { #map, .map { height: 340px; } }
.thumb { width: 54px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); background: #f5f5f5; cursor: zoom-in; }
.thumb.lg { width: 100%; height: auto; max-height: 360px; object-fit: contain; }
.modal { position: fixed; inset: 0; background: rgba(15, 20, 30, .55); display: flex; align-items: center; justify-content: center; z-index: 2000; padding: 16px; }
.modal .box { background: #fff; border-radius: 12px; max-width: 720px; width: 100%; max-height: 90vh; overflow: auto; padding: 18px; }
.toast { position: fixed; left: 50%; bottom: 80px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 3000; font-size: 13px; }
.login { max-width: 360px; margin: 12vh auto; }
.login .logo { text-align: center; font-size: 22px; font-weight: 700; color: var(--brand); margin-bottom: 18px; }
.login .logo span { color: var(--sun); }
.empty { color: var(--sub); text-align: center; padding: 30px 10px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 10px; font-size: 13px; }
.kv dt { color: var(--sub); }
.kv dd { margin: 0; }
.warnbar { background: var(--warn-soft); color: #7a5410; padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 10px; }
