/* =================================================================
   Design system
   ================================================================= */

:root {
  /* ── Neutrals — barely-tinted ocean ──────────────────────────── */
  --bg-page:       #f6f9fb;
  --bg-card:       #ffffff;
  --bg-hover:      #eff4f7;
  --bg-subtle:     #f1f5f8;

  --text:          #0f1d2c;
  --text-muted:    #64748b;
  --text-heading:  #0a1420;
  --text-on-accent:#ffffff;

  /* ── Borders ─────────────────────────────────────────────────── */
  --border:        #e1e8ed;
  --border-strong: #c9d3db;

  /* ── Brand: Reef Secrets (bright reef cyan, deep navy, gold) ─── */
  --accent:        #00a4db;   /* reef cyan — primary */
  --accent-hover:  #007fb0;   /* deeper on hover */
  --accent-soft:   #e0f4fb;   /* tint for backgrounds */
  --accent-subtle: #f0faff;
  --brand-navy:    #0b2b4a;   /* deep navy for strong accents */
  --brand-gold:    #f5b83d;   /* seahorse gold */

  /* ── Status — muted, earthy ──────────────────────────────────── */
  --status-normal:     #047857;
  --status-normal-bg:  #ecfdf5;
  --status-warn:       #b45309;
  --status-warn-bg:    #fef3c7;
  --status-crit:       #b91c1c;
  --status-crit-bg:    #fee2e2;
  --status-info:       #1e40af;
  --status-info-bg:    #e0e7ff;

  /* ── Shadows — just two, used sparingly ──────────────────────── */
  --shadow-xs:  0 1px 2px rgba(15, 29, 44, 0.04);
  --shadow-lg:  0 12px 32px rgba(15, 29, 44, 0.10);

  /* ── Type scale ──────────────────────────────────────────────── */
  --fs-xs:   0.75rem;    /* 12 */
  --fs-sm:   0.8125rem;  /* 13 */
  --fs-base: 0.9375rem;  /* 15 */
  --fs-md:   1rem;       /* 16 */
  --fs-lg:   1.125rem;   /* 18 */
  --fs-xl:   1.375rem;   /* 22 */
  --fs-2xl:  1.75rem;    /* 28 */

  /* ── Spacing rhythm (4px base) ───────────────────────────────── */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* ── Corner radii ────────────────────────────────────────────── */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;

  /* ── Fonts ───────────────────────────────────────────────────── */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', "SF Mono", Menlo, Monaco, Consolas, monospace;
}

/* =================================================================
   Global
   ================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: 'cv11';
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-3);
  color: var(--text-heading);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4, h5 { font-size: var(--fs-md); }

p { margin: 0 0 var(--sp-3); }

a, a:visited { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }

::selection { background: var(--accent-soft); color: var(--text-heading); }

/* Numeric data always uses tabular numerals so columns line up */
.tabular, .el-value, .target-hint, .gauge-scale, .num,
.manual-input input, input[type="number"] {
  font-variant-numeric: tabular-nums;
}

/* =================================================================
   Topbar
   ================================================================= */

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  padding: 0 var(--sp-6);
  min-height: 56px;
}
.topbar .navbar-brand,
.topbar .navbar-brand:hover {
  color: var(--text-heading);
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: -0.015em;
  padding: 0;
  margin-right: var(--sp-6);
}
.topbar .navbar-brand i { color: var(--accent); }

/* Shop link — small external link to Reef Secrets store */
.topbar .shop-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--r-md);
  text-decoration: none;
  transition: color 0.12s ease, background 0.12s ease;
}
.topbar .shop-link:hover {
  color: var(--accent);
  background: var(--accent-soft);
}
.topbar .shop-link i { font-size: 11px; opacity: 0.7; }

