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

:root {
  --bg-primary: #0b0f19;
  --bg-secondary: rgba(17, 24, 39, 0.7);
  --bg-tertiary: rgba(31, 41, 55, 0.5);
  
  --border-color: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.15);
  
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  
  --accent-primary: #3b82f6;      /* Blue */
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #10b981 100%);
  --accent-glow: 0 0 20px rgba(59, 130, 246, 0.15);
  
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;

  --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --font-title: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
  overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Typography */
h1, h2, h3, h4 {
  font-family: var(--font-title);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.gradient-text {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Layout */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 2rem;
  max-width: 1600px;
  margin: 0 auto;
  gap: 2rem;
}

/* Document pages (privacy policy, help/manual) — narrower, readable prose
   column reusing the app's dark/glass look instead of the wide dashboard grid. */
.doc-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.doc-back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.9rem;
  text-decoration: none;
  margin-bottom: 1.5rem;
  transition: color 0.2s ease;
}

.doc-back-link:hover {
  color: var(--text-primary);
}

.doc-header h1 {
  font-size: 1.75rem;
  margin-bottom: 0.5rem;
}

.doc-updated {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 2rem;
}

.doc-content h2 {
  font-size: 1.15rem;
  margin: 2rem 0 0.75rem;
  color: var(--text-primary);
}

.doc-content h2:first-child {
  margin-top: 0;
}

.doc-content h3 {
  font-size: 1rem;
  margin: 1.25rem 0 0.5rem;
  color: var(--text-primary);
}

.doc-content p {
  color: var(--text-secondary);
  line-height: 1.75;
  margin-bottom: 0.85rem;
}

.doc-content ul, .doc-content ol {
  color: var(--text-secondary);
  line-height: 1.75;
  margin: 0 0 0.85rem 1.4rem;
}

.doc-content li {
  margin-bottom: 0.35rem;
}

.doc-content strong {
  color: var(--text-primary);
}

.doc-content a {
  color: var(--accent-primary);
}

.doc-content code {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.85em;
}

.doc-footer-nav {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

/* App footer (index.html) — links to the help/privacy pages so they're
   reachable from the app itself, not just directly by URL (also required
   for Google OAuth verification: the privacy policy must be linked in-app). */
.app-footer {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.app-footer a {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-decoration: none;
  transition: color 0.2s ease;
}

.app-footer a:hover {
  color: var(--text-secondary);
}

header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}

.header-title-container {
  flex: 1 1 auto;
  min-width: 280px;
}

.header-title-container h1 {
  font-size: 2.25rem;
  margin-bottom: 0.25rem;
}

.header-title-container p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.app-about {
  margin-top: 0.6rem;
  max-width: 720px;
  font-size: 0.82rem !important;
  line-height: 1.6;
  color: var(--text-muted) !important;
}

.app-about code {
  background: var(--bg-tertiary);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.app-about a {
  color: var(--accent-primary);
}

/* Drop Zone / Upload Area */
.upload-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 2px dashed var(--border-color);
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 3rem 2rem;
  text-align: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(12px);
  margin-bottom: 1rem;
}

.upload-wrapper.dragover {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: var(--accent-glow);
  transform: scale(1.01);
}

.upload-icon {
  width: 64px;
  height: 64px;
  color: var(--accent-primary);
  margin-bottom: 1.5rem;
  transition: transform 0.3s ease;
}

.upload-wrapper:hover .upload-icon {
  transform: translateY(-5px);
}

.upload-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.upload-subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  max-width: 500px;
  line-height: 1.6;
}

.upload-btn {
  background: var(--accent-gradient);
  color: #fff;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 8px;
  font-family: var(--font-title);
  font-weight: 500;
  cursor: pointer;
  font-size: 0.95rem;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
  transition: all 0.2s ease;
}

.upload-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

/* Help Guide Link (prominent, for first-time visitors) */
.help-guide-container {
  margin-top: 1.25rem;
}

.help-guide-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.35);
  color: var(--accent-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.help-guide-btn i {
  width: 14px;
  height: 14px;
}

.help-guide-btn:hover {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--accent-primary);
}

/* Takeout Link */
.takeout-link-container {
  margin-top: 1rem;
}

.takeout-link-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-decoration: none;
  border-bottom: 1px dashed var(--border-color);
  padding-bottom: 2px;
  transition: all 0.2s ease;
}

.takeout-link-btn i {
  width: 14px;
  height: 14px;
}

.takeout-link-btn:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-hover);
}

/* Sample Data Trigger */
.sample-trigger-container {
  margin-top: 1rem;
}

