/* Leximo app shell - Aurora.
   Sits on top of plain Bootstrap 4 (grid + a few components) and
   replaces the Datta Able theme. Requires leximo-tokens.css. */

/* ---------------------------------------------------------------- Layout */

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--aurora-glow);
  background-repeat: no-repeat;
  background-size: 100% 420px;
}

.app-rail {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--rail-width);
  z-index: 1030;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
}

.app-rail__brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  border-radius: var(--radius-control);
  overflow: hidden;
}

.app-rail__brand img {
  max-width: 100%;
  height: auto;
}

.app-rail__link {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-control);
  color: var(--text-muted);
  transition: color 0.15s ease, background 0.15s ease;
}

.app-rail__link:hover,
.app-rail__link:focus {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.app-rail__link.is-active {
  color: var(--text);
  background: var(--accent-gradient-soft);
}

/* Gradient active indicator */
.app-rail__link.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 24px;
  border-radius: 0 3px 3px 0;
  background: var(--accent-gradient);
}

.app-rail__link i {
  font-size: 19px;
}

/* Tooltip label on hover, since the rail is icon-only */
.app-rail__link::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 10px;
  border-radius: var(--radius-control);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  box-shadow: var(--elev-2);
  z-index: 5;
}

.app-rail__link:hover::after {
  opacity: 1;
}

.app-rail__spacer {
  flex: 1;
}

.app-header {
  position: fixed;
  top: 0;
  right: 0;
  left: var(--rail-width);
  z-index: 1028;
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: var(--header-height);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.app-header__wordmark {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}

.app-header__wordmark:hover {
  text-decoration: none;
  color: var(--text);
}

.app-header__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.app-header__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.app-main {
  padding: calc(var(--header-height) + 22px) 22px 28px;
  margin-left: var(--rail-width);
}

/* Usage pills */
.usage-pill {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  white-space: nowrap;
  line-height: 1.4;
}

.usage-pill__label {
  font-size: 12px;
  color: var(--text-muted);
}

.usage-pill__value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.usage-pill--accent .usage-pill__value {
  color: var(--accent);
}

/* ------------------------------------------------------------- Dropdown */

.app-dropdown {
  position: relative;
}

.app-dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.app-dropdown__toggle:hover,
.app-dropdown__toggle:focus {
  border-color: var(--border-hover);
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.app-dropdown__toggle i {
  font-size: 15px;
  transition: transform 0.2s ease;
}

.app-dropdown.is-open .app-dropdown__toggle .app-dropdown__caret {
  transform: rotate(180deg);
}

.app-dropdown__menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 190px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  box-shadow: var(--elev-3);
  display: none;
  z-index: 1040;
}

.app-dropdown.is-open .app-dropdown__menu {
  display: block;
}

.app-dropdown__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.app-dropdown__item:hover,
.app-dropdown__item:focus {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.app-dropdown__item i {
  width: 16px;
  font-size: 15px;
  color: var(--text-muted);
  text-align: center;
}

.app-dropdown__divider {
  height: 1px;
  margin: 5px 0;
  background: var(--border);
}

/* ---------------------------------------------------------------- Cards */

.card {
  margin-bottom: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--elev-1);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  border-radius: var(--radius-card) var(--radius-card) 0 0;
}

.card-header h5 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-header .card-header__hint {
  font-size: 13px;
  color: var(--text-muted);
}

.card-block {
  padding: 20px;
}

.card--danger {
  border-color: rgba(var(--red-rgb), 0.45);
}

.card--danger .card-header h5 {
  color: var(--red);
}

/* ---------------------------------------------------------------- Forms */

.form-group {
  margin-bottom: 16px;
}

.form-section {
  margin-bottom: 28px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.form-section:last-of-type {
  margin-bottom: 20px;
  padding-bottom: 0;
  border-bottom: 0;
}

.form-section__title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.form-section__hint {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--text-muted);
}

.form-section__hint strong {
  color: var(--text);
  font-weight: 600;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--accent);
  flex: none;
}

.consent-row {
  margin-top: 4px;
  margin-bottom: 0;
  color: var(--text-muted);
}

.consent-row a {
  margin-left: 2px;
}

.apikey-reveal {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
}

.apikey-reveal code {
  flex: 1;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 13px;
  word-break: break-all;
}

