:root {
  --bg: #f6f4ed;
  --fg: #1f2a2a;
  --accent: #0d6e6e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
  color: var(--fg);
  background: radial-gradient(circle at top right, #dfeee8, var(--bg));
}

header,
nav,
main,
footer {
  max-width: 1360px;
  margin: 0 auto;
  padding: 1rem;
}

nav a {
  margin-right: 1rem;
  color: var(--accent);
  text-decoration: none;
}

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

th,
td {
  border-bottom: 1px solid #cfd9d9;
  padding: 0.5rem;
  text-align: left;
}

.gallery-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
}

.gallery-grid img {
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.lightbox-dialog {
  border: 0;
  padding: 0.5rem;
}

.lightbox-dialog img {
  max-width: 85vw;
  max-height: 80vh;
}

@media (max-width: 640px) {
  header,
  nav,
  main,
  footer {
    padding: 0.75rem;
  }
}

.dive-overview-panel {
  background: linear-gradient(180deg, #f6fbf8, #eef5f1);
  border: 1px solid #ccddd5;
  border-radius: 18px;
  color: #23433a;
  padding: 1rem;
  box-shadow: 0 10px 22px rgba(36, 70, 58, 0.12);
}

.dive-overview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.dive-overview-head h2 {
  margin: 0;
  color: #1f3f35;
  font-size: 1.45rem;
}

.dive-overview-controls {
  display: flex;
  gap: 0.6rem;
}

.dive-overview-controls input,
.dive-overview-controls select,
.dive-overview-controls button {
  border: 1px solid #b8d0c5;
  background: #ffffff;
  color: #2b4a40;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
}

.dive-overview-controls button {
  cursor: pointer;
  background: #e6f1ec;
  border-color: #a7c5b8;
  font-weight: 600;
}

.dives-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
}

.dives-table thead th {
  background: #e3f0e9;
  color: #0f5e52;
  border-bottom: 1px solid #c4dbd0;
  font-weight: 700;
  padding: 0.75rem 0.8rem;
}

.dives-table tbody td {
  background: rgba(255, 255, 255, 0.95);
  color: #1f3931;
  border-bottom: 1px solid #d8e7e0;
  padding: 0.75rem 0.8rem;
}

.dives-table tbody tr:hover td {
  background: rgba(222, 239, 232, 0.9);
}

.dives-table tbody tr[data-href] {
  cursor: pointer;
}

.dives-table tbody tr[data-href]:focus-visible {
  outline: 2px solid #0f8d72;
  outline-offset: -2px;
}

.dive-col-number a {
  color: #0f7c67;
  font-weight: 700;
  text-decoration: none;
}

.dive-col-when strong,
.dive-col-when small {
  display: block;
}

.dive-col-when small {
  color: #6c8f83;
}

.dive-pagination {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.dive-pagination a {
  border: 1px solid #b8d0c5;
  border-radius: 8px;
  padding: 0.32rem 0.62rem;
  color: #2f5f52;
  text-decoration: none;
  background: #ffffff;
}

.dive-pagination a[aria-current="page"] {
  background: linear-gradient(145deg, #0f8d72, #0d6e6e);
  border-color: #0f8d72;
  color: #f4fffb;
  font-weight: 700;
}

@media (max-width: 900px) {
  .dive-overview-head {
    flex-direction: column;
    align-items: stretch;
  }

  .dive-overview-controls {
    width: 100%;
    flex-direction: column;
  }

  .dives-table {
    display: block;
    overflow-x: auto;
  }
}

.dive-detail-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dive-hero {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: linear-gradient(180deg, #f6fbf8, #eef5f1);
  border: 1px solid #ccddd5;
  border-radius: 18px;
  color: #1f3f35;
  padding: 1rem 1.2rem;
}

.dive-hero-wide {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dive-hero-top {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 1rem;
}

.dive-hero-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
}

.dive-hero-title-wrap {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 1rem;
}

.dive-hero-title-text {
  min-width: 0;
}

.dive-hero h2 {
  margin: 0;
  font-size: 2rem;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dive-hero p {
  margin: 0.2rem 0 0;
  color: #4f7065;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dive-hero-badge {
  background: linear-gradient(145deg, #0f8d72, #0d6e6e);
  color: #f4fffb;
  border-radius: 14px;
  font-weight: 700;
  padding: 0.55rem 0.85rem;
  min-width: 104px;
  text-align: center;
}

.dive-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.dive-metric-grid-hero {
  width: 100%;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0;
  border-top: 1px solid #d4e3dc;
  padding-top: 0.75rem;
}

.dive-metric-card {
  background: #ffffff;
  border: 1px solid #d3e4dc;
  border-radius: 12px;
  padding: 0.8rem;
}

.dive-metric-card-hero {
  border: 0;
  border-right: 1px solid #d8e6e0;
  border-radius: 0;
  background: transparent;
  padding: 0.25rem 0.8rem;
}

.dive-metric-card-hero:last-child {
  border-right: 0;
}

.dive-metric-card h4 {
  margin: 0;
  color: #5d8074;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dive-metric-card p {
  margin: 0.35rem 0 0;
  font-size: 1.45rem;
  font-weight: 700;
  color: #1f3f35;
}

.dive-metric-card-hero p {
  font-size: 1.15rem;
  line-height: 1.25;
}

.dive-layout-grid {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.dive-logbook-column {
  position: sticky;
  top: 1rem;
}

.dive-logbook-panel {
  max-height: calc(100vh - 2rem);
  overflow: auto;
}

.dive-sequence-nav {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.dive-sequence-nav-top {
  margin-bottom: 0;
}

.dive-sequence-nav-top .dive-sequence-link {
  min-width: 42px;
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #bcd2c9;
  border-radius: 12px;
  background: #e8f2ed;
  font-size: 1.15rem;
  line-height: 1;
}

.dive-sequence-link {
  color: #176f61;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.dive-sequence-link.is-disabled {
  color: #8ea9a0;
}

.logbook-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.logbook-item {
  border: 1px solid #d8e5df;
  border-radius: 10px;
  background: #f8fcfa;
}

.logbook-item.is-active {
  border-color: #0f8d72;
  background: #e6f4ef;
}

.logbook-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.65rem;
  color: #284740;
  text-decoration: none;
}

.logbook-link[aria-current="page"] {
  cursor: default;
}

.logbook-number {
  font-weight: 700;
  color: #0f6958;
}

.logbook-meta {
  font-size: 0.82rem;
  color: #5d7b72;
}

.dive-content-column {
  min-width: 0;
}

.dive-detail-grid {
  display: grid;
  grid-template-columns: 1.8fr 1fr;
  gap: 1rem;
}

.dive-main-column,
.dive-side-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.dive-panel {
  background: #ffffff;
  border: 1px solid #d3e4dc;
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(36, 70, 58, 0.09);
}

.dive-panel h3 {
  margin-top: 0;
  color: #1f3f35;
}

#profile-chart,
#profile-rate-chart {
  width: 100%;
  max-width: 700px;
  height: auto;
  cursor: crosshair;
}

#profile-chart-legend,
#profile-rate-legend {
  margin: 0.65rem 0 0;
  font-size: 0.9rem;
  color: #4d6a60;
  min-height: 1.2rem;
}

.tanks-grid {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.tank-card {
  border: 1px solid #d8e6e0;
  border-radius: 12px;
  background: #f8fcfa;
  padding: 0.75rem;
}

.tank-card h4 {
  margin: 0 0 0.55rem;
  color: #126454;
  font-size: 0.96rem;
}

.tank-card dl {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

.tank-card dt {
  color: #5f8175;
  font-size: 0.78rem;
}

.tank-card dd {
  margin: 0.15rem 0 0;
  font-weight: 700;
}

.tank-empty {
  margin: 0;
  color: #6f8880;
}

.dive-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin: 0;
}

.dive-details-grid div {
  border-bottom: 1px solid #e0ece6;
  padding-bottom: 0.55rem;
}

.dive-details-grid .dive-details-full {
  grid-column: 1 / -1;
}

.dive-details-grid dt {
  color: #5f8175;
  font-size: 0.88rem;
}

.dive-details-grid dd {
  margin: 0.2rem 0 0;
  font-weight: 600;
  word-break: break-word;
}

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

  .dive-logbook-column {
    position: static;
  }

  .dive-logbook-panel {
    max-height: none;
  }
}

@media (max-width: 900px) {
  .dive-metric-grid {
    grid-template-columns: 1fr;
  }

  .dive-metric-grid-hero {
    grid-template-columns: 1fr;
    gap: 0.3rem;
    border-top: 0;
    padding-top: 0;
  }

  .dive-metric-card-hero {
    border-right: 0;
    border-bottom: 1px solid #d8e6e0;
    padding: 0.5rem 0;
  }

  .dive-metric-card-hero:last-child {
    border-bottom: 0;
  }

  .dive-detail-grid {
    grid-template-columns: 1fr;
  }

  .dive-details-grid {
    grid-template-columns: 1fr;
  }

  .dive-sequence-nav {
    flex-direction: column;
    align-items: flex-start;
  }

  .dive-sequence-nav-top {
    flex-direction: row;
  }

  .dive-hero-top,
  .dive-hero-title-wrap {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
  }

  .dive-hero-title-text,
  .dive-hero h2,
  .dive-hero p {
    width: 100%;
    white-space: normal;
  }

  .dive-hero-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .dive-hero h2 {
    font-size: 1.6rem;
  }

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