@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Noto+Sans+JP:wght@300;400;500;600;700&family=Roboto+Mono:wght@400;500&display=swap');

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

:root {
  /* KARTE-inspired color system */
  --color-black: #00100e;
  --color-white: #fff;

  /* Primary - Teal */
  --color-primary: #12a0a0;
  --color-primary-dark: #0e8989;
  --color-primary-light: #15bdbd;
  --color-primary-bg: #ecf7f7;
  --color-primary-bg-hover: #d9f0f0;
  --color-primary-alpha-light: #12a0a01f;
  --color-primary-alpha-medium: #12a0a03d;

  /* Text */
  --text-default: var(--color-black);
  --text-muted: #00100e8f;
  --text-muted-light: #00100e70;
  --text-muted-lighter: #00100e52;
  --text-inverted: var(--color-white);
  --text-primary: var(--color-primary);
  --text-negative: #d8270f;
  --text-positive: #2275f1;

  /* Backgrounds */
  --bg-default: var(--color-white);
  --bg-subtle: #f0f1f1;
  --bg-subtle-light: #f7f8f8;
  --bg-primary: var(--color-primary);
  --bg-inverted: #3d4948;
  --bg-action-hover: #00100e08;
  --bg-action-active: #00100e0f;

  /* Borders */
  --border-default: #00100e1f;
  --border-muted: #00100e0f;
  --border-primary: var(--color-primary);

  /* Status */
  --color-critical: #f25320;
  --color-critical-dark: #d8270f;
  --color-attention: #ff8726;
  --color-success: #1d76bf;

  /* Grays (alpha-based on --color-black) */
  --gray-100: #f7f8f8;
  --gray-200: #f0f1f1;
  --gray-300: #e0e2e2;
  --gray-400: #c2c6c5;
  --gray-500: #adb3b2;
  --gray-600: #8f9695;
  --gray-800: #3d4948;

  /* Shadows */
  --shadow-1: 0px 1px 8px 2px #00100e08, 0px 1px 4px -1px #00100e14;
  --shadow-2: 0px 2px 12px 4px #00100e08, 0px 2px 6px -1px #00100e14;
  --shadow-3: 0px 4px 20px 8px #00100e08, 0px 4px 10px -2px #00100e14;

  /* Sidebar */
  --sidebar-width: 240px;
  --sidebar-bg: var(--color-black);

  /* Fonts */
  --font-sans: 'Inter', 'Noto Sans JP', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'Roboto Mono', 'SF Mono', 'Consolas', monospace;

  /* Transitions */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --duration: 0.15s;
}

::selection { background: var(--color-primary-bg-hover); }
::-moz-selection { background: var(--color-primary-bg-hover); }

html { font-size: 14px; }

body {
  font-family: var(--font-sans);
  background: var(--bg-subtle-light);
  color: var(--text-default);
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  min-height: 100vh;
  font-feature-settings: "palt";
}

/* ===== Sidebar ===== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg);
  color: var(--text-inverted);
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 200ms var(--ease);
}

.sidebar::-webkit-scrollbar { width: 3px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.12); border-radius: 2px; }

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-logo h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.4;
  color: var(--color-white);
}

.sidebar-logo .sub {
  font-size: 10px;
  color: var(--gray-500);
  margin-top: 3px;
  letter-spacing: 0.02em;
  font-weight: 400;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 400;
  transition: all var(--duration) var(--ease);
  position: relative;
  letter-spacing: 0.01em;
}

.sidebar-nav a .nav-icon {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0.5;
  transition: opacity var(--duration) var(--ease);
}

.sidebar-nav a .nav-icon svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav a:hover {
  color: rgba(255,255,255,0.85);
}

.sidebar-nav a:hover .nav-icon {
  opacity: 0.85;
}

.sidebar-nav a.active {
  color: var(--color-white);
  font-weight: 500;
  background: rgba(255,255,255,0.06);
}

.sidebar-nav a.active .nav-icon {
  opacity: 1;
  color: var(--color-primary-light);
}

.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--color-primary);
  border-radius: 0 2px 2px 0;
}

.sidebar-nav .divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 10px 20px;
}

.sidebar-status {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.status-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-idle {
  background: rgba(255,255,255,0.06);
  color: var(--gray-500);
}
.status-idle::before {
  background: var(--gray-600);
}

.status-running {
  background: rgba(18,160,160,0.15);
  color: var(--color-primary-light);
  animation: pulse 2s var(--ease) infinite;
}
.status-running::before {
  background: var(--color-primary);
  animation: dot-pulse 1.5s var(--ease) infinite;
}

.status-done {
  background: rgba(29,118,191,0.15);
  color: #5ea3d4;
}
.status-done::before {
  background: var(--color-success);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ===== Main Content ===== */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-subtle-light);
}

.content {
  padding: 32px 40px;
  flex: 1;
  max-width: 960px;
}

/* ===== Page Header ===== */
.page-header {
  margin-bottom: 20px;
}

.page-header h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-default);
  letter-spacing: -0.02em;
  line-height: 1.4;
}

.page-header .desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.6;
}

.page-header .desc code {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 500;
}

/* ===== Tabs ===== */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== Forms ===== */
.form-card {
  background: var(--bg-default);
  border-radius: 8px;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 0 0 1px var(--border-muted), var(--shadow-1);
}

.form-grid {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  align-items: center;
  gap: 12px;
}

.form-row.full-width {
  grid-template-columns: 1fr;
}

.form-row label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-default);
  text-align: right;
  letter-spacing: 0.01em;
}

.form-row.full-width label {
  text-align: left;
  margin-bottom: 2px;
}

/* ===== Input System (KARTE-style shadow borders) ===== */
input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="password"] {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text-default);
  background: var(--bg-default);
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

input[type="text"]:hover,
input[type="email"]:hover,
input[type="url"]:hover,
input[type="number"]:hover,
input[type="password"]:hover {
  background: var(--bg-subtle-light);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="password"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha-light);
  background: var(--bg-default);
}

input::placeholder {
  color: var(--text-muted-lighter);
  font-weight: 400;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font-sans);
  font-weight: 400;
  color: var(--text-default);
  background: var(--bg-default);
  resize: vertical;
  line-height: 1.7;
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

textarea:hover {
  background: var(--bg-subtle-light);
}

textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha-light);
  background: var(--bg-default);
}

textarea::placeholder {
  color: var(--text-muted-lighter);
}

.input-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-group input { flex: 1; }
.input-group input.short { max-width: 90px; }

.input-group span:not(.input-label) {
  color: var(--text-muted-lighter);
  font-size: 13px;
}

.input-label {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 500;
}

/* ===== Monospace textarea ===== */
textarea.mono {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: 0;
}

/* ===== Checkbox (custom toggle-style) ===== */
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 36px;
  height: 20px;
  background: var(--gray-300);
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  flex-shrink: 0;
}

input[type="checkbox"]::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-white);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
  transition: transform var(--duration) var(--ease);
}

input[type="checkbox"]:checked {
  background: var(--color-primary);
}

input[type="checkbox"]:checked::after {
  transform: translateX(16px);
}

input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ===== Native Checkbox (opt-in) ===== */
input[type="checkbox"].native-cb {
  appearance: checkbox !important;
  -webkit-appearance: checkbox !important;
  width: 16px !important;
  height: 16px !important;
  min-width: 16px;
  background: none !important;
  border-radius: 0 !important;
  position: static !important;
}
input[type="checkbox"].native-cb::after {
  content: none !important;
}
input[type="checkbox"].native-cb:checked {
  background: none !important;
}
input[type="checkbox"].native-cb:checked::after {
  content: none !important;
  transform: none !important;
}

