:root {
  color-scheme: light;
  --bg: #f7f8f5;
  --surface: #ffffff;
  --text: #1e2722;
  --muted: #67736d;
  --border: #dfe5dd;
  --accent: #315f4b;
  --accent-dark: #214435;
  --danger: #a33a32;
  --danger-bg: #fff1ef;
  --success: #27654f;
  --success-bg: #eaf6ef;
  --shadow: 0 10px 30px rgba(30, 39, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

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

button,
input,
select {
  font: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  color: var(--text);
  font-weight: 800;
  letter-spacing: 0;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}

.nav-links form {
  margin: 0;
}

.link-button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
}

.page {
  width: min(960px, 100%);
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.65rem, 1.2rem + 2vw, 2.4rem);
}

h2 {
  font-size: 1.05rem;
}

.lede,
.timestamp,
.empty {
  color: var(--muted);
}

.login-panel,
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-panel {
  max-width: 420px;
  margin: 44px auto;
  padding: 24px;
}

.panel {
  padding: 16px;
  margin-bottom: 16px;
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 650;
}

input,
select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(49, 95, 75, 0.24);
  outline-offset: 2px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 750;
  letter-spacing: 0;
  cursor: pointer;
}

.primary-button {
  color: #fff;
  background: var(--accent);
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  color: var(--accent);
  background: var(--surface);
  border-color: var(--border);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 7px 10px;
  color: var(--danger);
  background: var(--danger-bg);
  border: 1px solid rgba(163, 58, 50, 0.28);
  border-radius: 8px;
  font-weight: 750;
  cursor: pointer;
}

.inline-form {
  margin: 0;
}

.alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 650;
}

.alert.success {
  color: var(--success);
  background: var(--success-bg);
}

.alert.error {
  color: var(--danger);
  background: var(--danger-bg);
}

.measurement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.measurement-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.brix-value {
  margin: 12px 0 4px;
  font-size: 2rem;
  line-height: 1;
  font-weight: 850;
}

.brix-value span {
  font-size: 0.95rem;
  color: var(--muted);
  font-weight: 700;
}

.timestamp {
  margin: 0;
  font-size: 0.85rem;
}

.filters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

th,
td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.85rem;
}

@media (min-width: 680px) {
  .page {
    padding-top: 32px;
  }

  .panel {
    padding: 20px;
  }

  .filters {
    grid-template-columns: 180px minmax(220px, 1fr);
    align-items: end;
  }
}

@media (max-width: 520px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .secondary-button {
    width: 100%;
  }
}
