:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #1e242c;
  --muted: #657080;
  --line: #d9dee7;
  --accent: #0f766e;
  --accent-2: #334155;
  --warn: #b45309;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-header {
  align-items: center;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  justify-content: space-between;
  min-height: 64px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  color: var(--accent);
  font-size: 18px;
  font-weight: 800;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

nav a {
  border-radius: 6px;
  color: var(--muted);
  font-weight: 650;
  padding: 8px 10px;
}

nav a:hover {
  background: #eef4f3;
  color: var(--accent);
}

main {
  margin: 0 auto;
  max-width: 1480px;
  padding: 28px;
}

.messages {
  margin: 16px auto 0;
  max-width: 1480px;
  padding: 0 28px;
}

.messages p {
  background: #e7f5ef;
  border: 1px solid #a7dbc8;
  border-radius: 6px;
  color: #075b47;
  margin: 0;
  padding: 10px 12px;
}

.undo-banner {
  align-items: center;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7c2d12;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 12px auto 0;
  max-width: 1480px;
  padding: 10px 28px;
}

.undo-banner span {
  font-weight: 800;
}

.undo-banner form {
  margin: 0;
}

.undo-banner button {
  background: #ffffff;
  border-color: #fed7aa;
  color: #9a3412;
  min-height: 32px;
}

.page-head {
  align-items: end;
  display: flex;
  gap: 18px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-head h1 {
  font-size: 34px;
  line-height: 1.05;
  margin: 0;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.import-note {
  color: var(--muted);
  margin: 0;
  text-align: right;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 24px;
}

.today-hero {
  align-items: stretch;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 180px;
  margin-bottom: 20px;
}

.today-hero h1 {
  font-size: 42px;
  line-height: 1.05;
  margin: 0;
}

.hero-copy {
  color: var(--muted);
  font-size: 17px;
  margin: 10px 0 0;
}

.progress-card {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 18px;
  text-align: center;
}

.progress-card span {
  color: var(--accent);
  font-size: 42px;
  font-weight: 850;
  line-height: 1;
}

.progress-card p {
  color: var(--muted);
  font-weight: 750;
  margin: 8px 0 0;
}

.next-action {
  align-items: center;
  background: #e7f5ef;
  border: 1px solid #a7dbc8;
  border-radius: 8px;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto auto;
  margin-bottom: 18px;
  padding: 20px;
}

.next-action h2 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0;
}

.next-action p {
  color: var(--muted);
  margin: 8px 0 0;
}

.big-done {
  font-size: 20px;
  min-height: 64px;
  min-width: 128px;
}

.source-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.source-tabs span {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-weight: 750;
  padding: 7px 10px;
}

.source-tabs strong {
  color: var(--ink);
  margin-left: 4px;
}

.calendar-toolbar {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-bottom: 14px;
}

.calendar-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 28px;
}

.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  padding: 0 4px;
  text-transform: uppercase;
}

.calendar-day {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-height: 112px;
  padding: 10px;
}

.calendar-day.is-muted {
  opacity: 0.45;
}

.calendar-day.is-today {
  border-color: var(--accent);
}

.calendar-day.is-selected {
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.22);
}

