/* =============================================================================
   FlowDesk v7 — Unified design language (FINAL cascade layer)
   =============================================================================
   Load AFTER responsive.css. Tokens only (var(--fd-*)).
   Goal: one institutional product on every page — same density, headers,
   cards, tables, forms, pricing, mobile dock. Charcoal + teal signal;
   emerald/rose only for directional data.
   ============================================================================= */

/* ---- Shell ---- */
body.fd-page.fd-shell-v7,
body.fd-page.fd-shell-v6,
body.fd-page.fd-shell-v5 {
  background: var(--fd-bg);
  color: var(--fd-text);
  font-family: var(--fd-font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.fd-shell-v7 .fd-content-inner,
.fd-shell-v6 .fd-content-inner,
.fd-shell-v2 .fd-content-inner {
  max-width: var(--fd-max, 1580px);
  margin-inline: auto;
  padding-inline: var(--fd-space-4);
}

/* ---- Page header (canonical pattern) ---- */
.fd-page-header,
.page-header,
.ui-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--fd-space-4);
  margin: 0 0 var(--fd-space-6);
  padding-bottom: var(--fd-space-4);
  border-bottom: 1px solid var(--fd-border);
}

.fd-page-header h1,
.page-header h1,
.ui-page-header h1 {
  margin: 0;
  font-size: var(--fd-text-display, 1.75rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: var(--fd-leading-tight, 1.2);
  color: var(--fd-text);
}

.fd-page-header p,
.page-header .sub,
.fd-page-lede,
.ui-page-header .lede {
  margin: 6px 0 0;
  max-width: 52rem;
  color: var(--fd-text-soft);
  font-size: var(--fd-text-md, 0.95rem);
  line-height: var(--fd-leading-body, 1.5);
}

.fd-page-header .actions,
.ui-page-header .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* ---- Cards / panels ---- */
.fd-card,
.fd-panel,
.ui-panel,
.panel {
  background: var(--fd-surface);
  border: 1px solid var(--fd-border);
  border-radius: var(--fd-radius-lg, 12px);
  box-shadow: var(--fd-shadow, none);
}

.fd-card-head,
.fd-panel-head,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--fd-space-3, 12px);
  padding: var(--fd-space-4, 16px) var(--fd-space-5, 20px);
  border-bottom: 1px solid var(--fd-border-soft);
}

.fd-card-title,
.fd-panel-title,
.panel-title {
  margin: 0;
  font-size: var(--fd-text-sm, 0.8rem);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fd-text-soft);
  font-family: var(--fd-font-mono);
}

.fd-card-body,
.fd-panel-body,
.panel-body {
  padding: var(--fd-space-5, 20px);
}

/* ---- Buttons ---- */
.fd-btn,
button.fd-btn,
a.fd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--fd-radius-sm, 8px);
  border: 1px solid var(--fd-border-strong);
  background: var(--fd-bg-subtle);
  color: var(--fd-text);
  font-size: var(--fd-text-sm, 0.875rem);
  font-weight: 550;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.fd-btn:hover {
  background: var(--fd-bg-hover);
  border-color: var(--fd-border-strong);
}

.fd-btn.primary,
.fd-btn--primary {
  background: var(--fd-accent);
  border-color: transparent;
  color: var(--fd-on-accent, #0b0d10);
}

.fd-btn.primary:hover,
.fd-btn--primary:hover {
  background: var(--fd-accent-hover, var(--fd-accent));
  filter: brightness(1.05);
}

.fd-btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--fd-text-soft);
}

.fd-btn.ghost:hover {
  color: var(--fd-text);
  background: var(--fd-bg-hover);
}

/* ---- Tables ---- */
.fd-table,
table.fd-table,
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fd-text-sm, 0.875rem);
  font-variant-numeric: tabular-nums;
}