.topbar .navbar-nav { gap: 0; }
.topbar .nav-link {
  color: var(--text-muted);
  padding: 16px 0;
  margin: 0 var(--sp-4) 0 0;
  border-radius: 0;
  font-weight: 500;
  font-size: var(--fs-sm);
  border-bottom: 2px solid transparent;
  transition: color 0.12s ease, border-color 0.12s ease;
}
.topbar .nav-link:hover {
  color: var(--text);
  background: transparent;
}
.topbar .nav-link.active {
  color: var(--text-heading);
  border-bottom-color: var(--accent);
  background: transparent;
}

/* =================================================================
   Buttons (Bootstrap overrides)
   ================================================================= */

.btn {
  font-family: var(--font-sans);
  font-weight: 500;
  font-size: var(--fs-sm);
  border-radius: var(--r-md);
  padding: 6px 12px;
  transition: background 0.1s ease, border-color 0.1s ease, color 0.1s ease;
}
.btn-sm { padding: 4px 10px; font-size: var(--fs-xs); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: var(--text-on-accent);
}

.btn-outline-light {
  color: var(--text);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
}
.btn-outline-light:hover {
  color: var(--text-heading);
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-secondary {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover {
  background: var(--border);
  border-color: var(--border-strong);
  color: var(--text-heading);
}

.btn-outline-danger {
  color: var(--status-crit);
  border-color: var(--border-strong);
}
.btn-outline-danger:hover {
  color: white;
  background: var(--status-crit);
  border-color: var(--status-crit);
}

.btn-outline-warning {
  color: var(--status-warn);
  border-color: var(--border-strong);
}
.btn-outline-warning:hover {
  color: white;
  background: var(--status-warn);
  border-color: var(--status-warn);
}

.btn:focus { box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.18); }

/* =================================================================
   Forms
   ================================================================= */

.form-control, .form-select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--r-md);
  font-family: var(--font-sans);
  font-size: var(--fs-sm);
  padding: 6px 10px;
  transition: border-color 0.1s ease, box-shadow 0.1s ease;
}
.form-control:focus, .form-select:focus {
  background: var(--bg-card);
  border-color: var(--accent);
  color: var(--text);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
  outline: 0;
}
.form-control::placeholder { color: var(--text-muted); opacity: 0.65; }
.form-control-sm { padding: 4px 8px; font-size: var(--fs-xs); }

.form-label {
  color: var(--text);
  font-weight: 500;
  font-size: var(--fs-sm);
  margin-bottom: 4px;
}
.form-text {
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

.input-group-text {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
}

/* Native input color-scheme */
input[type="date"].form-control,
input[type="number"].form-control,
input[type="text"].form-control,
input[type="password"].form-control { color-scheme: light; }
input[type="date"].form-control::-webkit-calendar-picker-indicator {
  opacity: 0.5; cursor: pointer; filter: none;
}

/* =================================================================
   Modals
   ================================================================= */

.modal-content {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header, .modal-footer {
  border-color: var(--border);
  padding: var(--sp-4) var(--sp-5);
}
.modal-body { padding: var(--sp-5); }
.modal-title { color: var(--text-heading); font-weight: 600; font-size: var(--fs-md); }
.btn-close { filter: none; opacity: 0.5; }
.btn-close:hover { opacity: 0.9; }

.dropdown-menu {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  font-size: var(--fs-sm);
}
.dropdown-item {
  color: var(--text);
  border-radius: var(--r-sm);
  padding: 6px 10px;
}
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--bg-hover);
  color: var(--text-heading);
}
.dropdown-divider { border-color: var(--border); margin: 4px 0; }

/* =================================================================
   Login
   ================================================================= */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse 80% 60% at 20% 20%, rgba(186, 230, 253, 0.35) 0%, transparent 60%),
    radial-gradient(ellipse 80% 60% at 80% 80%, rgba(153, 246, 228, 0.22) 0%, transparent 60%),
    var(--bg-page);
}
.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-8);
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.login-box h1 {
  font-size: var(--fs-xl);
  margin-bottom: var(--sp-6);
  font-weight: 700;
  text-align: center;
}
.login-box h1 i { color: var(--accent); }

