:root {
  --df-sidebar: #1e293b;
  --df-accent: #0d6efd;
  --df-fail: #dc3545;
  --df-base: 16px;
}

/* Compact layout, readable fonts */
html {
  font-size: var(--df-base);
}

body {
  background: #f1f5f9;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.df-sidebar {
  min-height: 100vh;
  background: var(--df-sidebar);
  padding: 0.6rem 0.7rem !important;
}

.df-sidebar .nav-link {
  color: #cbd5e1;
  border-radius: 0.3rem;
  margin-bottom: 0.15rem;
  padding: 0.35rem 0.6rem;
  font-size: 0.9375rem;
}

.df-sidebar .nav-link.active,
.df-sidebar .nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.df-brand {
  display: block;
  padding: 0.5rem 0.45rem;
  margin-bottom: 0.85rem !important;
  background: #fff;
  border-radius: 0.375rem;
  text-decoration: none;
  overflow: hidden;
  line-height: 0;
}

.df-brand:hover {
  opacity: 0.96;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.df-brand-logo {
  display: block;
  width: 100%;
  max-height: 52px;
  height: auto;
  object-fit: contain;
}

@media (min-width: 1200px) {
  .df-brand {
    padding: 0.55rem 0.5rem;
  }
}

main.col-md-10 {
  padding: 0.65rem 0.85rem !important;
}

h1.h3, .h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.df-card {
  border: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.07);
}

.df-card .card-body {
  padding: 0.6rem 0.75rem;
}

.df-card .card-header,
.df-card .card-footer {
  padding: 0.45rem 0.75rem;
  font-size: 0.9375rem;
}

.df-select-search {
  width: 100%;
  min-width: 0;
}

.df-select-search .choices {
  width: 100%;
  margin-bottom: 0;
}

.df-select-search .choices__inner {
  min-height: calc(1.5em + 0.75rem + 2px);
  padding: 0.375rem 2rem 0.375rem 0.75rem;
  font-size: 0.9375rem;
  border-radius: 0.375rem;
  border-color: #ced4da;
  background-color: #fff;
}

.df-select-search .choices__list--single {
  padding: 0;
}

