/* ── Falcon Dashboard ── */
:root {
  --fd-blue:    #00AEEF;
  --fd-bg:      #0B1729;
  --fd-navy:    #112240;
  --fd-mid:     #1A3355;
  --fd-line:    rgba(0, 174, 239, 0.14);
  --fd-text:    #E6EDF7;
  --fd-muted:   #8899AA;
  --fd-dim:     #566980;
  --fd-red:     #ef4444;
  --fd-amber:   #f59e0b;
  --fd-green:   #34d399;
}

/* View container */
#falcon-dashboard-view {
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: var(--fd-bg);
  color: var(--fd-text);
}

/* Top bar */
.fd-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--fd-line);
  background: var(--fd-bg);
  flex-shrink: 0;
}
.fd-topbar-eyebrow {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--fd-blue);
  margin-bottom: 1px;
}
.fd-topbar-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--fd-text);
  letter-spacing: 0.01em;
}
.fd-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.fd-timestamp {
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  color: var(--fd-dim);
}
.fd-refresh-btn {
  background: transparent;
  border: 1px solid var(--fd-line);
  color: var(--fd-muted);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
}
.fd-refresh-btn:hover { color: var(--fd-blue); border-color: var(--fd-blue); }
.fd-refresh-btn.spinning { animation: fd-spin 0.7s linear infinite; }
@keyframes fd-spin { to { transform: rotate(360deg); } }

