:root {
  --bg: #07111f;
  --panel: rgba(7, 22, 39, 0.88);
  --panel-strong: rgba(10, 29, 50, 0.96);
  --line: rgba(188, 161, 93, 0.25);
  --text: #eef3f8;
  --muted: #9fb0c3;
  --accent: #d4a94f;
  --accent-strong: #f1c56b;
  --danger: #e27d7d;
  --ok: #88d0a7;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Yu Gothic UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

.background {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(212, 169, 79, 0.2), transparent 28%),
    radial-gradient(circle at bottom right, rgba(55, 88, 146, 0.35), transparent 33%),
    linear-gradient(160deg, #06101c 0%, #081a2d 55%, #04111f 100%);
  z-index: -1;
}

.shell {
  width: calc(100% - 24px);
  margin: 24px auto 40px;
}

.hidden {
  display: none !important;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(16px);
}

.login-panel {
  width: min(560px, 100%);
  margin: 80px auto;
  padding: 32px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup-login {
  justify-content: center;
  margin-bottom: 18px;
}

.brand-icon {
  width: 54px;
  height: 54px;
  border-radius: 14px;
  flex: 0 0 auto;
}

.brand-icon-large {
  width: 84px;
  height: 84px;
  border-radius: 22px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 13px;
  color: var(--accent-strong);
}

h1, h2 {
  margin: 0 0 12px;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.5rem;
}

.lead, .hint {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 12px;
}

.compact {
  gap: 10px;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 14px;
}

.field-note {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

input, textarea, select, button {
  font: inherit;
}

input, textarea, select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 18, 31, 0.9);
  color: var(--text);
  padding: 12px 14px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

#job-bank-brands-text {
  min-height: 110px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
}

.primary {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #18202b;
  font-weight: 700;
}

.ghost {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

#job-form > button[type="submit"] {
  width: auto !important;
  min-width: 0;
  display: inline-flex;
  justify-self: start;
  align-self: start;
  justify-content: center;
  flex: 0 0 auto;
  padding: 10px 18px;
  order: 99;
}

.danger {
  background: rgba(226, 125, 125, 0.18);
  color: #ffd4d4;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}

.store-switcher {
  margin-bottom: 18px;
  padding: 14px 20px;
}

.store-picker {
  min-width: 320px;
}

.job-store-select {
  min-width: 320px;
}

.store-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
}

.store-check {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.top-actions, .button-row, .toolbar, .inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-field {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-field > input {
  flex: 1 1 auto;
}

.compact-action {
  padding: 10px 14px;
  white-space: nowrap;
}

.form-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-start;
}

.user-pill {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 14px;
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.subtabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.subtab {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.subtab.active {
  background: rgba(212, 169, 79, 0.16);
  color: var(--accent-strong);
}

.subtab-panel {
  display: none;
}

.subtab-panel.active {
  display: block;
}

.dashboard-contracts-host {
  gap: 18px;
}

.tab {
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
}

.tab.active {
  background: rgba(212, 169, 79, 0.16);
  color: var(--accent-strong);
}

.tab-panel {
  display: none;
  gap: 18px;
}

.tab-panel.active {
  display: grid;
}

.grid {
  display: grid;
  gap: 18px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.rule-panel {
  display: grid;
  gap: 12px;
}

.rule-panel.subtab-panel {
  display: none;
}

.rule-panel.subtab-panel.active {
  display: grid;
}

.rule-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-panel h3 {
  margin: 0;
}

.cost-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.cost-fields.subtab-panel {
  display: none;
}

.cost-fields.subtab-panel.active {
  display: grid;
}

.cost-fields .rule-panel-head,
.cost-fields .table-wrap {
  grid-column: 1 / -1;
}

.domestic-table {
  min-width: 520px;
}

.domestic-table td:first-child,
.domestic-table th:first-child {
  min-width: 180px;
}

.handling-table {
  min-width: 880px;
}

.handling-table td:nth-child(3),
.handling-table th:nth-child(3) {
  min-width: 420px;
}

.gap-ranges-table {
  min-width: 1180px;
}

.gap-ranges-table td:nth-child(7),
.gap-ranges-table th:nth-child(7) {
  min-width: 220px;
}

.jobs-grid,
.admin-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-health-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.jobs-manager-toolbar {
  justify-content: space-between;
  align-items: center;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.stat-card {
  padding: 18px;
  border-radius: 18px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.stat-card strong {
  display: block;
  font-size: 32px;
  margin-top: 8px;
}

.table-wrap {
  overflow: auto;
}

.jobs-table {
  min-width: 1460px;
}

.jobs-table th:first-child,
.jobs-table td:first-child {
  width: 44px;
}

.jobs-table td:nth-child(7),
.jobs-table th:nth-child(7) {
  min-width: 96px;
}

.jobs-table td:nth-child(8),
.jobs-table th:nth-child(8) {
  min-width: 165px;
}

.jobs-table td:nth-child(9),
.jobs-table th:nth-child(9) {
  min-width: 130px;
}

.jobs-table td:nth-child(10),
.jobs-table th:nth-child(10),
.jobs-table td:nth-child(11),
.jobs-table th:nth-child(11) {
  min-width: 170px;
}

.jobs-table td:nth-child(12),
.jobs-table th:nth-child(12) {
  min-width: 280px;
}

.jobs-table td:last-child,
.jobs-table th:last-child {
  min-width: 190px;
}

.job-actions-cell {
  white-space: nowrap;
}

.job-actions-cell button {
  margin-right: 8px;
}

.job-actions-cell button:last-child {
  margin-right: 0;
}

.verify-panel {
  padding: 18px;
}

.verify-summary-grid,
.verify-metric-grid {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.verify-result-list {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.verify-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(6, 17, 30, 0.9);
  overflow: hidden;
}

.verify-card summary {
  list-style: none;
  cursor: pointer;
  padding: 18px;
}

.verify-card summary::-webkit-details-marker {
  display: none;
}

.verify-card-body {
  padding: 0 18px 18px;
}

.verify-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.verify-status-cluster {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.verify-pill {
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 13px;
}

.verify-table th,
.verify-table td {
  padding: 8px 10px;
  vertical-align: top;
}

.verify-table th {
  width: 42%;
  color: var(--muted);
  text-align: left;
  font-weight: 600;
}

.verify-section-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.verify-settings-box {
  margin-top: 16px;
}

.verify-settings-box summary {
  cursor: pointer;
  color: var(--accent-strong);
  margin-bottom: 10px;
}

.verify-status-active {
  background: rgba(136, 208, 167, 0.18);
  color: #c6ffd8;
}

.verify-status-qty_zero {
  background: rgba(212, 169, 79, 0.18);
  color: #ffe2a2;
}

.verify-status-excluded,
.verify-status-error {
  background: rgba(226, 125, 125, 0.18);
  color: #ffd4d4;
}

.jobs-table tr.is-selected {
  background: rgba(212, 169, 79, 0.08);
}

.job-status {
  display: inline-flex;
  align-items: center;
  min-width: 82px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
}

.job-phase-cell {
  display: grid;
  gap: 2px;
  line-height: 1.35;
  white-space: normal;
}

.job-phase-cell span:first-child,
.jobs-table td:nth-child(7),
.jobs-table td:nth-child(9),
.jobs-table td:nth-child(10),
.jobs-table td:nth-child(11) {
  font-variant-numeric: tabular-nums;
}

.job-status-running {
  background: rgba(136, 208, 167, 0.18);
  color: var(--ok);
}

.job-status-queued {
  background: rgba(212, 169, 79, 0.18);
  color: var(--accent-strong);
}

.job-status-done {
  background: rgba(91, 129, 198, 0.18);
  color: #b9d3ff;
}

.job-status-failed,
.job-status-stopped {
  background: rgba(226, 125, 125, 0.18);
  color: #ffd4d4;
}

.rule-table {
  min-width: 760px;
}

.rule-table th {
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}

.rule-table td {
  min-width: 110px;
}

.rule-table td:last-child,
.rule-table th:last-child {
  min-width: 90px;
}

.rule-table input,
.rule-table select {
  min-width: 100px;
  padding: 10px 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.json-box, .log-box {
  margin: 0;
  background: rgba(4, 10, 18, 0.92);
  border-radius: 16px;
  padding: 16px;
  min-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
}

.compact-box {
  min-height: 80px;
  margin-bottom: 14px;
}

.log-box {
  max-height: 360px;
}

.checkbox {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox input {
  width: auto;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.success {
  color: var(--ok);
}

code {
  color: var(--accent-strong);
}

@media (max-width: 980px) {
  .settings-grid,
  .jobs-grid,
  .admin-grid,
  .admin-health-grid,
  .card-grid {
    grid-template-columns: 1fr;
  }

  .cost-fields.subtab-panel.active {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
  }

  .verify-card-head,
  .verify-section-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .verify-status-cluster {
    justify-content: flex-start;
  }
}
