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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f4f5f7;
  color: #1a1a2e;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ──────────────────────────────────────── */
header {
  background: #1a2e4a;
  color: white;
  padding: 0;
}
.header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 22px 24px;
}
header h1 {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.subtitle {
  font-size: 0.8rem;
  opacity: 0.55;
  margin-top: 3px;
}

/* ── Container ───────────────────────────────────── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* ── Form ────────────────────────────────────────── */
#analyze-form {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  padding: 28px 28px 24px;
  margin-bottom: 24px;
}

.input-section {
  margin-bottom: 22px;
}
.input-section h2 {
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6b7280;
  margin-bottom: 4px;
}
.section-hint {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 8px;
}

/* ── Inputs ──────────────────────────────────────── */
input[type="url"], textarea, select {
  font-family: inherit;
  font-size: 0.9rem;
  color: #1a1a2e;
  background: #f9fafb;
  border: 1.5px solid #e5e7eb;
  border-radius: 7px;
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="url"]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
input[type="url"], textarea {
  width: 100%;
  resize: vertical;
}
select { min-width: 110px; cursor: pointer; }

input::placeholder, textarea::placeholder {
  color: #c0c5ce;
}

/* ── Period selectors ────────────────────────────── */
.period-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.period-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: #6b7280;
  margin-bottom: 4px;
}
.select-pair {
  display: flex;
  gap: 6px;
}
.period-arrow {
  font-size: 1.2rem;
  color: #9ca3af;
  padding-top: 18px;
}

/* ── Stay length checkboxes ──────────────────────── */
.stay-checks {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.check-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.88rem;
  padding: 7px 14px;
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}
.check-label:has(input:checked) {
  background: #eff6ff;
  border-color: #3b82f6;
  color: #1d4ed8;
}
.check-label input[type="checkbox"] {
  accent-color: #3b82f6;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ── Error ───────────────────────────────────────── */
.form-error {
  background: #fef2f2;
  color: #b91c1c;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.85rem;
  margin-bottom: 14px;
  border: 1px solid #fecaca;
}

/* ── Submit button ───────────────────────────────── */
button[type="submit"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #1a2e4a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
}
button[type="submit"]:hover { background: #243d63; }
button[type="submit"]:active { transform: scale(0.99); }
button[type="submit"]:disabled {
  background: #94a3b8;
  cursor: not-allowed;
}

.btn-spinner {
  width: 16px;
  height: 16px;
  border: 2.5px solid rgba(255,255,255,0.25);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Progress bar ────────────────────────────────── */
.progress-bar {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  padding: 16px 20px;
  margin-bottom: 20px;
  text-align: center;
}
#progress-text {
  font-size: 0.88rem;
  color: #6b7280;
}

/* ── Result cards ────────────────────────────────── */
.result-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  padding: 20px 24px;
  margin-bottom: 16px;
  border-left: 4px solid transparent;
}

/* My property accent */
.result-card.mine {
  border-left-color: #e0434b;
}
.result-card.mine .card-badge {
  display: inline-block;
  background: #fef2f2;
  color: #e0434b;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 8px;
  vertical-align: middle;
}

.card-header {
  margin-bottom: 14px;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}
.card-header h3 a {
  color: #1a2e4a;
  text-decoration: none;
}
.card-header h3 a:hover { text-decoration: underline; }

.result-error {
  color: #b91c1c;
  background: #fef2f2;
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 0.85rem;
  border: 1px solid #fecaca;
}

/* ── Result table ────────────────────────────────── */
.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.result-table thead th {
  background: #f8f9fb;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.result-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;
}
.result-table tbody tr:last-child td { border-bottom: none; }
.result-table tbody tr:hover td { background: #fafbfd; }

/* Numeric columns right-aligned */
.result-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.result-table thead .num { text-align: right; }

/* Rate cells */
.rate-ok {
  font-weight: 600;
  color: #1a1a2e;
}
.rate-na {
  color: #d1d5db;
  font-size: 0.8rem;
}
.rate-below {
  color: #d1d5db;
  font-size: 0.75rem;
  cursor: help;
}
.rate-sub {
  color: #9ca3af;
  font-size: 0.72rem;
}
.rate-discount {
  font-size: 0.68rem;
  color: #15803d;
  font-weight: 500;
}

/* Availability badges */
.avail {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 600;
}
.avail-high  { background: #dcfce7; color: #15803d; }
.avail-mid   { background: #fef9c3; color: #a16207; }
.avail-low   { background: #fee2e2; color: #b91c1c; }

/* ── Charts ──────────────────────────────────────── */
.chart-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  padding: 20px 24px 16px;
  margin-bottom: 16px;
}
.chart-card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 2px;
}
.chart-hint {
  font-size: 0.78rem;
  color: #9ca3af;
  margin-bottom: 12px;
}
.chart-wrap {
  position: relative;
  height: 320px;
}

/* ── Season summary ──────────────────────────────── */
.summary-card {
  background: white;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.04);
  padding: 20px 24px;
  margin-bottom: 16px;
}
.summary-card h2 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 12px;
}
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.summary-table thead th {
  background: #f8f9fb;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
.summary-table tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.summary-table tbody tr:last-child td { border-bottom: none; }
.summary-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.summary-table thead .num { text-align: right; }
.summary-table .mine-row td { font-weight: 600; }
.summary-table .mine-row td:first-child { color: #e0434b; }

.position-above { color: #b91c1c; font-weight: 600; }
.position-below { color: #15803d; font-weight: 600; }
.position-only  { color: #6b7280; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 640px) {
  .container { padding: 16px 12px 40px; }
  #analyze-form { padding: 20px 16px 18px; }
  .period-row { flex-direction: column; align-items: flex-start; }
  .period-arrow { display: none; }
  .result-card { padding: 14px 12px; overflow-x: auto; }
  button[type="submit"] { padding: 12px 20px; }
}
