:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-alt: #eef2ec;
  --border: #d9e1d6;
  --text: #1c261d;
  --muted: #5a695c;
  --accent: #246a47;
  --accent-hover: #1c5538;
  --accent-soft: #e3f2ea;
  --open-bg: #dff5e7;
  --open-text: #135a33;
  --open-border: #8ad3a7;
  --sold-bg: #f1f3f0;
  --sold-text: #657266;
  --sold-border: #d8dfd6;
  --warn-bg: #fef3dc;
  --warn-text: #8a5600;
  --warn-border: #f0cf88;
  --danger: #b83b3b;
  --danger-soft: #fceaea;
  --shadow: 0 2px 10px rgba(24, 42, 28, 0.06);
  --radius: 14px;
}

[data-theme="dark"] {
  --bg: #111613;
  --surface: #19211c;
  --surface-alt: #222c26;
  --border: #2f3d34;
  --text: #edf3ee;
  --muted: #9eb0a2;
  --accent: #3ea870;
  --accent-hover: #4ec083;
  --accent-soft: #1b3828;
  --open-bg: #163b27;
  --open-text: #7ef0b1;
  --open-border: #2c6d49;
  --sold-bg: #202923;
  --sold-text: #8c9d8f;
  --sold-border: #324037;
  --warn-bg: #3b2d14;
  --warn-text: #f7ca72;
  --warn-border: #6d521f;
  --danger: #e26464;
  --danger-soft: #3a1d1d;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  overflow-x: hidden;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 20px 48px;
}

/* Header */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  border: 1px solid var(--open-border);
  display: grid;
  place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.08s;
  text-decoration: none;
}

.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-alt); }

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--surface-alt); }

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { border-color: var(--danger); }

.btn-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  border-radius: 8px;
}

.btn-icon {
  padding: 8px 10px;
}

.btn-mini {
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 600;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  cursor: pointer;
}
.btn-mini:hover { background: var(--accent-soft); }

/* Progress Banner */
.progress-banner {
  background: var(--surface);
  border: 1px solid var(--open-border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}

.progress-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.progress-track {
  height: 7px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s ease;
}

/* Summary Strip */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card, .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 700;
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 4px 0 2px;
}

.stat-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-topic-row, .stat-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 7px 0 4px;
}

.topic-pill {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 7px;
  font-size: 0.82rem;
  word-break: break-all;
}

.status-pill {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
}
.status-pill.ok { background: var(--open-bg); color: var(--open-text); }
.status-pill.warn { background: var(--warn-bg); color: var(--warn-text); }

/* Section Header */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.conn-pill {
  font-size: 0.8rem;
  color: var(--open-text);
  background: var(--open-bg);
  border: 1px solid var(--open-border);
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* Watch Cards */
.watches-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 26px;
}

.watch-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.watch-card.paused {
  opacity: 0.72;
}

.watch-card.has-matches {
  border-color: var(--open-border);
  box-shadow: 0 0 0 2px var(--open-bg), var(--shadow);
}

.watch-top {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.watch-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.watch-title {
  margin: 0;
  font-size: 1.12rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-alt);
  color: var(--muted);
  border: 1px solid var(--border);
}

.badge-active { background: var(--open-bg); color: var(--open-text); border-color: var(--open-border); }
.badge-paused { background: var(--warn-bg); color: var(--warn-text); border-color: var(--warn-border); }

.watch-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.watch-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  font-size: 0.87rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.watch-notes {
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0 0 12px;
  font-style: italic;
}

/* Matches Callout */
.matches-box {
  background: var(--open-bg);
  border: 1px solid var(--open-border);
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
}

.matches-box-title {
  font-weight: 800;
  color: var(--open-text);
  margin-bottom: 8px;
}

.match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.match-item {
  background: var(--surface);
  border: 1px solid var(--open-border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.match-prop {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--accent);
}

.match-room {
  font-weight: 700;
  font-size: 0.94rem;
}

.match-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
}

.match-price {
  font-weight: 800;
  font-size: 0.95rem;
}

/* Property availability grid (no horizontal scroll — wraps cleanly) */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.prop-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
}

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

.prop-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.prop-link {
  font-size: 0.78rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.prop-link:hover { text-decoration: underline; }

.seg-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.seg-pill {
  font-size: 0.77rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--sold-border);
  background: var(--sold-bg);
  color: var(--sold-text);
  text-decoration: none;
}

.seg-pill.open {
  background: var(--open-bg);
  border-color: var(--open-border);
  color: var(--open-text);
}

.seg-pill.err {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-text);
}

.prop-footnote {
  margin-top: 6px;
  font-size: 0.76rem;
  color: var(--muted);
}

.watch-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--muted);
}

/* History */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 11px 13px;
}

.history-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.history-msg {
  white-space: pre-line;
  font-size: 0.86rem;
  color: var(--muted);
  margin: 4px 0 6px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 18, 12, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.spacer { flex: 1; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group label {
  font-size: 0.83rem;
  font-weight: 700;
}

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

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.prop-check-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
}

.prop-check-card input { margin-top: 3px; }
.prop-check-title { font-weight: 700; font-size: 0.88rem; display: block; }
.prop-check-desc { font-size: 0.77rem; color: var(--muted); display: block; margin-top: 2px; }

.toggle-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toggle-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 0.88rem;
  cursor: pointer;
}

.toggle-item input { margin-top: 3px; }

.info-box {
  background: var(--accent-soft);
  border: 1px solid var(--open-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 0.86rem;
}

.info-box ol {
  margin: 6px 0 0;
  padding-left: 18px;
}

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.86rem;
  font-weight: 600;
}

.form-feedback {
  background: var(--open-bg);
  color: var(--open-text);
  border: 1px solid var(--open-border);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 0.86rem;
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 28px 16px;
  color: var(--muted);
  font-size: 0.92rem;
}

/* Toasts */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
  max-width: 360px;
}

.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--open-border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 11px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.88rem;
}

.muted { color: var(--muted); }
.hidden { display: none !important; }

/* Auth Gate */
.auth-gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-brand h1 { font-size: 1.2rem; }

.auth-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-hint {
  margin: 0;
  font-size: 0.86rem;
  color: var(--muted);
}

.btn-block { width: 100%; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Accounts Modal */
.modal-wide { max-width: 720px; }

.account-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.account-section:last-child { border-bottom: none; padding-bottom: 0; }
.account-section h3 { margin: 0; font-size: 1rem; }

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.inline-form input { flex: 1; min-width: 180px; }

.passkey-list, .roster-list, .audit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.passkey-row, .roster-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.passkey-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.invite-box {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.roster-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.roster-meta {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 8px;
}

.roster-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-details summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--muted);
  padding: 4px 0;
}

.audit-row {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
}