/* ===== Settings ===== */
.settings-grid { display: grid; gap: 4px; }

.setting-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  transition: background var(--duration) var(--ease);
}

.setting-item:hover {
  background: var(--bg-subtle-light);
}

.setting-item label {
  font-size: 12.5px;
  font-weight: 500;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.01em;
  color: var(--text-default);
  cursor: pointer;
}

.setting-item input[type="text"],
.setting-item input[type="email"],
.setting-item input[type="number"],
.setting-item input[type="password"] {
  max-width: 280px;
}

.setting-item input.short { max-width: 80px; }

.setting-desc {
  font-size: 11px;
  color: var(--text-muted-light);
  letter-spacing: 0.01em;
  line-height: 1.5;
}

.settings-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-primary);
  margin-top: 12px;
  padding: 8px 12px 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border-muted);
}

/* ===== Buttons ===== */
.actions {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 20px;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  letter-spacing: 0.01em;
  text-decoration: none;
  white-space: nowrap;
  gap: 6px;
}

.btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: var(--color-primary);
  color: var(--text-inverted);
  box-shadow: 0 1px 2px rgba(18,160,160,0.2);
}
.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 2px 6px rgba(18,160,160,0.25);
}
.btn-primary:active:not(:disabled) {
  background: var(--color-primary-light);
  transform: scale(0.98);
}

.btn-accent {
  background: var(--color-primary);
  color: var(--text-inverted);
  box-shadow: 0 1px 2px rgba(18,160,160,0.2);
}
.btn-accent:hover:not(:disabled) {
  background: var(--color-primary-dark);
  box-shadow: 0 2px 6px rgba(18,160,160,0.25);
}
.btn-accent:active:not(:disabled) {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-action-hover);
  color: var(--text-default);
  box-shadow: 0 0 0 1px var(--border-default);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-action-active);
  box-shadow: 0 0 0 1px var(--border-default), var(--shadow-1);
}

.btn-danger {
  background: var(--color-critical);
  color: var(--text-inverted);
}
.btn-danger:hover:not(:disabled) {
  background: var(--color-critical-dark);
}
.btn-danger:active:not(:disabled) {
  transform: scale(0.98);
}

.file-label {
  display: inline-flex;
  cursor: pointer;
}

.count-label {
  font-size: 11px;
  color: var(--text-muted-light);
  margin-left: auto;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ===== Execution Panel ===== */
.exec-panel {
  background: var(--bg-default);
  border-top: 1px solid var(--border-muted);
  padding: 20px 40px;
  box-shadow: 0 -2px 8px rgba(0,16,14,0.03);
}

.exec-buttons {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  align-items: center;
}

.exec-buttons .btn {
  height: 40px;
  padding: 0 28px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
}

.progress-wrap {
  background: var(--gray-200);
  border-radius: 4px;
  height: 24px;
  position: relative;
  margin-bottom: 14px;
  overflow: hidden;
}

.progress-bar {
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  height: 100%;
  transition: width 0.4s var(--ease);
  border-radius: 4px;
  position: relative;
}

/* shimmer is defined in animation section below */

.progress-text {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-default);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.log-area {
  width: 100%;
  background: var(--color-black);
  color: var(--gray-400);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  padding: 14px 16px;
  border: none;
  border-radius: 8px;
  resize: vertical;
  outline: none;
}

.log-area::placeholder {
  color: #00100e52;
}

/* ===== Results ===== */
.results-list { display: grid; gap: 10px; }

.result-card {
  background: var(--bg-default);
  box-shadow: 0 0 0 1px var(--border-muted), var(--shadow-1);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow var(--duration) var(--ease);
}
.result-card:hover {
  box-shadow: 0 0 0 1px var(--border-default), var(--shadow-2);
}

.result-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 12px 16px;
  font-size: 12.5px;
}

