/* ============================================================================
   ATLAS REDESIGN — Documents screen styles  ·  Phase 2
   Branch: atlas-redesign-2026-06-29

   Prefix: .rd-documents. Tokens only (--r-*) so Calm (almanac) + Operator
   themes both work automatically. No hardcoded hex. Theme-specific selectors
   (html[data-rtheme="operator"] …) are used only where a token can't express
   the tweak (rare). Mirrors the proven clientcare / pipeline patterns.
   ========================================================================== */

.rd-documents {
  font-family: var(--r-font-body);
  color: var(--r-body);
  padding: var(--r-gutter);
  max-width: var(--r-page-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---- page header --------------------------------------------------------- */
.rd-doc-head {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.rd-doc-eyebrow {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-clay);
}
.rd-doc-h1 {
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h1);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.01em;
  color: var(--r-ink);
  margin: 0;
}
.rd-doc-sub {
  margin: 3px 0 0;
  font-size: var(--r-fs-body);
  color: var(--r-muted);
  max-width: 640px;
  line-height: 1.45;
}

/* ---- KPI strip (4-up) ---------------------------------------------------- */
.rd-doc-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.rd-doc-kpi {
  background: var(--r-surface);
  border: 1px solid var(--r-hairline-2);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rd-doc-kpi-label {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-eyebrow);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--r-faint);
}
.rd-doc-kpi-value {
  font-family: var(--r-font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1;
  color: var(--r-ink);
}
.rd-doc-kpi-hint {
  font-size: var(--r-fs-meta);
  color: var(--r-muted);
}
.rd-doc-kpi[data-tone="alert"] .rd-doc-kpi-value { color: var(--r-clay-2); }
.rd-doc-kpi[data-tone="alert"] .rd-doc-kpi-hint  { color: var(--r-clay-2); font-weight: 600; }

/* ---- main grid (deals | side) -------------------------------------------- */
.rd-doc-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 20px;
  align-items: start;
  min-height: 0;
}
.rd-doc-main {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow: auto;
  max-height: calc(100vh - 300px);
  padding-right: 2px;
}
.rd-doc-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- deal group card ----------------------------------------------------- */
.rd-doc-deal {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 18px 20px;
  transition: box-shadow var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease);
}
.rd-doc-deal:hover {
  box-shadow: var(--r-shadow-hover);
  transform: translateY(-2px);
}
.rd-doc-deal--empty:hover { box-shadow: var(--r-shadow-card); transform: none; }

.rd-doc-deal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.rd-doc-deal-id { min-width: 0; }
.rd-doc-deal-addr {
  margin: 0;
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  line-height: 1.15;
  color: var(--r-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-doc-deal-sub {
  margin-top: 2px;
  font-size: var(--r-fs-meta);
  color: var(--r-faint);
}
.rd-doc-deal-pct {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rd-doc-deal-pct-text {
  font-family: var(--r-font-mono);
  font-size: 11px;
  color: var(--r-faint);
  white-space: nowrap;
}

/* completion ring — a real-% conic gradient (never fabricated; DASH center
   when no percent exists). Sits beside the linear progress bar below as a
   second, at-a-glance read of the same number. */
.rd-doc-deal-ring {
  --dpct: 0;
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: conic-gradient(var(--r-muted) calc(var(--dpct) * 1%), var(--r-well) 0);
}
.rd-doc-deal-ring[data-tone="good"]  { background: conic-gradient(var(--r-good)   calc(var(--dpct) * 1%), var(--r-well) 0); }
.rd-doc-deal-ring[data-tone="warn"]  { background: conic-gradient(var(--r-amber)  calc(var(--dpct) * 1%), var(--r-well) 0); }
.rd-doc-deal-ring[data-tone="alert"] { background: conic-gradient(var(--r-clay-2) calc(var(--dpct) * 1%), var(--r-well) 0); }
.rd-doc-deal-ring::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--r-surface);
}
.rd-doc-deal-ring-val {
  position: relative;
  font-family: var(--r-font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--r-ink);
}

/* progress bar */
.rd-doc-progress {
  height: 6px;
  border-radius: 5px;
  background: var(--r-well);
  overflow: hidden;
  margin-top: 10px;
}
.rd-doc-progress-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: var(--r-primary);
  transition: width var(--r-dur) var(--r-ease);
}
.rd-doc-progress-fill[data-tone="good"]  { background: var(--r-primary-2); }
.rd-doc-progress-fill[data-tone="warn"]  { background: var(--r-amber); }
.rd-doc-progress-fill[data-tone="alert"] { background: var(--r-clay); }