.login-partner {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: var(--sp-6);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  gap: 8px;
}
.login-partner .label {
  font-size: 10.5px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
.login-partner a { display: block; }
.login-partner img {
  max-height: 32px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.15s ease;
}
.login-partner a:hover img { opacity: 1; }

/* =================================================================
   Main content rhythm
   ================================================================= */

main.container-fluid {
  max-width: 1280px;
  padding: var(--sp-8) var(--sp-6);
}
section[data-view] { animation: fadein 0.15s ease; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Page-level H2 on each view */
section[data-view] > .d-flex > h2.h4 {
  font-size: var(--fs-xl);
  font-weight: 600;
  margin: 0;
}

/* =================================================================
   Cards (tests / tanks list)
   ================================================================= */

.card-dark {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-2);
  transition: border-color 0.12s ease;
}
.card-dark:hover { border-color: var(--border-strong); }
.card-dark .title {
  font-weight: 600;
  color: var(--text-heading);
  font-size: var(--fs-md);
  line-height: 1.3;
}
.card-dark .meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: 2px;
}

/* =================================================================
   Status chips & pills — flat, readable
   ================================================================= */

.status-chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  font-size: var(--fs-xs);
  font-weight: 600;
  border-radius: 4px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.4;
}
.status-chip.normal,
.pill-normal        { background: var(--status-normal-bg); color: var(--status-normal); }
.status-chip.low,
.status-chip.warning_low,
.status-chip.critical_low,
.pill-low           { background: var(--status-info-bg); color: var(--status-info); }
.status-chip.high,
.status-chip.warning_high,
.pill-off, .pill-warning
                    { background: var(--status-warn-bg); color: var(--status-warn); }
.status-chip.critical_high,
.pill-crit          { background: var(--status-crit-bg); color: var(--status-crit); }
.pill-empty         { background: var(--bg-subtle); color: var(--text-muted); }

.status-pills {
  display: inline-flex;
  gap: 6px;
  flex-wrap: wrap;
  font-size: var(--fs-xs);
}
.status-pills .pill {
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
  letter-spacing: 0;
}
.status-pills .pill i { font-size: 10px; }

/* =================================================================
   Category headings
   ================================================================= */

.elements-category-title {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
  margin: var(--sp-6) 0 var(--sp-3);
  padding: 0;
  border: 0;
}
.elements-category-title:first-child { margin-top: var(--sp-2); }

/* =================================================================
   Element gauge card
   ================================================================= */

.test-detail-wrap { max-width: 1280px; margin: 0 auto; }

.elements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}

.element-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  transition: border-color 0.12s ease;
}
.element-card:hover { border-color: var(--border-strong); }

.element-card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-3);
  margin-bottom: var(--sp-2);
}
.element-card .name {
  font-weight: 600;
  color: var(--text-heading);
  font-size: var(--fs-sm);
}
.element-card .value {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--text-heading);
  white-space: nowrap;
  letter-spacing: -0.01em;
}
.element-card .value .unit {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  margin-left: 2px;
}
.element-info-btn {
  color: var(--text-muted);
  padding: 0 0 0 6px !important;
  font-size: var(--fs-sm);
  line-height: 1;
  text-decoration: none;
}
.element-info-btn:hover { color: var(--accent); }
.element-description {
  margin-top: var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  font-size: var(--fs-xs);
  line-height: 1.55;
  color: var(--text);
  border-left: 3px solid var(--accent);
}