.form-label,
label.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.form-control,
select.form-control,
textarea.form-control {
  height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  color: var(--text);
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.form-control {
  height: auto;
  min-height: 90px;
}

.form-control::placeholder {
  color: var(--text-faint);
}

.form-control:focus {
  border-color: var(--accent);
  background: var(--bg-inset);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
  outline: none;
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--surface-3);
  color: var(--text-muted);
  cursor: not-allowed;
}

select.form-control {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 17px, calc(100% - 11px) 17px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.form-text,
.form-hint {
  margin-top: 5px;
  font-size: 12px;
  color: var(--text-muted);
}

/* File drop zone - wraps a real <input type="file"> which stays the source of truth */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: 1;
  min-height: 140px;
  padding: 18px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  color: var(--text-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.dropzone:hover {
  border-color: var(--accent);
  color: var(--text);
}

.dropzone.is-dragover {
  border-color: var(--accent);
  background: var(--accent-gradient-soft);
  color: var(--text);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--accent);
  color: var(--text);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone__icon {
  font-size: 20px;
  line-height: 1;
}

.dropzone__primary {
  font-size: 13px;
  font-weight: 500;
  word-break: break-all;
}

.dropzone__secondary {
  font-size: 12px;
  color: var(--text-faint);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s ease, background 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--accent-gradient);
  border-color: transparent;
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translate(20px, -50%);
  background: #fff;
}

.toggle-switch input:focus-visible + .toggle-slider {
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.3);
}

/* ------------------------------------------------------------- Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover,
.btn:focus {
  background: var(--surface-3);
  border-color: var(--border-hover);
  color: var(--text);
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn i {
  font-size: 15px;
}

.btn-primary,
.btn-accent {
  border-color: transparent;
  background: var(--accent-gradient);
  color: #0f1117;
  font-weight: 600;
}

.btn-primary:hover,
.btn-primary:focus,
.btn-accent:hover,
.btn-accent:focus {
  border-color: transparent;
  background: var(--accent-gradient);
  color: #0f1117;
  filter: brightness(1.08);
}

html[data-theme="light"] .btn-primary,
html[data-theme="light"] .btn-accent {
  color: #fff;
}

html[data-theme="light"] .btn-primary:hover,
html[data-theme="light"] .btn-primary:focus,
html[data-theme="light"] .btn-accent:hover,
html[data-theme="light"] .btn-accent:focus {
  color: #fff;
}

/* Datta's outline-secondary is used all over the templates as the default
   button; map it onto the neutral surface style rather than restyling markup. */
.btn-outline-secondary {
  border-color: var(--border);
  background: var(--surface-2);
  color: var(--text);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  border-color: var(--border-hover);
  background: var(--surface-3);
  color: var(--text);
}

.btn-outline-danger,
.btn-danger {
  border-color: rgba(var(--red-rgb), 0.5);
  background: rgba(var(--red-rgb), 0.12);
  color: var(--red);
}

.btn-outline-danger:hover,
.btn-outline-danger:focus,
.btn-danger:hover,
.btn-danger:focus {
  border-color: var(--red);
  background: rgba(var(--red-rgb), 0.2);
  color: var(--red);
}

.btn-link {
  height: auto;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
}

