/* TenantHub（マルチテナント管理） — Flow Pilot本体・OBとは別のログイン/アカウント体系。
   デザインはFlow Pilot本体の「搭乗券」ログイン画面(login.css)を踏襲し、
   アクセント色をデジタライズAIの青系に差し替えている。 */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: #f3f5f8;
  color: #1f2937;
  font-family: "Noto Sans JP", -apple-system, "Segoe UI", sans-serif;
  min-height: 100vh;
}
.hidden { display: none !important; }

/* ================= ログイン画面 ================= */
#loginScreen, #setPasswordScreen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: #eef0f4; padding: 24px 16px;
}
.login-card { width: 380px; max-width: 100%; background: #fff; border-radius: 20px; box-shadow: 0 8px 40px rgba(0,0,0,.1); overflow: hidden; }
.login-card .pass-top { padding: 26px 32px 20px; }
.login-card .lg-head-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; }
.login-card .lg-logo { display: flex; align-items: center; gap: 8px; }
.login-card .lg-logo svg { width: 26px; height: 26px; flex-shrink: 0; }
.login-card .lg-wordmark { font-family: "Oswald", sans-serif; font-size: 20px; font-weight: 700; letter-spacing: .5px; line-height: 1; }
.login-card .lg-wordmark .t1 { color: #1a1f36; }
.login-card .lg-wordmark .t2 { color: #2f6fed; }
.login-card .lg-meta { text-align: right; }
.login-card .lg-meta .bp-label { font-family: "JetBrains Mono", monospace; font-size: 9px; letter-spacing: 2px; color: #aaa; }
.login-card .lg-meta .bp-value { font-family: "JetBrains Mono", monospace; font-size: 11px; color: #888; margin-top: 3px; }

.login-card .lg-route { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.login-card .lg-route-end { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 4.6rem; }
.login-card .lg-route-place { font-size: 9.5px; color: #aaa; letter-spacing: .04em; }
.login-card .lg-iata { font-family: "JetBrains Mono", monospace; font-size: 22px; font-weight: 500; color: #1a1f36; letter-spacing: 1px; }
.login-card .lg-route-mid { flex: 1; display: flex; align-items: center; gap: 6px; }
.login-card .lg-route-dash { flex: 1; height: .5px; background: #ddd; }
.login-card .lg-plane { width: 16px; height: 16px; fill: #2f6fed; transform: rotate(90deg); flex-shrink: 0; }

.login-card .lg-subtitle { margin: 0 0 4px; font-size: 12px; color: #aaa; letter-spacing: .03em; line-height: 1.5; text-align: center; }

.login-card .lg-tear { display: flex; align-items: center; margin: 0 -1px; }
.login-card .lg-tear-dot { width: 18px; height: 18px; border-radius: 50%; background: #eef0f4; flex-shrink: 0; }
.login-card .lg-tear-line { flex: 1; border: none; border-top: 1.5px dashed #ddd; }

.login-card .pass-bottom { padding: 22px 32px 28px; }
.login-card .lg-field { margin-bottom: 15px; }
.login-card .lg-field label { display: block; font-size: 12px; color: #666; margin-bottom: 6px; }
.login-card input {
  width: 100%; padding: 10px 14px; border: 1px solid #e8e8e8; border-radius: 10px; font-size: 14px;
  color: #1a1f36; background: #f7f8fa; font-family: "Noto Sans JP", sans-serif; outline: none;
}
.login-card input::placeholder { color: #bbb; }
.login-card input:focus { border-color: #2f6fed; background: #fff; }
.login-card .lg-submit {
  width: 100%; padding: 13px; background: #1a1f36; color: #fff; border: none; border-radius: 12px;
  font-size: 14px; font-weight: 500; letter-spacing: .03em; cursor: pointer; margin-top: 2px; font-family: "Noto Sans JP", sans-serif;
}
.login-card .lg-submit:hover { opacity: .87; }
.login-card .lg-google {
  width: 100%; padding: 11px; margin-top: 10px; background: #eef2ff; color: #2743a8; border: 1px solid #c7d2fe;
  border-radius: 12px; font-size: 13px; font-weight: 500; cursor: pointer; font-family: "Noto Sans JP", sans-serif;
  display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.login-card .lg-google:hover { opacity: .9; }
.login-card .lg-google svg { width: 15px; height: 15px; }

.login-card .lg-error {
  margin: 0 0 14px; padding: 10px 12px; border-radius: 10px; background: #fef2f2; color: #b91c1c;
  font-size: 12px; border: 1px solid #fecaca;
}
.login-card .lg-keep { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: #94a3b8; margin: 2px 0 14px; cursor: pointer; }
.login-card .lg-keep input { width: auto; }

/* ================= アプリ本体 ================= */
#appScreen { min-height: 100vh; }
.th-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 30px; background: #ffffff; border-bottom: 1px solid #eceff3;
}
.th-topbar .id { display: flex; align-items: center; gap: 10px; }
.th-topbar .mark { width: 30px; height: 30px; flex-shrink: 0; }
.th-topbar .mark svg { width: 100%; height: 100%; display: block; }
.th-topbar h1 { margin: 0; font-size: 16px; font-weight: 700; color: #111827; }
.th-topbar .cap { margin: 1px 0 0; font-size: 11px; color: #9ca3af; letter-spacing: .04em; }
.th-topbar .topbar-right { display: flex; align-items: center; gap: 10px; }
.th-topbar .operator {
  font-size: 12px; color: #6b7280; background: #f5f7fb; padding: 6px 12px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.th-topbar .operator .dot { width: 6px; height: 6px; border-radius: 50%; background: #22c55e; }
.th-topbar .logout-btn {
  border: 1px solid #dde1e8; background: #fff; color: #6b7280; border-radius: 999px; padding: 6px 14px;
  font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.th-topbar .logout-btn:hover { background: #f5f7fb; color: #374151; }

.th-body { display: grid; grid-template-columns: 200px 1fr; min-height: calc(100vh - 63px); }
.th-menu { padding: 22px 12px; border-right: 1px solid #eceff3; }
.th-menu .m-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: #4b5563; cursor: pointer; margin-bottom: 2px; border: none; background: none;
  width: 100%; text-align: left; font-family: inherit;
}
.th-menu .m-item:hover { background: #f5f7fb; }
.th-menu .m-item.active { background: linear-gradient(135deg,#4f86ff,#1f4fcf); color: #fff; }
.th-menu .m-item .ic { width: 16px; height: 16px; display: inline-flex; flex-shrink: 0; }
.th-menu .m-item .ic svg { width: 16px; height: 16px; }

.th-main { padding: 26px 30px; }
.th-page-head h2 { margin: 0; font-size: 19px; font-weight: 700; color: #111827; }
.th-page-head p.sub { margin: 4px 0 0; font-size: 12.5px; color: #6b7280; max-width: 60ch; }

.th-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 18px 0 14px; flex-wrap: wrap; }
.th-toolbar .count { font-size: 12.5px; color: #6b7280; }
.btn-primary { border: 0; background: #111827; color: #fff; border-radius: 999px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; white-space: nowrap; }
.btn-primary:hover { opacity: .9; }
.btn-ghost { border: 1px solid #dde1e8; background: #fff; color: #374151; border-radius: 999px; padding: 8px 15px; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit; }

.th-table-scroll { overflow-x: auto; border-radius: 12px; }
table.th-table { width: 100%; min-width: 640px; border-collapse: collapse; font-size: 12.5px; background: #fff; border: 1px solid #eceff3; border-radius: 12px; overflow: hidden; }
table.th-table thead th { text-align: left; font-size: 11px; font-weight: 700; color: #6b7280; letter-spacing: .04em; text-transform: uppercase; padding: 10px 14px; border-bottom: 1.5px solid #eceff3; white-space: nowrap; background: #f9fafb; }
table.th-table tbody td { padding: 13px 14px; border-bottom: 1px solid #eceff3; vertical-align: middle; color: #1f2937; }
table.th-table tbody tr:last-child td { border-bottom: none; }
table.th-table tbody tr:hover td { background: #f9fafb; }
/* td に display:flex を当てるとセルでなくなり列幅・境界線が行ごとにずれるため、セルのまま余白だけ付ける */
.row-actions { white-space: nowrap; }
.row-actions .chip-btn + .chip-btn { margin-left: 6px; }
.chip-btn { border: 0; background: #f5f7fb; color: #334155; border-radius: 999px; padding: 6px 12px; font-size: 11.5px; font-weight: 600; cursor: pointer; white-space: nowrap; font-family: inherit; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.chip-btn:hover { background: #edf2f8; }
.chip-btn.link { background: #eef2ff; color: #3b45c7; }
.chip-btn.link:hover { background: #e2e7fd; }
.chip-btn:disabled { background: #f3f4f6; color: #c2c7d0; cursor: not-allowed; }

.th-empty-note { font-size: 13px; color: #6b7280; background: #fff; border: 1px dashed #dde1e8; border-radius: 12px; padding: 20px; text-align: center; }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.grey { background: #eef0f2; color: #6b7280; }
.badge.amber { background: #fff3cd; color: #8a6100; }
.badge.green { background: #d4edda; color: #256029; }
.badge-clickable { cursor: pointer; border: none; font-family: inherit; }
.badge-clickable:hover { filter: brightness(0.95); }

select.tenant-select { padding: 8px 12px; border: 1px solid #dde1e8; border-radius: 10px; font-size: 13px; font-family: inherit; background: #fff; color: #111827; min-width: 240px; }

/* ---- モーダル共通 ---- */
.modal-overlay { position: fixed; inset: 0; background: rgba(15,18,26,.42); display: none; align-items: center; justify-content: center; z-index: 40; padding: 20px; }
.modal-overlay.open { display: flex; }
.modal-card { width: 400px; max-width: 100%; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(10,12,20,.3); overflow: hidden; }
.modal-card .m-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid #eceff3; }
.modal-card .m-head h3 { margin: 0; font-size: 15px; font-weight: 700; color: #111827; }
.modal-card .m-close { border: none; background: none; font-size: 18px; color: #9ca3af; cursor: pointer; line-height: 1; }
.modal-card .m-body { padding: 18px 20px; display: grid; gap: 12px; max-height: 70vh; overflow-y: auto; }
.modal-card label { display: block; font-size: 11.5px; color: #6b7280; margin-bottom: 5px; font-weight: 600; }
.modal-card input { width: 100%; padding: 9px 11px; border: 1px solid #dde1e8; border-radius: 9px; font-size: 13px; font-family: inherit; background: #f9fafb; }
.modal-card input:focus { outline: none; border-color: #111827; background: #fff; }
.modal-card textarea { width: 100%; padding: 9px 11px; border: 1px solid #dde1e8; border-radius: 9px; font-size: 13px; font-family: inherit; background: #f9fafb; resize: vertical; }
.modal-card textarea:focus { outline: none; border-color: #111827; background: #fff; }
.modal-card select { width: 100%; padding: 9px 11px; border: 1px solid #dde1e8; border-radius: 9px; font-size: 13px; font-family: inherit; background: #f9fafb; color: #111827; }
.modal-card select:focus { outline: none; border-color: #111827; background: #fff; }
.modal-card .m-foot { padding: 14px 20px; border-top: 1px solid #eceff3; display: flex; justify-content: flex-end; gap: 8px; }
.modal-card .m-error { font-size: 12px; color: #b91c1c; }

.note-history { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 160px; overflow-y: auto; }
.note-history-item { background: #f9fafb; border: 1px solid #eceff3; border-radius: 8px; padding: 7px 10px; }
.note-history-item .nh-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 10.5px; color: #9ca3af; margin-bottom: 2px; }
.note-history-item .nh-detail { font-size: 12px; color: #374151; word-break: break-word; }
.note-history-empty { margin: 0; font-size: 11.5px; color: #9ca3af; }

/* 月額請求モーダル（1行＝毎月1通の請求書） */
.recurring-table { width: 100%; min-width: 520px; border-collapse: collapse; }
.recurring-table th { text-align: left; font-size: 11px; font-weight: 600; color: #6b7280; padding: 4px 6px; }
.recurring-table td { padding: 4px 6px; vertical-align: middle; }
.modal-card .recurring-table input { padding: 7px 9px; font-size: 12.5px; }
.modal-card .recurring-table input.rr-on { width: 16px; height: 16px; display: block; margin: 0 auto; }
.recurring-table tr.is-off input:not(.rr-on) { color: #9ca3af; }

/* 売上ダッシュボード */
.kpi-row { display: flex; gap: 10px; flex-wrap: wrap; }
.kpi { background: #fff; border: 1px solid #eceff3; border-radius: 12px; padding: 10px 16px; min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.kpi .kpi-label { font-size: 11px; color: #6b7280; font-weight: 600; }
.kpi strong { font-size: 18px; color: #111827; font-family: "JetBrains Mono", monospace; }
table.dash-table td.num { text-align: right; font-family: "JetBrains Mono", monospace; white-space: nowrap; }
table.dash-table .muted { color: #c2c7d0; }
table.dash-table tr.dash-total td { background: #f9fafb; border-top: 1.5px solid #eceff3; font-weight: 700; }
.dash-bar { height: 10px; border-radius: 999px; background: linear-gradient(90deg, #4f86ff, #1f4fcf); min-width: 0; }

.pane { display: none; }
.pane.active { display: block; }

@media (max-width: 720px) {
  .th-body { grid-template-columns: 1fr; }
  .th-menu { display: flex; border-right: none; border-bottom: 1px solid #eceff3; gap: 4px; padding: 10px; }
}