/* document rows */
.rd-doc-rows { margin-top: 6px; }
.rd-doc-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
  border-top: 1px solid var(--r-hairline);
}
.rd-doc-row:first-child { border-top: none; }
/* state iconography — a tinted chip, not a bare glyph, so present / missing /
   pending read at a glance across a long document list. */
.rd-doc-row-icon {
  font-size: 14px;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--r-muted);
  background: var(--r-well);
}
.rd-doc-row-icon[data-tone="good"]  { color: var(--r-primary); background: var(--r-mint-surface); }
.rd-doc-row-icon[data-tone="warn"]  { color: var(--r-amber); background: color-mix(in srgb, var(--r-amber) 16%, transparent); }
.rd-doc-row-icon[data-tone="alert"] { color: var(--r-clay-2); background: color-mix(in srgb, var(--r-clay-2) 14%, transparent); }
.rd-doc-row-icon[data-tone="muted"] { color: var(--r-faint); background: var(--r-well); }

.rd-doc-row-id { flex: 1 1 auto; min-width: 0; }
.rd-doc-row-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--r-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-doc-row-meta {
  font-size: 12px;
  color: var(--r-faint);
}
.rd-doc-row-meta[data-tone="alert"] { color: var(--r-clay-2); }
.rd-doc-row-meta[data-tone="warn"]  { color: var(--r-amber); }

/* state badge (ON FILE / E-SIGN) */
.rd-doc-badge {
  flex: 0 0 auto;
  font-family: var(--r-font-mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  border-radius: var(--r-radius-chip);
  padding: 2px 7px;
  background: var(--r-well);
  color: var(--r-muted);
}
.rd-doc-badge[data-tone="good"] { background: var(--r-mint-surface); color: var(--r-mint-ink); }
.rd-doc-badge[data-tone="warn"] {
  background: color-mix(in srgb, var(--r-amber) 18%, transparent);
  color: var(--r-amber);
}

/* request button (inline in doc row + missing rows) */
.rd-doc-request {
  appearance: none;
  flex: 0 0 auto;
  height: 28px;
  padding: 0 12px;
  border: none;
  border-radius: var(--r-radius-badge);
  background: var(--r-primary);
  color: var(--r-primary-ink);
  font-family: var(--r-font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter var(--r-dur) var(--r-ease),
              transform var(--r-dur) var(--r-ease),
              box-shadow var(--r-dur) var(--r-ease);
}
.rd-doc-request:hover { filter: brightness(1.06); transform: translateY(-1px); box-shadow: var(--r-shadow-hover); }
.rd-doc-request:active { transform: translateY(0); }
.rd-doc-request:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* open-in-Dotloop link on a doc row (S2 sweep — replaces the dead Request) */
.rd-doc-open {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--r-primary);
  text-decoration: none;
  opacity: 0;
  transition: opacity var(--r-dur) var(--r-ease), color var(--r-dur) var(--r-ease);
}
.rd-doc-row:hover .rd-doc-open,
.rd-doc-open:focus-visible { opacity: 1; }
.rd-doc-open:hover { color: var(--r-primary-2); }
.rd-doc-open:focus-visible { outline: var(--r-focus); outline-offset: 2px; }
.rd-doc-open i { font-size: 12px; }
/* no hover on touch — the link must always be reachable */
@media (hover: none), (max-width: 767px) {
  .rd-doc-open { opacity: 1; }
}

/* per-deal empty (no docs) */
.rd-doc-rows-empty {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .04em;
  color: var(--r-faint);
  text-align: center;
  padding: 16px 8px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
  margin-top: 8px;
}
.rd-doc-rows-empty i { font-size: 13px; vertical-align: -1px; }
/* positive honest state — every checklist slot really is filled */
.rd-doc-rows-empty[data-tone="good"] {
  color: var(--r-good);
  border-style: solid;
  border-color: color-mix(in srgb, var(--r-good) 30%, var(--r-border));
  background: var(--r-mint-surface);
}
.rd-doc-rows-empty[data-tone="good"] i { color: var(--r-good); }

/* screen-level empty state (no deals at all) */
.rd-doc-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 34px 18px;
  border: 1px dashed var(--r-border);
  border-radius: var(--r-radius-control);
}
.rd-doc-empty i { font-size: 30px; color: var(--r-faint); }
.rd-doc-empty-title {
  font-family: var(--r-font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--r-ink);
}
.rd-doc-empty-note {
  font-family: var(--r-font-mono);
  font-size: var(--r-fs-meta);
  letter-spacing: .03em;
  color: var(--r-faint);
  max-width: 360px;
  line-height: 1.5;
}