.result-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}
.result-date {
  font-weight: 600;
  color: var(--text-default);
  white-space: nowrap;
}
.result-counts { display: flex; align-items: center; gap: 6px; }
.badge-success {
  background: #d4edda; color: #155724; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-fail {
  background: #f8d7da; color: #721c24; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.result-total { font-size: 11px; color: var(--text-muted); white-space: nowrap; }

.result-label {
  flex: 1;
  min-width: 80px;
  max-width: 200px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.label-text {
  background: #e8f4fd; color: #0c5460; padding: 2px 10px; border-radius: 10px;
  font-size: 11px; font-weight: 500; display: inline-block; max-width: 200px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.label-placeholder {
  color: var(--text-muted-lighter); font-size: 11px;
  display: inline-block; white-space: nowrap;
}
.label-placeholder:hover { color: var(--color-primary); }
.label-input {
  border: 1px solid var(--color-primary); border-radius: 6px; padding: 2px 8px;
  font-size: 11px; width: 180px; outline: none;
  font-family: inherit;
}

.result-actions {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}
.btn-sm {
  padding: 4px 12px; border-radius: 6px; font-size: 11px; font-weight: 500;
  cursor: pointer; border: none; text-decoration: none; white-space: nowrap;
}
.btn-preview {
  background: var(--bg-subtle); color: var(--text-default);
  border: 1px solid var(--border-default);
}
.btn-preview:hover { background: var(--bg-subtle-light); }
.btn-download {
  color: var(--color-primary); background: none;
}
.btn-download:hover { color: var(--color-primary-dark); }

/* Preview table */
.result-preview {
  border-top: 1px solid var(--border-muted);
  padding: 0;
}
.preview-filters {
  display: flex; gap: 6px; padding: 10px 16px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-muted);
}
.filter-btn {
  padding: 3px 12px; border-radius: 14px; font-size: 11px; font-weight: 500;
  cursor: pointer; border: 1px solid var(--border-default);
  background: var(--bg-default); color: var(--text-muted);
}
.filter-btn.active {
  background: var(--color-primary); color: #fff; border-color: var(--color-primary);
}
.preview-table {
  width: 100%; border-collapse: collapse; font-size: 11.5px;
}
.preview-table thead { background: var(--bg-subtle); }
.preview-table th {
  padding: 8px 12px; text-align: left; font-weight: 600;
  color: var(--text-muted); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: 0.5px;
}
.preview-table td { padding: 7px 12px; border-top: 1px solid var(--border-muted); }
.preview-table tr:hover { background: var(--bg-subtle); }
.url-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reason-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); }
.status-success { color: #155724; font-weight: 600; }
.status-fail { color: #721c24; font-weight: 600; }

/* ===== Tracking ===== */
.tracking-stats { display: grid; gap: 8px; }

.track-item {
  padding: 14px 16px;
  background: var(--bg-default);
  box-shadow: 0 0 0 1px var(--border-muted), var(--shadow-1);
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.8;
  transition: box-shadow var(--duration) var(--ease);
}

.track-item:hover {
  box-shadow: 0 0 0 1px var(--border-default), var(--shadow-2);
}

.track-item .url {
  word-break: break-all;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.track-item .clicks {
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  color: var(--text-muted-lighter);
  font-size: 12px;
  padding: 24px 0;
  text-align: center;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-inverted);
  color: var(--text-inverted);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: var(--shadow-3);
  opacity: 0;
  transform: translateY(8px);
  animation: toastIn 0.2s var(--ease) forwards;
}

@keyframes toastIn {
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Scrollbar (main area) ===== */
.main::-webkit-scrollbar { width: 6px; }
.main::-webkit-scrollbar-track { background: transparent; }
.main::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
.main::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
  }

  .sidebar {
    width: 100%;
    min-height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-logo { padding: 14px 16px; }
  .sidebar-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0 8px 8px;
    gap: 2px;
  }
  .sidebar-nav a {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 6px;
  }
  .sidebar-nav a .nav-icon { display: none; }
  .sidebar-nav a.active::before { display: none; }
  .sidebar-nav a.active { background: rgba(255,255,255,0.1); }
  .sidebar-nav .divider { display: none; }
  .sidebar-status { padding: 10px 16px; }

  body { flex-direction: column; }
  .main { margin-left: 0; }
  .content { padding: 20px 16px; }
  .exec-panel { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }
  .form-row label { text-align: left; }
  .setting-item { flex-direction: column; align-items: flex-start; }
  .prospect-filter-bar { flex-direction: column; }
  .prospect-actions-bar { flex-wrap: wrap; }
}

/* =============================================
   Prospect Collection / List / Messages
   ============================================= */

/* Filter bar */
.prospect-filter-bar {
  display: flex; flex-direction: column; gap: 0;
  margin-bottom: 16px; padding: 14px 18px;
  background: var(--bg-subtle-light); border-radius: 10px;
}
.pf-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.pf-row--sub {
  padding-top: 10px; margin-top: 10px;
  border-top: 1px solid var(--border-muted);
}
.pf-row--actions {
  padding-top: 10px; margin-top: 10px;
  border-top: 1px solid var(--border-muted);
}
.pf-search-wrap {
  display: flex; align-items: center; gap: 6px;
  flex: 1; min-width: 180px;
  padding: 6px 10px; border: 1px solid var(--border-default);
  border-radius: 6px; background: var(--color-white);
}
.pf-search-icon { font-size: 13px; color: var(--text-muted-light); flex-shrink: 0; }
.pf-search-input {
  border: none; outline: none; background: transparent;
  font-size: 12.5px; width: 100%;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.pf-select {
  padding: 6px 10px; border: 1px solid var(--border-default); border-radius: 6px;
  font-size: 12.5px; background: var(--color-white);
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  min-width: 100px;
}
.pf-select--sm { min-width: 70px; font-size: 12px; padding: 5px 8px; }
.pf-group {
  display: flex; align-items: center; gap: 6px;
}
.pf-group-label {
  font-size: 11px; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.pf-divider {
  width: 1px; height: 18px; background: var(--border-default);
  margin: 0 4px; flex-shrink: 0;
}
.pf-date {
  padding: 5px 8px; border: 1px solid var(--border-default); border-radius: 6px;
  font-size: 12px; background: var(--color-white);
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.pf-date-sep { font-size: 12px; color: var(--text-muted); }
.pf-checkbox {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; white-space: nowrap;
}
.pf-count { font-weight: 700; font-size: 13px; color: var(--text-default); }
.pf-actions {
  display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap;
}

/* Stats */
.prospect-stats {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px;
}
.stat-item {
  font-size: 12.5px; color: var(--text-muted);
}
.stat-item strong {
  color: var(--text-default); font-weight: 600;
}

/* Table */
.prospect-table-wrap {
  overflow-x: auto; border-radius: 10px; border: 1px solid var(--border-default);
}
.prospect-table {
  width: 100%; min-width: 1800px; border-collapse: collapse; font-size: 12.5px;
}
.prospect-table th {
  background: var(--bg-subtle-light); padding: 8px 12px; text-align: left;
  font-weight: 600; color: var(--text-muted); border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.prospect-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--border-muted);
  vertical-align: middle;
}
.prospect-table tr:hover {
  background: var(--color-primary-bg);
}
.prospect-table th:nth-child(1),
.prospect-table td:nth-child(1) { width: 36px; } /* checkbox */
.prospect-table th:nth-child(2),
.prospect-table td:nth-child(2) { min-width: 140px; } /* 会社名 */
.prospect-table th:nth-child(3),
.prospect-table td:nth-child(3) { min-width: 130px; } /* ドメイン */
.prospect-table th:nth-child(4),
.prospect-table td:nth-child(4) { min-width: 100px; } /* 業種 */
.prospect-table th:nth-child(5),
.prospect-table td:nth-child(5) { min-width: 90px; } /* 所在地 */
.prospect-table th:nth-child(6),
.prospect-table td:nth-child(6) { min-width: 60px; } /* 規模 */
.prospect-table th:nth-child(7),
.prospect-table td:nth-child(7) { min-width: 80px; } /* ソース */
.prospect-table th:nth-child(8),
.prospect-table td:nth-child(8) { min-width: 85px; } /* 収集日 */
.prospect-table th:nth-child(9),
.prospect-table td:nth-child(9) { min-width: 70px; } /* ステータス */
.prospect-table th:nth-child(10),
.prospect-table td:nth-child(10) { min-width: 80px; } /* 営業結果 */
.prospect-table th:nth-child(11),
.prospect-table td:nth-child(11) { min-width: 50px; white-space: nowrap; } /* 操作 */
.company-cell { font-weight: 500; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.domain-cell { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 11.5px; }
.action-cell { white-space: nowrap; }

/* Campaign table (override prospect-table min-width) */
#campaignTable { min-width: 0; width: 100%; }
#campaignTable th:nth-child(1),
#campaignTable td:nth-child(1) { min-width: 200px; } /* 名前 */
#campaignTable th:nth-child(2),
#campaignTable td:nth-child(2) { min-width: 100px; } /* ステータス */
#campaignTable th:nth-child(3),
#campaignTable td:nth-child(3) { min-width: 80px; } /* 送信先数 */
#campaignTable th:nth-child(4),
#campaignTable td:nth-child(4) { min-width: 100px; } /* セグメント数 */
#campaignTable th:nth-child(5),
#campaignTable td:nth-child(5) { min-width: 100px; } /* 作成日 */
#campaignTable th:nth-child(6),
#campaignTable td:nth-child(6) { min-width: 80px; white-space: nowrap; } /* 操作 */

/* Segment badge */
.segment-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
  background: #e8f4f8; color: #0e6e7a;
}
.seg-web_production { background: #e0f2f1; color: #00695c; }
.seg-ad_agency { background: #fce4ec; color: #c62828; }
.seg-seo_company { background: #e8eaf6; color: #283593; }
.seg-branding_agency { background: #f3e5f5; color: #6a1b9a; }
.seg-system_dev { background: #e3f2fd; color: #1565c0; }
.seg-ec_support { background: #fff3e0; color: #e65100; }
.seg-other { background: var(--bg-subtle-light); color: var(--text-muted); }

/* Score badge */
.score-badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 600; min-width: 32px; text-align: center;
}
.score-high { background: #c8e6c9; color: #2e7d32; }
.score-mid { background: #fff9c4; color: #f57f17; }
.score-low { background: #ffcdd2; color: #c62828; }

/* Status pill */
.status-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 500; white-space: nowrap;
}
.st-collected { background: #e0e0e0; color: #616161; }
.st-analyzed { background: #bbdefb; color: #1565c0; }
.st-classified { background: #c5cae9; color: #283593; }
.st-message_generated { background: #dcedc8; color: #33691e; }
.st-approved { background: #c8e6c9; color: #2e7d32; }
.st-queued { background: #fff9c4; color: #f57f17; }
.st-sent { background: #b2dfdb; color: #00695c; }
.st-sending { background: #fff3e0; color: #e65100; }
.st-error { background: #ffcdd2; color: #c62828; }
.st-completed { background: #c8e6c9; color: #2e7d32; }
.st-rejected { background: #ffcdd2; color: #c62828; }
.st-failed { background: #ffcdd2; color: #c62828; }

/* Checkbox grid (業種・地域選択) */
.cb-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 6px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--bg-default);
}
.cb-grid label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: normal !important;
  white-space: nowrap;
  text-align: left;
  min-width: 110px;
  padding: 2px 0;
  cursor: pointer;
}
.cb-grid label:hover {
  background: rgba(0,0,0,0.03);
  border-radius: 3px;
}
.cb-select-all {
  width: 100%;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 4px !important;
  margin-bottom: 4px;
  font-weight: 600 !important;
  min-width: 100% !important;
}
.cb-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 1px;
}

/* Sortable table headers */
.sortable-th {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s;
}
.sortable-th:hover {
  background: rgba(0,0,0,0.04);
}
.sortable-th.active {
  color: var(--color-primary);
}
.sort-arrow {
  font-size: 10px;
  margin-left: 2px;
  opacity: 0.7;
}

/* Score rank badges */
.score-rank {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.5px;
  margin-right: 3px; white-space: nowrap;
}
.rank-sp { background: linear-gradient(135deg, #ffd700, #ffaa00); color: #4a3800; }
.rank-s  { background: #1976d2; color: #fff; }
.rank-a  { background: #388e3c; color: #fff; }
.rank-b  { background: #9e9e9e; color: #fff; }
.rank-c  { background: #e0e0e0; color: #757575; }
.score-value { font-size: 11px; font-weight: 500; color: #424242; }
.score-cell { white-space: nowrap; text-align: center; }

/* Utility */
.hidden-col { display: none; }

/* Small buttons */
.btn-sm {
  padding: 4px 10px; font-size: 11.5px; border-radius: 6px;
  border: none; cursor: pointer; font-weight: 500;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  transition: background 0.15s;
}
.btn-xs {
  padding: 2px 8px; font-size: 11px; border-radius: 5px;
  border: none; cursor: pointer; font-weight: 500;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.btn-xs.btn-primary { background: var(--color-primary); color: #fff; }
.btn-xs.btn-secondary { background: var(--bg-subtle-light); color: var(--text-muted); }
.btn-xs.btn-primary:hover { background: var(--color-primary-dark); }

/* Selection bar - KARTE style */
.prospect-selection-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; margin-top: 12px;
  background: var(--color-primary-bg); border: 1px solid var(--color-primary-alpha-medium);
  border-radius: 8px; font-size: 13px; color: var(--text-default);
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.prospect-selection-bar .selection-count {
  color: var(--color-primary-dark);
}
.prospect-selection-bar .selection-clear-btn {
  background: none; border: none; color: var(--text-muted);
  font-size: 12px; cursor: pointer; padding: 2px 8px;
  border-radius: 4px; transition: all 0.15s;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.prospect-selection-bar .selection-clear-btn:hover {
  background: var(--bg-action-hover); color: var(--text-default);
}

/* Pagination - KARTE style */
.prospect-pagination,
#crawl-companies-pagination {
  display: flex; gap: 4px; justify-content: center; align-items: center; margin-top: 16px;
}
.karte-page-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border-default); border-radius: 6px;
  background: var(--color-white); color: var(--text-default);
  font-size: 13px; font-weight: 500; cursor: pointer;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
  transition: all 0.15s ease;
  display: flex; align-items: center; justify-content: center;
}
.karte-page-btn:hover:not(.active):not(.disabled) {
  background: var(--bg-action-hover); border-color: var(--gray-400);
}
.karte-page-btn.active {
  background: var(--color-primary); color: var(--color-white);
  border-color: var(--color-primary); font-weight: 600;
}
.karte-page-btn.disabled {
  color: var(--text-muted-lighter); cursor: default;
  border-color: var(--border-muted);
}
.karte-page-ellipsis {
  display: flex; align-items: center; justify-content: center;
  min-width: 24px; height: 32px;
  color: var(--text-muted-lighter); font-size: 13px;
  user-select: none;
}

/* Modal */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
/* modal-overlay and modal-content moved to bottom of file with KARTE-aligned styles */
.modal-content {
  background: var(--color-white); border-radius: 8px;
  width: 90%; max-width: 800px; max-height: 85vh; overflow-y: auto;
  box-shadow: 0 0 0 1px var(--border-muted), 0 8px 32px rgba(0,16,14,0.18);
  padding: 20px 24px;
}
.btn-close {
  background: none; border: none; font-size: 24px; cursor: pointer;
  color: var(--text-muted); padding: 0 4px;
}
.modal-body { padding: 24px; }

/* Detail sections */
.detail-section { margin-bottom: 20px; }
.detail-section h4 {
  font-size: 13px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 8px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border-muted);
}
.detail-table { width: 100%; font-size: 12.5px; }
.detail-table td { padding: 4px 8px; vertical-align: top; }
.detail-table td:first-child { font-weight: 500; color: var(--text-muted); width: 120px; white-space: nowrap; }
.detail-table a { color: var(--color-primary); text-decoration: none; }
.detail-section ul { padding-left: 20px; font-size: 12.5px; }
.detail-section li { margin-bottom: 4px; }

/* Message cards in detail */
.message-card {
  border: 1px solid var(--border-default); border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.message-card.message-approved {
  border-color: #4caf50; background: #f1f8e9;
}
.message-header {
  display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.message-pattern {
  font-size: 11px; font-weight: 600; color: var(--color-primary);
  background: var(--color-primary-bg); padding: 2px 8px; border-radius: 4px;
}
.message-tone {
  font-size: 11px; color: var(--text-muted);
}
.message-subject { margin-bottom: 6px; }
.msg-subject-input {
  width: 100%; padding: 4px 8px; border: 1px solid var(--border-default);
  border-radius: 4px; font-size: 12.5px; font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.message-alt-subjects {
  font-size: 11px; color: var(--text-muted); margin-bottom: 6px;
}
.msg-body-input {
  width: 100%; padding: 8px; border: 1px solid var(--border-default);
  border-radius: 4px; font-size: 12.5px; resize: vertical;
  font-family: 'Inter', 'Noto Sans JP', sans-serif;
}
.message-personal {
  font-size: 11.5px; color: var(--text-muted); margin-top: 4px;
}
.message-actions {
  display: flex; gap: 6px; margin-top: 8px;
}

/* Message Manage */
.segment-group-title {
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
  padding-bottom: 8px; border-bottom: 1px solid var(--border-muted);
}
.message-manage-item {
  display: flex; gap: 12px; align-items: center;
  padding: 8px 12px; border-radius: 6px; cursor: pointer;
  transition: background 0.15s;
}
.message-manage-item:hover { background: var(--color-primary-bg); }
.mm-company { font-weight: 500; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mm-subject { flex: 2; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 12px; }
.mm-status { flex-shrink: 0; }
.mm-score { flex-shrink: 0; }

/* =============================================
   Report / Metrics
   ============================================= */

/* Stat cards */
.stat-card {
  background: var(--bg-default);
  border-radius: 8px;
  padding: 18px 16px;
  text-align: center;
  box-shadow: 0 0 0 1px var(--border-muted), var(--shadow-1);
  transition: box-shadow var(--duration) var(--ease);
}
.stat-card:hover {
  box-shadow: 0 0 0 1px var(--border-default), var(--shadow-2);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  margin-bottom: 4px;
}
.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Segment metrics table */
.segment-metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.segment-metrics-table th {
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-subtle-light);
}
.segment-metrics-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-muted);
}
.segment-metrics-table tr:hover {
  background: var(--color-primary-bg);
}

/* Send events table */
.send-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.send-events-table th {
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-subtle-light);
}
.send-events-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-muted);
}
.send-events-table tr:hover {
  background: var(--color-primary-bg);
}
.send-events-table select {
  padding: 3px 8px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  font-size: 11.5px;
  font-family: var(--font-sans);
  background: var(--bg-default);
}

/* =============================================
   Sequence Builder (Step 送信)
   ============================================= */
.sequence-step {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  position: relative;
}
.sequence-step:hover {
  border-color: var(--color-primary-alpha-medium);
}
.sequence-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.sequence-step-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  padding: 2px 10px;
  border-radius: 10px;
}
.sequence-step-remove {
  background: none;
  border: none;
  color: var(--text-muted-light);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--duration) var(--ease);
}
.sequence-step-remove:hover {
  color: var(--color-critical);
  background: #fef2f0;
}
.sequence-step-fields {
  display: grid;
  gap: 10px;
}
.sequence-step-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  gap: 8px;
}
.sequence-step-row label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: right;
}
.sequence-step-row input,
.sequence-step-row select,
.sequence-step-row textarea {
  font-size: 12.5px;
}
.sequence-step-inline {
  display: flex;
  gap: 12px;
}
.sequence-step-inline > div {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sequence-step-inline label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.sequence-step-inline input[type="number"] {
  width: 60px;
}
.sequence-step-inline select {
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: 5px;
  font-size: 12px;
  font-family: var(--font-sans);
}

/* Sequence states table */
.sequence-states-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.sequence-states-table th {
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-subtle-light);
}
.sequence-states-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-muted);
}

/* =============================================
   MA-style Sequence Flow
   ============================================= */
.sequence-flow-container {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 32px;
  overflow-x: auto;
  overflow-y: auto;
}

/* ===== Tree-based sequence flow (horizontal) ===== */
.sequence-flow-tree {
  display: inline-flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  min-width: min-content;
}

/* Wrapper: node + its children in a row */
.seq-tree-node-group {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0;
}

.seq-tree-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 0 10px 0 0;
}

.seq-tree-node {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  background: var(--bg-default);
  min-width: 200px;
}
.seq-tree-node:hover {
  border-color: var(--color-primary);
  box-shadow: 0 2px 8px rgba(18,160,160,0.12);
  transform: translateX(2px);
}
.seq-tree-node--root {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.seq-node-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: box-shadow 0.15s ease;
}
.seq-tree-node:hover .seq-node-icon {
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.seq-node-icon.step-initial {
  background: var(--color-primary);
  color: #fff;
}
.seq-node-icon.step-followup {
  background: #fff;
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
}
.seq-node-icon-emoji {
  font-size: 20px;
}

.seq-node-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.seq-node-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-default);
  line-height: 1.3;
}
.seq-node-subject {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.seq-node-condition {
  font-size: 10px;
  color: var(--color-primary);
  font-weight: 600;
}
.seq-node-schedule {
  font-size: 10px;
  color: var(--text-muted-light);
}
.seq-node-ab-badge {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
}

/* 送信済みバッジ（KARTE準拠） */
.seq-node-sent-badge {
  display: inline-block;
  background: #10b981;
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 6px;
  letter-spacing: 0.02em;
  vertical-align: middle;
}
.seq-node-icon.step-sent {
  background: #10b981 !important;
  border-color: #10b981 !important;
  color: #fff;
}
.seq-tree-node.seq-tree-node--sent {
  border-color: #10b981;
  background: linear-gradient(135deg, #f0fdf4 0%, #fff 100%);
}

/* 送信結果モーダル */
.send-result-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}
.send-result-card {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  text-align: center;
}
.send-result-card .result-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}
.send-result-card .result-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.send-result-card.result-success .result-value { color: #10b981; }
.send-result-card.result-fail .result-value { color: #ef4444; }
.send-result-list {
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border-default);
  border-radius: 6px;
}
.send-result-list table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
.send-result-list th {
  background: var(--bg-subtle);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
}
.send-result-list td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text-primary);
}
.send-result-list tr:hover { background: var(--bg-subtle); }
.status-sent { color: #10b981; font-weight: 600; }
.status-failed { color: #ef4444; font-weight: 600; }

/* Step result badges (KARTE style) */
.step-result-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
}
.step-result--sent {
  background: #ecfdf5;
  color: #10b981;
}
.step-result--failed {
  background: #fef2f2;
  color: #ef4444;
}
.step-result--skipped {
  background: #fffbeb;
  color: #f59e0b;
}

/* Tree add buttons */
.seq-tree-add-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px dashed var(--border-default);
  background: var(--bg-default);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s var(--ease);
  flex-shrink: 0;
}
.seq-tree-add-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-bg);
}

/* Tree children and connectors (horizontal layout) */
.seq-tree-children {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-left: 0;
  padding-left: 0;
  border-left: none;
  position: relative;
}

.seq-tree-children--branched {
  /* Vertical connecting line for multiple branches */
  padding-left: 20px;
}
.seq-tree-children--branched::before {
  content: '';
  position: absolute;
  left: 0;
  top: var(--branch-line-top, 25%);
  height: var(--branch-line-height, 50%);
  width: 2px;
  background: var(--color-primary-alpha-medium);
}

.seq-tree-branch {
  display: flex;
  flex-direction: row;
  align-items: center;
  position: relative;
}

/* Horizontal connector from vertical branch line to each branch */
.seq-tree-children--branched > .seq-tree-branch::before {
  content: '';
  position: absolute;
  left: -20px;
  top: 50%;
  width: 20px;
  height: 2px;
  background: var(--color-primary-alpha-medium);
}

.seq-tree-connector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px 0 8px;
  position: relative;
  flex-shrink: 0;
}
.seq-tree-connector::before {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--color-primary-alpha-medium);
  flex-shrink: 0;
}
.seq-tree-connector::after {
  content: '';
  display: block;
  width: 14px;
  height: 2px;
  background: var(--color-primary-alpha-medium);
  flex-shrink: 0;
}
.seq-tree-connector-line {
  display: none;
}
.seq-tree-connector-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
  background: var(--color-primary-bg);
  padding: 2px 8px;
  border-radius: 10px;
  border: 1px solid var(--color-primary-alpha-medium);
}

/* Branch add button */
.seq-tree-branch-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 4px 0 3px 7px;
  padding: 6px 14px;
  border: 1px dashed var(--border-default);
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  align-self: flex-start;
  white-space: nowrap;
}
.seq-tree-branch-add-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-bg);
}
.seq-tree-branch-add-icon {
  font-size: 13px;
}
/* Day-of-week chip for schedule */
.day-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border: 1px solid var(--border-default, #d0d5dd);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  background: #fff;
}
.day-chip:has(input:checked) {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.day-chip input { display: none; }
.seq-node-schedule {
  font-size: 9px;
  color: var(--text-muted);
  margin-top: 1px;
  max-width: 80px;
  text-align: center;
  line-height: 1.2;
}
.seq-node-ab-badge {
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  background: #f59e0b;
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  white-space: nowrap;
}

/* =============================================
   Send Status Cards
   ============================================= */
.send-status-card {
  transition: box-shadow 0.15s ease;
}
.send-status-card.sending {
  border-left: 4px solid var(--color-primary);
}
.send-status-card.completed {
  border-left: 4px solid var(--color-success);
}
.send-status-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.send-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
}
.send-status-badge.sending {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.send-status-badge.completed {
  background: rgba(16,185,129,0.1);
  color: #10b981;
}
.send-status-metrics {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.send-status-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.send-status-metric-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-default);
  line-height: 1.2;
}
.send-status-metric-label {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Status pill for send_failed */
.st-send_failed { background: rgba(239,68,68,0.1); color: #ef4444; }

/* Business result select */
.result-select {
  border: 1px solid var(--border-default);
  background: var(--bg-default);
  cursor: pointer;
}
.result-select:focus { border-color: var(--color-primary); }

/* Button warning */
.btn-warning {
  background: var(--color-attention);
  color: var(--text-inverted);
}
.btn-warning:hover:not(:disabled) {
  background: #e67500;
}
.btn-warning:active:not(:disabled) {
  transform: scale(0.98);
}

/* --- 企業収集（クローラー） --- */
.crawl-subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
  padding-bottom: 8px;
}
.crawl-subtab {
  padding: 6px 16px;
  border: 1px solid var(--border-default);
  border-radius: 6px 6px 0 0;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12.5px;
  font-family: var(--font-sans);
  font-weight: 500;
  transition: all 0.15s;
}
.crawl-subtab.active {
  background: var(--color-primary);
  color: #fff;
  border-color: var(--color-primary);
}
.crawl-subtab:hover:not(.active) {
  background: var(--bg-subtle);
}

/* --- Phase step indicator --- */
.phase-step {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 500;
  transition: all 0.3s var(--ease);
  background: var(--gray-200);
  color: var(--text-muted-light);
}
.phase-step.phase-active {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 1px 4px rgba(18, 160, 160, 0.3);
  animation: pulse 2s var(--ease) infinite;
}
.phase-step.phase-done {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
}
.phase-step.phase-pending {
  background: var(--gray-200);
  color: var(--text-muted-lighter);
}
.crawl-dropzone {
  border: 2px dashed var(--border-default);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
}
.crawl-dropzone:hover, .crawl-dropzone.dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-alpha-light);
}
.progress-bar-outer {
  width: 100%;
  height: 10px;
  background: var(--gray-200);
  border-radius: 5px;
  overflow: hidden;
}
.progress-bar-inner {
  height: 100%;
  background: var(--color-primary);
  border-radius: 5px;
  transition: width 0.3s ease;
  min-width: 2px;
}
/* .score-badge already defined above with score-high/mid/low variants */

/* ===== Campaign Stepper ===== */
.campaign-stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 24px;
  padding: 16px 0;
  overflow-x: auto;
}

.stepper-item {
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  cursor: pointer;
  position: relative;
}

.stepper-item:last-child {
  flex: 0 0 auto;
}

.stepper-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  background: var(--gray-200);
  color: var(--text-muted-light);
  transition: all 0.25s var(--ease);
  border: 2px solid transparent;
  position: relative;
  z-index: 1;
}

.stepper-item.active .stepper-circle {
  background: var(--color-primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(18, 160, 160, 0.35);
}

.stepper-item.completed .stepper-circle {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  border-color: var(--color-primary);
}

.stepper-item.completed .stepper-circle::after {
  content: '✓';
  position: absolute;
  font-size: 14px;
  font-weight: 700;
}

.stepper-item.completed .stepper-number {
  display: none;
}

.stepper-label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted-light);
  margin-left: 8px;
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}

.stepper-item.active .stepper-label {
  color: var(--text-default);
  font-weight: 600;
}

.stepper-item.completed .stepper-label {
  color: var(--color-primary-dark);
}

.stepper-line {
  flex: 1;
  height: 2px;
  background: var(--gray-300);
  margin: 0 8px;
  transition: background 0.25s var(--ease);
  min-width: 16px;
}

.stepper-item.completed + .stepper-item .stepper-line,
.stepper-item.completed .stepper-line {
  background: var(--color-primary);
}

/* Stepper line is placed between items */
.stepper-connector {
  flex: 1;
  height: 2px;
  background: var(--gray-300);
  min-width: 12px;
  max-width: 190px;
  transition: background 0.25s var(--ease);
}
.stepper-connector.done {
  background: var(--color-primary);
}

/* Step content panels — インラインstyleで完全制御。CSSはフォールバック用 */
.step-panel {
  display: none !important;
  opacity: 0;
}

.step-panel.active {
  display: block !important;
  opacity: 1;
  animation: none;
}

@keyframes stepFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Step navigation buttons */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border-muted);
}