.sample-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sample-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.manual-add-trigger-container {
  margin-top: 1rem;
}

/* Dashboard Layout (Grid) */
.dashboard-grid {
  display: none;
  flex-direction: column;
  gap: 2rem;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.dashboard-grid.visible {
  opacity: 1;
  transform: translateY(0);
}

/* showDashboard() sets style.display="grid" on this element at runtime
   (overriding the display:none above), making it a single-column implicit
   grid — so its direct children are grid items whose default min-width:auto
   pins them to their content's max-content size. That let the filter row
   (search + 5 dropdowns + date range) push .table-card past the page edge,
   silently clipped by body's overflow-x:hidden with no way to scroll to it
   (reported: 操作 column unreachable, no horizontal scrollbar). */
.dashboard-grid > * {
  min-width: 0;
}

/* Bottom Grid for Map & Charts */
.bottom-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
}

@media (max-width: 1024px) {
  .bottom-grid {
    grid-template-columns: 1fr;
  }
}

/* Stats Row */
.stats-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
}

.stat-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  transition: border-color 0.3s ease;
}

.stat-card:hover {
  border-color: var(--border-hover);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card:nth-child(2) .stat-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
}

.stat-card:nth-child(3) .stat-icon {
  background: rgba(6, 182, 212, 0.1);
  color: var(--info);
}

.stat-card:nth-child(4) .stat-icon {
  background: rgba(139, 92, 246, 0.1);
  color: #8b5cf6;
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--font-title);
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.15rem;
}

/* Glass Card */
.glass-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-title {
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  white-space: nowrap;
}

/* カテゴリー比率チャートの集計軸トグル（Google連動 / マイカテゴリー） */
.cat-axis-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}

.cat-axis-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cat-axis-toggle-btn:hover {
  color: var(--text-primary);
}

.cat-axis-toggle-btn.active {
  background: var(--accent-primary);
  color: #fff;
}

/* Filters Component */
.filter-row {
  display: flex;
  /* Without this, a flex item's default min-width:auto keeps it at its
     unwrapped max-content size, so flex-wrap below never actually gets a
     chance to kick in — the row (and everything containing it) just grows
     past the page instead, silently clipped by body's overflow-x:hidden
     with no way to scroll to it (reported: 操作 column unreachable). */
  min-width: 0;
  gap: 1rem;
  flex-wrap: wrap;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 1rem 0.65rem 2.5rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.search-icon {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.select-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.65rem 2rem 0.65rem 1rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.9rem;
  min-width: 150px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
}

.select-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

/* 最終更新日の期間フィルター */
.date-range-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-input {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  cursor: pointer;
  color-scheme: dark;
}

.date-input:focus {
  border-color: var(--accent-primary);
  outline: none;
}

.date-range-sep {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Actions Menu */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
}

.action-buttons a.btn {
  text-decoration: none;
}

/* Google Drive Sync */
.drive-sync {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.drive-sync-status {
  font-size: 0.8rem;
  color: var(--text-secondary);
  max-width: 260px;
  line-height: 1.4;
}

.drive-sync-status.is-error {
  color: #ef4444;
}

.unsaved-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  white-space: nowrap;
}

/* Local offline cache toggle (Phase 3) */
.local-cache-toggle-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.local-cache-toggle-switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
}

.local-cache-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.local-cache-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  transition: background 0.2s ease;
}

.local-cache-toggle-slider::before {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: 2px;
  top: 2px;
  background: var(--text-secondary);
  border-radius: 50%;
  transition: transform 0.2s ease, background 0.2s ease;
}

.local-cache-toggle-switch input:checked + .local-cache-toggle-slider {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}

.local-cache-toggle-switch input:checked + .local-cache-toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}

.local-cache-toggle-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.6rem 1.25rem;
  border-radius: 8px;
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn:hover {
  border-color: var(--border-hover);
  background: rgba(255, 255, 255, 0.05);
}

.btn-primary {
  background: var(--accent-primary);
  border: none;
}

.btn-primary:hover {
  background: #2563eb;
}

/* Map Container */
#map {
  height: 280px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #111;
  z-index: 1; /* Leaflet layering fix */
}

/* Leaflet Custom Styles */
.leaflet-container {
  font-family: var(--font-body) !important;
}

.leaflet-popup-content-wrapper {
  background: rgba(15, 23, 42, 0.95) !important;
  backdrop-filter: blur(8px);
  color: var(--text-primary) !important;
  border: 1px solid var(--border-color);
  border-radius: 8px !important;
  padding: 0.25rem;
}

.leaflet-popup-tip {
  background: rgba(15, 23, 42, 0.95) !important;
  border: 1px solid var(--border-color);
}