/* Gauge — simpler, flatter, precise */
.gauge {
  --stop1: 15%;
  --stop2: 30%;
  --stop3: 70%;
  --stop4: 85%;
  --marker-pos: 50%;
  position: relative;
  height: 8px;
  margin: var(--sp-3) 0 var(--sp-1);
}
.gauge-track {
  position: absolute; inset: 0;
  border-radius: 2px;
  overflow: hidden;
  background: linear-gradient(
    to right,
    #dc2626 0%, #dc2626 var(--stop1),
    #d97706 var(--stop1), #d97706 var(--stop2),
    #047857 var(--stop2), #047857 var(--stop3),
    #d97706 var(--stop3), #d97706 var(--stop4),
    #dc2626 var(--stop4), #dc2626 100%
  );
  box-shadow: inset 0 0 0 1px rgba(15, 29, 44, 0.08);
}
.gauge-track::after {
  content: "";
  position: absolute;
  left: var(--stop2);
  right: calc(100% - var(--stop3));
  top: 0; bottom: 0;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.3);
}
.gauge-marker {
  position: absolute;
  top: -5px; bottom: -5px;
  left: var(--marker-pos);
  width: 2px;
  background: var(--text-heading);
  transform: translateX(-50%);
  border-radius: 1px;
  pointer-events: none;
}
.gauge-marker::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 8px;
  height: 8px;
  background: var(--text-heading);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 1px 3px rgba(15,29,44,0.3);
}
.gauge-marker.out-of-range { background: var(--status-crit); }
.gauge-marker.out-of-range::before { background: var(--status-crit); }

.gauge-scale {
  display: flex;
  justify-content: space-between;
  font-size: 10.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: var(--sp-2);
  padding: 0 1px;
}

.element-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--sp-2);
  gap: var(--sp-2);
  flex-wrap: wrap;
}
.element-card-foot .target-range {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
}

/* =================================================================
   Dashboard
   ================================================================= */

.dashboard-tank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-6) var(--sp-6);
  margin-bottom: var(--sp-6);
}
.dashboard-tank-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-4);
}
.dashboard-tank-header h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
.dashboard-tank-meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--sp-3);
}
.dashboard-tank-actions { display: flex; gap: var(--sp-2); }
.dashboard-tank-card .elements-grid {
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-2);
}

/* =================================================================
   History — chart cards
   ================================================================= */

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--sp-3);
}
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.chart-card h6 {
  margin-bottom: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-heading);
}
.chart-card canvas { max-height: 160px; }
.chart-card .unit-badge {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 400;
  font-family: var(--font-mono);
}
.elements-category-title.history-cat { grid-column: 1 / -1; }

/* =================================================================
   Breakdown
   ================================================================= */

.breakdown-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  line-height: 1.65;
  color: var(--text);
  font-size: var(--fs-base);
}
.breakdown-content h2 {
  font-size: var(--fs-md);
  color: var(--text-heading);
  font-weight: 600;
  margin: var(--sp-6) 0 var(--sp-3);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0;
}
.breakdown-content h2:first-child { margin-top: 0; }
.breakdown-content ol, .breakdown-content ul {
  padding-left: var(--sp-5);
  margin: 0 0 var(--sp-3);
}
.breakdown-content li { margin-bottom: var(--sp-2); }
.breakdown-content strong { color: var(--text-heading); font-weight: 600; }
.breakdown-content p { margin: 0 0 var(--sp-3); }
.breakdown-meta {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* =================================================================
   Tank-type badge — subdued
   ================================================================= */

.tank-type-badge {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* =================================================================
   Admin table
   ================================================================= */

.admin-users-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: var(--fs-sm);
}
.admin-users-table th, .admin-users-table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.admin-users-table tbody tr:last-child td { border-bottom: 0; }
.admin-users-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-subtle);
}
.admin-users-table tbody tr:hover { background: var(--bg-hover); }

/* =================================================================
   Manual entry
   ================================================================= */

.manual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--sp-3);
}
.manual-input label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
  font-weight: 500;
}
.manual-input .input-group-text {
  background: var(--bg-subtle);
  min-width: 48px;
  justify-content: center;
}
.manual-input .form-control { font-family: var(--font-mono); }
.manual-input .target-hint {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-mono);
}
.manual-category-title {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: var(--sp-4) 0 var(--sp-2);
  grid-column: 1 / -1;
  font-weight: 600;
}

/* =================================================================
   Empty state
   ================================================================= */