.df-select-search .choices__list--single .choices__item {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.df-select-search .choices__list--dropdown .choices__item {
  font-size: 0.9375rem;
}

/* Keep searchable selects above sticky tables and later cards (Manual Run preview). */
.df-run-filter-card {
  position: relative;
  z-index: 20;
}

.df-select-search .choices.is-open {
  z-index: 1060;
}

.df-select-search .choices__list--dropdown,
.df-select-search .choices__list[aria-expanded] {
  z-index: 1060;
}

.df-select-search .choices[data-type*="select-one"]::after {
  border-color: #6c757d transparent transparent;
}

.df-select-search.is-disabled .choices__inner {
  background-color: #e9ecef;
}

.df-run-form {
  display: block;
}

.df-run-filters,
.df-filter-bar {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.75rem 1.25rem;
  align-items: end;
}

.df-run-field,
.df-filter-field {
  min-width: 0;
}

.df-run-form .form-control,
.df-run-form .form-select,
.df-filter-bar .form-control,
.df-filter-bar .form-select,
.df-run-form .df-select-search .choices__inner,
.df-filter-bar .choices__inner {
  height: 38px;
  min-height: 38px;
}

.df-run-form .form-control,
.df-run-form .form-select,
.df-filter-bar .form-control,
.df-filter-bar .form-select {
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

.df-run-form .df-select-search .choices__inner,
.df-filter-bar .choices__inner {
  display: flex;
  align-items: center;
  padding-top: 0.375rem;
  padding-bottom: 0.375rem;
}

.df-filter-field .form-label {
  font-size: 0.875rem;
  margin-bottom: 0.25rem;
}

.df-filter-field-action .btn,
.df-run-field-action .btn {
  height: 38px;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.df-filter-action-label,
.df-run-action-label {
  visibility: hidden;
}

.df-run-field-trip {
  grid-column: span 1;
}

.df-run-trip-inline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.df-run-trip-inline .form-control {
  flex: 1 1 8rem;
  min-width: 0;
}

.df-run-trip-inline .df-run-check-inline {
  flex: 0 0 auto;
}

.df-run-check-inline {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 38px;
  padding-left: 0.1rem;
}

.df-run-check-inline .form-check-input {
  margin: 0;
  flex-shrink: 0;
}

.df-run-check-inline .form-check-label {
  font-size: 0.875rem;
  color: #334155;
  user-select: none;
  margin-bottom: 0;
}

@media (max-width: 991.98px) {
  .df-run-filters,
  .df-filter-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .df-run-field-trip {
    grid-column: 1 / -1;
  }

  .df-run-field-action,
  .df-filter-field-action {
    grid-column: 1 / -1;
  }
}

@media (max-width: 575.98px) {
  .df-run-filters,
  .df-filter-bar {
    grid-template-columns: 1fr;
  }
}

.df-kpi {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.15;
}

.df-job-id {
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
}

.job-name-cell {
  min-width: 12rem;
  max-width: 18rem;
}

.df-jobs-table th,
.df-jobs-table td {
  vertical-align: middle;
}

.df-kpi + .text-muted,
.card .text-muted.small {
  font-size: 0.8125rem;
}

/* Buttons & forms — compact padding, readable text */
.btn {
  padding: 0.28rem 0.65rem;
  font-size: 0.875rem;
  line-height: 1.4;
}

.btn-sm {
  padding: 0.2rem 0.5rem;
  font-size: 0.8125rem;
}

.btn-group .btn {
  padding: 0.18rem 0.5rem;
}

.form-label {
  font-size: 0.8125rem;
  margin-bottom: 0.15rem;
  font-weight: 500;
}

.form-control,
.form-select {
  padding: 0.3rem 0.5rem;
  font-size: 0.875rem;
  min-height: 2rem;
}

.form-check-label {
  font-size: 0.875rem;
}

.form-check-input {
  width: 0.95rem;
  height: 0.95rem;
  margin-top: 0.12rem;
}

.row.g-2 {
  --bs-gutter-y: 0.3rem;
  --bs-gutter-x: 0.45rem;
}

.row.g-3 {
  --bs-gutter-y: 0.45rem;
  --bs-gutter-x: 0.55rem;
}

.mb-3 {
  margin-bottom: 0.55rem !important;
}

.mb-4 {
  margin-bottom: 0.75rem !important;
}

/* Tables */
.table td,
.table th {
  vertical-align: middle;
}

.table-sm > :not(caption) > * > * {
  padding: 0.35rem 0.5rem;
  font-size: 0.875rem;
}

.table > :not(caption) > * > * {
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
}

.badge {
  font-size: 0.75rem;
  padding: 0.28em 0.5em;
}

.status-badge {
  text-transform: capitalize;
}

.row-failed {
  background: #fff5f5 !important;
}

.row-failed td {
  border-color: #fecaca !important;
}

.json-preview {
  max-height: 360px;
  overflow: auto;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 0.375rem;
  padding: 0.75rem;
  font-size: 0.8125rem;
}

.btn-filter.active {
  background: var(--df-accent);
  color: #fff;
  border-color: var(--df-accent);
}

.namespace-row td {
  background: #f8fafc;
  font-size: 0.875rem;
}

.log-labels .badge {
  font-weight: 500;
  margin: 0 0.1rem 0.1rem 0;
}

.log-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
}

/* Logs table — horizontal scroll for wide context + payload columns */
.logs-table-wrap {
  width: 100%;
  overflow-x: auto;
}

#logsTable {
  table-layout: fixed;
  min-width: 1400px;
  width: 100%;
}

#logsTable col.col-w-job { width: 11%; }
#logsTable col.col-w-type { width: 5%; }
#logsTable col.col-w-zone { width: 6%; }
#logsTable col.col-w-ns { width: 6%; }
#logsTable col.col-w-trip { width: 6%; }
#logsTable col.col-w-dur { width: 5%; }
#logsTable col.col-w-time { width: 7%; }
#logsTable col.col-w-step { width: 8%; }
#logsTable col.col-w-status { width: 4%; }
#logsTable col.col-w-json { width: 3%; }
#logsTable col.col-w-payload { width: 19%; }

#logsTable th,
#logsTable td {
  overflow: hidden;
}

