:root {
  --blue-50:  #eff6ff;
  --blue-100: #dbeafe;
  --blue-200: #bfdbfe;
  --blue-400: #60a5fa;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-400: #9ca3af;
  --gray-600: #4b5563;
  --gray-800: #1f2937;
  --red-500:  #ef4444;
  --red-100:  #fee2e2;
  --radius:   8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--blue-50);
  color: var(--gray-800);
  min-height: 100vh;
}

/* Nav */
nav {
  background: white;
  border-bottom: 1px solid var(--blue-200);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--blue-600);
  text-decoration: none;
}
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a {
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.95rem;
}
.nav-links a.active { color: var(--blue-600); font-weight: 600; }
.nav-links a:hover { color: var(--blue-600); }
.nav-links .logout { color: var(--gray-400); }

/* Main */
main { max-width: 960px; margin: 0 auto; padding: 2rem 1.5rem; }

/* Flash */
.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash-error   { background: var(--red-100);  color: var(--red-500); }
.flash-success { background: var(--blue-100); color: var(--blue-700); }

/* Page header */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.5rem; font-weight: 700; flex: 1; }
.back { color: var(--blue-500); text-decoration: none; font-size: 0.9rem; white-space: nowrap; }
.back:hover { color: var(--blue-700); }

/* Buttons */
.btn {
  background: var(--blue-500);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: var(--blue-600); }
.btn-sm {
  background: var(--blue-100);
  color: var(--blue-700);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius);
  text-decoration: none;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
}
.btn-sm:hover { background: var(--blue-200); }
.btn-danger {
  background: var(--red-500);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn-danger:hover { opacity: 0.85; }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; }

/* Auth card */
.auth-card {
  max-width: 380px;
  margin: 5rem auto;
  background: white;
  border-radius: var(--radius);
  padding: 2.5rem;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  text-align: center;
}
.auth-card h1 { color: var(--blue-600); font-size: 1.8rem; margin-bottom: 1.5rem; }

/* Forms */
form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-600);
}
form input, form select, form textarea {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 0.95rem;
  background: white;
  color: var(--gray-800);
  width: 100%;
}
form input:focus, form select:focus, form textarea:focus {
  outline: none;
  border-color: var(--blue-400);
  box-shadow: 0 0 0 3px var(--blue-100);
}
form button[type="submit"] {
  margin-top: 1rem;
  width: 100%;
  padding: 0.65rem;
  background: var(--blue-500);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  cursor: pointer;
}
form button[type="submit"]:hover { background: var(--blue-600); }
form button[type="submit"]:disabled { opacity: 0.5; cursor: not-allowed; }

.form-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row.dims { grid-template-columns: repeat(4, 1fr); }

/* Sliders */
.sliders { display: flex; flex-direction: column; gap: 0.75rem; }
.slider-group label {
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
.slider-group input[type="range"] {
  padding: 0;
  border: none;
  box-shadow: none;
  accent-color: var(--blue-500);
}

/* Char counter */
.char-counter { font-size: 0.8rem; color: var(--gray-400); text-align: right; }

/* Error list */
.error-list {
  background: var(--red-100);
  color: var(--red-500);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 1rem;
}

/* Cards */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 1rem; color: var(--gray-600); }
.mt { margin-top: 1.5rem; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}
.section-header h3 { margin-bottom: 0; }

/* Spot grid */
.spot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.spot-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  transition: box-shadow 0.15s;
  border: 1px solid var(--blue-100);
}
.spot-card:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.12); border-color: var(--blue-200); }
.spot-card h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }

.conditions { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.75rem; }
.condition-row { display: flex; justify-content: space-between; font-size: 0.875rem; }
.condition-row .label { color: var(--gray-400); }
.condition-row .value { font-weight: 600; color: var(--blue-700); }
.buoy-tag {
  display: inline-block;
  background: var(--blue-50);
  color: var(--blue-600);
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-right: 0.25rem;
}

/* Dashboard */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.conditions-large { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.stat { text-align: center; }
.stat-value { display: block; font-size: 1.75rem; font-weight: 700; color: var(--blue-600); }
.stat-label { font-size: 0.8rem; color: var(--gray-400); }
.data-date { font-size: 0.8rem; color: var(--gray-400); margin-top: 0.75rem; text-align: right; }

/* Bar chart */
.bar-chart { display: flex; align-items: flex-end; gap: 0.5rem; height: 120px; }
.bar-col { display: flex; flex-direction: column; align-items: center; flex: 1; height: 100%; }
.bar-wrap { flex: 1; display: flex; align-items: flex-end; width: 100%; }
.bar {
  width: 100%;
  background: var(--blue-400);
  border-radius: 4px 4px 0 0;
  min-height: 4px;
  transition: height 0.3s;
}
.bar-label { font-size: 0.7rem; color: var(--gray-400); margin-top: 0.25rem; }

/* Tables */
.log-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.log-table th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 2px solid var(--gray-200);
  color: var(--gray-400);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.log-table td { padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--gray-100); }
.log-table tr.clickable { cursor: pointer; }
.log-table tr.clickable:hover td { background: var(--blue-50); }

/* Board grid */
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.board-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  text-decoration: none;
  color: inherit;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--blue-100);
  transition: box-shadow 0.15s;
}
.board-card:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.12); border-color: var(--blue-200); }
.board-card h3 { margin-bottom: 0.4rem; }
.board-sub { font-size: 0.85rem; color: var(--blue-600); margin-bottom: 0.3rem; }
.board-dims { font-size: 0.8rem; color: var(--gray-400); }
.board-brand { font-size: 0.8rem; color: var(--gray-400); margin-top: 0.2rem; }

/* Detail view */
.detail-card {
  background: white;
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  margin-bottom: 1.5rem;
}
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1rem;
}
.detail-grid div { display: flex; flex-direction: column; gap: 0.2rem; }
.label { font-size: 0.75rem; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; }
.description { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--gray-100); }
.description p { margin-top: 0.5rem; line-height: 1.6; }

/* Danger zone */
.danger-zone {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  border: 1px solid var(--red-100);
}
.danger-zone h4 { font-size: 0.95rem; margin-bottom: 0.5rem; }
.delete-form { display: flex; gap: 0.75rem; margin-top: 0.75rem; }
.delete-form input { max-width: 240px; }

/* Misc */
.empty { color: var(--gray-400); font-size: 0.95rem; margin-top: 0.5rem; }
.muted { color: var(--gray-400); font-size: 0.875rem; }
.no-data { font-size: 0.85rem; color: var(--gray-400); margin: 0.5rem 0; }

@media (max-width: 640px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.dims { grid-template-columns: 1fr 1fr; }
  nav { padding: 0 1rem; }
  main { padding: 1rem; }
}