.empty-state {
  text-align: center;
  padding: var(--sp-10) var(--sp-4);
  color: var(--text-muted);
  font-size: var(--fs-sm);
}
.empty-state i {
  font-size: 36px;
  opacity: 0.3;
  display: block;
  margin-bottom: var(--sp-4);
  color: var(--text-muted);
}

/* =================================================================
   Version pill
   ================================================================= */

#version-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted) !important;
  background: var(--bg-subtle);
  padding: 2px 8px !important;
  border-radius: 4px;
  text-decoration: none;
  border: 1px solid var(--border);
  transition: color 0.1s ease, background 0.1s ease;
}
#version-pill:hover {
  color: var(--text) !important;
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

/* =================================================================
   Guide (reef-keeping reference)
   ================================================================= */

.guide-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--sp-6);
  align-items: start;
}
.guide-sidebar {
  position: sticky;
  top: var(--sp-6);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
}
.guide-sidebar h2 {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 var(--sp-3);
  font-weight: 600;
}
.guide-toc {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.guide-toc a {
  display: block;
  padding: 6px 10px;
  font-size: var(--fs-sm);
  color: var(--text);
  border-radius: var(--r-sm);
  border-left: 2px solid transparent;
  transition: background 0.1s ease, color 0.1s ease;
}
.guide-toc a:hover {
  background: var(--bg-hover);
  color: var(--text-heading);
}
.guide-toc a.active {
  background: var(--accent-soft);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.guide-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-8);
  min-height: 400px;
  max-width: 820px;
  line-height: 1.65;
}
.guide-content h1 {
  font-size: var(--fs-2xl);
  margin: 0 0 var(--sp-4);
  padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border);
}
.guide-content h2 {
  font-size: var(--fs-lg);
  margin: var(--sp-6) 0 var(--sp-3);
  color: var(--text-heading);
  border: 0;
  padding: 0;
}
.guide-content h3 {
  font-size: var(--fs-md);
  margin: var(--sp-5) 0 var(--sp-2);
  color: var(--text-heading);
}
.guide-content p, .guide-content li { color: var(--text); }
.guide-content ul, .guide-content ol {
  padding-left: var(--sp-5);
  margin-bottom: var(--sp-4);
}
.guide-content li { margin-bottom: 6px; }
.guide-content strong { color: var(--text-heading); font-weight: 600; }
.guide-content code {
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.88em;
}
.guide-content table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--sp-4) 0;
  font-size: var(--fs-sm);
}
.guide-content th, .guide-content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.guide-content th {
  background: var(--bg-subtle);
  font-weight: 600;
  color: var(--text-heading);
}
.guide-content tr:hover td { background: var(--bg-hover); }
.guide-content blockquote {
  border-left: 3px solid var(--accent);
  padding: 0 0 0 var(--sp-4);
  margin: var(--sp-4) 0;
  color: var(--text-muted);
  font-style: italic;
}
.guide-content .guide-img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: var(--r-md);
  margin: var(--sp-4) 0;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
}
.guide-content p:has(.guide-img) {
  margin: 0;
}
@media (max-width: 768px) {
  .guide-layout { grid-template-columns: 1fr; }
  .guide-sidebar { position: static; }
}

/* =================================================================
   Admin tabs
   ================================================================= */

.admin-tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  padding: 0 0 0 0;
}
.admin-tab {
  background: transparent;
  border: 0;
  padding: 10px 16px;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--fs-sm);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: color 0.1s ease, border-color 0.1s ease;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  color: var(--text-heading);
  border-bottom-color: var(--accent);
}

/* Login logs table */
.login-logs-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  font-size: var(--fs-sm);
}
.login-logs-table th, .login-logs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.login-logs-table th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 500;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.login-logs-table tbody tr:hover { background: var(--bg-hover); }
.login-logs-table .log-success { color: var(--status-normal); font-weight: 600; }
.login-logs-table .log-fail { color: var(--status-crit); font-weight: 600; }
.login-logs-table .log-ip { font-family: var(--font-mono); font-size: var(--fs-xs); }