.fd-table th,
.table-wrap th {
  text-align: left;
  font-family: var(--fd-font-mono);
  font-size: var(--fd-text-xs, 0.7rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fd-text-dim);
  padding: 10px 12px;
  border-bottom: 1px solid var(--fd-border);
  white-space: nowrap;
}

.fd-table td,
.table-wrap td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--fd-border-soft);
  color: var(--fd-text);
}

.fd-table tr:hover td,
.table-wrap tr:hover td {
  background: var(--fd-bg-hover);
}

/* Direction — data only */
.bull, .td-comp.bull, .dir.bull, .driver-delta.bull { color: var(--fd-bull); }
.bear, .td-comp.bear, .dir.bear, .driver-delta.bear { color: var(--fd-bear); }
.flat, .td-comp.flat { color: var(--fd-neutral, var(--fd-text-dim)); }
.bull-mild { color: var(--fd-bull); opacity: 0.85; }
.bear-mild { color: var(--fd-bear); opacity: 0.85; }

/* ---- Forms ---- */
input[type="text"],
input[type="search"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
  background: var(--fd-bg);
  border: 1px solid var(--fd-border);
  border-radius: var(--fd-radius-sm, 8px);
  color: var(--fd-text);
  padding: 10px 12px;
  font-size: var(--fd-text-md, 0.95rem);
  font-family: inherit;
  transition: border-color 0.15s ease, outline 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--fd-accent-soft, rgba(45, 212, 191, 0.25));
  border-color: var(--fd-accent-dim, var(--fd-accent));
}

/* ---- Empty states ---- */
.fd-empty,
.empty {
  padding: var(--fd-space-8, 32px) var(--fd-space-5, 20px);
  text-align: center;
  color: var(--fd-text-soft);
  border: 1px dashed var(--fd-border);
  border-radius: var(--fd-radius-lg, 12px);
  background: var(--fd-bg-soft, var(--fd-bg-subtle));
}

/* ---- Metric tiles ---- */
.fd-metric,
.fd-stat-card {
  background: var(--fd-surface);
  border: 1px solid var(--fd-border);
  border-radius: var(--fd-radius, 10px);
  padding: var(--fd-space-4, 16px);
}

.fd-metric .label,
.fd-stat-card .label {
  font-size: var(--fd-text-xs, 0.7rem);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fd-text-dim);
  font-family: var(--fd-font-mono);
}

.fd-metric .value,
.fd-stat-card .value {
  font-size: var(--fd-text-xl, 1.35rem);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  color: var(--fd-text);
}

/* ---- Desk / CS messages ---- */
.fd-desk-msg,
.cs-msg {
  border-radius: var(--fd-radius, 10px);
  border: 1px solid var(--fd-border);
  background: var(--fd-bg-subtle);
  padding: 12px 14px;
  margin: 8px 0;
}

/* ---- Top bar / nav ---- */
.fd-globalbar,
.fd-topbar {
  border-bottom: 1px solid var(--fd-border);
  background: var(--fd-glass-bg, var(--fd-surface));
  backdrop-filter: blur(var(--fd-glass-blur, 12px));
}

.fd-globalnav-link--on,
.fd-sidebar-link--on,
.fd-mobile-nav-link--on {
  color: var(--fd-accent) !important;
}

/* ---- Footer ---- */
.site-foot {
  margin-top: var(--fd-space-8, 32px);
  padding: var(--fd-space-5, 20px) 0;
  border-top: 1px solid var(--fd-border-soft);
  color: var(--fd-text-dim);
  font-size: var(--fd-text-xs, 0.7rem);
}

.site-foot a {
  color: var(--fd-text-soft);
  text-decoration: none;
}

.site-foot a:hover {
  color: var(--fd-accent);
}

/* ---- Mobile dock ---- */
.fd-mobile-nav {
  border-top: 1px solid var(--fd-border);
  background: var(--fd-rail, var(--fd-surface));
  z-index: 40;
}

