/* ── リセット & 基本 ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #2563eb;
  --primary-h:  #1d4ed8;
  --danger:     #dc2626;
  --danger-h:   #b91c1c;
  --success:    #16a34a;
  --warning:    #d97706;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-300:   #d1d5db;
  --gray-400:   #9ca3af;
  --gray-500:   #6b7280;
  --gray-600:   #4b5563;
  --gray-700:   #374151;
  --gray-800:   #1f2937;
  --gray-900:   #111827;
  --shadow-sm:  0 1px 2px rgba(0,0,0,.05);
  --shadow:     0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --radius:     8px;
  --radius-lg:  12px;
  --font:       'Hiragino Kaku Gothic ProN', 'Hiragino Sans', Meiryo, sans-serif;
}

body { font-family: var(--font); background: var(--gray-100); color: var(--gray-800); line-height: 1.5; }

/* ── 認証画面 ─────────────────────────────────────────────────── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center;
             background: linear-gradient(135deg, #1e40af 0%, #3b82f6 50%, #60a5fa 100%); }

.auth-container { width: 100%; max-width: 420px; padding: 16px; }

.auth-card { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: 40px 36px; }

.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo .logo-icon { font-size: 42px; display: block; margin-bottom: 8px; }
.auth-logo h1 { font-size: 20px; font-weight: 700; color: var(--gray-800); }

.auth-tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 24px; }
.tab-btn { flex: 1; padding: 10px; background: none; border: none; font-size: 14px; font-weight: 600;
           color: var(--gray-500); cursor: pointer; transition: color .2s; }
.tab-btn.active { color: var(--primary); border-bottom: 2px solid var(--primary); margin-bottom: -2px; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--gray-700); }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px; border: 1.5px solid var(--gray-300); border-radius: var(--radius);
  font-size: 14px; font-family: var(--font); transition: border-color .2s, box-shadow .2s;
  background: #fff; color: var(--gray-800);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
.form-group textarea { resize: vertical; min-height: 72px; }

.error-msg { background: #fef2f2; border: 1px solid #fecaca; color: var(--danger);
             font-size: 13px; padding: 10px 12px; border-radius: var(--radius); }
.success-msg { background: #f0fdf4; border: 1px solid #86efac; color: #15803d;
               font-size: 13px; padding: 10px 12px; border-radius: var(--radius); }
.remember-row { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 8px; }
.remember-label { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--gray-600); cursor: pointer; }
.remember-label input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--primary); }
.forgot-link { font-size: 12px; color: var(--primary); text-decoration: none; }
.forgot-link:hover { text-decoration: underline; }

/* ── ボタン ──────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px;
       padding: 9px 16px; border: none; border-radius: var(--radius); font-size: 13px;
       font-weight: 600; cursor: pointer; transition: background .15s, opacity .15s; font-family: var(--font); }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover  { background: var(--primary-h); }
.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover   { background: var(--danger-h); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1.5px solid var(--gray-300); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover  { opacity: .88; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── ダッシュボード ───────────────────────────────────────────── */
.app-layout { display: flex; flex-direction: column; min-height: 100vh; }

/* ヘッダー */
.app-header { background: var(--primary); color: #fff; padding: 0 24px;
              display: flex; align-items: center; justify-content: space-between; height: 56px;
              box-shadow: var(--shadow-md); position: sticky; top: 0; z-index: 100; }
.app-header h1 { font-size: 17px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; gap: 14px; }
.user-info { font-size: 13px; opacity: .9; }
.logout-btn { background: rgba(255,255,255,.2); color: #fff; border: 1px solid rgba(255,255,255,.35);
              padding: 5px 12px; font-size: 12px; }
.logout-btn:hover { background: rgba(255,255,255,.3); }

/* メインエリア */
.app-main { padding: 24px; max-width: 1600px; margin: 0 auto; width: 100%; }

