:root {
  --bg: #fbfbfa;
  --bg-elevated: #f2f7f5;
  --card: #ffffff;
  --border: #e4e7e5;
  --text: #191c1a;
  --muted: #565c59;
  --faint: #8b918d;
  --accent: #2f9a7c;
  --accent-strong: #237e65;
  --accent-soft: #eafbf5;
  --danger: #a33a3a;
  --danger-soft: #fff0f0;
  --radius: 12px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

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

.wrap {
  width: min(100% - 48px, 880px);
  margin: 0 auto;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border);
  background: rgba(251, 251, 250, 0.9);
  backdrop-filter: blur(8px);
}

.nav .wrap {
  position: relative;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-weight: 700;
}

.brand img { width: 26px; height: 26px; }

.nav-cta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 14px;
}

.nav-links a {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.nav-links a:hover,
.nav-links a.is-active {
  color: var(--text);
}

.nav-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  padding: 10px;
  cursor: pointer;
}

.nav-toggle span {
  width: 20px;
  height: 2px;
  display: block;
  margin: 4px auto;
  border-radius: 2px;
  background: var(--text);
}

.cb-auth-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cb-auth-email {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  font: 600 14px/1 var(--font);
  cursor: pointer;
}

.btn .icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.btn-icon .icon {
  width: 20px;
  height: 20px;
}

.btn-tiny {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 12px;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.btn.danger {
  color: var(--danger);
  border-color: #efc4c4;
}
.btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

main { flex: 1; padding: 40px 0 56px; }

.hero {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(28px, 4vw, 38px);
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0;
  max-width: 520px;
  color: var(--muted);
}

.hero-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.meta {
  color: var(--faint);
  font-size: 13px;
}

.panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 22px;
  margin-bottom: 18px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 { margin: 0; }

.login-action {
  margin-bottom: 18px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elevated);
  padding: 14px 16px;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.goal-grid {
  display: grid;
  gap: 12px;
}

.goal-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  padding: 16px 18px;
  color: inherit;
}

.goal-card:hover { color: inherit; }

.goal-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.goal-card p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bg-elevated);
}

.progress > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

.month-grid {
  display: grid;
  gap: 12px;
}

.month-card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  padding: 16px 18px;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.month-card:hover {
  color: inherit;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.month-card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

.month-card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

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

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 12px 0;
}

.list-item:last-child { border-bottom: 0; }

.list-main {
  min-width: 0;
  flex: 1;
}

.list-main.is-action {
  cursor: pointer;
  border-radius: 10px;
}

.list-item > input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.list-item .title { font-weight: 600; }

.list-item .sub {
  color: var(--muted);
  font-size: 13px;
}

.list-item.is-action {
  cursor: pointer;
  border-radius: 10px;
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
}

.list-item.is-action:hover,
.list-item.is-action:focus-visible {
  outline: none;
  background: var(--bg-elevated);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.check-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--accent);
}

.badge {
  display: inline-block;
  margin-left: 6px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
}

.is-inactive .title,
.is-inactive .sub {
  color: var(--faint);
  text-decoration: line-through;
}

label {
  display: block;
  margin: 12px 0 6px;
  font-size: 13px;
  font-weight: 600;
}

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: 16px var(--font);
  background: #fff;
  color: var(--text);
}

.empty { color: var(--muted); }
.empty.error, .message-error { color: var(--danger); }

.message {
  min-height: 20px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

.message-success { color: var(--accent-strong); }

.modal {
  width: min(100% - 32px, 480px);
  max-height: min(90vh, 720px);
  margin: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card);
  padding: 0;
  color: var(--text);
  box-shadow: 0 24px 48px rgba(25, 28, 26, 0.18);
}

.modal::backdrop {
  background: rgba(25, 28, 26, 0.45);
}

.modal-form,
.modal-body {
  display: flex;
  flex-direction: column;
  max-height: min(90vh, 720px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.modal-content {
  overflow: auto;
  padding: 8px 20px 4px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 20px 20px;
}

.modal-actions .btn { flex: 1 1 auto; }

.modal-actions .btn-danger-fill {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.modal-actions .btn-danger-fill:hover {
  background: #8a2f2f;
  border-color: #8a2f2f;
  color: #fff;
}

.modal-text {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.modal-text strong { color: var(--text); }

footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
}

footer .wrap {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 820px) {
  .wrap { width: min(100% - 32px, 880px); }
  .nav-toggle { display: block; }

  .hero { align-items: stretch; }

  .hero-toolbar { width: 100%; }
  .hero-toolbar .btn { flex: 1 1 auto; }

  .stats { grid-template-columns: 1fr; }

  .nav-cta {
    position: absolute;
    top: calc(100% + 8px);
    right: 16px;
    width: min(280px, calc(100vw - 32px));
    display: none;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--card);
    padding: 12px;
    box-shadow: 0 16px 32px rgba(25, 28, 26, 0.16);
  }

  .nav.nav-menu-open .nav-cta { display: grid; }

  .nav-cta .btn,
  .nav-cta .cb-auth-controls,
  .nav-cta .cb-auth-controls > *,
  .nav-cta .nav-links {
    width: 100%;
  }

  .nav-cta .cb-auth-controls,
  .nav-cta .nav-links { display: grid; }

  .cb-auth-email {
    max-width: none;
    padding: 8px 4px;
    text-align: center;
  }
}
