:root {
  --bg: #f6f4ee;
  --card-bg: #fffefb;
  --text: #182420;
  --text-dim: #647169;
  --border: #e3ddcd;
  --accent: #0f6b64;
  --accent-2: #189c8e;
  --danger: #c9392f;
  --success: #1a9c6a;
  --shadow: 0 1px 2px rgba(24, 36, 32, 0.05), 0 10px 28px rgba(24, 36, 32, 0.07);
  --radius: 20px;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1a1a;
    --card-bg: #102524;
    --text: #eaf3f0;
    --text-dim: #8fada5;
    --border: #1d3b38;
    --accent: #36cbbb;
    --accent-2: #7fe6d8;
    --danger: #f0685a;
    --success: #3ecf8e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
}

a { color: var(--accent); }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.app-header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.app-header .brand-icon {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.app-header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.app-header .back {
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent);
  white-space: nowrap;
}

.wrap {
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
  max-width: 640px;
  margin: 0 auto;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}

.card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.card h3 {
  margin: 0 0 10px;
  font-size: 0.9rem;
  font-weight: 650;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin: 12px 0 6px;
}

label:first-child { margin-top: 0; }

input[type="text"],
input[type="tel"],
input[type="url"],
input[type="password"],
input[type="time"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
}

textarea { min-height: 70px; resize: vertical; }

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

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

.checkbox-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
}

.checkbox-row label {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
}

.tag-pill input { width: 16px; height: 16px; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 650;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

.btn.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
}

.btn.small {
  padding: 8px 12px;
  font-size: 0.82rem;
  min-height: 36px;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 1.8rem;
  line-height: 56px;
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow);
}

.venue-card {
  position: relative;
  overflow: hidden;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 10px;
}

.venue-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.venue-link {
  display: block;
  text-decoration: none;
  color: var(--text);
}

.venue-card .name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
}

.venue-card .meta {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 3px;
}

.venue-refresh {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.venue-refresh .last-refreshed {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.venue-card .inactive-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 6px;
  padding: 1px 6px;
  margin-left: 6px;
}

.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.filter-bar select, .filter-bar input {
  flex: 1;
}

.hours-row {
  display: grid;
  grid-template-columns: 78px 1fr 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.hours-row:last-of-type { border-bottom: none; }

.hours-row .day-label {
  font-size: 0.85rem;
  font-weight: 650;
}

.hours-row .closed-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-dim);
}

.hours-row .closed-toggle input { width: 16px; height: 16px; margin: 0; }

.event-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
}

.event-card .ev-name {
  font-weight: 650;
  font-size: 0.98rem;
}

.event-card .ev-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.event-card .ev-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.empty-note {
  color: var(--text-dim);
  font-size: 0.88rem;
  padding: 6px 0;
}

.flash {
  background: color-mix(in srgb, var(--success) 15%, transparent);
  color: var(--success);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.error-box {
  background: color-mix(in srgb, var(--danger) 15%, transparent);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
}

.back-link {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
}

.back-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px;
}

.login-card .brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 0 0 20px;
}

.login-card .brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  font-family: var(--font-display);
  font-size: 1.3rem;
  margin: 0;
  text-align: center;
}

/* ===================== Refresh progress + summary modal ===================== */

.refresh-btn {
  position: relative;
}

.refresh-btn .spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0.75;
  margin-right: 2px;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

.refresh-btn.loading {
  cursor: progress;
}

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

.modal-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  inset: 0;
  z-index: 100;
  padding: 20px;
  background: rgba(10, 20, 18, 0.5);
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  width: 100%;
  max-width: 440px;
  max-height: min(80vh, 560px);
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.modal-close:hover {
  background: var(--bg);
  color: var(--text);
}

.modal-section {
  margin-bottom: 14px;
}

.modal-section h3 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 650;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.modal-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.modal-list li {
  font-size: 0.9rem;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}

.modal-list li:last-child {
  border-bottom: none;
}
