/* ============ Reset + base ============ */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #111827;
  background: #f9fafb;
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: contain;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
a { color: #1d4ed8; text-decoration: none; }

/* ============ Layout ============ */
header.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #ffffff;
  border-bottom: 0.5px solid #e5e7eb;
  position: sticky; top: 0; z-index: 50;
}
header.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 600; color: #1d4ed8; }
header.topbar .brand img { width: 28px; height: 28px; border-radius: 6px; }
header.topbar .user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #6b7280; }
header.topbar .user img { width: 28px; height: 28px; border-radius: 50%; }
header.topbar a.logout { font-size: 12px; color: #6b7280; padding: 4px 8px; border: 0.5px solid #e5e7eb; border-radius: 6px; }

main { padding: 16px; padding-bottom: 80px; max-width: 1200px; margin: 0 auto; }

/* ============ Tabs (bottom nav on mobile, top tabs on desktop) ============ */
nav.tabs {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; background: #ffffff;
  border-top: 0.5px solid #e5e7eb;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 100;
}
nav.tabs button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px;
  background: none; border: none; color: #6b7280;
  font-size: 11px; font-weight: 500;
}
nav.tabs button .icon { font-size: 20px; line-height: 1; }
nav.tabs button.active { color: #1d4ed8; }
nav.tabs button:focus-visible { outline: 2px solid #1d4ed8; outline-offset: -4px; }

@media (min-width: 768px) {
  nav.tabs {
    position: static; border-top: none; border-bottom: 0.5px solid #e5e7eb;
    background: #ffffff; padding-bottom: 0;
    max-width: 1200px; margin: 0 auto;
  }
  nav.tabs button {
    flex: 0 0 auto; flex-direction: row; gap: 8px;
    padding: 14px 20px; font-size: 14px;
  }
  nav.tabs button .icon { font-size: 18px; }
  main { padding-bottom: 16px; }
}

/* ============ Cards ============ */
.card {
  background: #ffffff;
  border: 0.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 12px;
}
.card h3 { margin: 0 0 8px 0; font-size: 14px; font-weight: 600; color: #374151; }

/* ============ Stat cards grid ============ */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
}
.stat {
  background: #ffffff;
  border: 0.5px solid #e5e7eb;
  border-radius: 12px;
  padding: 14px;
}
.stat .label { font-size: 12px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 24px; font-weight: 700; margin-top: 4px; color: #111827; }
.stat .delta { font-size: 12px; margin-top: 4px; }
.stat .delta.up { color: #16a34a; }
.stat .delta.down { color: #dc2626; }
.stat .delta.neutral { color: #6b7280; }

/* ============ Filters ============ */
.filters {
  display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px;
}
.filters select, .filters input {
  padding: 10px 12px;
  border: 0.5px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
  min-height: 44px;
}

/* ============ Charts ============ */
.chart-wrap {
  position: relative;
  height: 180px;
}
@media (min-width: 768px) {
  .chart-wrap { height: 240px; }
}

/* ============ Table ============ */
.dates-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.dates-table th, .dates-table td {
  text-align: left; padding: 10px 8px;
  border-bottom: 0.5px solid #f3f4f6;
}
.dates-table th { font-weight: 600; color: #6b7280; font-size: 12px; }
.dates-table td.km { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 639px) {
  .dates-table .col-province,
  .dates-table .col-venue,
  .dates-table .col-show { display: none; }
}

/* ============ Upload tab ============ */
.drop {
  border: 1.5px dashed #cbd5e1;
  border-radius: 12px;
  padding: 28px 16px;
  text-align: center;
  background: #ffffff;
  transition: all 0.15s ease;
}
.drop.dragover { border-color: #1d4ed8; background: #eff6ff; }
.drop label.pick {
  display: inline-block; padding: 12px 20px;
  background: #1d4ed8; color: #fff; border-radius: 8px;
  font-weight: 600; cursor: pointer;
  min-height: 44px;
}
.drop input[type=file] { position: absolute; left: -9999px; opacity: 0; }
.drop .hint { color: #6b7280; font-size: 13px; margin-top: 10px; }

.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid #e5e7eb; border-top-color: #1d4ed8;
  border-radius: 50%; animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(255,255,255,0.92);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px;
}
.overlay .spinner { width: 36px; height: 36px; border-width: 3px; }

/* ============ Preview ============ */
.preview-card { background: #fff; border: 0.5px solid #e5e7eb; border-radius: 12px; padding: 16px; margin-bottom: 12px; }
.preview-card h4 { margin: 0 0 8px 0; font-size: 15px; }
.preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 639px) { .preview-grid { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; color: #6b7280; text-transform: uppercase; }
.field input, .field textarea, .field select {
  padding: 10px 12px; border: 0.5px solid #d1d5db; border-radius: 8px;
  background: #fff; min-height: 44px;
}
.field textarea { min-height: 70px; resize: vertical; }
.actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.btn {
  min-height: 44px; padding: 10px 18px;
  border-radius: 8px; border: 0.5px solid #d1d5db;
  background: #fff; color: #111827; font-weight: 600;
}
.btn.primary { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }
.btn.danger { background: #fff; color: #dc2626; border-color: #fecaca; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ Hotel tab ============ */
.hotel-grid {
  display: grid; grid-template-columns: 1fr; gap: 10px;
}
@media (min-width: 768px) {
  .hotel-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .hotel-grid { grid-template-columns: repeat(3, 1fr); }
}
.hotel-card {
  background: #fff; border: 0.5px solid #e5e7eb; border-radius: 12px;
  padding: 14px; cursor: pointer;
}
.hotel-card h4 { margin: 0 0 4px 0; font-size: 15px; }
.hotel-card .city { color: #6b7280; font-size: 13px; }
.hotel-card .meta { margin-top: 8px; display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: #6b7280; }
.rating-badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.rating-badge.good { background: #dcfce7; color: #166534; }
.rating-badge.mid { background: #fef3c7; color: #92400e; }
.rating-badge.bad { background: #fee2e2; color: #991b1b; }
.rating-badge.none { background: #f3f4f6; color: #6b7280; }
.hotel-card .last-stay { font-size: 12px; color: #6b7280; margin-top: 6px; }

/* Vote pills */
.vote-row {
  display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0;
}
.vote-pill {
  min-width: 44px; min-height: 44px; padding: 0 10px;
  border-radius: 999px; border: 0.5px solid #d1d5db;
  background: #fff; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}
.vote-pill.selected { background: #1d4ed8; color: #fff; border-color: #1d4ed8; }

/* ============ Modal ============ */
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  display: none; align-items: center; justify-content: center;
  padding: 16px; z-index: 300;
}
.modal-bg.open { display: flex; }
.modal {
  background: #fff; border-radius: 12px; padding: 20px;
  max-width: 560px; width: 100%;
  max-height: 90dvh; overflow-y: auto;
}
.modal h3 { margin: 0 0 12px 0; }
.modal .close {
  position: absolute; right: 16px; top: 12px;
  background: none; border: none; font-size: 22px; color: #6b7280;
}

/* ============ Misc ============ */
.section-title { font-size: 12px; color: #6b7280; text-transform: uppercase; margin: 16px 0 8px; letter-spacing: 0.04em; }
.empty {
  text-align: center; padding: 32px 16px; color: #6b7280; font-size: 14px;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.login-card {
  max-width: 360px; margin: 80px auto; background: #fff;
  border: 0.5px solid #e5e7eb; border-radius: 12px;
  padding: 28px 24px; text-align: center;
}
.login-card h1 { font-size: 22px; margin: 0 0 8px; color: #1d4ed8; }
.login-card p { color: #6b7280; margin: 0 0 20px; font-size: 14px; }
.google-btn {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 12px 18px; background: #fff; color: #111827;
  border: 0.5px solid #d1d5db; border-radius: 8px;
  font-weight: 600; min-height: 48px; text-decoration: none;
}

/* Restore HTML5 [hidden] semantics — author rules like .overlay{display:flex}
   silently override the UA's [hidden]{display:none}, which broke the overlay
   visibility toggle. !important here just re-asserts the standard behavior. */
[hidden] { display: none !important; }