.btn-link:hover {
  background: transparent;
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Inline spinner used by the dashboard submit button */
.submit-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(var(--accent-rgb), 0.3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: leximo-spin 0.7s linear infinite;
}

@keyframes leximo-spin {
  to {
    transform: rotate(360deg);
  }
}

/* --------------------------------------------------------------- Tables */

.table {
  width: 100%;
  margin: 0;
  border-collapse: separate;
  border-spacing: 0;
  color: var(--text);
  font-size: 13.5px;
}

.table th,
.table td {
  padding: 10px 14px;
  border-top: none;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table tbody tr {
  transition: background 0.12s ease;
}

.table-hover tbody tr:hover {
  background: var(--surface-2);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table-responsive {
  max-height: calc(100vh - 330px);
  overflow-y: auto;
  border-radius: 0 0 var(--radius-card) var(--radius-card);
}

.card-block.table-border-style {
  padding: 0;
}

/* Cells that hold row action buttons */
.table .cell-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.table .cell-mono {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.icon-btn:hover,
.icon-btn:focus {
  color: var(--text);
  border-color: var(--border-hover);
  background: var(--surface-3);
  text-decoration: none;
}

.icon-btn--danger:hover {
  color: var(--red);
  border-color: rgba(var(--red-rgb), 0.5);
}

.icon-btn i {
  font-size: 14px;
}

/* Status pills */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  text-transform: capitalize;
}

.status-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}

.status-pill--done {
  background: rgba(var(--green-rgb), 0.14);
  border-color: rgba(var(--green-rgb), 0.35);
  color: var(--green);
}

.status-pill--running {
  background: rgba(var(--accent-rgb), 0.14);
  border-color: rgba(var(--accent-rgb), 0.35);
  color: var(--accent);
}

.status-pill--running::before {
  animation: leximo-pulse 1.4s ease-in-out infinite;
}

@keyframes leximo-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}

.status-pill--failed {
  background: rgba(var(--red-rgb), 0.14);
  border-color: rgba(var(--red-rgb), 0.35);
  color: var(--red);
}

.status-pill--queued {
  background: rgba(var(--yellow-rgb), 0.14);
  border-color: rgba(var(--yellow-rgb), 0.35);
  color: var(--yellow);
}

.status-pill--idle {
  background: var(--surface-3);
  border-color: var(--border);
  color: var(--text-muted);
}

/* --------------------------------------------------------------- Modals */

.leximo-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--overlay);
  backdrop-filter: blur(4px);
}

.leximo-modal.is-open {
  display: flex;
}

.leximo-modal__content {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 26px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--elev-3);
}

.leximo-modal__content--wide {
  max-width: 1000px;
}

.leximo-modal__content--danger {
  border-color: rgba(var(--red-rgb), 0.5);
}

