/* 365LIFE 営業管理 共通スタイル（スマホ優先） */

:root {
    --main: #1996a3;
    --main-dark: #127580;
    --main-light: #e6f4f5;
    --text: #333;
    --muted: #777;
    --line: #e3e6e8;
    --bg: #f5f7f8;
    --warn-bg: #fff4e0;
    --warn-text: #9a5b00;
    --error-bg: #fdecec;
    --error-text: #b42318;
    --success-bg: #e8f6ee;
    --success-text: #1e7a46;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.6;
}

a { color: var(--main-dark); }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---- ヘッダー ---- */
.app-header { background: var(--main); color: #fff; }
.app-header-inner {
    max-width: 960px; margin: 0 auto; padding: 10px 16px;
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.app-title { color: #fff; font-weight: bold; text-decoration: none; font-size: 16px; }
.logout { display: flex; align-items: center; gap: 8px; margin: 0; }
.logout .user-name { font-size: 13px; color: #fff; }
.logout button {
    background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.6);
    border-radius: 6px; padding: 3px 10px; font-size: 13px;
}
.app-nav {
    max-width: 960px; margin: 0 auto; padding: 0 8px;
    display: flex; overflow-x: auto;
}
.app-nav a {
    color: #fff; text-decoration: none; padding: 8px 12px; white-space: nowrap;
    border-bottom: 3px solid transparent; font-size: 14px;
}
.app-nav a.active { border-bottom-color: #fff; font-weight: bold; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; }

/* ---- 共通パーツ ---- */
.panel {
    background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 14px; margin-bottom: 14px;
}
.panel.narrow { max-width: 420px; margin: 24px auto; }
.panel.warn { background: var(--warn-bg); border-color: #f3d9a8; }
details.panel summary { cursor: pointer; font-weight: bold; }
details.panel[open] summary { margin-bottom: 12px; }

.page-head, .section-head {
    display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px;
}
.section-head h2 { margin: 0; }
.back { margin: 0 0 10px; font-size: 14px; }

.flash { padding: 10px 12px; border-radius: 8px; margin: 0 0 12px; }
.flash-success { background: var(--success-bg); color: var(--success-text); }
.flash-error { background: var(--error-bg); color: var(--error-text); }
.flash-warn { background: var(--warn-bg); color: var(--warn-text); }

.btn-primary {
    display: inline-block; background: var(--main); color: #fff; border: 0; border-radius: 8px;
    padding: 12px 16px; font-size: 16px; font-weight: bold; text-decoration: none; text-align: center;
}
.btn-primary:active { background: var(--main-dark); }
.btn-primary.small { padding: 8px 12px; font-size: 14px; }
button.btn-primary.small { background: var(--main); color: #fff; border: 0; border-radius: 8px; }
button.btn-primary.small:active { background: var(--main-dark); }
button.small { padding: 4px 10px; font-size: 13px; border-radius: 6px; border: 1px solid var(--line); background: #fff; }

.empty { background: #fff; padding: 24px; text-align: center; border-radius: 10px; color: var(--muted); }

/* ---- フォーム ---- */
.form { display: flex; flex-direction: column; gap: 12px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.form input[type="text"], .form input[type="tel"], .form input[type="email"], .form input[type="password"],
.form input[type="datetime-local"], .form select, .form textarea,
.toolbar input, .toolbar select, .filters select, .filters input[type="text"] {
    font-size: 16px;               /* iPhoneで入力時に拡大されない大きさ */
    padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--text);
    width: 100%; font-family: inherit;
}
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.hint { color: var(--main-dark); font-size: 13px; }

/* ---- ステージの色 ---- */
.badge {
    display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
    background: #eef0f2; color: #555; white-space: nowrap;
}
.stage-inquiry    { background: #fdecec; color: #b42318; }
.stage-proposing  { background: #fff4e0; color: #9a5b00; }
.stage-viewing    { background: #eaf2ff; color: #1d4ed8; }
.stage-visited    { background: #efeaff; color: #6d28d9; }
.stage-applied    { background: #e6f4f5; color: #127580; }
.stage-contracted { background: #e8f6ee; color: #1e7a46; }
.stage-lost       { background: #eef0f2; color: #666; }

/* ---- 顧客一覧 ---- */
.toolbar { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 10px; }
.toolbar button { padding: 9px; border-radius: 6px; border: 1px solid var(--line); background: #fff; font-size: 15px; }

.stage-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 10px; }
.stage-tabs a {
    white-space: nowrap; text-decoration: none; color: var(--text); background: #fff;
    border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 14px;
}
.stage-tabs a span { color: var(--muted); font-size: 12px; }
.stage-tabs a.active { background: var(--main); border-color: var(--main); color: #fff; }
.stage-tabs a.active span { color: #fff; }

.customer-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.customer-row {
    display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px;
    padding: 10px 14px; text-decoration: none; color: var(--text);
}
.row-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-sub, .row-meta { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---- 顧客詳細 ---- */
.customer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.info-list { list-style: none; margin: 0; padding: 0; }
.info-list li { display: flex; flex-wrap: wrap; gap: 4px 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); font-size: 14px; overflow-wrap: anywhere; }
.info-list li span:first-child { width: 88px; flex-shrink: 0; color: var(--muted); }
.memo { background: var(--bg); border-radius: 8px; padding: 8px 10px; font-size: 14px; margin: 10px 0 0; }

.stage-choices { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-choice {
    flex-direction: row !important; align-items: center; gap: 4px !important;
    border-radius: 999px; padding: 6px 12px; font-size: 14px !important; cursor: pointer;
    border: 2px solid transparent;
}
.stage-choice input { display: none; }
.stage-choice:has(input:checked) { border-color: currentColor; font-weight: bold; }
.only-lost, .only-contracted { display: none !important; }
.stage-form:has(input[value="lost"]:checked) .only-lost { display: flex !important; }
.stage-form:has(input[value="contracted"]:checked) .only-contracted { display: flex !important; }

.type-choices { display: flex; flex-wrap: wrap; gap: 12px; }
.type-choices label { flex-direction: row; align-items: center; gap: 4px; color: var(--text); font-size: 15px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.tl-head { display: flex; align-items: center; gap: 8px; }
.tl-body { font-size: 14px; margin-top: 2px; }
.tl-stage .tl-body, .tl-created .tl-body, .tl-edit .tl-body { color: var(--muted); }

.dup-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 8px; }
.dup-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dup-list form { margin: 0; }

/* ---- 問い合わせ物件 ---- */
.hint-muted { color: var(--muted); font-size: 12px; }
.site-365life { background: var(--main-light); color: var(--main-dark); }
.parsed-list { list-style: none; margin: 0; padding: 10px; background: var(--bg); border-radius: 8px; display: grid; gap: 6px; font-size: 14px; word-break: break-all; }
.iprop { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
.iprop.needs { border-color: #f3d9a8; background: #fffaf0; }
.iprop-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; word-break: break-all; }
.iprop .note { margin-top: 4px; }
.iprop-edit { margin-top: 6px; }
.iprop-edit summary { cursor: pointer; font-size: 13px; color: var(--main-dark); }
.iprop-edit .form { margin-top: 8px; }
.delete-form { margin: 8px 0 0; text-align: right; }
.link-danger { background: none; border: 0; color: var(--error-text); font-size: 13px; text-decoration: underline; padding: 0; }

/* ---- 分析 ---- */
.toolbar.period label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.stat-label { display: block; font-size: 12px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: bold; }
.stat-value small { font-size: 13px; margin-left: 2px; font-weight: normal; color: var(--muted); }
.analysis-grid { display: grid; grid-template-columns: 1fr; gap: 0 14px; }
.tally { width: 100%; border-collapse: collapse; font-size: 14px; }
.tally th { text-align: left; font-weight: normal; padding: 5px 8px 5px 0; white-space: nowrap; width: 1%; }
.tally td { padding: 5px 0; }
.tally .bar-cell { width: 100%; padding-right: 10px; }
.tally .bar { display: block; height: 10px; min-width: 2px; background: var(--main); border-radius: 0 4px 4px 0; }
.tally tr.unknown .bar { background: #c9cfd3; }
.tally tr.unknown th { color: var(--muted); }
.tally tr:hover { background: var(--bg); }
.tally .num { text-align: right; white-space: nowrap; padding-left: 8px; font-variant-numeric: tabular-nums; }

/* ---- KPI ---- */
.sub-tabs { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.sub-tabs a { padding: 6px 14px; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; font-size: 14px; }
.sub-tabs a.active { color: var(--main-dark); border-bottom-color: var(--main); font-weight: bold; }
.stat-sub { display: block; font-size: 12px; color: var(--muted); }
.toolbar.period select { width: auto; }
.table-scroll { overflow-x: auto; margin: 0 -14px; padding: 0 14px; }
.kpi-table { width: 100%; border-collapse: collapse; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.kpi-table th, .kpi-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: right; }
.kpi-table thead th { font-size: 12px; color: var(--muted); font-weight: normal; border-bottom: 2px solid var(--line); }
.kpi-table tbody th, .kpi-table tfoot th { text-align: left; font-weight: normal; }
.kpi-table .rate { font-weight: bold; }
.kpi-table .sub { color: var(--muted); font-size: 12px; font-weight: normal; }
.kpi-table tfoot th, .kpi-table tfoot td { border-top: 2px solid var(--line); border-bottom: 0; font-weight: bold; }
.kpi-table tbody tr:hover { background: var(--bg); }
.kpi-table .note { margin: 0; }

/* ---- 物件一覧 ---- */
.filters {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
}
.filters label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 4px; }
.filters label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
.filters label.check input { width: 20px; height: 20px; }
.filter-actions { grid-column: 1 / -1; display: flex; align-items: center; gap: 16px; }
.filter-actions button {
    flex: 1; background: var(--main); color: #fff; border: 0; border-radius: 8px;
    padding: 12px; font-size: 16px; font-weight: bold;
}
.filter-actions button:active { background: var(--main-dark); }
.filter-actions a { color: var(--muted); font-size: 14px; }

.summary { margin: 16px 0 8px; }

.property-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.property-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.card-head .name { font-weight: bold; color: var(--main-dark); text-decoration: none; }
.card-head .rent { font-weight: bold; white-space: nowrap; font-size: 17px; }
.card-sub { color: var(--muted); font-size: 13px; text-align: right; }
.specs { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.specs .muted { color: var(--muted); }
.note {
    display: inline-block; margin: 8px 6px 0 0; padding: 2px 8px; border-radius: 4px;
    background: var(--warn-bg); color: var(--warn-text); font-size: 13px;
}
.pager { display: flex; justify-content: center; gap: 20px; margin: 20px 0; }

/* ---- 画面が広いとき（PC） ---- */
@media (min-width: 720px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
    .toolbar { grid-template-columns: 180px 1fr 90px; }
    .toolbar.period { grid-template-columns: auto auto auto 90px; justify-content: start; }
    .stat-row { grid-template-columns: repeat(4, 1fr); }
    .analysis-grid { grid-template-columns: 1fr 1fr; }
    .filters { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .property-list { grid-template-columns: 1fr 1fr; }
}

/* ---- メール取り込み ---- */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0 0 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.button-row form { margin: 0; }
.btn-secondary {
    background: #fff; color: var(--main-dark); border: 1px solid var(--main); border-radius: 8px;
    padding: 8px 12px; font-size: 14px; font-weight: bold;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table thead th { font-size: 12px; color: var(--muted); font-weight: normal; border-bottom: 2px solid var(--line); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table .wrap { white-space: normal; min-width: 180px; }
.data-table input[type="checkbox"] { width: 18px; height: 18px; }
.error-text { color: var(--error-text); }
.plain-list { margin: 0; padding-left: 1.2em; }
.plain-list li { margin-bottom: 4px; }
.inline-form { margin: 0; }

.badge.mail-in  { background: #eaf2ff; color: #1d4ed8; }
.badge.mail-out { background: #e6f4f5; color: #127580; }
.tl-subject { font-weight: bold; font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.tl-mail .tl-body { overflow-wrap: anywhere; }
.mail-body summary { cursor: pointer; list-style: none; font-size: 14px; color: var(--text); }
.mail-body summary::-webkit-details-marker { display: none; }
.mail-body .mail-preview { color: var(--muted); overflow-wrap: anywhere; }
.mail-body .mail-more { color: var(--main-dark); margin-left: 6px; font-size: 13px; white-space: nowrap; }
.mail-body[open] .mail-preview { display: none; }
.mail-body .mail-close { display: none; color: var(--main-dark); font-size: 13px; }
.mail-body[open] .mail-more { display: none; }
.mail-body[open] .mail-close { display: inline; }
.note.unassigned { margin: 0; }

/* ---- 一覧から担当を割り当てる ---- */
.row-assign {
    display: flex; align-items: center; gap: 6px; margin: 0;
    padding: 6px 14px 10px; border-top: 1px dashed var(--line); background: #fff;
    border-radius: 0 0 10px 10px;
}
.row-assign select {
    font-size: 14px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.customer-list li { background: #fff; border-radius: 10px; }
.inline-select { display: flex; flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.inline-select select { font-size: 15px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.code-line { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; font-size: 13px; overflow-wrap: anywhere; }
.code-line code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; }

/* メール作成画面 */
.radio-row { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 12px; }
.radio-row label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 15px; }
.signature-preview { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px;
    font-size: 13px; white-space: pre-wrap; margin: 0 0 12px; }
.ai-summary { background: #fffdf3; border: 1px solid #f0e2b0; border-radius: 8px; padding: 12px 14px;
    white-space: pre-wrap; font-size: 14px; margin: 0 0 12px; }

/* LINE連携 */
.line-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin-bottom: 10px; background: #fff; }
.line-card p { margin: 6px 0 10px; }
.line-card .inline-select { flex-wrap: wrap; }
.line-code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 18px; letter-spacing: 2px;
    background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; }

/* 予定（来店・内見） */
.form-details { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; background: #fff; margin-top: 12px; }
.form-details > summary { cursor: pointer; font-weight: 600; color: var(--main-dark); }
.form-details[open] > summary { margin-bottom: 10px; }
.field-row { display: flex; flex-wrap: wrap; gap: 10px 16px; }
.field-row > label { flex: 1 1 160px; }
tr.muted td { color: var(--muted); }

/* 貼り付けの見本（LINEの呼び名の一括取り込み） */
.code-sample { background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
    padding: 10px 12px; overflow-x: auto; white-space: pre; margin: 0 0 12px; }
label.block { display: block; margin: 0 0 12px; }
label.block textarea { display: block; margin-top: 4px; }