.calendar-date {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.calendar-day strong {
  color: var(--ink);
  font-size: 24px;
  line-height: 1;
}

.calendar-day small {
  color: var(--muted);
  font-weight: 750;
}

.calendar-progress {
  background: #e5e9f0;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

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

.compact-progress {
  min-height: 96px;
  width: 180px;
}

.action-list,
.completed-list {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.action-row {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: auto minmax(0, 1fr);
  padding: 12px;
}

.action-row.is-complete-row {
  opacity: 0.72;
}

.done-stamp {
  align-items: center;
  background: #e7f5ef;
  border: 1px solid #a7dbc8;
  border-radius: 6px;
  color: #075b47;
  display: flex;
  font-weight: 850;
  justify-content: center;
  min-height: 48px;
  min-width: 72px;
}

.check-button {
  min-height: 48px;
  min-width: 72px;
}

.action-buttons {
  display: grid;
  gap: 8px;
}

.snooze-button {
  background: #f8fafc;
  border-color: var(--line);
  color: var(--accent-2);
  cursor: pointer;
  font-weight: 800;
  min-height: 48px;
}

.snooze-button.small {
  font-size: 12px;
  min-height: 34px;
  min-width: 96px;
  padding: 6px 8px;
}

.timer-button {
  background: #334155;
  border-color: #334155;
  color: #ffffff;
  font-weight: 850;
  min-height: 48px;
  min-width: 86px;
}

.timer-button.small {
  font-size: 12px;
  min-height: 34px;
  min-width: 96px;
  padding: 6px 8px;
}

.timer-chip {
  align-items: center;
  background: #ecfeff;
  border: 1px solid #67e8f9;
  border-radius: 6px;
  color: #155e75;
  display: flex;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  justify-content: center;
  min-height: 34px;
  min-width: 96px;
  padding: 6px 8px;
}

.timer-chip.is-running::before {
  content: "Live ";
  font-size: 11px;
  margin-right: 4px;
  text-transform: uppercase;
}

.mini-timer {
  color: #155e75;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.action-main h3 {
  font-size: 18px;
  line-height: 1.25;
  margin: 0;
}

.action-main p {
  color: var(--muted);
  margin: 5px 0 0;
}

.action-main .task-meta,
.next-action .task-meta {
  color: #475569;
  font-size: 13px;
  font-weight: 750;
}

.action-main span {
  margin-left: 8px;
}

.empty-state {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
}

.completed-row {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  padding: 10px 12px;
  text-decoration: line-through;
}

.snoozed-row {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  color: #7c2d12;
  padding: 10px 12px;
}

.snoozed-row span {
  color: #9a3412;
  font-weight: 800;
  margin-left: 8px;
}

.compact-head {
  margin-top: 8px;
}

.quick-add,
.edit-form,
.analytics-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 16px;
}

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

.quick-capture-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.inline-form p,
.edit-form p {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}

.inline-form label,
.edit-form label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.inline-form textarea,
.edit-form textarea {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 84px;
  padding: 8px 10px;
}

.inline-form button {
  align-self: end;
}

.edit-form {
  display: grid;
  gap: 14px;
  max-width: 760px;
}

.form-actions {
  display: flex;
  gap: 10px;
}

.form-actions a,
.row-actions a {
  color: var(--accent);
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.analytics-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.analytics-panel.wide {
  grid-column: 1 / -1;
}

.bar-chart {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  min-height: 230px;
}

.scatter-plot {
  background:
    linear-gradient(to right, transparent 0, transparent calc(25% - 1px), #dfe5ed 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), #dfe5ed 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), #dfe5ed 75%, transparent calc(75% + 1px)),
    linear-gradient(to top, transparent 0, transparent calc(25% - 1px), #dfe5ed 25%, transparent calc(25% + 1px), transparent calc(50% - 1px), #dfe5ed 50%, transparent calc(50% + 1px), transparent calc(75% - 1px), #dfe5ed 75%, transparent calc(75% + 1px)),
    #f7fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  height: 320px;
  position: relative;
}

.dot {
  border: 2px solid #ffffff;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  height: 15px;
  position: absolute;
  transform: translate(-50%, 50%);
  width: 15px;
}

.dot-habits {
  background: #0f766e;
}

.dot-tasks {
  background: #2563eb;
}

.dot-scheduled {
  background: #b45309;
}

.axis-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  position: absolute;
  text-transform: uppercase;
}

.y-high {
  left: 12px;
  top: 10px;
}

.y-low {
  bottom: 10px;
  left: 12px;
}

.x-start {
  bottom: 10px;
  left: 50px;
}

.x-end {
  bottom: 10px;
  right: 12px;
}

.hour-chart {
  align-items: end;
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(24, minmax(0, 1fr));
  min-height: 170px;
}

.hour-slot {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: end;
}

.hour-bar {
  background: #334155;
  border-radius: 4px 4px 0 0;
  min-height: 8px;
  width: 100%;
}

.hour-slot span {
  color: var(--muted);
  font-size: 10px;
}

.bar-slot {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  justify-content: end;
}

.bar {
  background: var(--accent);
  border-radius: 5px 5px 0 0;
  min-height: 10px;
  width: 100%;
}

.bar-slot span {
  color: var(--muted);
  font-size: 12px;
}

.bar-slot strong {
  font-size: 13px;
}

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

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

.leader-row small {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 650;
  margin-top: 2px;
}

.subtask-list {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.subtask-row {
  align-items: center;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  padding: 7px 8px;
}

.subtask-row.is-complete {
  color: var(--muted);
  text-decoration: line-through;
}

.mini-button {
  font-size: 12px;
  min-height: 28px;
  padding: 4px 8px;
}

.mini-button.secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--accent-2);
}

.subtask-add {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 10px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: block;
  font-weight: 700;
  min-height: 100px;
  padding: 18px;
}

.metric span {
  color: var(--ink);
  display: block;
  font-size: 32px;
  line-height: 1;
  margin-bottom: 10px;
}

.two-column {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-bottom: 24px;
}

.section-title {
  align-items: baseline;
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title h2 {
  font-size: 19px;
  margin: 0;
}

.section-title a {
  color: var(--accent);
  font-weight: 700;
}

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}

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

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
}

th {
  background: #f0f3f6;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

td strong {
  display: block;
  min-width: 180px;
}

td small {
  color: var(--muted);
  display: block;
  line-height: 1.35;
  margin-top: 3px;
  max-width: 560px;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  background: #edf2f7;
  border: 1px solid #d7dee8;
  border-radius: 999px;
  display: inline-block;
  font-size: 12px;
  font-weight: 750;
  padding: 4px 8px;
  white-space: nowrap;
}

.filters {
  align-items: center;
  display: flex;
  gap: 8px;
}

input,
select,
button {
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
}

input[type="search"] {
  min-width: 260px;
}

button,
.icon-button {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
}

.icon-button {
  min-height: 32px;
  padding: 5px 9px;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  padding: 24px;
  text-align: center;
}

.stack {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.bar-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 10px;
}

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

code {
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
}

@media (max-width: 860px) {
  .app-header,
  .page-head,
  .undo-banner {
    align-items: flex-start;
    flex-direction: column;
  }

  main {
    padding: 18px;
  }

  .metric-grid,
  .two-column,
  .today-hero,
  .next-action,
  .inline-form,
  .quick-capture-form,
  .subtask-add,
  .calendar-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .calendar-weekday {
    display: none;
  }

  .filters {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  input[type="search"],
  select,
  button {
    min-width: 0;
    width: 100%;
  }
}