.leximo-modal__title {
  margin: 0 0 12px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.leximo-modal__close {
  position: absolute;
  right: 14px;
  top: 12px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.leximo-modal__close:hover {
  color: var(--text);
}

.leximo-modal__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.modal-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-checkbox input {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* Key/value block used by the job information modal */
.job-info {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  overflow-x: auto;
}

.job-info code {
  display: block;
  padding: 1px 0;
  color: var(--text-soft);
  background: transparent;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
}

.job-info table {
  margin-top: 8px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.job-info table td {
  padding: 2px 12px 2px 0;
}

/* -------------------------------------------------------------- Content */

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text);
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

hr {
  border-top-color: var(--border);
}

code,
kbd {
  font-family: var(--font-mono);
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-danger {
  color: var(--red) !important;
}

.text-success {
  color: var(--green) !important;
}

.page-title {
  margin: 0 0 18px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.maintenance-banner {
  position: sticky;
  top: 0;
  z-index: 1099;
  padding: 9px 16px;
  background: rgba(var(--yellow-rgb), 0.16);
  border-bottom: 1px solid rgba(var(--yellow-rgb), 0.4);
  color: var(--text);
  font-weight: 600;
  text-align: center;
}

/* Django messages */
.alert {
  padding: 11px 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.alert-success {
  border-color: rgba(var(--green-rgb), 0.4);
  background: rgba(var(--green-rgb), 0.12);
}

.alert-danger,
.alert-error {
  border-color: rgba(var(--red-rgb), 0.4);
  background: rgba(var(--red-rgb), 0.12);
}

.alert-warning {
  border-color: rgba(var(--yellow-rgb), 0.4);
  background: rgba(var(--yellow-rgb), 0.12);
}

/* Bootstrap resets that would otherwise fight the tokens */
.dropdown-menu {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.close {
  color: var(--text-muted);
  text-shadow: none;
}

.close:hover {
  color: var(--text);
}

/* ----------------------------------------------------------------- Help */

.help-section,
.help-note {
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.help-section:last-child,
.help-note:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.help-section h5,
.help-note h5 {
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
}

.help-section p,
.help-note p {
  margin-bottom: 10px;
  color: var(--text-soft);
  font-size: 14px;
}

.help-list {
  margin: 0 0 10px;
  padding-left: 20px;
  color: var(--text-soft);
  font-size: 14px;
}

.help-list li {
  margin-bottom: 5px;
}

.help-list ul {
  margin-top: 5px;
  padding-left: 20px;
  color: var(--text-muted);
}

.help-note {
  padding: 16px 18px;
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: var(--radius-control);
  background: var(--accent-gradient-soft);
}

/* ------------------------------------------------------------ Dashboard */

.job-submit {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(320px, 1.6fr);
  gap: 20px 28px;
  align-items: stretch;
}

.job-submit__file {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.job-submit__controls {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.job-submit__row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.job-submit__field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.job-submit__field--timeline {
  align-items: flex-start;
  min-width: 72px;
}

.job-submit__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 4px;
}

.job-submit__footer .consent-row {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.job-submit__action {
  flex: none;
  white-space: nowrap;
}

@media (max-width: 991.98px) {
  .job-submit {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .job-submit__file .dropzone {
    min-height: 110px;
  }
}

@media (max-width: 575.98px) {
  .job-submit__row {
    grid-template-columns: 1fr;
  }

  .job-submit__footer {
    flex-direction: column;
    align-items: stretch;
  }

  .job-submit__action {
    width: 100%;
  }
}

.jobs-empty {
  padding: 30px 14px;
  color: var(--text-muted);
  text-align: center;
}

.jobs-filename {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 320px;
  height: 30px;
  padding: 0 10px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.jobs-filename:hover {
  border-color: rgba(var(--accent-rgb), 0.45);
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent);
  text-decoration: none;
}

.jobs-filename:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.jobs-filename__icon {
  flex: none;
  font-size: 14px;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.jobs-filename:hover .jobs-filename__icon {
  color: var(--accent);
}

.jobs-filename__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------------------------------------------------- Chips multiselect */

.chips {
  position: relative;
}

.chips__native {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.chips__control {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 32px 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--bg-inset);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chips__control:hover {
  border-color: var(--border-hover);
}

.chips.is-open .chips__control,
.chips__control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.18);
  outline: none;
}

.chips__items {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.chips__placeholder {
  color: var(--text-faint);
  font-size: 14px;
  line-height: 28px;
}

.chips__chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  padding: 3px 4px 3px 9px;
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: var(--radius-pill);
  background: rgba(var(--accent-rgb), 0.14);
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.5;
}

.chips__chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chips__remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.chips__remove:hover {
  background: rgba(var(--accent-rgb), 0.25);
  color: var(--text);
}

.chips__caret {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 15px;
  pointer-events: none;
  transition: transform 0.2s ease;
}

.chips.is-open .chips__caret {
  transform: translateY(-50%) rotate(180deg);
}

.chips__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  z-index: 1050;
  display: none;
  padding: 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface-2);
  box-shadow: var(--elev-3);
}

.chips.is-open .chips__menu {
  display: block;
}

.chips__search {
  width: 100%;
  height: 32px;
  margin-bottom: 6px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-inset);
  color: var(--text);
  font-size: 13px;
}

.chips__search:focus {
  border-color: var(--accent);
  outline: none;
}

.chips__options {
  max-height: 230px;
  overflow-y: auto;
}

.chips__option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.chips__option:hover {
  background: var(--surface-3);
}

.chips__option.is-selected {
  color: var(--accent);
  font-weight: 500;
}

.chips__option.is-selected::after {
  content: "\2713";
  font-size: 13px;
}

.chips__empty {
  padding: 9px 10px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

/* ---------------------------------------------------------- Responsive */

@media (max-width: 991.98px) {
  :root {
    --rail-width: 56px;
  }

  .app-header {
    padding: 0 14px;
    gap: 10px;
  }

  .app-main {
    padding: calc(var(--header-height) + 16px) 14px 22px;
  }

  .usage-pill {
    padding: 4px 9px;
  }

  .usage-pill__label {
    font-size: 11px;
  }

  .usage-pill__value {
    font-size: 12px;
  }
}

@media (max-width: 767.98px) {
  .app-header__wordmark {
    display: none;
  }

  /* Metrics move below the header bar on narrow screens */
  .app-header {
    flex-wrap: wrap;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .app-header__meta {
    order: 3;
    width: 100%;
    gap: 6px;
    padding-bottom: 4px;
  }

  .app-main {
    padding-top: calc(var(--header-height) + 58px);
  }

  .table-responsive {
    max-height: none;
  }
}
