/* Jaipur Properties — dashboard styles.
   Palette and component primitives provided by the owner; component-specific
   styles (repo banner, loan table, EMI calculator, charts, projects filters,
   freshness pills) layered on top using the same tokens. */

:root {
  --brand: #b71c1c;
  --brand-dark: #7f0000;
  --accent: #f5b400;
  --bg: #fafafa;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e5e5e5;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --radius: 12px;
  --maxw: 1100px;

  --good: #1B7F4A;
  --warn: #b58a2e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f0f10;
    --surface: #18181b;
    --text: #f1f1f1;
    --muted: #a1a1aa;
    --border: #2a2a2e;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: hidden; max-width: 100vw; }
body {
  margin: 0;
  font-family: 'Noto Sans Devanagari', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a, a:visited { color: inherit; text-decoration: none; }
img { display: block; max-width: 100%; height: auto; }

header.site {
  background: var(--brand);
  color: #fff;
  border-bottom: 3px solid var(--accent);
  box-shadow: var(--shadow);
}
.bar {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.4rem;
}
.brand .logo {
  width: 34px; height: 34px;
  background: #fff;
  color: var(--brand);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 1.15rem;
}
.date-strip {
  margin-left: auto;
  font-size: .82rem;
  opacity: .92;
  display: flex;
  gap: 10px;
  align-items: center;
}
.refresh-btn {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.28);
  color: #fff;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: .8rem;
  cursor: pointer;
  font-family: inherit;
}
.refresh-btn:hover { background: rgba(255,255,255,.25); }
.refresh-btn[aria-busy="true"] { opacity: .6; pointer-events: none; }

main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 20px 16px 60px;
}

section.feed { margin-bottom: 36px; scroll-margin-top: 90px; }
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin: 8px 0 14px;
  flex-wrap: wrap;
}
.section-head h2 {
  font-size: 1.25rem;
  margin: 0;
  padding-left: 12px;
  border-left: 4px solid var(--brand);
  font-weight: 800;
}
.section-head .count {
  color: var(--muted);
  font-size: .82rem;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}
.grid-text {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}
.card-text {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: 10px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card-text:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(0,0,0,.10); }
.card-text a,
.card-text a:visited { display: block; color: var(--text); }
.card-text h3 {
  font-size: 1rem;
  margin: 0 0 6px;
  line-height: 1.45;
  font-weight: 700;
  color: var(--text);
}
.card-text a:hover h3 { color: var(--brand); }
@media (prefers-color-scheme: dark) {
  .card-text a:hover h3 { color: var(--accent); }
}
.card-text .desc {
  font-size: .88rem;
  color: var(--muted);
  margin: 0 0 8px;
}
.card-text .info {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: .76rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.card-text .info .src { font-weight: 700; color: var(--brand); }
.card-text .info .dot { width: 3px; height: 3px; background: currentColor; border-radius: 50%; opacity: .5; }

.empty-note {
  padding: 16px;
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: .9rem;
  grid-column: 1/-1;
}

.editorial-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.editorial-card h2 {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--brand);
}
.editorial-card p {
  margin: 0 0 12px;
  font-size: .95rem;
  line-height: 1.7;
}
.editorial-card .byline {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: .85rem;
  color: var(--muted);
}
.editorial-card .byline strong { color: var(--text); }

