/* ==========================================================================
   Pipeline Risk Radar — tool-specific styles
   (shared tokens and layout come from /assets/css/styles.css)
   ========================================================================== */

/* ---------- Load panel ---------- */
.load-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 32px;
  align-items: stretch;
}
@media (max-width: 820px) { .load-grid { grid-template-columns: 1fr; } }
.load-grid .hint { max-width: 62ch; margin-bottom: 20px; }

.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--teal-light); outline-offset: 2px; }

.btn-link {
  background: none;
  border: none;
  color: var(--teal);
  padding: 12px 8px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-link:hover { color: var(--teal-hover); }

.drop-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  color: var(--muted);
  font-size: 0.92rem;
  min-height: 140px;
  transition: border-color 0.15s, background-color 0.15s;
}
.drop-zone.is-over { border-color: var(--teal); background: var(--teal-tint); color: var(--teal-hover); }
@media (max-width: 820px) { .drop-zone { display: none; } }

.status-msg { margin: 16px 0 0; font-size: 0.95rem; color: var(--teal-hover); font-weight: 500; }
.status-msg:empty { display: none; }
.status-msg.is-error { color: var(--high-fg); }

/* ---------- Summary bar ---------- */
.summary {
  margin: 24px 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 2fr);
  background: var(--navy-800);
  color: #fff;
  border-radius: var(--radius);
  overflow: hidden;
}
.stat {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.stat:last-child { border-right: none; }
.stat-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.7); font-weight: 600; }
.stat-hint { text-transform: none; letter-spacing: 0; font-weight: 400; }
.stat-value { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.stat-sub { font-size: 0.88rem; color: rgba(255, 255, 255, 0.7); }

.type-counts { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.type-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 0.85rem;
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  padding: 5px 12px 5px 6px;
  cursor: pointer;
}
.type-chip:hover { border-color: rgba(255, 255, 255, 0.4); }
.type-chip[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); }
.type-count {
  min-width: 24px; height: 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  display: inline-grid; place-items: center;
  font-weight: 700; font-size: 0.8rem;
  padding: 0 6px;
}

@media (max-width: 1000px) {
  .summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-types { grid-column: 1 / -1; border-top: 1px solid rgba(255, 255, 255, 0.08); }
}
@media (max-width: 600px) {
  .summary { grid-template-columns: 1fr; }
  .stat { border-right: none; border-bottom: 1px solid rgba(255, 255, 255, 0.08); padding: 18px 20px; }
  .stat-value { font-size: 1.6rem; }
}

/* ---------- Table panel ---------- */
.table-panel { padding: 0; }
.table-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  padding: 28px 28px 0;
}
.table-head .hint { margin: 0; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--line);
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 150px; }
.field-grow { flex: 1 1 240px; }
.field label { font-size: 0.82rem; font-weight: 600; color: var(--muted); }
.field input,
.field select {
  font: inherit;
  font-size: 0.95rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #c5cdd9;
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 42px;
}
.field input:focus-visible,
.field select:focus-visible { border-color: var(--teal); }

.table-wrap { overflow-x: auto; }
.table-wrap:focus-visible { outline-offset: -3px; }

.deals {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  min-width: 1100px;
}
.deals th,
.deals td {
  text-align: left;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.deals th {
  background: var(--surface-alt);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.deals th button {
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.deals th button::after {
  content: "↕";
  font-size: 0.85em;
  opacity: 0.4;
}
.deals th[aria-sort="ascending"] button::after { content: "↑"; opacity: 1; color: var(--teal); }
.deals th[aria-sort="descending"] button::after { content: "↓"; opacity: 1; color: var(--teal); }
.deals th[aria-sort="ascending"],
.deals th[aria-sort="descending"] { color: var(--ink); }
.deals th.num, .deals td.num { text-align: right; }
.deals th.num button { flex-direction: row-reverse; }
.deals td.num { font-variant-numeric: tabular-nums; font-weight: 600; }
.deals tbody tr:hover { background: #fafbfc; }
.deals tbody tr.row-high td:first-child { box-shadow: inset 3px 0 0 var(--high-fg); }
.deals tbody tr.row-warning td:first-child { box-shadow: inset 3px 0 0 #c98a00; }
.deals tbody tr.row-closed { color: var(--muted); }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }

.cell-name { min-width: 220px; }
.deal-name { display: block; font-weight: 600; }
.deal-next { display: block; font-size: 0.84rem; color: var(--muted); margin-top: 2px; }
.cell-reasons { min-width: 260px; }

.reasons { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.reason { font-size: 0.85rem; padding-left: 14px; position: relative; }
.reason::before {
  content: "";
  position: absolute; left: 0; top: 0.55em;
  width: 7px; height: 7px; border-radius: 50%;
}
.reason-high::before { background: var(--high-fg); }
.reason-warning::before { background: #c98a00; }

.empty-state { padding: 48px 28px; text-align: center; color: var(--muted); margin: 0; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: 0.02em;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-high { background: var(--high-bg); color: var(--high-fg); }
.badge-closed { background: #e9edf3; color: var(--muted); }

/* ---------- Rules reference ---------- */
.rules ul { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.rules li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.rules .hint { margin: 0; }
