/* ── Google Sign-in Button ───────────────────────────────────────────── */
.btn-google {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 1.4rem;
  background: #fff;
  color: #3c4043;
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid #dadce0;
  border-radius: 4px;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}
.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* ── User Bar ─────────────────────────────────────────────────────────── */
.user-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 1rem;
  font-size: 0.82rem;
  color: #555;
  margin-bottom: 1rem;
}
.user-bar a {
  color: #3a6ea5;
  text-decoration: none;
}
.user-bar a:hover { text-decoration: underline; }

/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f5f6f8;
  color: #1a1a2e;
  line-height: 1.6;
  padding: 2rem 1rem;
}

/* ── Layout ──────────────────────────────────────────────────────────── */
.container {
  max-width: 720px;
  margin: 0 auto;
}

h1 {
  font-size: 1.8rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.subtitle {
  color: #555;
  margin-bottom: 2rem;
}

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: #3a6ea5;
  text-decoration: none;
  font-size: 0.9rem;
}
.back-link:hover { text-decoration: underline; }

/* ── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #dde1e7;
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}

.card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1rem 0 0.5rem;
}

hr { border: none; border-top: 1px solid #eee; margin: 1rem 0; }

/* ── Form Elements ───────────────────────────────────────────────────── */
label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-top: 1rem;
  margin-bottom: 0.3rem;
  color: #333;
}
label:first-of-type { margin-top: 0; }

textarea, input[type="email"], select {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #ccd0d5;
  border-radius: 6px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fafafa;
  transition: border-color 0.15s;
}
textarea:focus, input:focus, select:focus {
  outline: none;
  border-color: #3a6ea5;
  background: #fff;
}

select[multiple] {
  padding: 0.3rem;
}

input[type="file"] {
  padding: 0.4rem 0;
  border: none;
  background: transparent;
  font-size: 0.875rem;
}

.hint {
  font-size: 0.82rem;
  color: #666;
  margin-bottom: 0.75rem;
}

kbd {
  display: inline-block;
  padding: 0.1em 0.4em;
  font-size: 0.8em;
  background: #eee;
  border: 1px solid #bbb;
  border-radius: 3px;
}

code {
  font-family: "SFMono-Regular", Consolas, monospace;
  background: #f0f2f5;
  padding: 0.15em 0.35em;
  border-radius: 3px;
  font-size: 0.85em;
}

.hidden { display: none !important; }

/* ── Optional badge ──────────────────────────────────────────────────── */
.optional-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 500;
  color: #6b7280;
  background: #f3f4f6;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 0.1em 0.55em;
  vertical-align: middle;
  margin-left: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ── Download Button ─────────────────────────────────────────────────── */
