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

:root {
  --sidebar-w: 200px;
  --sidebar-bg: #1C1C1E;
  --sidebar-text: #EBEBF5;
  --sidebar-muted: #8E8E93;
  --sidebar-active: #0071E3;
  --bg: #F0F2F5;
  --card-bg: #FFFFFF;
  --border: #E5E7EB;
  --text: #1D1D1F;
  --text-muted: #6B7280;
  --primary: #0071E3;
  --primary-hover: #0063C6;
  --danger: #EF4444;
  --danger-hover: #DC2626;
  --success: #10B981;
  --warn: #F59E0B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100vh; }

/* ── サイドバー ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 20px;
}

.app-logo {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: white;
  flex-shrink: 0;
}

.app-title { font-size: 12px; color: var(--sidebar-muted); line-height: 1.3; }

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 8px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--sidebar-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}

.nav-item:hover { background: rgba(255,255,255,0.08); color: var(--sidebar-text); }
.nav-item.active { background: var(--primary); color: white; }

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.nav-icon svg { width: 18px; height: 18px; }

/* ── サイドバーフッター ── */
.sidebar-footer {
  padding: 12px 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.user-info { margin-bottom: 10px; }
.user-name { font-size: 12px; color: var(--sidebar-text); font-weight: 500; }

.sidebar-links { display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  background: transparent;
  border: none;
  color: var(--sidebar-muted);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: none;
  transition: color 0.15s;
}
.sidebar-link:hover { color: var(--sidebar-text); }
.logout-btn { color: #FF6B6B; }
.logout-btn:hover { color: #FF4444; }

/* ── メインコンテンツ ── */
.content { flex: 1; overflow-y: auto; padding: 28px 32px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── ページヘッダー ── */
.page-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px;
}
.page-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.3px; }
.header-actions { display: flex; gap: 8px; }

/* ── カード ── */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 14px; font-weight: 600; }
.card-body { padding: 18px; }
.log-card { display: flex; flex-direction: column; }

/* ── 統計カード ── */
.stats-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 24px; min-width: 160px;
}
.stat-card-sm { min-width: 110px; padding: 14px 18px; }
.stat-card-done .stat-value { color: var(--success); }
.stat-card-total .stat-value { color: var(--primary); }
.stat-value { font-size: 36px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card-sm .stat-value { font-size: 28px; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── ボタン ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 8px 16px; border-radius: 8px; border: none;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 0.15s, opacity 0.15s; white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #0EA271; }
.btn-warning { background: #F59E0B; color: white; }
.btn-warning:hover:not(:disabled) { background: #D97706; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover:not(:disabled) { background: var(--bg); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger); }
.btn-danger-outline:hover { background: #FEF2F2; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; font-weight: 600; }
.hidden { display: none !important; }

/* ── フォーム ── */
.form-body { display: flex; flex-direction: column; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-row { display: flex; gap: 20px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
.input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; color: var(--text); background: white;
  transition: border-color 0.15s; outline: none;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,113,227,0.12); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236B7280'%3E%3Cpath fill-rule='evenodd' d='M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z' clip-rule='evenodd'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; cursor: pointer; }
.help-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.input-wrap { display: flex; position: relative; }
.input-wrap .input { flex: 1; padding-right: 60px; }
.toggle-pw-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; color: var(--primary);
  font-size: 12px; cursor: pointer; font-weight: 500;
}

/* ── ダッシュボード ── */
.control-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.control-label { font-size: 14px; font-weight: 500; min-width: 60px; }
.control-input-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.unit { color: var(--text-muted); }
.progress-section { margin-top: 16px; }
.progress-bar-wrap { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; margin-bottom: 6px; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width 0.4s ease; }
.progress-text { font-size: 13px; color: var(--text-muted); }

/* ── ログ ── */
.log-area {
  height: 280px; overflow-y: auto; padding: 12px 16px;
  font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
  font-size: 12px; line-height: 1.7; background: #0D0D0D; color: #C8C8C8;
}
.log-line { display: block; word-break: break-all; }
.log-line.error { color: #FF6B6B; }
.log-line.warn { color: #FFC857; }
.log-line.success { color: #6BCB77; }

/* ── パターンタブ ── */
.pattern-tab-bar { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.pattern-tab {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border);
  background: white; font-size: 13px; font-weight: 500; cursor: pointer;
  color: var(--text-muted); transition: all 0.15s;
}
.pattern-tab:hover { border-color: var(--primary); color: var(--primary); }
.pattern-tab.active { background: var(--primary); color: white; border-color: var(--primary); }
.pattern-tab.has-content { color: var(--text); }
.pattern-tab.active.has-content { color: white; }
.pattern-form { display: none; flex-direction: column; gap: 16px; }
.pattern-form.active { display: flex; }
.pattern-form textarea {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; font-family: inherit; resize: vertical; min-height: 100px;
  outline: none; transition: border-color 0.15s; line-height: 1.6;
}
.pattern-form textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,113,227,0.12); }

/* ── アクション行 ── */
.action-row { display: flex; align-items: center; gap: 12px; margin-top: 4px; margin-bottom: 20px; }
.save-msg { font-size: 13px; color: var(--success); font-weight: 500; }

/* ── 地域管理 ── */
.add-loc-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.add-loc-form .select { min-width: 160px; }
.add-loc-form .input[type="text"] { flex: 1; min-width: 180px; }
.filter-row { display: flex; gap: 6px; margin-bottom: 12px; }
.filter-btn {
  padding: 5px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: white; font-size: 12px; cursor: pointer; color: var(--text-muted); transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--primary); color: var(--primary); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* ── テーブル ── */
.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  padding: 10px 14px; text-align: left; font-weight: 600; font-size: 12px;
  color: var(--text-muted); background: var(--bg); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #F9FAFB; }
.empty-row { text-align: center; color: var(--text-muted); padding: 32px !important; }
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.status-badge.pending { background: #FEF3C7; color: #92400E; }
.status-badge.done { background: #D1FAE5; color: #065F46; }
.delete-btn {
  padding: 4px 10px; border-radius: 6px; border: 1px solid #FECACA;
  background: transparent; color: var(--danger); font-size: 12px; cursor: pointer; transition: background 0.15s;
}
.delete-btn:hover { background: #FEF2F2; }
.note-cell { font-size: 12px; color: var(--text-muted); }
.note-cell.note-error { color: var(--danger); font-weight: 500; }

/* ── タイトル設計 ── */
.tw-group-card { margin-bottom: 12px; }
.tw-count-badge {
  display: inline-block; padding: 3px 10px; background: var(--primary); color: white;
  border-radius: 12px; font-size: 12px; font-weight: 600;
}
.tw-preview { min-height: 60px; max-height: 240px; overflow-y: auto; }
.tw-preview-item { padding: 4px 8px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text); }
.tw-preview-item:last-child { border-bottom: none; }
.tw-preview-more { padding: 6px 8px; font-size: 12px; color: var(--text-muted); font-style: italic; }
.tw-words-input {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 13px; font-family: inherit; resize: vertical; background: white; color: var(--text); line-height: 1.6;
}
.tw-words-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(0,113,227,0.1); }
.form-group-inline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.form-group-inline .form-label { margin-bottom: 0; white-space: nowrap; }
.form-group-inline .help-text { margin-top: 0; }

/* ── 求人文章 - 画像エリア ── */
.pattern-image-area { margin-top: 4px; }
.pattern-img-wrap { display: flex; align-items: flex-start; gap: 12px; }
.pattern-img-preview { width: 160px; height: 110px; object-fit: cover; border-radius: var(--radius); border: 1px solid var(--border); }
.pattern-img-actions { display: flex; flex-direction: column; gap: 8px; }
.pattern-img-empty {
  display: flex; align-items: center; gap: 8px; width: 160px; height: 110px;
  border: 2px dashed var(--border); border-radius: var(--radius);
  justify-content: center; flex-direction: column; font-size: 12px; color: var(--text-muted);
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.pattern-img-empty:hover { border-color: var(--primary); background: rgba(0,113,227,0.04); color: var(--primary); }
.pattern-img-empty-icon { font-size: 22px; line-height: 1; }

/* ── 地域テーブル ── */
.title-cell { max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; color: var(--text-muted); }
.btn-danger-text { color: var(--danger) !important; }
.btn-danger-text:hover { background: rgba(239,68,68,0.06) !important; }
.empty-text { color: var(--text-muted); font-size: 13px; padding: 8px 0; }

/* ── パターンタブ 動的操作 ── */
.pattern-tab-wrap { position: relative; display: inline-flex; }
.pattern-tab-del {
  position: absolute; top: -6px; right: -6px; width: 18px; height: 18px;
  border-radius: 50%; background: var(--danger); color: white; border: none;
  font-size: 11px; line-height: 1; cursor: pointer; display: none;
  align-items: center; justify-content: center; padding: 0; z-index: 1;
}
.pattern-tab-wrap:hover .pattern-tab-del { display: flex; }
.pattern-tab-add {
  display: inline-flex; align-items: center; padding: 6px 12px;
  border: 1px dashed var(--border); border-radius: 6px; background: transparent;
  color: var(--text-muted); font-size: 13px; cursor: pointer; transition: all 0.15s;
}
.pattern-tab-add:hover { border-color: var(--primary); color: var(--primary); background: rgba(0,113,227,0.04); }
.pattern-form-header { display: flex; justify-content: flex-end; margin-bottom: 8px; }

/* ============================================================
   ガイド
   ============================================================ */
.guide-toc { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px 16px; }
.guide-toc-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 12px 5px 6px;
  background: white; border: 1px solid var(--border); border-radius: 20px;
  font-size: 12px; color: var(--text); cursor: pointer; text-decoration: none; transition: all 0.15s;
}
.guide-toc-item:hover { background: #EFF6FF; border-color: var(--primary); color: var(--primary); }
.guide-toc-num {
  width: 20px; height: 20px; background: var(--primary); color: white; border-radius: 50%;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.guide-section {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: visible;
}
.guide-section:last-child { margin-bottom: 0; }
.guide-h2 {
  display: flex; align-items: center; gap: 10px; padding: 13px 20px;
  background: #F4F7FF; border-bottom: 2px solid var(--primary);
  border-radius: var(--radius) var(--radius) 0 0; font-size: 15px; font-weight: 700; color: var(--text);
}
.guide-h2-num {
  width: 26px; height: 26px; background: var(--primary); color: white; border-radius: 6px;
  font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.guide-h3 {
  font-size: 12px; font-weight: 700; color: var(--primary);
  letter-spacing: 0.6px; text-transform: uppercase; padding: 16px 20px 8px;
}
.guide-body { padding: 14px 20px; }
.guide-body p { line-height: 1.75; color: var(--text); }
.guide-table-wrap { padding: 4px 20px 16px; overflow-x: auto; }
.guide-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  border-radius: 8px; overflow: hidden; border: 1px solid var(--border);
}
.guide-table th {
  background: #F9FAFB; padding: 9px 14px; text-align: left;
  font-weight: 600; font-size: 12px; border-bottom: 1px solid var(--border); color: var(--text-muted);
}
.guide-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  line-height: 1.65; vertical-align: top; color: var(--text);
}
.guide-table tr:last-child td { border-bottom: none; }
.guide-table td:first-child { font-weight: 500; white-space: nowrap; }
.guide-table code {
  background: #F3F4F6; border-radius: 4px; padding: 1px 5px;
  font-size: 12px; font-family: 'SF Mono', Menlo, monospace; color: var(--text);
}
.guide-steps { padding: 4px 20px 16px; }
.guide-step { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid #F3F4F6; }
.guide-step:last-child { border-bottom: none; }
.guide-step-num {
  width: 22px; height: 22px; background: var(--primary); color: white; border-radius: 50%;
  font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}
.guide-step-body { flex: 1; line-height: 1.7; font-size: 13px; }
.guide-step-body strong { font-weight: 600; }
.guide-callout {
  margin: 0 20px 16px; padding: 11px 14px; border-radius: 8px; font-size: 13px;
  line-height: 1.7; display: flex; gap: 8px; align-items: flex-start;
}
.guide-callout-tip { background: #EFF6FF; border: 1px solid #BFDBFE; color: #1E40AF; }
.guide-callout-warn { background: #FFFBEB; border: 1px solid #FDE68A; color: #92400E; }
.guide-callout-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.guide-badge-draft { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; background: var(--primary); color: white; font-size: 12px; font-weight: 600; }
.guide-badge-publish { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 4px; background: var(--success); color: white; font-size: 12px; font-weight: 600; }
