:root {
  --teal-50: #effcfb;
  --teal-100: #d6f5f2;
  --teal-200: #aeeae4;
  --teal-400: #3ec9bd;
  --teal-500: #1fada1;
  --teal-600: #158f85;
  --teal-700: #0f6d66;
  --neutral-50: #f7f9f9;
  --neutral-100: #eef1f1;
  --neutral-200: #dde3e3;
  --neutral-600: #5b6866;
  --neutral-800: #2a3433;
  --danger: #d1495b;
  --success: #1fada1;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 109, 102, 0.12), 0 1px 2px rgba(15, 109, 102, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--neutral-50);
  color: var(--neutral-800);
  line-height: 1.5;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  background: var(--teal-600);
  color: white;
  box-shadow: var(--shadow);
}

.topbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.brand {
  color: white;
  font-weight: 700;
  font-size: 1.15rem;
}

.brand:hover {
  text-decoration: none;
  opacity: 0.9;
}

.nav {
  display: flex;
  gap: 1.25rem;
}

.nav a {
  color: rgba(255, 255, 255, 0.85);
  font-weight: 500;
}

.nav a:hover {
  color: white;
  text-decoration: none;
}

.nav a.active {
  color: white;
  border-bottom: 2px solid white;
  padding-bottom: 2px;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.card {
  background: white;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
}

.card-title {
  margin-top: 0;
  margin-bottom: 1rem;
  font-size: 1.05rem;
  color: var(--teal-700);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 260px;
  max-height: 260px;
}

.chart-container canvas {
  max-width: 100%;
  max-height: 100%;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .grid {
    grid-template-columns: 1.4fr 1fr;
    align-items: start;
  }
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.day-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.day-title {
  margin: 0;
  font-size: 1.25rem;
}

.day-nav {
  white-space: nowrap;
  font-weight: 500;
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-today {
  background: var(--teal-100);
  color: var(--teal-700);
}

.backfill-note {
  background: var(--teal-50);
  border: 1px solid var(--teal-200);
  color: var(--teal-700);
  border-radius: var(--radius);
  padding: 0.6rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.entry-form .field {
  margin-bottom: 1.1rem;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.3rem;
  font-size: 0.9rem;
  color: var(--neutral-800);
}

.field input {
  width: 100%;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--neutral-50);
}

.field input:focus {
  outline: none;
  border-color: var(--teal-400);
  background: white;
}

.trend {
  display: inline-block;
  margin-top: 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.trend-down {
  color: var(--success);
}

.trend-up {
  color: var(--danger);
}

.trend-flat {
  color: var(--neutral-600);
}

.progress-bar {
  margin-top: 0.5rem;
  height: 8px;
  background: var(--neutral-100);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--teal-500);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-label {
  display: block;
  font-size: 0.78rem;
  color: var(--neutral-600);
  margin-top: 0.25rem;
}

.btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background: var(--teal-600);
  color: white;
}

.btn-primary:hover {
  background: var(--teal-700);
}

.btn-small {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
  background: var(--neutral-100);
  color: var(--neutral-800);
}

.btn-small:hover {
  background: var(--neutral-200);
}

.btn-warning {
  background: #fbe6d4;
  color: #9a5a12;
}

.btn-success {
  background: var(--teal-100);
  color: var(--teal-700);
}

.habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.habit-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--neutral-100);
}

.habit-item:last-child {
  border-bottom: none;
}

.habit-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  cursor: pointer;
  font-weight: 500;
}

.habit-checkbox {
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--teal-600);
}

.muted {
  color: var(--neutral-600);
}

.small {
  font-size: 0.82rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.range-form select {
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid var(--neutral-200);
}

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

.log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.log-table th,
.log-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--neutral-100);
  white-space: nowrap;
}

.log-table th {
  color: var(--teal-700);
  font-weight: 600;
  background: var(--teal-50);
}

.check-yes {
  color: var(--teal-600);
  font-weight: 700;
}

.check-no {
  color: var(--neutral-200);
}

.inline-form {
  display: flex;
  gap: 0.6rem;
}

.inline-form input[type="text"] {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
}

.manage-habit-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.manage-habit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--neutral-100);
  flex-wrap: wrap;
}

.manage-habit-item.inactive {
  opacity: 0.55;
}

.rename-form {
  display: flex;
  gap: 0.5rem;
  flex: 1;
  min-width: 200px;
}

.rename-form input[type="text"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--neutral-200);
  border-radius: 8px;
}

.manage-habit-actions {
  display: flex;
  gap: 0.4rem;
}

.manage-habit-actions form {
  display: inline;
}

.flash-stack {
  margin-bottom: 1rem;
}

.flash {
  padding: 0.65rem 1rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.flash-success {
  background: var(--teal-100);
  color: var(--teal-700);
}

.flash-error {
  background: #fbe0e2;
  color: var(--danger);
}
