:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --success: #12b76a;
  --warning: #f79009;
  --danger: #f04438;
  --sidebar: #0f172a;
  --radius-lg: 22px;
  --radius-md: 16px;
  --shadow: 0 18px 48px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 248px 1fr;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: var(--sidebar);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 15px;
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .24);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.brand strong,
.brand span { display: block; }

.brand strong { font-size: 14px; }
.brand span { margin-top: 3px; color: #94a3b8; font-size: 11px; }

.nav { display: grid; gap: 8px; }

.nav-item {
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  text-align: left;
  color: #cbd5e1;
  background: transparent;
  font-weight: 700;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,.1);
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  border-radius: 12px;
  color: #cbd5e1;
  background: rgba(255,255,255,.06);
  font-size: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  display: inline-block;
  margin-right: 7px;
  border-radius: 50%;
  background: #22c55e;
}

.main {
  min-width: 0;
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 5px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
}

h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 29px; letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 20px; }
h3 { margin-bottom: 16px; font-size: 16px; }

.button {
  min-height: 42px;
  border-radius: 12px;
  padding: 0 18px;
  border: 1px solid transparent;
  font-weight: 800;
}

.button-primary {
  color: #fff;
  background: var(--primary);
}
.button-primary:hover { background: var(--primary-dark); }

.button-secondary {
  color: #344054;
  border-color: var(--line);
  background: #fff;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.kpi-card {
  min-height: 148px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(15, 23, 42, .04);
}

.kpi-card span,
.kpi-card small {
  display: block;
  color: var(--muted);
}

.kpi-card span { font-size: 13px; font-weight: 800; }
.kpi-card strong {
  display: block;
  margin: 13px 0 4px;
  font-size: 36px;
  letter-spacing: -.05em;
}
.kpi-card small { font-size: 12px; }
.kpi-card.attention { border-color: rgba(247, 144, 9, .35); }

.panel-grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 20px;
}

.panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-header,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.section-title-row h3 { margin-bottom: 0; }
.section-title-row span { color: var(--muted); font-size: 12px; }

.text-button {
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 800;
}

.lead-list { display: grid; gap: 10px; }

.lead-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
}

.lead-item:hover {
  border-color: rgba(37, 99, 235, .35);
  background: #fff;
}

.lead-item strong,
.lead-item span { display: block; }

.lead-item span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.type-summary { display: grid; gap: 14px; }

.type-row {
  display: grid;
  grid-template-columns: 150px 1fr 36px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.type-row strong { font-size: 12px; }
.type-bar {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f7;
}
.type-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #7c3aed);
}

.filters {
  display: grid;
  grid-template-columns: 1.4fr repeat(3, .8fr);
  gap: 14px;
  margin-bottom: 20px;
}

.filters label,
.form-grid label,
.memo-field {
  display: grid;
  gap: 7px;
  color: #475467;
  font-size: 12px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(37, 99, 235, .55);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  white-space: nowrap;
}

th, td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 12px;
}

th { color: var(--muted); font-weight: 800; }
td strong { font-size: 13px; }
.company-cell span { display: block; margin-top: 3px; color: var(--muted); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 27px;
  padding: 0 10px;
  border-radius: 999px;
  color: #344054;
  background: #f2f4f7;
  font-size: 11px;
  font-weight: 800;
}

.badge.hot { color: #b54708; background: #fffaeb; }
.badge.success { color: #027a48; background: #ecfdf3; }
.badge.info { color: #175cd3; background: #eff8ff; }

.detail-button {
  border: 0;
  color: var(--primary);
  background: transparent;
  font-weight: 900;
}

.loading-state,
.error-state,
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
}

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid #dbe5f5;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .52);
}

.modal {
  width: min(920px, 100%);
  max-height: 92vh;
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 30px 100px rgba(0,0,0,.25);
}

.modal-header,
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px;
}

.modal-header { border-bottom: 1px solid var(--line); }
.modal-footer { border-top: 1px solid var(--line); }
.modal-footer > div { display: flex; gap: 10px; }
.modal-footer span { color: var(--muted); font-size: 12px; }

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  font-size: 22px;
}

.modal-body {
  max-height: calc(92vh - 152px);
  overflow-y: auto;
  padding: 24px;
}

.detail-section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child { border-bottom: 0; }

.company-summary {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 20px;
  padding-top: 0;
}

.detail-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.detail-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.detail-grid { margin-top: 18px; }

.detail-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-soft);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.tag {
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 12px;
  font-weight: 800;
}

.improvement-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 24px;
}

.improvement-list li {
  padding: 13px 14px;
  border-radius: 12px;
  background: var(--surface-soft);
  font-size: 13px;
}

.answer-list { display: grid; gap: 10px; }

.answer-row {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
}
.answer-row span { display: block; color: var(--muted); font-size: 11px; }
.answer-row strong { display: block; margin-top: 4px; font-size: 13px; }

.memo-field { margin-top: 16px; }

@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }
  .brand { padding-bottom: 12px; }
  .nav {
    grid-template-columns: repeat(2, 1fr);
  }
  .sidebar-note { display: none; }
  .main { padding: 20px 14px; }
  .topbar { align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .kpi-card { min-height: 124px; padding: 17px; }
  .kpi-card strong { font-size: 29px; }
  .filters { grid-template-columns: 1fr; }
  .company-summary,
  .detail-grid,
  .form-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal {
    max-height: 96vh;
    border-radius: 24px 24px 0 0;
  }
  .modal-body { max-height: calc(96vh - 150px); }
  .modal-footer {
    align-items: flex-start;
    flex-direction: column;
  }
  .modal-footer > div,
  .modal-footer .button { width: 100%; }
}
