/* Dive Log — "ship's log" theme.
   Surface light at the top of the page fading into abyssal blue;
   foam-white text, dive-flag red accents, tabular numerals for data. */

:root {
  --surface: #0e2a3d;
  --abyss: #061520;
  --card: #10344cdd;
  --line: #1e4a66;
  --foam: #e8f1f5;
  --muted: #8fb0c4;
  --flag-red: #e03e36;
  --sun: #f4c95d;
  --trace: #4fd1c5;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-body: "Avenir Next", "Segoe UI", Verdana, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--foam);
  font-family: var(--font-body);
  background: linear-gradient(180deg, #14425f 0%, var(--surface) 18%, var(--abyss) 100%) fixed;
}

h1, h2, h3, .brand { font-family: var(--font-display); letter-spacing: 0.02em; }
a { color: var(--trace); }

/* ── Top bar ─────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap;
  padding: 0.7rem 1.2rem;
  background: #071a28ee;
  border-bottom: 2px solid var(--flag-red);
  position: sticky; top: 0; z-index: 50;
}
.brand { font-size: 1.25rem; font-weight: 700; color: var(--foam); text-decoration: none; }
.topbar nav { display: flex; gap: 1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; padding: 0.2rem 0; border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--foam); border-bottom-color: var(--trace); }
.logout { margin-left: auto; }
.logout button { background: none; border: 1px solid var(--line); color: var(--muted);
  border-radius: 4px; padding: 0.3rem 0.7rem; cursor: pointer; }
.logout button:hover { color: var(--foam); border-color: var(--muted); }

main { max-width: 68rem; margin: 0 auto; padding: 1.4rem 1.2rem 4rem; }

.flash {
  max-width: 68rem; margin: 0.8rem auto 0; padding: 0.6rem 1rem;
  background: #14425f; border-left: 4px solid var(--sun); border-radius: 4px;
}
.error { color: #ff9088; }

/* ── Stats bar ───────────────────────────────────────── */
.stats-bar {
  display: flex; gap: 2rem; align-items: center; flex-wrap: wrap;
  padding: 1rem 1.4rem; margin-bottom: 1.2rem;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
}
.stat { display: flex; flex-direction: column; }
.stat-num {
  font-size: 1.7rem; font-family: var(--font-display);
  font-variant-numeric: tabular-nums; color: var(--sun);
}
.stat-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.stats-bar .button { margin-left: auto; }

/* ── Buttons & forms ─────────────────────────────────── */
.button, button[type="submit"] {
  display: inline-block; padding: 0.45rem 1rem; border-radius: 4px;
  border: 1px solid var(--line); background: #14425f; color: var(--foam);
  text-decoration: none; cursor: pointer; font-size: 0.95rem;
}
.button.primary, button.primary { background: var(--flag-red); border-color: var(--flag-red); font-weight: 600; }
.button:hover, button[type="submit"]:hover { filter: brightness(1.15); }
.button.danger { border-color: var(--flag-red); color: #ff9088; background: none; }

label { display: block; margin: 0.6rem 0 0.2rem; color: var(--muted); font-size: 0.9rem; }
input, select, textarea {
  width: 100%; max-width: 26rem; padding: 0.45rem 0.6rem;
  background: #0a2233; color: var(--foam);
  border: 1px solid var(--line); border-radius: 4px; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--trace); border-color: var(--trace); }

.filters { display: flex; gap: 0.8rem; margin-bottom: 0.8rem; }
.filters select { width: auto; }

/* ── Dive table ──────────────────────────────────────── */
.dive-table { width: 100%; border-collapse: collapse; }
.dive-table th {
  text-align: left; font-size: 0.75rem; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--muted); padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.dive-table td { padding: 0.55rem 0.7rem; border-bottom: 1px solid #12344a; }
.dive-table tbody tr { cursor: pointer; }
.dive-table tbody tr:hover { background: #103049; }
.dive-table .num { font-variant-numeric: tabular-nums; text-align: left; white-space: nowrap; }
.dive-table .dim { opacity: 0.45; }
.rating { color: var(--sun); letter-spacing: 0.1em; }
.muted { color: var(--muted); }
.empty { color: var(--muted); text-align: center; padding: 2rem; }

.depth-bar {
  display: block; height: 3px; margin-top: 3px; width: 100%;
  background: linear-gradient(90deg, var(--trace) var(--depth, 0%), #12344a var(--depth, 0%));
  border-radius: 2px;
}

/* ── Cards / detail pages ────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem;
}
.field-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.8rem 1.4rem;
}
.field-grid dt { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); }
.field-grid dd { margin: 0.1rem 0 0; font-variant-numeric: tabular-nums; }

.profile-chart svg { width: 100%; height: auto; }

.photo-grid { display: flex; flex-wrap: wrap; gap: 0.8rem; }
.photo-grid img {
  max-height: 10rem; border-radius: 6px; border: 1px solid var(--line);
}
.photo-grid img.signature { background: var(--foam); padding: 0.4rem; }

.form-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 2rem; }
@media (max-width: 40rem) { .form-cols { grid-template-columns: 1fr; } }
.tank-row {
  display: flex; gap: 1rem; flex-wrap: wrap; align-items: end;
  border: 1px solid var(--line); border-radius: 6px; margin: 0.6rem 0; padding: 0.6rem 0.8rem;
}
.tank-row label { margin: 0; }
.tank-row input { max-width: 7rem; }

/* ── Auth pages ──────────────────────────────────────── */
.auth-page { display: grid; place-items: center; min-height: 100vh; }
.auth-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 2rem 2.4rem; min-width: 20rem;
}
.auth-card h1 { margin-top: 0; }
.auth-card button { margin-top: 1rem; width: 100%; background: var(--flag-red); border-color: var(--flag-red); }

/* ── Map ─────────────────────────────────────────────── */
#map { height: 26rem; border-radius: 8px; border: 1px solid var(--line); }

@media (max-width: 40rem) {
  .stats-bar { gap: 1.1rem; }
  .filters { flex-wrap: wrap; }
}