.step-nav .btn {
  min-width: 120px;
}

.step-nav-spacer {
  flex: 1;
}

/* ===== Report KPI Cards ===== */
.report-kpi-card {
  background: var(--bg-default);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 0 0 1px var(--border-muted), var(--shadow-1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.report-kpi-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-default);
  line-height: 1.2;
}

.report-kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

/* Segment metrics table styling */
.segment-metrics-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.segment-metrics-table th {
  background: var(--bg-subtle);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
}
.segment-metrics-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-muted);
}
.segment-metrics-table tr:hover td {
  background: var(--bg-subtle-light);
}

/* Send events table styling */
.send-events-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.send-events-table th {
  background: var(--bg-subtle);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 1;
}
.send-events-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-muted);
}
.send-events-table tr:hover td {
  background: var(--bg-subtle-light);
}
.send-events-table .url-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.send-events-table select {
  font-size: 12px;
  padding: 2px 6px;
}
.badge-success {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
}
.badge-fail {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

@media (max-width: 768px) {
  .report-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* ===== Campaign Section Panels ===== */
.section-panel {
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.section-panel-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-default);
  margin-bottom: 12px;
  display: block;
}

.section-panel-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 8px;
  line-height: 1.5;
}

/* Template toolbar */
.template-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  padding: 10px 16px;
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 6px;
  flex-wrap: wrap;
}

