@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

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

:root {
  --bg:            #f0f2f5;
  --surface:       #ffffff;
  --surface-2:     #f8fafc;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --text-secondary:#64748b;
  --text-muted:    #94a3b8;

  --green:         #10b981;
  --green-bg:      #ecfdf5;
  --green-text:    #065f46;

  --amber:         #f59e0b;
  --amber-bg:      #fffbeb;
  --amber-text:    #92400e;

  --red:           #ef4444;
  --red-bg:        #fef2f2;
  --red-text:      #991b1b;

  --blue:          #3b82f6;
  --blue-dark:     #2563eb;

  --radius:        10px;
  --radius-sm:     6px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 12px rgba(0,0,0,.1);
  --font:          'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

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

/* ── Header ────────────────────────────────────────────────────────────────── */
.header {
  background: #0f172a;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-shrink: 0;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
  white-space: nowrap;
}

.header-sub   { color: #94a3b8; font-weight: 400; }
.header-brand { font-size: 12px; color: #475569; }

.page-nav {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 3px;
}

.page-nav-link {
  padding: 5px 14px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 500;
  color: rgba(255,255,255,.55);
  text-decoration: none;
  transition: color .15s, background .15s;
  white-space: nowrap;
}

.page-nav-link:hover { color: #fff; text-decoration: none; }

.page-nav-link--active {
  background: rgba(255,255,255,.15);
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rate-chip {
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 4px 13px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.updated-at {
  font-size: 12px;
  color: #475569;
  white-space: nowrap;
}

.btn-icon {
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}

.btn-icon:hover { color: #fff; background: rgba(255,255,255,.1); }

.btn-icon.spinning { animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Demo / error banners ──────────────────────────────────────────────────── */
.demo-banner {
  background: #fef3c7;
  border-bottom: 1px solid #fde68a;
  padding: 9px 24px;
  font-size: 13px;
  text-align: center;
  color: #92400e;
}
.demo-banner a { color: #92400e; font-weight: 600; }

/* ── Summary stat row ──────────────────────────────────────────────────────── */
.summary {
  max-width: 1400px;
  margin: 24px auto 0;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

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

.stat-value {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
}

.stat-card.stat-amber .stat-value { color: var(--amber); }
.stat-card.stat-red   .stat-value { color: var(--red);   }

/* ── Filter bar ────────────────────────────────────────────────────────────── */
.filter-bar {
  max-width: 1400px;
  margin: 16px auto 0;
  padding: 0 24px;
  display: flex;
  gap: 8px;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 16px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}

.filter-btn:hover { color: var(--text); border-color: var(--text-muted); }

.filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: #fff;
}

/* ── Tabs ──────────────────────────────────────────────────────────────────── */
.tabs-bar {
  max-width: 1400px;
  margin: 20px auto 0;
  padding: 0 24px;
  display: flex;
  border-bottom: 1px solid var(--border);
}

.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }

/* ── Main content area ─────────────────────────────────────────────────────── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ── Card grid ─────────────────────────────────────────────────────────────── */
.cards-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 16px;
}

/* ── Property card ─────────────────────────────────────────────────────────── */
.prop-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .15s, transform .15s;
}

.prop-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.prop-card--empty { opacity: .55; }
.prop-card--empty:hover { transform: none; box-shadow: var(--shadow); }

.prop-card__header {
  padding: 16px 16px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.prop-card__name {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
  flex: 1;
}

/* ── Badges ────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  line-height: 1.4;
}

.badge--green { background: var(--green-bg); color: var(--green-text); }
.badge--amber { background: var(--amber-bg); color: var(--amber-text); }
.badge--red   { background: var(--red-bg);   color: var(--red-text);   }
.badge--empty { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }

/* ── Metric sections ───────────────────────────────────────────────────────── */
.prop-card__metrics {
  padding: 14px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.metric__header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
}

.metric__label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
}

.metric__value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
  min-width: 2px;
}

.progress-fill--green { background: var(--green); }
.progress-fill--amber { background: var(--amber); }
.progress-fill--red   { background: var(--red);   }

.metric__footer {
  display: flex;
  justify-content: space-between;
  margin-top: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.metric__remain--over { color: var(--red); font-weight: 600; }

/* ── Card footer ───────────────────────────────────────────────────────────── */
.prop-card__footer {
  margin-top: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.table-view { overflow-x: auto; }

.table-wrapper {
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: 13px;
}

.data-table thead tr {
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
}

.data-table th {
  padding: 11px 16px;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-secondary);
  white-space: nowrap;
  user-select: none;
}

.data-table th:first-child { text-align: left; }
.data-table th:last-child  { text-align: center; }

.data-table th.sortable { cursor: pointer; }
.data-table th.sortable:hover { background: #eef2f7; color: var(--text); }
.data-table th.sort-active { color: var(--blue); }

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.data-table td:first-child { text-align: left; }
.data-table td:last-child  { text-align: center; }

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--surface-2); }

.td-name  { font-weight: 500; min-width: 190px; white-space: normal; }
.td-over  { color: var(--red); font-weight: 600; }
.row--empty td { color: var(--text-muted); font-style: italic; }

/* ── Settings modal ────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 24px;
}

.modal {
  background: var(--surface);
  border-radius: 12px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

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

.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-header .btn-icon { color: var(--text-secondary); font-size: 16px; }
.modal-header .btn-icon:hover { color: var(--text); background: var(--surface-2); }

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

.modal-body label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  display: block;
}

.modal-body input[type="url"],
.modal-body input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color .15s;
}

.modal-body input:focus { border-color: var(--blue); }

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  align-self: flex-start;
  transition: background .15s;
}

.btn-primary:hover { background: var(--blue-dark); }

.btn-link {
  background: none;
  border: none;
  color: var(--red-text);
  font-family: var(--font);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  align-self: flex-start;
}

.modal-rule {
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.csv-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover { background: var(--border); }

.csv-filename {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: -2px;
}

.setup-steps {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-top: 6px;
}

.setup-steps h3 {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 10px;
}

.setup-steps ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setup-steps li {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.setup-steps code {
  background: var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
  font-family: 'Courier New', monospace;
}

/* ── Loading / error ───────────────────────────────────────────────────────── */
.state-message {
  padding: 64px 32px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  grid-column: 1 / -1;
}

.state-message--error { color: var(--red); }
.state-message a { font-weight: 600; }

/* ── Utility ───────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Responsive ────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .summary { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .header-brand,
  .updated-at { display: none; }

  .header-inner { padding: 0 16px; }
  .main         { padding: 16px;  }
  .summary      { padding: 0 16px; gap: 10px; }
  .tabs-bar     { padding: 0 16px; }

  .cards-view   { grid-template-columns: 1fr; }
  .stat-value   { font-size: 24px; }
}