/* Request list */
.request-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.request-card .req-subject {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text-heading);
  margin-bottom: 4px;
}
.request-card .req-meta {
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-bottom: var(--sp-2);
}
.request-card .req-body {
  margin-bottom: var(--sp-3);
  white-space: pre-wrap;
}
.request-card .req-status-pending    { color: var(--status-warn); }
.request-card .req-status-acknowledged { color: var(--status-info); }
.request-card .req-status-completed  { color: var(--status-normal); }

/* Notification bell */
#btn-requests {
  color: var(--text-muted);
  position: relative;
  padding: 8px 10px !important;
}
#btn-requests:hover { color: var(--text-heading); }
.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: var(--status-crit);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 999px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}

/* Photos gallery */
.photos-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-2);
}
.photo-card {
  position: relative;
  border-radius: var(--r-md);
  overflow: hidden;
  border: 1px solid var(--border);
  aspect-ratio: 1 / 1;              /* square thumbs fit both orientations */
  background: var(--bg-subtle);
}
.photo-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  cursor: zoom-in;
}
.photo-card .photo-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 4px;
}
.photo-card:hover .photo-actions { display: flex; }
.photo-card .photo-caption {
  position: absolute;
  bottom: 0;
  left: 0; right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
  color: white;
  padding: 12px 10px 8px;
  font-size: var(--fs-xs);
  line-height: 1.3;
}

/* Photos thumbnail strip on tank cards */
.tank-photos-strip {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  overflow-x: auto;
}
.tank-photos-strip img {
  height: 48px;
  width: 64px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

/* ── Tanks view — card grid with photo banner ─────────────────────── */
.tanks-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}
.tank-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.tank-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.tank-cover {
  position: relative;
  aspect-ratio: 4/3;                /* friendlier for portrait phone shots */
  background: linear-gradient(135deg, #dfeef3 0%, #c5dde5 100%);
  overflow: hidden;
}
.tank-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
}
.tank-cover-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-muted);
}
.tank-cover-empty i { font-size: 36px; opacity: 0.5; }
.tank-cover-empty .hint { font-size: var(--fs-xs); }

.tank-cover-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  pointer-events: none;
}
.tank-cover-badge .tank-type-badge,
.tank-cover-badge .tank-photo-count {
  pointer-events: auto;
  background: rgba(15, 29, 44, 0.82);
  color: #ffffff;
  backdrop-filter: blur(6px);
  border: 0;
}
.tank-photo-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.tank-photo-count i { font-size: 10px; }

.tank-card-body {
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tank-card-body .title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-heading);
  margin: 0;
  line-height: 1.3;
}
.tank-card-body .meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.tank-card-body .notes {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 2px;
  white-space: pre-wrap;
}
.tank-card-actions {
  padding: var(--sp-2) var(--sp-3) var(--sp-3);
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* "Set as display" ribbon on the photos modal */
.photo-card .photo-actions .btn {
  padding: 2px 7px;
  font-size: var(--fs-xs);
}
.photo-card.is-cover {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.photo-card.is-cover::before {
  content: "DISPLAY";
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.05em;
  z-index: 2;
}

/* =================================================================
   Toasts
   ================================================================= */

.toast {
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
}
.toast.text-bg-dark {
  background: var(--text-heading) !important;
  color: #ffffff !important;
  border-color: var(--text-heading);
}
.toast.text-bg-success {
  background: var(--status-normal) !important;
  border-color: var(--status-normal);
}
.toast.text-bg-danger {
  background: var(--status-crit) !important;
  border-color: var(--status-crit);
}

/* =================================================================
   Utilities
   ================================================================= */

.text-muted  { color: var(--text-muted) !important; }
.text-danger { color: var(--status-crit) !important; }
.spinner-border.text-light { color: var(--accent) !important; }
.text-bg-success { background: var(--status-normal) !important; }
.text-bg-danger  { background: var(--status-crit) !important; }

/* Bootstrap card tweaks for dropdown-toggle in topbar */
.topbar .dropdown-toggle::after { margin-left: 6px; vertical-align: 1px; }

/* Upload progress bar */
.progress {
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  height: 4px;
}
.progress-bar { background: var(--accent); }

/* Bootstrap spinner border color */
.spinner-border {
  border-color: var(--border);
  border-right-color: var(--accent);
}

/* =================================================================
   Gear modal
   ================================================================= */

.gear-field {
  margin-bottom: var(--sp-3);
}
.gear-field label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
  display: block;
}
.gear-field textarea {
  min-height: 58px;
  resize: vertical;
  font-family: var(--font-sans);
}

/* Gear summary on tank card body */
.tank-gear-summary {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.tank-gear-summary .gear-pill {
  background: var(--bg-subtle);
  border-radius: 3px;
  padding: 1px 6px;
  white-space: nowrap;
}

/* =================================================================
   Lightbox (full-size photo viewer)
   ================================================================= */

.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: var(--sp-4);
  cursor: zoom-out;
}
.photo-lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: var(--r-md);
}

