/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #ffffff;
  --bg-light: #f7f8fa;
  --bg-hover: #f0f1f3;
  --border: #e0e2e6;
  --text: #1a1a1a;
  --text-muted: #6b7280;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --yellow: #ca8a04;
  --yellow-bg: #fef9c3;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --blue-bg: #dbeafe;
  --radius: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg-light);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* === Login === */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-light);
}
.login-box {
  background: var(--bg);
  padding: 40px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  text-align: center;
  width: 360px;
}
.login-box h1 { font-size: 24px; margin-bottom: 8px; }
.login-box p { color: var(--text-muted); margin-bottom: 24px; }
.login-box input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  margin-bottom: 12px;
}
.login-box button {
  width: 100%;
  padding: 10px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
}
.login-box button:hover { background: var(--primary-hover); }
.error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* === App Shell === */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 52px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-title { font-size: 18px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.logged-in-badge {
  font-size: 12px;
  color: var(--green);
  background: var(--green-bg);
  padding: 2px 8px;
  border-radius: 12px;
}

.app-body { display: flex; flex: 1; }

/* === Sidebar === */
.sidebar {
  width: 200px;
  background: var(--bg);
  border-right: 1px solid var(--border);
  padding: 16px 0;
  flex-shrink: 0;
}
.nav-link {
  display: block;
  padding: 10px 20px;
  color: var(--text);
  font-size: 14px;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-link:hover { background: var(--bg-hover); text-decoration: none; }
.nav-link.active {
  background: var(--blue-bg);
  border-left-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

/* === Content === */
.content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  max-width: 1200px;
}

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--red); color: white; border-color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  padding: 4px;
}
.btn-link:hover { text-decoration: underline; }

/* === Cards === */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card .value { font-size: 28px; font-weight: 700; margin-top: 4px; }

/* === Tables === */
.table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--bg-hover); }
tbody tr:last-child td { border-bottom: none; }

/* Row color coding */
tr.row-signed { background: var(--green-bg); }
tr.row-signed:hover { background: #bbf7d0; }
tr.row-followup { background: var(--yellow-bg); }
tr.row-followup:hover { background: #fef08a; }
tr.row-ignore { background: var(--red-bg); }
tr.row-ignore:hover { background: #fecaca; }

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-blue { background: var(--blue-bg); color: var(--primary); }
.badge-gray { background: var(--bg-light); color: var(--text-muted); }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

/* Inline select (for status bar dropdowns) */
.inline-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  background: var(--bg);
  cursor: pointer;
}

/* === Filters Bar === */
.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.filters-bar input,
.filters-bar select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.filters-bar input[type="text"] { width: 180px; }
.filters-bar label {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* === Clickable table rows === */
.clickable-row { cursor: pointer; }

/* === Contact bar === */
.contact-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding: 14px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.contact-bar-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.contact-bar-item .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  font-weight: 600;
}
.contact-bar-item a { font-weight: 600; }

/* === Park Detail === */
.detail-header {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.detail-header h1 { font-size: 22px; margin-bottom: 4px; }
.detail-header .subtitle { color: var(--text-muted); font-size: 14px; }
.detail-header .contact-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 12px;
  font-size: 13px;
}
.detail-header .contact-row span { color: var(--text-muted); }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

/* Two-column layout for park detail */
.detail-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
  align-items: start;
}
.detail-col-left, .detail-col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Contact bar labels for dual-source */
.contact-bar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
  width: 100%;
  margin-bottom: -8px;
}
.contact-bar-research {
  margin-top: -8px;
  background: var(--blue-bg);
  border-color: #bfdbfe;
}

/* Read-only display grid */
.readonly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
}
.readonly-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}
.readonly-item .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  font-weight: 600;
}

/* Save status inline messages */
.save-status {
  font-size: 12px;
  margin-left: 8px;
}
.save-ok { color: var(--green); }
.save-error { color: var(--red); }

.detail-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.detail-section h3 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.detail-section.full-width {
  grid-column: 1 / -1;
}

/* Status bar */
.status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 12px 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
}
.status-item { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.status-item .label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; }

/* Stars */
.stars { display: inline-flex; gap: 2px; cursor: pointer; }
.stars .star { color: var(--border); font-size: 18px; }
.stars .star.filled { color: #f59e0b; }

/* Research panel indicators */
.indicator-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 8px;
}
.indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 8px;
  border-radius: var(--radius);
  background: var(--bg-light);
}
.indicator .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-gray { background: #d1d5db; }

/* Digital score badge */
.digital-score {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 16px;
  color: white;
}
.score-high { background: var(--green); }
.score-mid { background: var(--yellow); }
.score-low { background: var(--red); }

/* Notes list */
.note-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 12px;
}
.note-body { font-size: 13px; color: var(--text); white-space: pre-wrap; }

/* Email list */
.email-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.email-item:last-child { border-bottom: none; }
.email-subject { font-weight: 600; font-size: 13px; }
.email-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--bg);
  border-radius: 8px;
  padding: 24px;
  width: 560px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.15);
}
.modal h2 { font-size: 18px; margin-bottom: 16px; }
.modal .email-preview {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  white-space: pre-wrap;
  font-size: 13px;
  max-height: 300px;
  overflow-y: auto;
}

/* Suggested opener */
.suggested-opener {
  background: var(--yellow-bg);
  border: 1px solid #fde68a;
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--yellow);
  margin-top: 4px;
}

/* Quick log inline form */
.quick-log-form {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px;
  padding: 12px;
  background: var(--bg-light);
  border-radius: var(--radius);
}
.quick-log-form select,
.quick-log-form textarea {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
}
.quick-log-form textarea { flex: 1; min-height: 36px; resize: none; }

/* === Utility === */
.page-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.empty-state {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}
.loading { text-align: center; padding: 40px; color: var(--text-muted); }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.mb-16 { margin-bottom: 16px; }
.mt-12 { margin-top: 12px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }

/* Checkbox row */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.checkbox-row input[type="checkbox"] { width: auto; }
.checkbox-row input[type="date"] { width: auto; padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; }

/* === Preset pill buttons === */
.preset-group { display: flex; gap: 4px; }
.preset-pill {
  border-radius: 16px;
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.preset-active {
  background: var(--primary) !important;
  color: white !important;
  border-color: var(--primary) !important;
}

/* === Summary bar === */
.summary-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
}

/* === Row left-border color coding === */
.row-indicator {
  width: 4px;
  padding: 0 !important;
  border-bottom: none !important;
}
.border-green { background: var(--green); }
.border-yellow { background: var(--yellow); }
.border-red { background: var(--red); }
.border-orange { background: #ea580c; }

/* === Color-coded due dates === */
.due-date {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 600;
}
.due-overdue { background: var(--red-bg); color: var(--red); }
.due-today { background: var(--yellow-bg); color: var(--yellow); }
.due-upcoming { background: var(--green-bg); color: var(--green); }

/* === Expanded email body in table === */
.email-body-preview {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  white-space: pre-wrap;
  font-size: 13px;
  max-height: 300px;
  overflow-y: auto;
}
.email-expand td { padding: 0 12px 12px 12px; }

/* === Research preview === */
.research-preview {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 8px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .sidebar { width: 160px; }
  .content { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid-2col { grid-template-columns: 1fr; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .filters-bar { flex-direction: column; align-items: stretch; }
}