.template-bar label {
  font-weight: 600;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-default);
  text-align: left;
}

/* Form label stack (vertical layout) */
.form-label-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 16px;
}

.form-label-stack > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-default);
  text-align: left;
}

.form-label-stack .hint {
  font-size: 11px;
  color: var(--text-muted);
  margin: 2px 0 4px;
  line-height: 1.4;
}

.form-label-stack code {
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 500;
}

/* AI Correction panel */
.ai-correct-panel {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: var(--color-primary-bg);
  border: 1px solid var(--color-primary-alpha-medium);
  border-radius: 8px;
}

.ai-correct-panel .panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-primary-dark);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ai-correct-panel .input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.ai-correct-panel .input-row input[type="text"] {
  flex: 1;
}

.ai-correct-panel .preview-area {
  margin-top: 12px;
}

.ai-correct-panel .preview-area textarea {
  background: var(--bg-default);
  border: 1px solid var(--border-default);
}

.ai-correct-panel .action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

/* AB Test Section */
.ab-section {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}

.ab-toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-default);
}

.ab-warning {
  margin: 12px 0;
  padding: 10px 14px;
  background: #fef6e7;
  border: 1px solid var(--color-attention);
  border-radius: 6px;
  font-size: 11px;
  color: #8a6b00;
  line-height: 1.5;
}