/* =================================================================
   Navbar toggler for mobile
   ================================================================= */

.navbar-toggler {
  border: 1px solid var(--border);
  color: var(--text);
  padding: 4px 10px;
  font-size: 1.2rem;
}
.navbar-toggler:focus { box-shadow: none; }
.navbar-toggler i { vertical-align: middle; }

/* =================================================================
   Mobile responsive
   ================================================================= */

@media (max-width: 991px) {
  .topbar {
    padding: 8px var(--sp-4);
    flex-wrap: wrap;
  }
  .topbar .navbar-collapse {
    width: 100%;
    margin-top: var(--sp-2);
    padding: var(--sp-2) 0;
    border-top: 1px solid var(--border);
  }
  .topbar .nav-link {
    padding: 10px 12px !important;
    margin: 0 !important;
    border-bottom: 0;
    border-left: 2px solid transparent;
    border-radius: var(--r-sm);
  }
  .topbar .nav-link.active {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
    background: var(--bg-hover);
  }
  /* Put topbar action buttons on their own row on phones */
  .topbar > .container-fluid > div.d-flex {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 6px !important;
    margin-top: 0;
  }
  main.container-fluid {
    padding: var(--sp-4) var(--sp-3);
  }
  .elements-grid,
  .tanks-grid,
  .history-grid,
  .dashboard-tank-card .elements-grid {
    grid-template-columns: 1fr;
  }
  .tank-cover {
    aspect-ratio: 4/3;
  }
}

@media (max-width: 640px) {
  :root { --fs-base: 0.9375rem; }
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.2rem; }
  .test-detail-wrap { max-width: 100%; }
  .guide-layout { grid-template-columns: 1fr; }
  .guide-sidebar { position: static; margin-bottom: var(--sp-3); }
  .guide-content { padding: var(--sp-5); }
  .modal-body { padding: var(--sp-4); }
  .modal-header, .modal-footer { padding: var(--sp-3) var(--sp-4); }
  /* Upload buttons + Manual button stack neatly */
  #btn-upload, #btn-manual { flex: 1; }
  #version-pill { order: -1; }
  .shop-link { display: none; }  /* hide non-essential topbar link on small phones */

  /* Full-width photo in photo cards on narrow screens (better for portrait) */
  .photos-gallery { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

/* =================================================================
   Small tweaks for Bootstrap's nav-tabs in the upload modal
   ================================================================= */
.nav-tabs {
  border-bottom: 1px solid var(--border);
}
.nav-tabs .nav-link {
  color: var(--text-muted);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 8px 14px;
  font-weight: 500;
  font-size: var(--fs-sm);
  background: transparent;
}
.nav-tabs .nav-link.active {
  color: var(--text-heading);
  border-bottom-color: var(--accent);
  background: transparent;
}
.nav-tabs .nav-link:hover {
  color: var(--text);
  border-color: transparent transparent var(--border-strong);
}