.btn-download {
  display: inline-block;
  margin: 0.5rem 0 0.75rem;
  padding: 0.55rem 1.1rem;
  background: #16a34a;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 7px;
  text-decoration: none;
  transition: background 0.15s;
}
.btn-download:hover { background: #15803d; }

/* ── Submit Button ───────────────────────────────────────────────────── */
.btn-submit {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: #2563eb;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 0.5rem;
}
.btn-submit:hover { background: #1d4ed8; }

/* ── Status Page ─────────────────────────────────────────────────────── */
.status-row {
  display: flex;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #f0f0f0;
  align-items: flex-start;
}
.status-row:last-child { border-bottom: none; }

.label {
  flex: 0 0 110px;
  font-weight: 500;
  font-size: 0.875rem;
  color: #555;
  padding-top: 0.05rem;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.82rem;
  word-break: break-all;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.2em 0.65em;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-running   { background: #dbeafe; color: #1e40af; }
.badge-success   { background: #d1fae5; color: #065f46; }
.badge-failed    { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.badge-awaiting_confirmation { background: #ffedd5; color: #9a3412; }

/* ── Checkbox group (vertical) + voyage-update preview ──────────────────────── */
.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-top: 0.4rem;
}
.checkbox-group label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-weight: normal;
  cursor: pointer;
}
.voyage-preview-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.6rem;
  font-size: 0.92rem;
}
.voyage-preview-table th, .voyage-preview-table td {
  border: 1px solid #e5e7eb;
  padding: 0.4rem 0.6rem;
  text-align: left;
}
.voyage-preview-table th { background: #f9fafb; }
.voyage-preview-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.confirm-box {
  background: #fff7ed;
  border: 1px solid #fdba74;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}
.btn-confirm {
  background: #c0392b; color: #fff; border: none; border-radius: 6px;
  padding: 0.7rem 1.4rem; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.btn-confirm:hover { background: #a93226; }

/* Info/success/error/cancelled boxes */
.info-box, .success-box, .error-box, .cancelled-box {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-top: 1rem;
  font-size: 0.9rem;
}
.info-box      { background: #eff6ff; border: 1px solid #bfdbfe; color: #1e40af; }
.success-box   { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.error-box     { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.cancelled-box { background: #f9fafb; border: 1px solid #d1d5db; color: #6b7280; }

/* ── Abort Buttons ───────────────────────────────────────────────────── */
.btn-abort {
  padding: 0.45rem 1rem;
  background: #fff;
  color: #b91c1c;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.btn-abort:hover { background: #fef2f2; border-color: #f87171; }

.btn-abort-small {
  padding: 0.25rem 0.65rem;
  background: transparent;
  color: #b91c1c;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid #fca5a5;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-abort-small:hover { background: #fef2f2; }

.error-detail {
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 0.75rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #7f1d1d;
}

/* ── Active Job Banner ───────────────────────────────────────────────── */
.active-job-banners {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}
.active-job-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid #2563eb;
  border-radius: 8px;
  padding: 0.75rem 1.1rem;
  font-size: 0.9rem;
  color: #1e40af;
}
.active-job-banner a {
  white-space: nowrap;
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}
.active-job-banner a:hover { text-decoration: underline; }

/* ── Tabs: level 1 (category) ───────────────────────────────────────── */
.tab-nav-top {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.tab-top-btn {
  padding: 0.4rem 1rem;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #6b7280;
  background: #eef0f4;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tab-top-btn:hover { background: #e2e5eb; }
.tab-top-btn.active {
  background: #1a1a2e;
  color: #fff;
}
.tab-top-btn-danger.active { background: #b45309; }

/* ── Tabs: level 2 (tool within the category) ───────────────────────── */
.tab-nav-sub {
  border-bottom: 2px solid #dde1e7;
  margin-bottom: 1.5rem;
}

.tab-sub-group {
  display: none;
  gap: 0;
}
.tab-sub-group.active { display: flex; }

.tab-btn {
  padding: 0.6rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 500;
  color: #555;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: #1a1a2e; }
.tab-btn.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
  font-weight: 600;
}
.tab-btn-danger.active {
  color: #b45309;
  border-bottom-color: #b45309;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Progress Bar ────────────────────────────────────────────────────── */
.progress-wrap {
  width: 100%;
  height: 10px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
  margin: 0.9rem 0 0.35rem;
}
.progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
  width: var(--w, 0%);
  transition: width 0.5s ease;
}
.progress-text {
  display: block;
  font-size: 0.82rem;
  color: #1e40af;
}

.phase-text {
  display: block;
  font-size: 0.78rem;
  color: #6b7280;
  margin-top: 0.25rem;
  min-height: 1em;
}

/* ── Job History Table ───────────────────────────────────────────────── */
.job-history {
  margin-top: 2rem;
}
.job-history h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: #1a1a2e;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin: 0 -1.5rem;
  width: calc(100% + 3rem);
}
.history-table thead {
  background: #f8f9fb;
  border-top: 1px solid #dde1e7;
  border-bottom: 1px solid #dde1e7;
}
.history-table th {
  text-align: left;
  padding: 0.6rem 1.5rem;
  font-weight: 600;
  color: #555;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.history-table td {
  padding: 0.6rem 1.5rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
}
.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover td { background: #fafbff; }

.history-date { color: #888; font-size: 0.82rem; white-space: nowrap; }

.history-link {
  color: #2563eb;
  text-decoration: none;
  font-weight: 500;
  font-size: 0.85rem;
}
.history-link:hover { text-decoration: underline; }

.progress-cell { white-space: nowrap; }
.mini-progress-wrap {
  display: inline-block;
  width: 60px;
  height: 6px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 0.35rem;
}
.mini-progress-fill {
  height: 100%;
  background: #2563eb;
  border-radius: 999px;
}
.mini-progress-text {
  font-size: 0.8rem;
  color: #555;
  vertical-align: middle;
}

.radio-group {
  display: flex;
  gap: 1.5rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}
.radio-group label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: normal;
  cursor: pointer;
}

/* ── Recent Jobs: hide extra rows, show-more button ─────────────────────────── */
.job-row-hidden { display: none; }

.job-history-more {
  padding: 0.6rem 1.5rem 0.2rem;
  margin: 0 -1.5rem;
  border-top: 1px solid #f0f0f0;
}
.btn-show-more {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.btn-show-more:hover { text-decoration: underline; }

/* ── Scraper Health section ──────────────────────────────────────────────────── */
.health-report-section { margin-top: 2rem; }
.health-report-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: #1a1a2e;
}

.health-report-loading { color: #999; font-size: 0.875rem; }

.health-report-wrap {
  overflow-x: auto;
  margin: 0.75rem -1.5rem 0;
}

.health-report-table {
  border-collapse: collapse;
  font-size: 0.8rem;
  min-width: 100%;
}
.health-report-table thead {
  background: #f8f9fb;
  border-top: 1px solid #dde1e7;
  border-bottom: 1px solid #dde1e7;
}
.health-report-table th {
  padding: 0.5rem 0.75rem;
  font-weight: 600;
  color: #555;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: left;
}
.health-report-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  vertical-align: middle;
}
.health-report-table tr:last-child td { border-bottom: none; }
.health-report-table tr:hover td { background: #fafbff; }

.health-report-emoji { text-align: center !important; font-size: 1rem; }
.health-report-scraper { font-family: monospace; font-size: 0.82rem; color: #222; white-space: nowrap; }
.health-report-imo { font-family: monospace; color: #555; }
.health-report-note {
  color: #777;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.health-report-legend { margin: 0.6rem 1.5rem 0; font-size: 0.78rem; }

/* ── DB Fetch Panel ──────────────────────────────────────────────────────── */
.db-fetch-details {
  margin-top: 1.25rem;
  border-top: 1px solid #eee;
  padding-top: 0.9rem;
}
.db-fetch-details summary {
  cursor: pointer;
  color: #2563eb;
  font-weight: 500;
  font-size: 0.875rem;
  user-select: none;
  list-style: none;
}
.db-fetch-details summary::-webkit-details-marker { display: none; }
.db-fetch-details:not([open]) summary::before { content: '▸ '; }
.db-fetch-details[open] summary::before { content: '▾ '; }
.db-fetch-body { margin-top: 0.85rem; }
.db-fetch-row {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  flex-wrap: wrap;
}
.db-fetch-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.db-fetch-field label { margin-top: 0; margin-bottom: 0; }
.db-fetch-field .radio-group { margin-top: 0.25rem; }
.db-date-input {
  width: auto;
  padding: 0.45rem 0.6rem;
  font-size: 0.875rem;
}
.btn-fetch-db {
  padding: 0.45rem 1rem;
  background: #2563eb;
  color: #fff;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-fetch-db:hover { background: #1d4ed8; }

/* ── Mobile (≤640px) ─────────────────────────────────────────────────────────
   No responsive rules existed before this block. Main goal: stop wide tables and
   the tab bar from overflowing the viewport by making them scroll horizontally
   within their own box instead of pushing the whole page wide. */
@media (max-width: 640px) {
  body { padding: 1.25rem 0.75rem; }
  h1 { font-size: 1.5rem; }
  .subtitle { margin-bottom: 1.25rem; }
  .card { padding: 1.15rem 1rem; }

  /* Tab bar: scroll sideways instead of overflowing when the labels don't fit */
  .tab-nav-top,
  .tab-sub-group.active {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
  }
  .tab-nav-top::-webkit-scrollbar,
  .tab-sub-group::-webkit-scrollbar { height: 0; }
  .tab-top-btn { flex: 0 0 auto; white-space: nowrap; }
  .tab-btn {
    flex: 0 0 auto;
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    white-space: nowrap;
  }

  /* Wide tables: keep them inside the card and scroll horizontally on overflow */
  .history-table,
  .voyage-preview-table {
    display: block;
    width: 100%;
    margin: 0.5rem 0 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* history-table used a negative-margin edge-to-edge trick that overflows on
     narrow screens — neutralised above (margin/width reset). */
  .health-report-wrap { margin: 0.75rem 0 0; }

  /* Long monospace strings (job IDs / UUIDs) must wrap, not widen the layout */
  .mono { word-break: break-all; }
  .status-row { flex-wrap: wrap; gap: 0.15rem 0.5rem; }

  /* Forms and inputs never wider than the card */
  input, textarea, select { max-width: 100%; box-sizing: border-box; }
}

/* ── Argus oil price dashboard ─────────────────────────────────────── */
.argus-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1.25rem;
  margin-top: 0.75rem;
}
.argus-period-group { display: flex; gap: 0.35rem; }
.argus-period-btn {
  padding: 0.35rem 0.75rem;
  border: 1px solid #dde1e7;
  border-radius: 6px;
  background: #fff;
  color: #555;
  font-size: 0.82rem;
  cursor: pointer;
}
.argus-period-btn:hover { background: #f8f9fb; }
.argus-period-btn.active { background: #2a78d6; border-color: #2a78d6; color: #fff; }

.argus-group-filters { display: flex; flex-wrap: wrap; gap: 1rem; font-size: 0.85rem; color: #444; }
.argus-group-filters label { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }

.argus-series-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.1rem;
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid #eee;
}
.argus-series-filters label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: #444;
}
.argus-series-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.argus-chart-wrap { position: relative; height: 320px; margin-top: 0.5rem; }

.argus-table-scroll { overflow-x: visible; margin-top: 0.5rem; }
.argus-table {
  border-collapse: collapse;
  font-size: 0.74rem;
  width: 100%;
  table-layout: auto;
}
.argus-table thead {
  background: #f8f9fb;
  border-top: 1px solid #dde1e7;
  border-bottom: 1px solid #dde1e7;
}
.argus-table th {
  padding: 0.4rem 0.35rem;
  font-weight: 600;
  color: #555;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: center;
  white-space: normal;
  vertical-align: bottom;
  line-height: 1.25;
}
.argus-table th:first-child { text-align: left; }
.argus-table td {
  padding: 0.35rem 0.4rem;
  border-bottom: 1px solid #f0f0f0;
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  vertical-align: middle;
}
.argus-table td:first-child { white-space: normal; }
.argus-table td:first-child {
  text-align: left;
  font-weight: 500;
  color: #1a1a2e;
  min-width: 150px;
}
.argus-table tr:last-child td { border-bottom: none; }
.argus-table tr:hover td { background: #fafbff; }
.argus-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.4rem;
  vertical-align: middle;
}
.argus-discount-neg { color: #006300; }
.argus-discount-pos { color: #b02a2a; }