/* My Book / All Falcon scope toggle */
.fd-scope-bar {
  display: flex;
  gap: 4px;
  padding: 10px 16px 0;
}
.fd-scope-btn {
  background: transparent;
  border: 1px solid var(--fd-line);
  color: var(--fd-muted);
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.fd-scope-btn:hover { color: var(--fd-blue); border-color: var(--fd-blue); }
.fd-scope-btn.active {
  background: rgba(0, 174, 239, 0.12);
  border-color: var(--fd-blue);
  color: var(--fd-blue);
}

/* Scrollable body */
.fd-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* States */
.fd-loading, .fd-error {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 40px 20px;
  color: var(--fd-muted);
  font-size: 0.875rem;
}
.fd-error { color: var(--fd-red); }

/* KPI strip */
.fd-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}
.fd-kpi {
  background: var(--fd-navy);
  border: 1px solid var(--fd-line);
  border-radius: 10px;
  padding: 12px 14px;
}
.fd-kpi-val {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--fd-text);
  line-height: 1.1;
  margin-bottom: 2px;
}
.fd-kpi-label {
  font-size: 0.7rem;
  color: var(--fd-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1px;
}
.fd-kpi-sub { font-size: 0.65rem; color: var(--fd-dim); }
.fd-kpi-red .fd-kpi-val   { color: var(--fd-red); }
.fd-kpi-amber .fd-kpi-val { color: var(--fd-amber); }

/* 2-column grid */
.fd-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
@media (max-width: 520px) { .fd-grid-2 { grid-template-columns: 1fr; } }

/* Cards */
.fd-card {
  background: var(--fd-navy);
  border: 1px solid var(--fd-line);
  border-radius: 10px;
  padding: 12px 14px;
}
.fd-h3 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fd-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fd-count {
  background: var(--fd-mid);
  color: var(--fd-blue);
  border-radius: 20px;
  padding: 1px 7px;
  font-size: 0.65rem;
  font-weight: 700;
}
.fd-sub { font-size: 0.6rem; color: var(--fd-dim); font-weight: 400; margin-left: 4px; }

/* Feed rows */
.fd-feed { display: flex; flex-direction: column; gap: 4px; }
.fd-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
  background: var(--fd-mid);
  transition: background 0.12s;
  font-size: 0.78rem;
  min-width: 0;
}
.fd-row:hover { background: rgba(0, 174, 239, 0.12); }
.fd-tag {
  flex-shrink: 0;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 4px;
  padding: 1px 6px;
}
.fd-tag-red   { background: rgba(239,68,68,0.18);  color: var(--fd-red); }
.fd-tag-amber { background: rgba(245,158,11,0.18); color: var(--fd-amber); }
.fd-tag-ok    { background: rgba(0,174,239,0.15);  color: var(--fd-blue); }
.fd-row-loan  { font-weight: 600; color: var(--fd-text); flex-shrink: 0; }
.fd-row-text  { color: var(--fd-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fd-empty     { color: var(--fd-dim); font-size: 0.78rem; padding: 10px 4px; }

/* Chart */
.fd-chart-wrap {
  height: 300px;
  position: relative;
}

/* Donuts */
.fd-donuts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
@media (max-width: 400px) { .fd-donuts { grid-template-columns: 1fr; } }
.fd-donut { position: relative; }
.fd-donut canvas { height: 120px !important; }
.fd-donut-cap {
  text-align: center;
  font-size: 0.65rem;
  color: var(--fd-muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Loan table */
.fd-table-scroll { overflow-x: auto; margin-top: 4px; }
.fd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}
.fd-table th {
  padding: 5px 8px;
  text-align: left;
  color: var(--fd-muted);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--fd-line);
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
}
.fd-table th:hover { color: var(--fd-blue); }
.fd-table th.al-r, .fd-table td.al-r { text-align: right; }
.fd-table th.al-c, .fd-table td.al-c { text-align: center; }
.fd-table th.fd-sorted { color: var(--fd-blue); }
.fd-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--fd-line);
  color: var(--fd-text);
  white-space: nowrap;
}
.fd-table tbody tr { cursor: pointer; transition: background 0.1s; }
.fd-table tbody tr:hover { background: rgba(0,174,239,0.07); }
.fd-td-loan { font-weight: 500; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.fd-td-status { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.fd-ltv-red   { color: var(--fd-red); font-weight: 600; }
.fd-ltv-amber { color: var(--fd-amber); font-weight: 600; }
.fd-ltv-ok    { color: var(--fd-text); }

/* Footer */
.fd-foot {
  font-family: ui-monospace, monospace;
  font-size: 0.6rem;
  color: var(--fd-dim);
  text-align: center;
  padding: 4px;
  margin-top: 4px;
}

/* Loan detail modal */
.fd-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(3px);
  padding: 16px;
}
.fd-modal.hidden { display: none; }
.fd-modal-inner {
  position: relative;
  background: var(--fd-navy);
  border: 1px solid var(--fd-line);
  border-radius: 14px;
  width: 100%;
  max-width: 580px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.fd-modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 1;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--fd-mid);
  border: 1px solid var(--fd-line);
  color: var(--fd-muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.12s;
}
.fd-modal-close:hover { color: var(--fd-blue); }
.lm-photo { width: 100%; height: 160px; object-fit: cover; border-radius: 14px 14px 0 0; }
.lm-pad { padding: 16px 18px 22px; }
.lm-eyebrow { font-size: 0.65rem; color: var(--fd-muted); font-family: ui-monospace, monospace; text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 4px; }
.lm-title { font-size: 1.15rem; font-weight: 700; color: var(--fd-text); margin: 0 0 3px; }
.lm-addr { font-size: 0.78rem; color: var(--fd-muted); margin-bottom: 14px; }
.lm-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.lm-stat { background: var(--fd-mid); border-radius: 8px; padding: 8px 10px; }
.lm-stat-l { font-size: 0.65rem; color: var(--fd-dim); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.lm-stat-v { font-size: 0.85rem; font-weight: 600; color: var(--fd-text); }
.lm-links { display: flex; gap: 8px; margin-bottom: 14px; }
.lm-link { font-size: 0.72rem; color: var(--fd-blue); text-decoration: none; border: 1px solid var(--fd-line); border-radius: 6px; padding: 3px 9px; }
.lm-link:hover { background: rgba(0,174,239,0.1); }
.lm-section-h { font-size: 0.65rem; color: var(--fd-muted); text-transform: uppercase; letter-spacing: 0.08em; margin: 14px 0 8px; font-weight: 600; }
.lm-note { font-size: 0.78rem; color: var(--fd-text); background: var(--fd-mid); border-radius: 8px; padding: 8px 10px; margin-bottom: 10px; }
.lm-note-date { font-size: 0.65rem; color: var(--fd-dim); font-family: ui-monospace, monospace; margin-right: 6px; }
.lm-timeline { display: flex; flex-direction: column; gap: 6px; }
.lm-tl { display: flex; gap: 10px; font-size: 0.75rem; }
.lm-tl-date { flex-shrink: 0; width: 72px; color: var(--fd-dim); font-family: ui-monospace, monospace; font-size: 0.65rem; padding-top: 1px; }
.lm-tl-note { color: var(--fd-text); }

/* Inline CSS visibility — #app.falcon-mode handled in index.html */
