/* ============ DigiStep Ops — デジステップ統合運用システム ============ */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --sidebar: #0c1222;
  --sidebar-active: rgba(79, 110, 245, 0.16);
  --accent: #3556e0;
  --accent-hover: #2a45c2;
  --accent-soft: #e8edfd;
  --green: #0d9468;
  --green-soft: #e0f5ed;
  --red: #d23b3b;
  --red-soft: #fdeaea;
  --orange: #c47812;
  --orange-soft: #fcf1de;
  --purple: #6d4fc4;
  --purple-soft: #efeafb;
  --text: #1a2433;
  --text-sub: #667182;
  --border: #e4e7ee;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(13, 23, 48, .06), 0 3px 12px rgba(13, 23, 48, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* ---- ログイン画面 ---- */
.login-screen {
  position: fixed; inset: 0; z-index: 1000;
  background: linear-gradient(160deg, #0c1222 0%, #18233f 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 36px 32px;
  width: 100%; max-width: 400px; box-shadow: 0 24px 64px rgba(0,0,0,.4);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-card label { margin-top: 14px; }
.login-card input { margin-top: 2px; padding: 11px 12px; font-size: 15px; }
.login-btn { width: 100%; justify-content: center; margin-top: 22px; padding: 12px; font-size: 14.5px; }
.login-error { margin-top: 12px; color: var(--red); font-size: 12.5px; background: var(--red-soft); padding: 9px 12px; border-radius: 8px; }
.login-note { margin-top: 18px; font-size: 11.5px; color: var(--text-sub); line-height: 1.6; }

/* ---- ブランド ---- */
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, #4669f0, #2a3fb8);
  color: #fff; font-weight: 800; font-size: 17px;
  display: inline-flex; align-items: center; justify-content: center;
  letter-spacing: -.5px;
}
.brand-name { font-size: 15px; font-weight: 700; color: inherit; letter-spacing: .2px; }
.brand-sub { font-size: 10.5px; color: #5e6a82; margin-top: 1px; }
.login-card .brand-name { color: var(--text); }
.login-card .brand-sub { color: var(--text-sub); }

/* ---- レイアウト ---- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px; flex-shrink: 0;
  background: var(--sidebar); color: #aab3c5;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .brand {
  padding: 18px 16px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar .brand-name { color: #fff; }
.sidebar .brand-sub { color: #5e6a82; }
.sidebar nav { padding: 12px 10px; flex: 1; }
.sidebar .nav-group { font-size: 10px; font-weight: 700; color: #5e6a82; letter-spacing: 1.5px; padding: 14px 12px 6px; text-transform: uppercase; }
.sidebar .nav-group:first-child { padding-top: 4px; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin-bottom: 2px;
  color: #8b96ab; text-decoration: none; border-radius: 8px;
  font-size: 13px; font-weight: 500; transition: background .15s, color .15s;
}
.sidebar nav a svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #dde3ee; }
.sidebar nav a.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.sidebar nav a.active svg { opacity: 1; color: #7d97ff; }
.sidebar nav a .nav-badge {
  margin-left: auto; background: var(--red); color: #fff;
  border-radius: 10px; font-size: 10.5px; padding: 1px 7px; font-weight: 700;
}
.sidebar .footer { padding: 14px 16px; font-size: 11px; color: #5e6a82; border-top: 1px solid rgba(255,255,255,.07); }
.sidebar .footer .ai-status { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.on { background: #34d399; box-shadow: 0 0 6px rgba(52,211,153,.6); } .dot.off { background: #5e6a82; }
.logout-btn {
  width: 100%; background: rgba(255,255,255,.06); color: #aab3c5;
  border: none; border-radius: 7px; padding: 7px; font-size: 11.5px; cursor: pointer;
  font-family: inherit;
}
.logout-btn:hover { background: rgba(255,255,255,.12); color: #fff; }

.main { flex: 1; padding: 24px 30px 60px; max-width: 1480px; min-width: 0; }

.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.page-header .desc { color: var(--text-sub); font-size: 12.5px; margin-top: 4px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- 共通部品 ---- */
.card {
  background: var(--panel); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 18px 20px; margin-bottom: 16px;
}
.card h2 { font-size: 14px; font-weight: 700; margin-bottom: 13px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card h2 .count { color: var(--text-sub); font-weight: 500; font-size: 12px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; cursor: pointer;
  font-size: 12.5px; font-weight: 600; transition: all .15s;
  text-decoration: none; font-family: inherit; line-height: 1.4;
}
.btn:hover { border-color: #c3cad8; background: #f8f9fb; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.success { background: var(--green); border-color: var(--green); color: #fff; }
.btn.success:hover { filter: brightness(.93); }
.btn.danger { background: #fff; border-color: #ecc8c8; color: var(--red); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: 4px 10px; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.badge { display: inline-block; padding: 2.5px 9px; border-radius: 6px; font-size: 11px; font-weight: 700; white-space: nowrap; letter-spacing: .2px; }
.badge.gray { background: #eef1f5; color: #5d6878; }
.badge.blue { background: var(--accent-soft); color: var(--accent); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.orange { background: var(--orange-soft); color: var(--orange); }
.badge.purple { background: var(--purple-soft); color: var(--purple); }
.badge.yellow { background: #fef7e0; color: #b06000; }
.badge.teal { background: #e4f7f6; color: #007b83; }

input[type=text], input[type=url], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=password], textarea, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 13.5px; font-family: inherit; background: #fff;
  color: var(--text);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
label { font-size: 11.5px; font-weight: 600; color: var(--text-sub); display: block; margin-bottom: 5px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-row { margin-bottom: 12px; }

table.list { width: 100%; border-collapse: collapse; }
table.list th {
  text-align: left; font-size: 11px; color: var(--text-sub); font-weight: 600;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
  text-transform: uppercase; letter-spacing: .4px;
}
table.list td { padding: 10px; border-bottom: 1px solid #eef0f4; vertical-align: middle; font-size: 13px; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover { background: #f7f9fd; }
.empty { color: var(--text-sub); text-align: center; padding: 28px 0; font-size: 13px; }

/* ---- KPIカード ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 15px 17px;
}
.kpi .label { font-size: 11.5px; color: var(--text-sub); font-weight: 600; }
.kpi .value { font-size: 25px; font-weight: 800; margin-top: 5px; letter-spacing: -.5px; }
.kpi .value small { font-size: 12px; font-weight: 600; color: var(--text-sub); letter-spacing: 0; }
.kpi.alert .value { color: var(--red); }
.kpi.money .value { color: var(--green); }

/* ---- かんばん ---- */
.track-label {
  font-size: 11px; font-weight: 700; color: var(--text-sub);
  text-transform: uppercase; letter-spacing: 1px; margin: 4px 0 8px;
}
.kanban { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kanban-col {
  min-width: 224px; width: 224px; flex-shrink: 0;
  background: #eef0f5; border-radius: var(--radius); padding: 10px;
}
.kanban-col.drag-over { outline: 2px dashed var(--accent); background: var(--accent-soft); }
.kanban-col h3 {
  font-size: 12px; font-weight: 700; padding: 2px 4px 9px;
  display: flex; justify-content: space-between; color: var(--text);
}
.kanban-col h3 .cnt { color: var(--text-sub); font-weight: 600; }
.kanban-card {
  background: #fff; border-radius: 8px; box-shadow: 0 1px 2px rgba(0,0,0,.07);
  padding: 10px 12px; margin-bottom: 8px; cursor: grab; border-left: 3px solid var(--accent);
}
.kanban-card:hover { box-shadow: 0 3px 10px rgba(0,0,0,.1); }
.kanban-card .t { font-size: 12.5px; font-weight: 700; line-height: 1.4; }
.kanban-card .c { font-size: 11.5px; color: var(--text-sub); margin-top: 3px; }
.kanban-card .meta { display: flex; gap: 5px; margin-top: 7px; flex-wrap: wrap; }
.kanban-card.src-aimitsu { border-left-color: var(--purple); }
.kanban-card.src-scraping { border-left-color: var(--orange); }
.kanban-card.src-manual { border-left-color: var(--accent); }
.kanban-card.src-csv { border-left-color: var(--orange); }

/* ---- モーダル ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(12,18,34,.55);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 4vh 16px; z-index: 100; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 880px;
  box-shadow: 0 24px 64px rgba(0,0,0,.3); margin-bottom: 4vh;
}
.modal-head {
  padding: 18px 24px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.modal-head h2 { font-size: 16.5px; }
.modal-head .sub { color: var(--text-sub); font-size: 12px; margin-top: 5px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-sub); line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px 24px; }
.modal-tabs { display: flex; gap: 2px; padding: 0 24px; border-bottom: 1px solid var(--border); }
.modal-tabs button {
  background: none; border: none; padding: 11px 14px; cursor: pointer;
  font-size: 13px; font-weight: 600; color: var(--text-sub);
  border-bottom: 2px solid transparent; font-family: inherit;
}
.modal-tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---- 生成文面ボックス ---- */
.gen-box { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.gen-box .gen-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 14px; background: #f8f9fb; border-bottom: 1px solid var(--border);
  font-size: 12px; font-weight: 700; flex-wrap: wrap;
}
.gen-box .gen-head .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.gen-box pre {
  padding: 14px; white-space: pre-wrap; font-family: inherit;
  font-size: 13px; line-height: 1.7; max-height: 320px; overflow-y: auto;
}
.gen-empty { padding: 13px; color: var(--text-sub); font-size: 12.5px; }

/* ---- 活動ログ ---- */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #f0f2f6; font-size: 12.5px; }
.timeline li:last-child { border-bottom: none; }
.timeline li .time { color: var(--text-sub); white-space: nowrap; font-size: 11.5px; padding-top: 1px; }
.timeline li .msg { flex: 1; line-height: 1.55; }

/* ---- 分析結果 ---- */
.score-circle {
  width: 70px; height: 70px; border-radius: 50%; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #fff; flex-shrink: 0;
}
.score-circle .s { font-size: 21px; font-weight: 800; line-height: 1; }
.score-circle .g { font-size: 10.5px; }
.analysis-flex { display: flex; gap: 18px; align-items: flex-start; }
.issue-list { list-style: none; font-size: 12.5px; }
.issue-list li { padding: 4px 0 4px 18px; line-height: 1.5; position: relative; }
.issue-list li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 7px; height: 7px; border-radius: 2px; background: var(--orange); }
.issue-list.good li::before { background: var(--green); border-radius: 50%; }

/* ---- トースト ---- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1a2433; color: #fff; padding: 12px 18px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: slideIn .25s ease; max-width: 380px; line-height: 1.5;
}
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes slideIn { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- ローディング ---- */
.spinner {
  display: inline-block; width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -2px;
}
.btn:not(.primary):not(.success) .spinner { border-color: rgba(0,0,0,.15); border-top-color: var(--text-sub); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 明細エディタ ---- */
.items-editor table { width: 100%; border-collapse: collapse; margin-bottom: 10px; }
.items-editor th { font-size: 11px; color: var(--text-sub); text-align: left; padding: 4px 6px; }
.items-editor td { padding: 4px 6px; }
.items-editor input { padding: 6px 8px; font-size: 13px; }
.items-total { text-align: right; font-size: 13px; line-height: 1.8; padding-right: 8px; }
.items-total .grand { font-size: 16px; font-weight: 800; color: var(--green); }

.followup-row { background: #fdf8ef !important; }
.muted { color: var(--text-sub); font-size: 12px; }
.section-divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
code { background: #eef1f5; border-radius: 4px; padding: 1px 6px; font-size: 12px; }
details summary { user-select: none; }

@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar .brand-text, .sidebar nav a .txt, .sidebar .footer .ai-status span:last-child, .logout-btn { display: none; }
  .sidebar nav a { justify-content: center; padding: 11px 0; }
  .sidebar nav a .nav-badge { position: absolute; margin-left: 22px; margin-top: -16px; }
  .main { padding: 16px 12px; }
  .modal-body, .modal-head, .modal-tabs { padding-left: 14px; padding-right: 14px; }
}

/* ---- Proposal Banner ---- */
.proposal-banner {
  background: linear-gradient(135deg, #efeafb 0%, #e8edfd 100%);
  border: 1px solid var(--purple);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  animation: slideDown 0.3s ease-out;
}
@keyframes slideDown {
  from { transform: translateY(-10px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.proposal-banner-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 4px;
}
.proposal-banner-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.proposal-banner-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ---- アコーディオン（ステップ進行） ---- */
.step-accordion {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  background: #fff;
  transition: all 0.25s ease;
}
.step-accordion[open] {
  box-shadow: 0 4px 16px rgba(12, 18, 34, 0.05);
}
.step-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #f8f9fb;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 13.5px;
  list-style: none;
  outline: none;
  border-bottom: 1px solid transparent;
}
.step-summary::-webkit-details-marker {
  display: none;
}
.step-summary:hover {
  background: #f1f3f7;
}
.step-accordion[open] .step-summary {
  background: #fff;
  border-bottom-color: var(--border);
}
.step-summary-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--text-sub);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  transition: background 0.2s ease;
}
.step-title {
  color: var(--text);
  font-weight: 700;
}
.step-summary-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 状態別のスタイル */
/* 1. 推奨（アクティブ）ステップ */
.step-accordion.active-step {
  border-color: var(--accent);
  background: linear-gradient(180deg, #ffffff 0%, #fbfbfe 100%);
}
.step-accordion.active-step .step-summary {
  background: #f5f7ff;
}
.step-accordion.active-step[open] .step-summary {
  background: #fff;
}
.step-accordion.active-step .step-number {
  background: var(--accent);
}
.step-accordion.active-step .step-title {
  color: var(--accent);
}

/* 2. 完了ステップ */
.step-accordion.completed-step {
  border-color: #cbd5e1;
}
.step-accordion.completed-step .step-summary {
  background: #f8f9fb;
  opacity: 0.85;
}
.step-accordion.completed-step .step-number {
  background: var(--green);
}

/* 3. 未着手/未来ステップ */
.step-accordion.future-step {
  opacity: 0.7;
}
.step-accordion.future-step:hover {
  opacity: 1.0;
}
.step-accordion.future-step .step-number {
  background: var(--text-sub);
}

.step-content {
  padding: 16px;
  background: #fff;
}