/* サマリーカード */
.summary-cards { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 16px; }
.summary-card { background: #fff; border-radius: var(--radius); padding: 18px 20px;
                box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.summary-card.ok    { border-color: var(--success); }
.summary-card.ng    { border-color: var(--danger); }
.summary-card.dup   { border-color: var(--warning); }
.summary-card.new   { border-color: #8b5cf6; }
.summary-card.today { border-color: #0891b2; }
.summary-card.appo  { border-color: #d97706; }
.summary-card-label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase;
                      letter-spacing: .5px; display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.summary-card-value { font-size: 24px; font-weight: 700; color: var(--gray-800); margin-top: 4px; }
.summary-me { background: #e0f2fe; color: #0369a1; font-size: 10px; font-weight: 700;
              padding: 1px 6px; border-radius: 99px; text-transform: none; letter-spacing: 0; }

/* ツールバー */
.toolbar { background: #fff; border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
           box-shadow: var(--shadow); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar-search { flex: 2; min-width: 280px; position: relative; }
.toolbar-search input { width: 100%; padding-left: 34px; font-size: 15px; padding-top: 11px; padding-bottom: 11px; }
.toolbar-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
                                color: var(--gray-400); font-size: 14px; pointer-events: none; }
.toolbar-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar-filters select { padding: 8px 10px; font-size: 13px; border: 1.5px solid var(--gray-300);
                           border-radius: var(--radius); background: #fff; color: var(--gray-700);
                           font-family: var(--font); cursor: pointer; }
.toolbar-actions { display: flex; gap: 8px; margin-left: auto; }

/* テーブル */
.table-wrap { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.table-header { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between;
                border-bottom: 1px solid var(--gray-200); }
.table-header-title { font-size: 14px; font-weight: 700; color: var(--gray-700); }
.table-header-right { display: flex; align-items: center; gap: 12px; }
.record-count { font-size: 12px; color: var(--gray-500); }
.page-size-select { font-size: 12px; padding: 4px 8px; border: 1px solid var(--gray-300);
                    border-radius: var(--radius); color: var(--gray-700); background: #fff; cursor: pointer; }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1000px; }
thead th { background: var(--gray-50); padding: 11px 14px; text-align: left; font-size: 12px;
            font-weight: 700; color: var(--gray-600); border-bottom: 2px solid var(--gray-200);
            white-space: nowrap; cursor: pointer; user-select: none; }
thead th:hover { background: var(--gray-100); }
thead th .sort-arrow { margin-left: 4px; color: var(--gray-400); }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .1s; }
tbody tr:hover { background: #eff6ff; }
tbody td { padding: 11px 14px; vertical-align: middle; }

/* 重複行グレーアウト */
tbody tr.row-duplicate { background: #d1d5db; }
tbody tr.row-duplicate td { color: var(--gray-500); }
tbody tr.row-duplicate:hover { background: #c3c8d1; }
td.actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }

/* バッジ */
.badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 99px;
         font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-ok      { background: #dcfce7; color: #15803d; }
.badge-ng      { background: #fee2e2; color: #b91c1c; }
.badge-existing { background: #ede9fe; color: #6d28d9; }
.badge-new     { background: #dbeafe; color: #1d4ed8; }
.badge-follow  { background: #fef3c7; color: #b45309; }
.badge-dup     { background: #fee2e2; color: #b91c1c; }
.badge-nodup   { background: var(--gray-100); color: var(--gray-500); }

/* 事業内容タグ */
.biz-tag { display: inline-block; background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0;
           font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 99px;
           margin: 1px 2px 1px 0; white-space: nowrap; }

/* 時間帯別架電チャート */
.hourly-wrap { background: #fff; border-radius: var(--radius); padding: 14px 18px 12px;
               margin-bottom: 16px; box-shadow: var(--shadow); }
.hourly-title { font-size: 12px; font-weight: 700; color: var(--gray-600); margin-bottom: 12px; }
.hourly-blocks { display: flex; gap: 20px; }
.hourly-block  { flex: 1; }
.hourly-block-label { font-size: 11px; font-weight: 700; color: var(--gray-500);
                      margin-bottom: 6px; letter-spacing: .3px; }
.hourly-grid { display: grid; grid-template-columns: 54px repeat(6, 1fr); gap: 2px; }
.hg-cell { padding: 5px 4px; text-align: center; font-size: 12px; border-radius: 4px; }
.hg-header { font-weight: 700; color: var(--gray-600); font-size: 11px; background: var(--gray-50); }
.hg-row-label { text-align: left; font-size: 11px; font-weight: 700; padding-left: 2px;
                display: flex; align-items: center; }
.hg-call { background: #eff6ff; color: #1d4ed8; font-weight: 700; }
.hg-gate { background: #f0fdf4; color: #15803d; font-weight: 700; }
.hg-appo { background: #fef9c3; color: #854d0e; font-weight: 700; }
.hg-row-label.hg-call { background: none; color: #1d4ed8; }
.hg-row-label.hg-gate { background: none; color: #15803d; }
.hg-row-label.hg-appo { background: none; color: #854d0e; }

/* インライン架電可否セレクト */
.inline-select { border: none; border-radius: 99px; font-size: 11px; font-weight: 700;
                 padding: 3px 8px; cursor: pointer; font-family: var(--font); outline: none;
                 appearance: none; -webkit-appearance: none; text-align: center; }
.inline-ok  { background: #dcfce7; color: #15803d; }
.inline-ng  { background: #fee2e2; color: #b91c1c; }
.inline-ok:hover { background: #bbf7d0; }
.inline-ng:hover { background: #fecaca; }

/* 顧客ステータスインライン */
.inline-cust-new      { background: #dbeafe; color: #1d4ed8; }
.inline-cust-existing { background: #ede9fe; color: #6d28d9; }
.inline-cust-follow   { background: #fef3c7; color: #b45309; }
.inline-cust-new:hover      { background: #bfdbfe; }
.inline-cust-existing:hover { background: #ddd6fe; }
.inline-cust-follow:hover   { background: #fde68a; }

/* 架電結果インライン */
.inline-result-none { background: var(--gray-100); color: var(--gray-400); }
.inline-result-appo { background: #fef9c3; color: #854d0e; }
.inline-result-ng   { background: #fee2e2; color: #b91c1c; }
.inline-result-miss { background: #f3f4f6; color: var(--gray-500); }
.inline-result-inq  { background: #ede9fe; color: #6d28d9; }
.inline-result-mail { background: #dbeafe; color: #1d4ed8; }
.inline-result-gate { background: #d1fae5; color: #065f46; }
.inline-result-none:hover { background: #e5e7eb; }
.inline-result-appo:hover { background: #fde047; }
.inline-result-ng:hover   { background: #fecaca; }
.inline-result-miss:hover { background: #e5e7eb; }
.inline-result-inq:hover  { background: #ddd6fe; }
.inline-result-mail:hover { background: #bfdbfe; }
.inline-result-gate:hover { background: #a7f3d0; }

/* 架電結果バッジ */
.badge-result-none { background: var(--gray-100); color: var(--gray-400); }
.badge-result-appo { background: #fef9c3; color: #854d0e; border: 1px solid #fde047; }
.badge-result-ng   { background: #fee2e2; color: #b91c1c; }
.badge-result-miss { background: #f3f4f6; color: var(--gray-500); }
.badge-result-inq  { background: #ede9fe; color: #6d28d9; }
.badge-result-mail { background: #dbeafe; color: #1d4ed8; }
.badge-result-gate { background: #d1fae5; color: #065f46; }

/* 窓口突破チェックボックス */
/* チェックボックス列 */
th.check-col, td.check-col { width: 36px; text-align: center; padding: 0 4px; }
th.check-col input, td.check-col input { width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary); }

th.gate-col, td.gate-col { width: 64px; text-align: center; }
.gate-check-label { display: flex; align-items: center; justify-content: center; cursor: pointer; }
.gate-checkbox {
  width: 18px; height: 18px; cursor: pointer; accent-color: #059669;
  border-radius: 4px;
}
/* フォーム内 窓口突破チェック */
.gate-form-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; padding-top: 4px; }
.gate-form-check { width: 18px; height: 18px; cursor: pointer; accent-color: #059669; }

/* ページネーション */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 16px; }
.page-btn { width: 34px; height: 34px; border: 1.5px solid var(--gray-300); background: #fff;
            border-radius: var(--radius); font-size: 13px; cursor: pointer; display: flex;
            align-items: center; justify-content: center; transition: all .15s; }
.page-btn:hover { background: var(--gray-100); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* モーダル */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
                 display: flex; align-items: center; justify-content: center; padding: 16px;
                 animation: fadeIn .15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal { background: #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
         width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column;
         animation: slideUp .2s; }
.modal-lg { max-width: 720px; }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.modal-header { padding: 20px 24px 16px; border-bottom: 1px solid var(--gray-200);
                display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.modal-title { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.modal-close { background: none; border: none; font-size: 20px; color: var(--gray-400);
               cursor: pointer; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--gray-100); color: var(--gray-600); }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-200); display: flex;
                justify-content: flex-end; gap: 10px; flex-shrink: 0; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .form-group.full { grid-column: 1 / -1; }

/* Sheetsインポートモーダル */
.import-steps { display: flex; flex-direction: column; gap: 20px; }
.import-step { border: 1.5px solid var(--gray-200); border-radius: var(--radius); padding: 16px; }
.import-step-title { font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 12px;
                     display: flex; align-items: center; gap: 6px; }
.step-num { background: var(--primary); color: #fff; width: 20px; height: 20px; border-radius: 50%;
            display: inline-flex; align-items: center; justify-content: center; font-size: 11px; }
.import-note { font-size: 12px; color: var(--gray-500); margin-top: 8px; line-height: 1.6; }
.import-result { margin-top: 14px; padding: 12px 14px; border-radius: var(--radius);
                 font-size: 13px; font-weight: 600; }
.import-result.success { background: #dcfce7; color: #15803d; }
.import-result.error   { background: #fee2e2; color: #b91c1c; }

/* インポートタブ */
.import-tabs { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 2px; }
.import-tab-btn { flex: 1; padding: 10px 8px; background: none; border: none; font-size: 13px;
                  font-weight: 600; color: var(--gray-500); cursor: pointer; font-family: var(--font);
                  transition: color .2s; }
.import-tab-btn.active { color: var(--primary); border-bottom: 2px solid var(--primary); margin-bottom: -2px; }
.import-tab-btn:hover { color: var(--gray-700); }

/* CSVドロップゾーン */
.csv-drop-zone { border: 2px dashed var(--gray-300); border-radius: var(--radius); padding: 32px 20px;
                 text-align: center; cursor: pointer; transition: all .2s; margin-top: 8px; }
.csv-drop-zone:hover, .csv-drop-zone.dragover { border-color: var(--primary); background: #eff6ff; }
.csv-drop-icon { font-size: 36px; margin-bottom: 8px; }
.csv-drop-text { font-size: 14px; font-weight: 600; color: var(--gray-600); }
.csv-drop-sub  { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* スプレッドシート管理 */
.sheet-item { display: flex; align-items: center; justify-content: space-between; gap: 12px;
              padding: 10px 12px; background: var(--gray-50); border-radius: var(--radius);
              border: 1px solid var(--gray-200); margin-bottom: 6px; }
.sheet-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.sheet-item-name { font-size: 13px; font-weight: 700; color: var(--gray-700); }
.sheet-item-url  { font-size: 11px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* コピーボタン付き入力 */
.input-with-badge { display: flex; align-items: center; gap: 8px; }
.input-with-badge input { flex: 1; }

/* 空状態 */
.empty-state { padding: 60px 20px; text-align: center; color: var(--gray-400); }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-text { font-size: 15px; font-weight: 600; color: var(--gray-500); margin-bottom: 6px; }
.empty-sub  { font-size: 13px; }

/* トースト通知 */
#toast-container { position: fixed; top: 70px; right: 20px; z-index: 9999;
                   display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 18px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
         box-shadow: var(--shadow-md); animation: slideIn .2s; min-width: 220px; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }
.toast-success { background: #15803d; color: #fff; }
.toast-error   { background: #b91c1c; color: #fff; }
.toast-info    { background: var(--gray-800); color: #fff; }

/* ローディング */
.loading { display: flex; align-items: center; justify-content: center; padding: 60px;
           color: var(--gray-400); font-size: 14px; gap: 10px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--gray-200);
           border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* レスポンシブ */
@media (max-width: 640px) {
  .app-main { padding: 14px; }
  .toolbar  { flex-direction: column; align-items: stretch; }
  .toolbar-actions { margin-left: 0; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .form-group.full { grid-column: auto; }
  .summary-cards { grid-template-columns: repeat(3, 1fr); }
  .summary-card-value { font-size: 20px; }
  .summary-card { padding: 12px 14px; }
}