.error-box {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.error-box button {
  margin-top: 12px;
  background: var(--brand);
  color: #fff;
  border: 0;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}

footer {
  border-top: 1px solid var(--border);
  padding: 22px 16px;
  text-align: center;
  color: var(--muted);
  font-size: .85rem;
  background: var(--surface);
}
footer .disclaimer {
  max-width: var(--maxw);
  margin: 0 auto 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
  font-size: .78rem;
  line-height: 1.55;
  text-align: left;
}
footer .disclaimer strong { color: var(--brand-dark); font-weight: 800; }
footer .disclaimer a { color: var(--brand-dark); font-weight: 700; }
footer .disclaimer a:hover { text-decoration: underline; }
@media (prefers-color-scheme: dark) {
  footer .disclaimer strong,
  footer .disclaimer a { color: var(--accent); }
}
footer .footer-meta { font-size: .78rem; }

.fade-in { animation: fade .35s ease-out both; }
@keyframes fade {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ────────────────────────────────────────────────────────────────
   Component additions: freshness pills, signals strip, projects,
   loan table, EMI calc, chart wrappers, news columns. Layered on
   top of the primitives above, using the same palette tokens. */

.fresh-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
  margin-left: auto;
}
.fresh-badge::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.fresh-badge.fresh-fresh { background: rgba(27,127,74,0.12);  color: var(--good); }
.fresh-badge.fresh-aging { background: rgba(245,180,0,0.22);  color: var(--brand-dark); }
.fresh-badge.fresh-stale { background: rgba(183,28,28,0.14);  color: var(--brand); }

/* Signals — buy/hold/wait */
.signal-card { display: flex; flex-direction: column; gap: 6px; }
.signal-badge {
  display: inline-block;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 2px 10px;
  border-radius: 4px;
  width: fit-content;
}
.signal-badge.BUY  { background: rgba(27,127,74,0.15);  color: var(--good); }
.signal-badge.HOLD { background: rgba(245,180,0,0.22);  color: var(--brand-dark); }
.signal-badge.WAIT { background: rgba(183,28,28,0.14);  color: var(--brand); }

.signal-locality { font-size: 1rem; font-weight: 800; }
.signal-project { font-size: .82rem; color: var(--muted); }
.signal-rationale { font-size: .88rem; line-height: 1.5; }
.signal-horizon {
  font-size: .68rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Decision (Buy or Hold) cards — yellow accent, top of page */
#decision .editorial-card {
  margin-bottom: 0;
}

/* Projects */
.projects-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  align-items: center;
}
.filter-label {
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-right: 4px;
}
.filter-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.filter-pill.on {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.project-card .chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.status-chip, .perf-chip {
  display: inline-block;
  font-size: .62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 2px 8px;
  border-radius: 4px;
}
.status-chip.upcoming { background: rgba(183,28,28,0.10); color: var(--brand); }
.status-chip.ongoing  { background: rgba(245,180,0,0.22); color: var(--brand-dark); }
.status-chip.ready    { background: rgba(27,127,74,0.15); color: var(--good); }
.perf-chip.good       { background: rgba(27,127,74,0.15); color: var(--good); }
.perf-chip.neutral    { background: rgba(245,180,0,0.22); color: var(--brand-dark); }
.perf-chip.poor       { background: rgba(183,28,28,0.14); color: var(--brand); }

.project-row {
  display: flex;
  justify-content: space-between;
  font-size: .78rem;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  margin-top: 4px;
}
.project-row span:first-child { color: var(--muted); }
.project-row span:last-child  { font-weight: 700; }

.perf-bar { display: flex; gap: 3px; margin-top: 4px; }
.perf-bar i {
  flex: 1; height: 6px;
  background: var(--border);
  border-radius: 2px;
}
.perf-bar i.on.good    { background: var(--good); }
.perf-bar i.on.neutral { background: var(--accent); }
.perf-bar i.on.poor    { background: var(--brand); }

.project-note {
  font-size: .76rem;
  color: var(--muted);
  font-style: italic;
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  margin-top: 4px;
}

/* Charts */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}
.chart-wrap canvas { width: 100% !important; height: 340px !important; }

/* Home loans */
.repo-banner {
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  box-shadow: var(--shadow);
}
.repo-banner .repo-val {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--accent);
  margin-left: 6px;
}
.repo-banner .repo-note { font-size: .85rem; opacity: .95; max-width: 60%; }