.ab-variant-card {
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 16px;
  margin-top: 12px;
}

.ab-variant-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #f59e0b;
  color: #fff;
  font-weight: 700;
  font-size: 12px;
}

.ab-variant-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.ab-variant-header strong {
  font-size: 13px;
}

.ab-info {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 10px;
  line-height: 1.5;
}

/* Schedule Section */
.schedule-section {
  margin-bottom: 16px;
  padding: 16px 20px;
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}

.schedule-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.schedule-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.schedule-field > label {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
  font-weight: 500;
}

.schedule-field .note {
  font-size: 10px;
  color: var(--text-muted-light);
  margin-top: 4px;
  line-height: 1.4;
}

.schedule-note {
  font-size: 10px;
  color: var(--text-muted-light);
  margin-top: 10px;
  line-height: 1.4;
}

.time-range {
  display: flex;
  align-items: center;
  gap: 6px;
}

.time-range span {
  font-size: 12px;
  color: var(--text-muted);
}

/* Date/Time inputs KARTE style */
input[type="time"],
input[type="date"] {
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: #1a1a1a;
  background: var(--bg-default);
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  color-scheme: light;
}
input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
  color: #1a1a1a;
}

input[type="time"]:focus,
input[type="date"]:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha-light);
}

/* Select KARTE style */
select {
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 4px;
  font-size: 12px;
  font-family: var(--font-sans);
  color: var(--text-default);
  background: var(--bg-default) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%2300100e8c'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  outline: none;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}

select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha-light);
}

