@import url('tokens.css');

.wf-module--track {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--neutral-200, #f8fafc);
  padding: 32px 24px 48px;
  color: #0f172a;
}

.wf-track-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 32px;
}

.wf-track-header h2 {
  font-size: 28px;
  margin: 0 0 8px;
}

.wf-track-header p {
  margin: 0;
  color: #475569;
  max-width: 560px;
  line-height: 1.5;
}

.wf-track-actions {
  display: flex;
  gap: 12px;
}

.wf-track-actions button {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

#track-connect-btn {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.28);
}

#track-connect-btn:hover:not([disabled]),
#track-connect-btn:focus-visible:not([disabled]) {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.32);
}

#track-refresh-btn {
  background: #f1f5f9;
  color: #1e293b;
  border: 1px solid #cbd5f5;
}

#track-refresh-btn:hover:not([disabled]),
#track-refresh-btn:focus-visible:not([disabled]) {
  background: #e2e8f0;
  transform: translateY(-1px);
}

#track-connect-btn[disabled],
#track-refresh-btn[disabled] {
  cursor: progress;
  opacity: 0.7;
  transform: none;
  box-shadow: none;
}

.wf-track-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

.wf-track-summary-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wf-track-summary-card h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 0;
  color: #64748b;
}

.wf-track-summary-card strong {
  font-size: 26px;
  font-weight: 700;
  color: #0f172a;
}

.wf-track-summary-card span {
  font-size: 13px;
  color: #64748b;
}

.wf-track-table-section,
.wf-track-visual-section {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  padding: 24px;
  margin-bottom: 32px;
}

.wf-track-table-section h3,
.wf-track-visual-section h3 {
  margin-top: 0;
  font-size: 20px;
  color: #0f172a;
}

.wf-track-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 16px;
}

.wf-track-table thead th {
  text-align: left;
  padding: 12px 10px;
  background: #1d4ed8;
  color: #fff;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.wf-track-table tbody tr {
  border-bottom: 1px solid #e2e8f0;
}

.wf-track-table tbody td {
  padding: 10px;
  font-size: 14px;
  color: #0f172a;
}

.wf-track-table tbody td.plan,
.wf-track-table tbody td.actual,
.wf-track-table tbody td.delta {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.wf-track-table tbody tr.section-row td {
  background: #f8fafc;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wf-track-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.wf-track-status--over {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.wf-track-status--under {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.wf-track-status--on {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.wf-track-message {
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #1e293b;
  font-size: 14px;
}

#track-sankey {
  width: 100%;
  min-height: 360px;
  position: relative;
}

#track-sankey svg {
  width: 100%;
  height: 100%;
}

.wf-track-loading {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

@media (max-width: 900px) {
  .wf-module--track {
    padding: 24px 16px 32px;
  }

  .wf-track-summary {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .wf-track-header h2 {
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .wf-track-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .wf-track-actions button {
    flex: 1 1 auto;
  }
}