.map-popup-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-size: 0.85rem;
  max-width: 220px;
}

.map-popup-header {
  font-weight: 600;
  font-family: var(--font-title);
  color: #fff;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.25rem;
}

.map-popup-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

.tag {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 500;
}

.tag-prefecture {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.tag-category {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.map-popup-comment {
  color: var(--text-secondary);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-popup-link {
  color: var(--accent-primary);
  text-decoration: none;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.map-popup-link:hover {
  text-decoration: underline;
}

/* Charts Card Layout */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.chart-container {
  position: relative;
  height: 320px;
  width: 100%;
}

/* Table Card Layout */
.table-card {
  min-height: 400px;
}

.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  max-height: 550px;
  overflow-y: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

thead {
  /* Fully opaque — this sticks over scrolling rows, so any transparency
     lets the row underneath show through it (reported: table data visible
     bleeding through the header while scrolling). */
  background: rgb(17, 24, 39);
  position: sticky;
  top: 0;
  z-index: 2;
}

th {
  padding: 1rem;
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
}

th:hover {
  color: var(--text-primary);
}

td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.col-name {
  font-weight: 500;
  min-width: 180px;
  max-width: 280px;
}

.col-pref {
  min-width: 140px;
  width: 140px;
}

.col-cat {
  min-width: 170px;
  width: 170px;
}

.col-my-cat {
  min-width: 170px;
  width: 170px;
}

.google-cat-label {
  font-size: 0.85rem;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.col-address {
  color: var(--text-secondary);
  min-width: 200px;
  max-width: 320px;
  font-size: 0.85rem;
}

/* Horizontally scrollable cell container */
.cell-scrollable {
  white-space: nowrap;
  overflow-x: auto;
  max-width: 100%;
  scrollbar-width: thin;
}

.cell-scrollable::-webkit-scrollbar {
  height: 4px;
}

.cell-scrollable::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.cell-scrollable::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

.rating-stars {
  color: var(--warning);
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}

/* Edit Form Elements inside Table */
.editable-select {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid transparent;
  color: var(--text-primary);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
}

.editable-select:hover {
  border-color: var(--border-color);
}

.editable-select:focus {
  border-color: var(--accent-primary);
  outline: none;
  background: var(--bg-tertiary);
}

/* マイ都道府県/マイカテゴリーで手動上書き中のセルを視覚的に区別する */
.editable-select.has-override {
  border-left: 3px solid var(--accent-primary);
}

.cat-cell-inner {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.cat-cell-inner .editable-select {
  flex: 1;
  min-width: 0;
}

/* Geminiなどから取得した生の業種ラベルがあることを示す目印。
   常時見えるアイコン＋ホバーで実際のラベルをtitleツールチップ表示する。 */
.google-cat-raw-badge {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--accent-primary);
  cursor: help;
}

/* List empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.empty-state h3 {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
  color: var(--text-primary);
}

/* Link Actions */
.maps-link-btn {
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.maps-link-btn:hover {
  color: var(--accent-primary);
}

/* Detail Review inside table */
.review-text-cell {
  font-size: 0.85rem;
  color: var(--text-secondary);
  min-width: 200px;
  max-width: 320px;
}

/* Loading Overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 25, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(59, 130, 246, 0.1);
  border-radius: 50%;
  border-top-color: var(--accent-primary);
  animation: spin 1s ease-in-out infinite;
  margin-bottom: 1.5rem;
}

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

.loading-text {
  font-family: var(--font-title);
  font-size: 1.25rem;
  font-weight: 500;
  color: #fff;
  margin-bottom: 0.5rem;
}

.loading-progress {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Category Settings Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  padding: 1rem;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.modal-desc {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.5;
}

.add-category-form {
  display: flex;
  gap: 0.5rem;
}

.add-category-form .search-input {
  padding-left: 1rem;
}

.add-category-form input[type="color"] {
  width: 44px;
  height: 42px;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  cursor: pointer;
  flex-shrink: 0;
}

.custom-category-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.custom-category-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
  padding: 1rem 0;
}

.custom-category-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
}

.custom-category-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.custom-category-name {
  flex: 1;
  font-size: 0.9rem;
}

.custom-category-count {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.custom-category-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.custom-category-delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.custom-category-edit {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.custom-category-edit:hover {
  color: var(--accent-primary);
  background: rgba(99, 102, 241, 0.1);
}

.custom-category-item-editing {
  gap: 0.5rem;
}

.custom-category-edit-color {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-tertiary);
  cursor: pointer;
  flex-shrink: 0;
}

.custom-category-edit-name {
  flex: 1;
  padding: 0.5rem 0.7rem;
  font-size: 0.85rem;
}

.custom-category-save,
.custom-category-cancel {
  padding: 0.4rem 0.7rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

/* Manual Add (クチコミを手動で追加) Modal */
.manual-add-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.manual-add-form .search-input {
  padding-left: 1rem;
}

.manual-add-row {
  display: flex;
  gap: 0.75rem;
}

.manual-add-row .select-input,
.manual-add-row .date-input {
  flex: 1;
}

.manual-add-textarea {
  resize: vertical;
  min-height: 70px;
  font-family: var(--font-body);
  line-height: 1.5;
}

.modal-divider {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 0;
}

.manual-csv-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.manual-csv-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Gemini連携カテゴリー取得 Modal */
.gemini-cat-status {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.gemini-cat-step {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.gemini-cat-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.gemini-cat-textarea {
  resize: vertical;
  min-height: 90px;
  font-family: var(--font-mono, monospace);
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 0.75rem 1rem;
}

/* Used where the textarea is only copied into/pasted from (a copy button
   handles reading the prompt, and the response is just pasted in) — shrink it
   so the 適用結果 list below gets more of the modal's vertical space. */
.gemini-cat-textarea-compact {
  min-height: 60px;
}

.gemini-cat-result-list {
  max-height: 220px;
  overflow-y: auto;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.gemini-cat-result-list-large {
  max-height: 420px;
}

.gemini-cat-result-list:empty {
  display: none;
  border: none;
  padding: 0;
}

.gemini-cat-result-heading {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0 0 0.5rem;
}

.gemini-cat-result-list ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
}

/* スポット情報のGemini検索（手動追加の補助）
   .modal-card自体が既にスクロールするので、ここでは独自のスクロール領域は
   持たせない（入れ子のスクロールコンテナはクリック判定が不安定になるため）。 */
.place-lookup-result-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.place-lookup-result-list:empty {
  display: none;
}

.place-lookup-query-block {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.85rem 1rem;
}

.place-lookup-query-header {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.6rem;
}

.place-lookup-empty {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.place-lookup-candidate {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-top: 1px solid var(--border-color);
}

.place-lookup-candidate:first-of-type {
  border-top: none;
}

.place-lookup-candidate-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.place-lookup-candidate-info strong {
  color: var(--text-primary);
  font-size: 0.85rem;
}

.place-lookup-candidate-warning {
  color: #f59e0b;
}

.place-lookup-candidate .btn {
  flex-shrink: 0;
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.place-lookup-candidate-rating {
  flex-shrink: 0;
  width: auto;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.place-lookup-added-msg {
  font-size: 0.85rem;
  color: #10b981;
}

.unknown-spot-select-all {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  cursor: pointer;
}

.unknown-spot-list {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.unknown-spot-item {
  display: block;
  padding: 0.6rem 0.85rem;
  border-top: 1px solid var(--border-color);
  cursor: pointer;
}

.unknown-spot-item:first-child {
  border-top: none;
}

.unknown-spot-item label {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  cursor: pointer;
}

.unknown-spot-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.unknown-spot-item-info strong {
  color: var(--text-primary);
  font-size: 0.85rem;
  font-weight: 500;
}

.unknown-spot-empty {
  padding: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.unknown-spot-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.deleted-spots-badge {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.deleted-spot-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.deleted-spot-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

.deleted-spot-item-actions .btn {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
  
  .column-side {
    position: static;
    height: auto;
  }
}

@media (max-width: 768px) {
  .stats-container {
    grid-template-columns: 1fr;
  }

  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  /* Places table -> stacked cards. 8 columns don't fit a phone screen,
     so each row becomes a bordered card with label/value pairs instead
     of relying on horizontal scroll. */
  .table-wrapper {
    overflow-x: visible;
    max-height: none;
    border: none;
    background: transparent;
  }

  table, tbody {
    display: block;
    width: 100%;
  }

  thead {
    display: none;
  }

  tr {
    display: block;
    margin-bottom: 0.75rem;
    padding: 0.85rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-tertiary);
  }

  td {
    display: block;
    padding: 0.4rem 0;
    border-bottom: none;
    max-width: none;
    min-width: 0;
    width: 100%;
  }

  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
  }

  .col-name {
    font-size: 1.05rem;
    font-weight: 600;
    padding-bottom: 0.6rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--border-color);
  }

  .col-name::before {
    content: none;
  }

  .col-actions > div {
    justify-content: flex-end;
  }

  .cell-scrollable {
    white-space: normal;
    overflow-x: visible;
  }
}