#logsTable th.col-trip-date,
#logsTable td.col-trip-date {
  white-space: nowrap;
}

#logsTable th.col-time,
#logsTable td.col-time {
  white-space: normal;
  line-height: 1.25;
  font-size: 0.8125rem;
}

#logsTable th.col-labels,
#logsTable td.col-labels {
  white-space: normal;
}

#logsTable th.col-msg,
#logsTable td.col-msg {
  max-width: 0;
}

#logsTable td.text-truncate-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#logsTable th.col-json,
#logsTable td.col-json {
  text-align: center;
  padding-left: 0.2rem;
  padding-right: 0.2rem;
}

#logsTable th.col-payload,
#logsTable td.col-payload {
  max-width: 0;
}

.log-payload-cell {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  width: 100%;
  min-width: 0;
  overflow: hidden;
}

.log-payload-text {
  flex: 1 1 auto;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8125rem;
  color: #334155;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-copy {
  flex-shrink: 0;
  padding: 0.1rem 0.3rem;
  line-height: 1;
  color: #64748b;
  font-size: 0.875rem;
}

.btn-copy:hover {
  color: var(--df-accent);
}

.expand-btn {
  width: 1.45rem;
  height: 1.45rem;
  padding: 0;
  line-height: 1;
  font-size: 0.75rem;
}

.list-group-item {
  padding: 0.4rem 0.7rem;
  font-size: 0.875rem;
}

.kpi-clickable {
  cursor: pointer;
  transition: box-shadow 0.15s ease;
}

.kpi-clickable:hover {
  box-shadow: 0 2px 8px rgba(220, 53, 69, 0.18);
}

.kpi-link {
  font-size: 0.7rem;
  text-decoration: none;
}

.kpi-link:hover {
  text-decoration: underline;
}

#chartCanvas {
  max-height: 200px;
}

.df-preview-progress {
  height: 4px;
}

.df-preview-progress .progress-bar {
  background-color: var(--df-accent, #0d6efd);
}

.df-preview-summary .badge {
  font-size: 0.8125rem;
  margin-right: 0.35rem;
}

.df-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
}

.df-preview-table-wrap {
  max-height: 420px;
  overflow: auto;
}

.df-preview-row-clickable {
  cursor: pointer;
}

.df-preview-row-clickable:hover {
  background-color: #f8fafc;
}

.df-preview-row-open {
  background-color: #f1f5f9;
}

.df-preview-row-open .df-row-chevron {
  transform: rotate(180deg);
}

.df-row-chevron {
  font-size: 0.75rem;
  color: #64748b;
  transition: transform 0.15s ease;
}

.df-preview-check {
  width: 2rem;
}

.df-field-diff-table {
  font-size: 0.8125rem;
  margin: 0.5rem 0 0 2rem;
}

.df-field-diff-table td {
  vertical-align: top;
  padding: 0.2rem 0.5rem;
}

.df-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.text-bg-datasink {
  background-color: #6f42c1 !important;
  color: #fff !important;
}

.timeline-rerun-btn {
  padding: 0.15rem 0.4rem;
}

.df-active-job-card .font-monospace {
  word-break: break-all;
}

.df-active-zone-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--bs-secondary-color);
}

.df-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  padding: 1.5rem;
}

.df-login-card {
  width: 100%;
  max-width: 340px;
  border: 0;
  border-radius: 0.75rem;
}

.df-login-card .card-body {
  padding: 1.75rem 2rem 2rem;
}

.df-login-logo {
  max-width: 160px;
  height: auto;
}

.df-login-actions {
  margin-top: 0.25rem;
  text-align: center;
}

.df-login-actions .btn {
  min-width: 7.5rem;
  padding: 0.45rem 2rem;
}

.df-logout-link {
  opacity: 0.85;
}

.df-logout-link:hover {
  opacity: 1;
}