/* ---- missing & required card --------------------------------------------- */
.rd-doc-missing {
  background: var(--r-surface);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  box-shadow: var(--r-shadow-card);
  padding: 18px 20px;
}
.rd-doc-missing-title {
  margin: 0 0 2px;
  font-family: var(--r-font-display);
  font-size: var(--r-fs-h2);
  font-weight: 600;
  color: var(--r-ink);
}
.rd-doc-miss-list { margin-top: 8px; }
.rd-doc-miss {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 0;
  border-top: 1px solid var(--r-hairline);
}
.rd-doc-miss-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--r-alert);
}
.rd-doc-miss-dot[data-tone="warn"] { background: var(--r-amber); }
.rd-doc-miss-id { flex: 1 1 auto; min-width: 0; }
.rd-doc-miss-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--r-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rd-doc-miss-sub {
  font-size: 12px;
  color: var(--r-faint);
}
.rd-doc-miss-action {
  appearance: none;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  font-family: var(--r-font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--r-primary);
  cursor: pointer;
  padding: 4px 2px;
  border-radius: var(--r-radius-chip);
  transition: color var(--r-dur) var(--r-ease);
}
.rd-doc-miss-action i { font-size: 12px; }
.rd-doc-miss-action:hover { color: var(--r-primary-2); }
.rd-doc-miss-action:focus-visible { outline: var(--r-focus); outline-offset: 2px; }

/* ---- Dotloop sync footer ------------------------------------------------- */
.rd-doc-sync {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 16px;
  background: var(--r-well);
  border: 1px solid var(--r-border);
  border-radius: var(--r-radius-card);
  font-size: 12.5px;
  color: var(--r-muted);
}
.rd-doc-sync i { font-size: 17px; color: var(--r-primary); flex: 0 0 auto; }
.rd-doc-sync[data-state="off"] i { color: var(--r-faint); }
.rd-doc-sync[data-state="off"] { color: var(--r-faint); }

/* ---- entrance + reduced motion -------------------------------------------- */
@keyframes rd-doc-deal-rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.rd-doc-deal:not(.rd-doc-deal--empty) { animation: rd-doc-deal-rise .3s var(--r-ease) both; }
@media (prefers-reduced-motion: reduce) {
  .rd-doc-deal, .rd-doc-progress-fill { animation: none !important; transition: none !important; }
}
html[data-rmotion="reduced"] .rd-doc-deal,
html[data-rmotion="reduced"] .rd-doc-progress-fill { animation: none !important; transition: none !important; }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 980px) {
  .rd-doc-grid { grid-template-columns: minmax(0, 1fr); } /* bare 1fr's auto min let nowrap deal-head chips push the column past the viewport */
  .rd-doc-main { max-height: none; overflow: visible; min-width: 0; }
}
@media (max-width: 720px) {
  .rd-doc-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rd-doc-deal-head { flex-wrap: wrap; row-gap: 8px; }
}
@media (max-width: 480px) {
  .rd-doc-deal { padding: 16px; }
  .rd-doc-deal-ring { width: 32px; height: 32px; }
  .rd-doc-deal-ring-val { font-size: 9px; }
  .rd-doc-deal-pct-text { display: none; }
}