@media (max-width: 900px) {
  .fd-sidebar { display: none !important; }
  .fd-shell-v7 .fd-content-inner,
  .fd-shell-v6 .fd-content-inner {
    padding-inline: var(--fd-space-3, 12px);
  }
  .fd-page-header h1,
  .page-header h1,
  .ui-page-header h1 {
    font-size: 1.4rem;
  }
}

/* ---- Pricing grid (unified) ---- */
.fd-pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--fd-space-4, 16px);
}

.fd-pricing-grid--cs {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.fd-pricing-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: var(--fd-space-5, 20px);
  background: var(--fd-bg-subtle);
  border: 1px solid var(--fd-border);
  border-radius: var(--fd-radius-lg, 12px);
  min-height: 280px;
}

.fd-pricing-card.is-featured {
  border-color: var(--fd-accent);
  box-shadow: 0 0 0 1px var(--fd-accent);
}

.fd-pricing-card--sm {
  min-height: 220px;
}

.fd-pricing-flag {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: var(--fd-text-xs, 0.7rem);
  font-family: var(--fd-font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fd-accent);
}

.fd-pricing-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--fd-text);
}

.fd-pricing-blurb {
  margin: 0;
  color: var(--fd-text-soft);
  font-size: var(--fd-text-sm, 0.875rem);
  line-height: 1.45;
}

.fd-pricing-price {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fd-text);
  letter-spacing: -0.02em;
}

.fd-pricing-price span {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--fd-text-dim);
}

.fd-pricing-feats {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fd-pricing-feats li {
  font-size: var(--fd-text-sm, 0.875rem);
  color: var(--fd-text-soft);
  padding-left: 1.1em;
  position: relative;
  line-height: 1.4;
}

.fd-pricing-feats li::before {
  content: "·";
  position: absolute;
  left: 0;
  color: var(--fd-accent);
  font-weight: 700;
}

.fd-pricing-card .fd-btn {
  margin-top: auto;
  width: 100%;
}

.fd-pricing-note {
  margin: var(--fd-space-5, 20px) 0 0;
  color: var(--fd-text-soft);
  font-size: var(--fd-text-sm, 0.875rem);
  line-height: 1.5;
  max-width: 48rem;
}

/* ---- CS product surfaces ---- */
.cs-hero,
.pr-grid,
.cs-grid {
  gap: var(--fd-space-4, 16px);
}

.cs-trust .fd-card {
  min-height: 88px;
}

/* ---- Drivers list (stock / desk) ---- */
.driver,
li.driver {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--fd-border-soft);
  font-size: var(--fd-text-sm, 0.875rem);
}

.driver-label {
  font-family: var(--fd-font-mono);
  font-size: var(--fd-text-xs, 0.7rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fd-text-dim);
  min-width: 7rem;
}

.driver-value {
  font-variant-numeric: tabular-nums;
  font-weight: 550;
  color: var(--fd-text);
}

.driver-note {
  color: var(--fd-text-soft);
  font-size: var(--fd-text-xs, 0.7rem);
}

/* ---- Conviction badges ---- */
.badge-conviction {
  display: inline-block;
  font-family: var(--fd-font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--fd-border);
  color: var(--fd-text-soft);
}

.badge-conviction--high {
  border-color: var(--fd-bull);
  color: var(--fd-bull);
}

.badge-conviction--mid {
  border-color: var(--fd-accent);
  color: var(--fd-accent);
}

.badge-conviction--low,
.badge-conviction--thin {
  border-color: var(--fd-border-strong);
  color: var(--fd-text-dim);
}

.badge-stale,
.badge-age {
  font-family: var(--fd-font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fd-text-dim);
}

/* ---- Section rhythm ---- */
.fd-section + .fd-section,
section.fd-panel + section.fd-panel {
  margin-top: var(--fd-space-6, 24px);
}

/* ---- Focus / a11y ---- */
a:focus-visible,
button:focus-visible,
.fd-btn:focus-visible {
  outline: 2px solid var(--fd-accent);
  outline-offset: 2px;
}
