:root {
  color-scheme: light;
  --amber: #b5651d;
  --bg: #faf6f0;
  --text: #2a2016;
  --border: #ddd0bd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topnav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: var(--amber);
  color: #fff;
}

.topnav .brand { font-weight: bold; }

.nav-links { display: flex; gap: 1rem; }
.nav-links a { color: #fff; text-decoration: none; opacity: 0.9; }
.nav-links a:hover { opacity: 1; text-decoration: underline; }

.nav-user { display: flex; align-items: center; gap: 0.75rem; }

.logout-form { display: inline; }

.logout-form button {
  background: none;
  border: 1px solid #fff;
  color: #fff;
  padding: 0.25rem 0.75rem;
  border-radius: 4px;
  cursor: pointer;
}

.page { padding: 1.5rem; max-width: 960px; margin: 0 auto; }

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2rem;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }

.auth-form input {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.auth-form button {
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--amber);
  color: #fff;
  cursor: pointer;
}

.error { color: #b00020; font-size: 0.9rem; }
.success { color: #1e7d32; font-size: 0.9rem; }

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: var(--amber);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th { background: #f1e8dc; }

.record-form {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.record-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }

.record-form input,
.record-form select,
.record-form textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
}

.record-form button {
  padding: 0.6rem;
  border: none;
  border-radius: 4px;
  background: var(--amber);
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}

.period-form {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.period-form label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.85rem; }

.period-form input {
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.period-form button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  background: var(--amber);
  color: #fff;
  cursor: pointer;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.stat-label { font-size: 0.8rem; color: #7a6b57; margin-bottom: 0.25rem; }
.stat-value { font-size: 1.4rem; font-weight: bold; }
.stat-sub { font-size: 0.8rem; color: #7a6b57; margin-top: 0.25rem; }

.trend-chart {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  height: 180px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.trend-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.trend-bar {
  width: 60%;
  min-height: 2px;
  background: var(--amber);
  border-radius: 3px 3px 0 0;
}

.trend-label { font-size: 0.75rem; margin-top: 0.4rem; color: #7a6b57; }