.loans-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 18px;
}
.loans-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.loans-table th, .loans-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.loans-table th {
  background: rgba(183,28,28,0.06);
  font-weight: 800;
  color: var(--brand);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.loans-table tr:last-child td { border-bottom: none; }
.loans-table .rate {
  font-weight: 800;
  color: var(--brand);
  white-space: nowrap;
}

.emi-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.emi-box h3 {
  margin: 0;
  color: var(--brand);
  font-size: 1.05rem;
  font-weight: 800;
}
.emi-field { display: flex; flex-direction: column; gap: 4px; }
.emi-field label {
  font-size: .75rem;
  color: var(--muted);
  font-weight: 700;
}
.emi-field label span { color: var(--text); font-weight: 800; }
.emi-field-row { display: flex; align-items: center; gap: 10px; }
.emi-field-row input[type="range"] {
  flex: 1;
  accent-color: var(--brand);
}
.emi-field-row input[type="number"] {
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .85rem;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}
.emi-result {
  background: rgba(245,180,0,0.10);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.emi-result div { font-size: .78rem; color: var(--muted); }
.emi-result strong {
  display: block;
  font-size: 1.1rem;
  color: var(--brand);
  font-weight: 800;
}

/* News two-column layout */
.news-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.news-col > h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--brand);
  padding-bottom: 6px;
  border-bottom: 2px solid var(--accent);
}
.news-impact {
  display: inline-block;
  font-size: .62rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.news-impact.positive { background: rgba(27,127,74,0.15); color: var(--good); }
.news-impact.neutral  { background: rgba(245,180,0,0.22); color: var(--brand-dark); }
.news-impact.negative { background: rgba(183,28,28,0.14); color: var(--brand); }

@media (max-width: 800px) {
  .loans-grid { grid-template-columns: 1fr; }
  .news-grid  { grid-template-columns: 1fr; }
  .repo-banner .repo-note { max-width: 100%; }
}

/* ── MOBILE — keep everything within the viewport, no horizontal scroll. */
@media (max-width: 600px) {
  .bar {
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand { font-size: 1.1rem; }
  .brand .logo { width: 30px; height: 30px; font-size: 1rem; }
  .date-strip { font-size: .72rem; gap: 6px; }
  .refresh-btn { padding: 5px 10px; font-size: .72rem; }

  main { padding: 14px 12px 36px; }

  section.feed { margin-bottom: 26px; scroll-margin-top: 70px; }
  .section-head { gap: 8px; margin: 6px 0 10px; }
  .section-head h2 { font-size: 1.05rem; padding-left: 10px; }
  .section-head .count { font-size: .72rem; }

  .grid       { grid-template-columns: 1fr; gap: 12px; }
  .grid-text  { grid-template-columns: 1fr; gap: 10px; }

  .editorial-card { padding: 14px 16px; }
  .editorial-card h2 { font-size: 1rem; }
  .editorial-card p { font-size: .88rem; line-height: 1.55; }

  .chart-wrap { padding: 12px; }
  .chart-wrap canvas { height: 260px !important; }

  /* Loans table: let it scroll within itself instead of pushing the page. */
  .loans-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: .78rem;
  }
  .loans-table th, .loans-table td { white-space: normal; }

  .repo-banner {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
  }
  .repo-banner .repo-val { font-size: 1.25rem; }
  .repo-banner .repo-note { font-size: .8rem; }

  .emi-box { padding: 14px; }
  .emi-field-row input[type="number"] { width: 90px; font-size: .8rem; }
  .emi-result { grid-template-columns: 1fr; gap: 6px; }

  .projects-filters { gap: 6px; }
  .filter-pill { padding: 5px 10px; font-size: .72rem; }

  footer { padding: 18px 12px; }
  footer .disclaimer { font-size: .76rem; }
}

@media (max-width: 380px) {
  .brand { font-size: 1rem; }
  #dash-updated { display: none; }
}

/* ── Dark-mode contrast pass for every coloured pill ─────────────
   On the dark surface (#18181b) the light-mode 12–22% tints plus
   --brand-dark / --brand text became hard to read. In dark mode
   bump the background opacity and swap text to a brighter on-brand
   shade. Placed at end of file so it always wins source-order. */
@media (prefers-color-scheme: dark) {
  /* Amber — HOLD, ongoing, neutral, aging */
  .signal-badge.HOLD,
  .status-chip.ongoing,
  .perf-chip.neutral,
  .news-impact.neutral,
  .fresh-badge.fresh-aging {
    background: rgba(245, 180, 0, 0.30);
    color: var(--accent);
  }
  /* Red — WAIT, upcoming, poor, negative, stale */
  .signal-badge.WAIT,
  .status-chip.upcoming,
  .perf-chip.poor,
  .news-impact.negative,
  .fresh-badge.fresh-stale {
    background: rgba(255, 100, 100, 0.18);
    color: #ff8a8a;
  }
  /* Green — BUY, ready, good, positive, fresh */
  .signal-badge.BUY,
  .status-chip.ready,
  .perf-chip.good,
  .news-impact.positive,
  .fresh-badge.fresh-fresh {
    background: rgba(80, 200, 130, 0.20);
    color: #66d49b;
  }
}
