/* Scale everything down — Pico CSS uses rem units */
:root {
  font-size: 75%;
}

/* Two-column detail grid */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0 2rem;
}

.detail-grid > section {
  min-width: 0;
}

/* Status badges */
.badge {
  display: inline-block;
  padding: 0.25em 0.5em;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.badge-pending {
  background-color: #fff3cd;
  color: #664d03;
}

.badge-approved {
  background-color: #d1e7dd;
  color: #0a3622;
}

.badge-rejected {
  background-color: #f8d7da;
  color: #58151c;
}

.badge-running {
  background-color: #cfe2ff;
  color: #052c65;
}

/* Dashboard summary grid */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.summary-card {
  text-align: center;
}

.summary-card h2 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.summary-card p {
  margin: 0;
  color: var(--pico-muted-color);
}

/* Toast notifications */
#toast:empty {
  display: none;
}

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  z-index: 1000;
  animation: toast-in 0.3s ease, toast-out 0.3s ease 2.7s forwards;
}

.toast-success {
  background-color: #d1e7dd;
  color: #0a3622;
  border: 1px solid #a3cfbb;
}

.toast-error {
  background-color: #f8d7da;
  color: #58151c;
  border: 1px solid #f1aeb5;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Active nav state */
nav a[aria-current="page"],
nav details summary[aria-current="page"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* Vessel search layout — two columns */
.search-layout {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) 3fr;
  gap: 0 2rem;
  align-items: start;
}

.search-main {
  position: sticky;
  top: 1rem;
}

.search-filters h3 {
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

/* Vessel filter grid — 4 columns */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0 1.5rem;
}

.filter-grid > * {
  min-width: 0;
}

/* Compact filter sections */
.filter-section {
  margin-bottom: 0.5rem;
}

.filter-section summary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 600;
  color: var(--pico-muted-color);
  padding: 0.5rem 0;
  list-style: none;
  cursor: pointer;
}

.filter-section summary::-webkit-details-marker {
  display: none;
}

/* Active filter summary chips */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

.filter-chip {
  display: inline-block;
  padding: 0.2em 0.6em;
  border-radius: 1rem;
  font-size: 0.75rem;
  background-color: var(--pico-secondary-background);
  color: var(--pico-secondary-inverse);
}

/* HTMX loading indicator */
.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: inline-block;
}

/* Review detail — two-column layout with sticky decision panel */
.review-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 2rem;
  align-items: start;
}

.review-data {
  min-width: 0; /* prevent overflow from <pre> */
}

.review-decision {
  position: sticky;
  top: 1rem;
}

@media (max-width: 1200px) {
  .review-layout {
    grid-template-columns: 1fr;
  }
}

/* Pipeline sub-navigation */
.pipeline-nav {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--pico-muted-border-color);
}

.pipeline-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pipeline-nav li {
  margin: 0;
  padding: 0;
}

.pipeline-nav a {
  display: block;
  padding: 0.5rem 1rem;
  text-decoration: none;
  color: var(--pico-muted-color);
  font-size: 0.85rem;
  border-bottom: 2px solid transparent;
}

.pipeline-nav a:hover {
  color: var(--pico-primary);
}

.pipeline-nav a[aria-current="page"] {
  color: var(--pico-primary);
  border-bottom-color: var(--pico-primary);
  font-weight: 600;
}

/* Pipeline layer flow */
.pipeline-layers {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.pipeline-layer-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.pipeline-layer-group > h3 {
  font-size: 0.85rem;
  margin: 0;
  color: var(--pico-muted-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.pipeline-count-boxes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
}

.pipeline-count-box {
  display: block;
  padding: 1rem;
  border: 1px solid var(--pico-muted-border-color);
  border-radius: var(--pico-border-radius);
  text-align: center;
  text-decoration: none;
  color: inherit;
  background: var(--pico-card-background-color);
}

.pipeline-count-box:hover {
  border-color: var(--pico-primary);
}

.pipeline-count-box .count {
  font-size: 1.75rem;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.pipeline-count-box .label {
  font-size: 0.8rem;
  color: var(--pico-muted-color);
  display: block;
  margin-top: 0.25rem;
}

/* Vessel history table — sticky header rows + first column */
.history-table-wrap {
  overflow: auto;
  max-height: 80vh;
}

.history-table {
  border-collapse: separate;
  border-spacing: 0;
}

.history-table thead th,
.history-table thead td {
  position: sticky;
  background-color: var(--pico-background-color);
  z-index: 2;
}

.history-table thead tr:nth-child(1) th,
.history-table thead tr:nth-child(1) td {
  top: 0;
}

.history-table thead tr:nth-child(2) th,
.history-table thead tr:nth-child(2) td {
  top: var(--history-row-1, 2.5rem);
}

.history-table thead tr:nth-child(3) th,
.history-table thead tr:nth-child(3) td {
  top: var(--history-row-2, 5rem);
}

.history-table thead tr:nth-child(4) th,
.history-table thead tr:nth-child(4) td {
  top: var(--history-row-3, 7.5rem);
}

.history-table tbody th {
  position: sticky;
  left: 0;
  background-color: var(--pico-background-color);
  z-index: 1;
}

.history-table thead th:first-child {
  left: 0;
  z-index: 3;
}

/* Vertical column separators — merged cells skip internal boundaries */
.history-table th,
.history-table td {
  border-right: 1px solid var(--pico-muted-border-color);
}

.history-table th:last-child,
.history-table td:last-child {
  border-right: none;
}

/* Group section headers between tbody groups */
.history-table th.history-group {
  text-align: left;
  background-color: var(--pico-secondary-background);
  color: var(--pico-secondary-inverse);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem;
  border-right: none;
}

.history-table tbody + tbody th.history-group {
  border-top: 2px solid var(--pico-muted-border-color);
}

/* Entities list — country chips */
.country-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.5rem 0 0.75rem;
}

.country-chips .chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.2em 0.6em;
  border-radius: 1rem;
  font-size: 0.8rem;
  background-color: var(--pico-secondary-background);
  color: var(--pico-secondary-inverse);
}

.country-chips .chip-remove {
  background: none;
  border: none;
  color: inherit;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0.1em;
  margin: 0;
  width: auto;
  cursor: pointer;
}

/* Inline form buttons with tight horizontal padding (HTMX-edited tables).
   Vertical sizing left to Pico's defaults so they line up with inputs. */
.btn-slim {
  padding-left: 0.4rem;
  padding-right: 0.4rem;
  width: auto;
  margin: 0;
}
