:root {
  --bg: #f5f7f2;
  --surface: #ffffff;
  --surface-2: #eef3ea;
  --text: #172018;
  --muted: #657064;
  --line: #d8e0d2;
  --green: #3c7c42;
  --green-dark: #24582a;
  --blue: #246a8f;
  --amber: #a86e13;
  --red: #a6422b;
  --shadow: 0 12px 32px rgba(31, 45, 30, 0.08);
}

* { box-sizing: border-box; }

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

button, input, textarea, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  min-height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 36px max(24px, calc((100vw - 1180px) / 2)) 30px;
  background:
    linear-gradient(90deg, rgba(20, 54, 25, 0.92), rgba(54, 113, 58, 0.74)),
    url("https://images.unsplash.com/photo-1622163642998-1ea32b0bbc67?auto=format&fit=crop&w=1800&q=80") center / cover;
  color: white;
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 1;
  max-width: 760px;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
}

.top-actions {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button {
  white-space: nowrap;
}

.date-control {
  display: grid;
  gap: 5px;
  color: rgba(255,255,255,0.86);
  font-size: 0.78rem;
  font-weight: 700;
}

.date-control input,
.top-actions button {
  min-height: 42px;
  border: 1px solid rgba(255,255,255,0.38);
  border-radius: 8px;
  background: rgba(255,255,255,0.14);
  color: white;
  padding: 8px 12px;
}

.date-control input {
  color-scheme: dark;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 10px max(16px, calc((100vw - 1180px) / 2));
  background: rgba(245, 247, 242, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
  overflow-x: auto;
}

.tab {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 7px 12px;
  font-weight: 800;
}

.tab.active {
  color: var(--green-dark);
  background: var(--surface);
  border-color: var(--line);
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 28px auto 72px;
}

.view { display: none; }
.view.active { display: block; }

.dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(280px, 0.8fr);
  gap: 18px;
}

.panel, .day-card, .resource-card, .week-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.primary-panel {
  min-height: 360px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading h2, .panel h2 {
  margin: 4px 0 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1.15;
}

.meta-row, .tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--green-dark);
  padding: 4px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.pill.blue { color: var(--blue); }
.pill.amber { color: var(--amber); }
.pill.red { color: var(--red); }

.progress-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.progress-summary div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
}

.progress-summary strong,
.progress-summary span {
  display: block;
}

.progress-summary strong {
  font-size: 1.25rem;
  color: var(--green-dark);
}

.progress-summary span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.session-block {
  display: grid;
  gap: 12px;
}

.time-row {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.time-row:last-child { border-bottom: 0; }

.time-row strong {
  color: var(--green-dark);
}

.time-row p {
  margin: 2px 0 0;
  color: var(--muted);
}

.link-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.link-list a {
  color: var(--green-dark);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.metrics-form {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.metrics-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.metrics-form input,
.metrics-form textarea,
.metrics-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--text);
  padding: 9px 10px;
}

.metrics-form textarea {
  min-height: 76px;
  resize: vertical;
}

.save-state {
  color: var(--green-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.day-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.day-actions button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green-dark);
  padding: 7px 10px;
  font-weight: 850;
}

.day-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.status-note {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.focus-list {
  display: grid;
  gap: 12px;
}

.focus-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.focus-item strong {
  display: block;
}

.focus-item span {
  display: block;
  color: var(--muted);
  margin-top: 3px;
}

.phase-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.phase-nav button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--green-dark);
  padding: 8px 11px;
  font-weight: 850;
}

.program-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.day-card {
  min-height: 190px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  text-align: left;
  padding: 14px;
  color: inherit;
}

.day-card.done {
  background: #f1f6ee;
}

.day-card.skipped {
  background: #faf7ef;
}

.day-card.deferred {
  background: #fff4ef;
  border-color: #efb4a3;
}

.day-card h3 {
  margin: 8px 0 6px;
  font-size: 1rem;
}

.day-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.day-number {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

.review-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.week-card {
  padding: 16px;
}

.week-card h3 {
  margin: 0 0 10px;
}

.metric-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

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

.resource-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.resource-card {
  padding: 18px;
}

.resource-card h3 {
  margin: 0 0 8px;
}

.resource-card p {
  margin: 0 0 12px;
  color: var(--muted);
}

dialog {
  width: min(760px, calc(100% - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

dialog::backdrop {
  background: rgba(14, 24, 14, 0.52);
}

.dialog-card {
  position: relative;
  max-height: 86vh;
  overflow: auto;
  border-radius: 8px;
  background: white;
  padding: 24px;
  box-shadow: 0 18px 70px rgba(0,0,0,0.24);
}

.close-button {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  font-size: 1.4rem;
  line-height: 1;
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    justify-content: flex-end;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .time-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .progress-summary {
    grid-template-columns: 1fr;
  }
}