/* Modal Overlay (KARTE-aligned) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,16,14,0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay > .modal {
  position: relative;
  top: auto;
  left: auto;
  background: var(--bg-default);
  border-radius: 8px;
  box-shadow: 0 0 0 1px var(--border-muted), 0 8px 32px rgba(0,16,14,0.18);
  padding: 0;
  width: 90%;
  overflow: hidden;
}

.modal-overlay > .modal > .modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-default);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-overlay > .modal > .modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-default);
}

/* Modal body padding */
.modal-body-inner {
  padding: 20px 24px;
}

/* Modal footer */
.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  border-top: 1px solid var(--border-default);
}

/* ===== Sequence Step Modal (enlarged) ===== */
.seq-step-modal {
  width: min(960px, 90vw) !important;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.seq-modal-body {
  overflow-y: auto;
  padding: 24px 32px !important;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Top bar: delay + condition in a horizontal row */
.seq-modal-topbar {
  display: flex;
  gap: 20px;
  align-items: flex-end;
  padding: 16px 20px;
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}

.seq-modal-topbar-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seq-modal-topbar-item--grow {
  flex: 1;
}

.seq-modal-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.seq-modal-delay-input {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seq-modal-delay-input input[type="number"] {
  width: 72px;
}

.seq-modal-delay-suffix {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Schedule section in modal */
.seq-modal-schedule {
  padding: 16px 20px;
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
}

.seq-modal-schedule-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-default);
  margin-bottom: 12px;
}

.seq-modal-schedule-grid {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.seq-modal-schedule-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 16px;
}

.seq-modal-schedule-row {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.seq-modal-schedule-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.seq-modal-start-radio-row {
  display: flex;
  align-items: center;
  gap: 20px;
}

.seq-modal-radio-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-default);
  cursor: pointer;
  white-space: nowrap;
  padding: 2px 0;
}

.seq-modal-radio-label input[type="radio"] {
  accent-color: var(--color-primary);
  margin: 0;
  width: 18px;
  height: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.seq-modal-start-pickers {
  display: flex;
  align-items: center;
  gap: 8px;
}

.seq-modal-start-pickers.is-hidden {
  display: none;
}

.seq-modal-start-pickers input[type="date"],
.seq-modal-start-pickers input[type="time"] {
  padding: 6px 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-default);
  background: #fff;
}

.seq-modal-days {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

/* Message section */
.seq-modal-message-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.seq-modal-message-section textarea {
  min-height: 160px;
  resize: vertical;
}

/* A/B section in modal */
.seq-modal-ab {
  margin-top: 0 !important;
}

/* Stepper refinement */
.campaign-stepper {
  background: var(--bg-default);
  border-radius: 8px;
  padding: 16px 24px;
  margin-bottom: 20px;
  box-shadow: 0 0 0 1px var(--border-muted);
}

/* Campaign detail header */
.campaign-detail-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.campaign-detail-header .campaign-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-default);
}

/* Filter row */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

/* Campaign Step1: 営業先選択セクション */
.camp-step1-section {
  background: var(--bg-subtle-light);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  margin-bottom: 16px;
  overflow: hidden;
}

.camp-step1-section-header {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-default);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-default);
}

.camp-step1-section-body {
  padding: 14px 16px;
}

.camp-step1-field-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.camp-step1-select {
  font-size: 13px;
  min-width: 200px;
  padding: 7px 12px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
}

.camp-step1-select--sm {
  min-width: 130px;
}

.camp-step1-hint {
  font-size: 12px;
  color: var(--text-muted-lighter);
}

.camp-step1-search {
  width: 100%;
  font-size: 13px;
  padding: 8px 12px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
  margin-top: 2px;
}

.camp-step1-search::placeholder {
  color: var(--text-muted-lighter);
}

.camp-step1-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border-default);
}

.camp-step1-count {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-default);
}

/* Manual Send Mode */
.manual-send-card {
  margin-bottom: 16px;
}

.manual-dest-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 14px;
  border-bottom: 2px solid var(--border-default, #e0e0e0);
}

.manual-dest-tab {
  flex: 1;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted-lighter);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  text-align: center;
}

.manual-dest-tab:hover {
  color: var(--text-default, #333);
}

.manual-dest-tab.active {
  color: var(--color-primary, #12a0a0);
  border-bottom-color: var(--color-primary, #12a0a0);
}

.manual-url-textarea {
  width: 100%;
  font-size: 13px;
  font-family: var(--font-mono, 'SF Mono', 'Fira Code', monospace);
  padding: 10px 12px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
  resize: vertical;
  line-height: 1.6;
}

.manual-url-textarea::placeholder {
  color: var(--text-muted-lighter);
}

.manual-msg-template-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.manual-msg-template-bar label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.manual-msg-input {
  width: 100%;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
}

.manual-msg-textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 13px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
  resize: vertical;
  line-height: 1.6;
}

.manual-send-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

/* Report tab buttons */
.report-tab-btn {
  padding: 10px 20px;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-sans);
  transition: all var(--duration) var(--ease);
}

.report-tab-btn:hover {
  color: var(--text-default);
}

.report-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* Sub-tab buttons (formdata) */
.sub-tab-btn {
  padding: 10px 24px;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-family: var(--font-sans);
  transition: all var(--duration) var(--ease);
}

.sub-tab-btn:hover {
  color: var(--text-default);
}

.sub-tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

/* ==========================================
   Animations (inspired by ad-survey sample)
   ========================================== */

/* Base fade-in */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.fade-in {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}

/* Scale-in for modals */
@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95); }
  to   { opacity: 1; transform: scale(1); }
}

/* Tab content transition */
.tab-content.active {
  animation: fadeIn 0.5s ease forwards;
}

/* Form cards stagger within active tab */
.tab-content.active .form-card {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}
.tab-content.active .form-card:nth-child(1) { animation-delay: 0.05s; }
.tab-content.active .form-card:nth-child(2) { animation-delay: 0.15s; }
.tab-content.active .form-card:nth-child(3) { animation-delay: 0.25s; }
.tab-content.active .form-card:nth-child(4) { animation-delay: 0.35s; }

/* Page header fade */
.tab-content.active .page-header {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}

/* Report KPI cards stagger */
.report-kpi-card {
  animation: fadeIn 0.5s ease forwards;
  opacity: 0;
}
.report-kpi-grid .report-kpi-card:nth-child(1) { animation-delay: 0.1s; }
.report-kpi-grid .report-kpi-card:nth-child(2) { animation-delay: 0.2s; }
.report-kpi-grid .report-kpi-card:nth-child(3) { animation-delay: 0.3s; }
.report-kpi-grid .report-kpi-card:nth-child(4) { animation-delay: 0.4s; }
.report-kpi-grid .report-kpi-card:nth-child(5) { animation-delay: 0.5s; }
.report-kpi-grid .report-kpi-card:nth-child(6) { animation-delay: 0.6s; }

/* Modal overlay - fade */
.modal-overlay {
  animation: fadeIn 0.2s ease forwards;
}

/* Modal content - scale in */
.modal-overlay .modal,
.modal-overlay .seq-step-modal {
  animation: scaleIn 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Progress bar shimmer */
@keyframes shimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}
.progress-bar::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255,255,255,0.2) 50%, transparent 100%);
  animation: shimmer 2s ease-in-out infinite;
}

/* Prospect table rows stagger */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Step panel transition — 重複ルール削除済み。.step-panel.active は上部で統合管理 */

/* Stepper circle completion pulse */
@keyframes stepPulse {
  0%   { box-shadow: 0 0 0 0 rgba(18,160,160,0.4); }
  70%  { box-shadow: 0 0 0 8px rgba(18,160,160,0); }
  100% { box-shadow: 0 0 0 0 rgba(18,160,160,0); }
}
.stepper-item.completed .stepper-circle {
  animation: stepPulse 0.6s ease;
}

/* Sidebar nav items hover */
.sidebar-nav a {
  transition: color 0.2s ease;
}

/* Button press effect */
.btn:active {
  transform: scale(0.97);
}

/* Card hover subtle lift */
.form-card {
  transition: box-shadow 0.2s ease;
}
.form-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

/* Count pulse for KPI values */
@keyframes countPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* Collect mode button switch */
.collect-mode-btn {
  transition: all 0.2s ease !important;
}

/* Usage bar fill animation */
.usage-bar-fill {
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Filter bar fade-in */
.prospect-filter-bar {
  animation: fadeIn 0.5s ease 0.1s forwards;
  opacity: 0;
}

/* Campaign stepper fade-in */
.campaign-stepper {
  animation: fadeIn 0.5s ease 0.05s forwards;
  opacity: 0;
}

/* Sequence flow tree fade-in */
.sequence-flow-tree {
  animation: fadeIn 0.5s ease 0.1s forwards;
  opacity: 0;
}

/* Toast notification slide */
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* =========================================================
   AI Chat Panel (AIおすすめリスト生成) - KARTE compliant
   ========================================================= */
.ai-chat-card {
  /* Match the default form-card width — left-aligned, full content width */
  padding: 20px 24px;
}

.ai-chat-log {
  max-height: 62vh;
  overflow-y: auto;
  padding: 4px 4px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 16px;
}

.ai-chat-log::-webkit-scrollbar { width: 6px; }
.ai-chat-log::-webkit-scrollbar-track { background: transparent; }
.ai-chat-log::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.ai-chat-input-area {
  padding: 12px 4px 4px;
  border-top: 1px solid var(--border-muted);
}

.ai-chat-msg {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.ai-chat-msg--user {
  flex-direction: row-reverse;
}
.ai-chat-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.ai-chat-msg--ai .ai-chat-avatar {
  background: var(--color-primary);
  color: var(--color-white);
}
.ai-chat-msg--user .ai-chat-avatar {
  background: var(--gray-200);
  color: var(--text-default);
}
.ai-chat-bubble {
  max-width: 78%;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.75;
  word-break: break-word;
}
.ai-chat-msg--ai .ai-chat-bubble {
  background: var(--bg-subtle);
  border: 1px solid var(--border-muted);
  color: var(--text-default);
}
.ai-chat-msg--user .ai-chat-bubble {
  background: var(--color-primary);
  color: var(--color-white);
  border: 1px solid var(--color-primary);
}

/* Condition / refine input forms inside ai-chat-input-area */
.ai-chat-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 560px;
  margin: 0 auto;
}
.ai-chat-form-title {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 2px;
}
.ai-chat-form-grid {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px 12px;
  align-items: center;
}
.ai-chat-form-grid label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.ai-chat-form-grid label.align-start {
  align-self: start;
  padding-top: 8px;
}
.ai-chat-form-grid input[type="text"],
.ai-chat-form-grid textarea,
.ai-chat-form textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg-default);
  font-family: inherit;
  color: var(--text-default);
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
}
.ai-chat-form-grid textarea,
.ai-chat-form textarea {
  resize: vertical;
  line-height: 1.6;
}
.ai-chat-form-grid input[type="text"]:focus,
.ai-chat-form-grid textarea:focus,
.ai-chat-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-alpha-light);
}
.ai-chat-form-hint {
  font-size: 11px;
  color: var(--text-muted-lighter);
  text-align: center;
}
.ai-chat-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* Scoring progress bar inside ai-chat */
.ai-scoring-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.ai-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes ai-spin {
  to { transform: rotate(360deg); }
}
.ai-scoring-barwrap {
  margin-top: 10px;
}
.ai-scoring-bartrack {
  width: 100%;
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}
.ai-scoring-barfill {
  width: 5%;
  height: 100%;
  background: var(--color-primary);
  border-radius: 3px;
  transition: width 0.5s var(--ease);
}
.ai-scoring-pct {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Save-result form inside ai-chat */
.ai-chat-save-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: stretch;
  max-width: 520px;
  margin: 0 auto;
}
.ai-chat-save-form hr {
  border: none;
  border-top: 1px solid var(--border-muted);
  margin: 2px 0;
}
.ai-chat-count-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-muted);
}
.ai-chat-count-row input[type="number"] {
  width: 110px;
  height: 34px;
  padding: 0 12px;
  text-align: center;
  font-size: 14px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  background: var(--bg-default);
  color: var(--text-default);
}
.ai-chat-group-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-chat-radio-row {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-wrap: wrap;
}
.ai-chat-radio-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-default);
}
.ai-chat-sublabel {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: 4px;
}
.ai-chat-inline-input {
  flex: 1;
  min-width: 160px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-default);
  color: var(--text-default);
}
.ai-chat-subnote {
  font-size: 12px;
  color: var(--text-muted);
}

@keyframes aiPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

@media (max-width: 640px) {
  .ai-chat-bubble { max-width: 90%; }
  .ai-chat-form-grid { grid-template-columns: 1fr; }
  .ai-chat-form-grid label { text-align: left; }
}
