:root {
  --bg: #f4f6f1;
  --surface: #ffffff;
  --surface-2: #edf0ea;
  --ink: #18201b;
  --muted: #647067;
  --line: #d7ddd2;
  --accent: #1f6f5b;
  --accent-2: #9f4a38;
  --warn: #b98222;
  --shadow: 0 10px 28px rgba(24, 32, 27, 0.08);
}

* {
  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;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

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

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  filter: brightness(0.94);
}

button.ghost {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 64px;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 246, 241, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: var(--ink);
  font-size: 1.2rem;
  font-weight: 800;
}

.topbar nav {
  display: flex;
  gap: 14px;
}

.page {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 48px;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100% - 32px));
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-shell h1 {
  margin: 0 0 22px;
}

.login-form,
.edit-form,
.note-form,
.terminal-form {
  display: grid;
  gap: 14px;
}

.error {
  margin: 0;
  color: var(--accent-2);
  font-weight: 700;
}

.command-band {
  margin-bottom: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.capture-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
}

.summary-grid {
  display: grid;
  grid-template-columns: 180px 180px minmax(260px, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.summary-panel {
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.summary-panel h2,
.quadrant h2,
.history h2,
.terminal-output h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.metric {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 800;
}

.recommendation {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

.mode-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.mode-filter a {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  padding: 7px 12px;
  font-size: 0.9rem;
}

.mode-filter a.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.task-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.quadrant {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.task-card {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.task-card p,
.summary-panel p,
.event p {
  margin: 0;
}

.task-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
}

.task-head a {
  color: var(--ink);
  font-weight: 800;
}

.task-head span,
.task-meta span {
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 700;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.empty {
  margin: 8px 0 0;
  color: var(--muted);
}

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

.edit-form,
.history,
.terminal-form,
.terminal-output {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.actions,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.inline-form {
  margin-top: 12px;
}

.checkbox {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}

.event {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.event span {
  color: var(--muted);
  font-size: 0.85rem;
}

.terminal-page {
  display: grid;
  gap: 16px;
}

/* ── Codex terminal page ───────────────────────────────── */

body.codex-body {
  overflow: hidden;
}

.codex-terminal-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px);
  background: #0c1210;
  color: #b8d4be;
  font-family: 'Courier New', Courier, ui-monospace, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
}

.terminal-output-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 22px 10px;
}

.tline {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.tline + .tline {
  margin-top: 1px;
}

.tline-user {
  color: #7ec88a;
  margin-top: 12px;
}

.tline-assistant {
  color: #c8dcbe;
  margin-bottom: 2px;
}

.tline-status {
  color: #3d6048;
  font-style: italic;
}

.tlog-details {
  margin-top: 4px;
  color: #3d6048;
}

.tlog-details summary {
  cursor: pointer;
  user-select: none;
  color: #3d6048;
  font-style: italic;
  list-style: none;
}

.tlog-details summary::before {
  content: "▶ ";
  font-style: normal;
}

.tlog-details[open] summary::before {
  content: "▼ ";
}

.tlog-details pre {
  margin: 4px 0 0 14px;
  color: #3d6048;
  font-family: inherit;
  font-size: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.terminal-input-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 22px;
  border-top: 1px solid #182a1e;
  background: #090e0c;
  flex-shrink: 0;
}

.prompt-glyph {
  color: #7ec88a;
  padding-top: 7px;
  flex-shrink: 0;
  user-select: none;
}

.terminal-input-bar textarea {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 0;
  color: #c8dcbe;
  font-family: 'Courier New', Courier, ui-monospace, monospace;
  font-size: 0.88rem;
  line-height: 1.6;
  resize: none;
  outline: none;
  padding: 6px 0;
  overflow: hidden;
  min-height: 1.6em;
  width: 100%;
}

.terminal-input-bar textarea::placeholder {
  color: #4a7a58;
}

.terminal-input-bar textarea:focus {
  border-bottom: 1px solid #3d6048;
}

.terminal-btns {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.terminal-btns button {
  min-height: 26px;
  padding: 0 12px;
  font-size: 0.8rem;
  border-radius: 3px;
  font-family: inherit;
  background: #1a3222;
  color: #7ec88a;
  border: 1px solid #274d34;
}

.terminal-btns button:hover {
  filter: none;
  background: #274d34;
}

.terminal-btns button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.terminal-btns button.ghost {
  background: transparent;
  color: #3d6048;
  border: 1px solid #182a1e;
}

.terminal-btns button.ghost:hover {
  background: #111e15;
}

.terminal-hint {
  padding: 3px 22px 6px;
  background: #090e0c;
  color: #3d6048;
  font-family: 'Courier New', Courier, ui-monospace, monospace;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.terminal-output pre {
  overflow: auto;
  max-height: 520px;
  margin: 0 0 12px;
  border-radius: 8px;
  background: #101511;
  color: #e7f1e9;
  padding: 14px;
}

.terminal-output pre.stderr {
  color: #ffd0c7;
}

@media (max-width: 1050px) {
  .task-layout {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .two-column,
  .summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .capture-form,
  .chat-composer,
  .task-layout,
  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Finance pages ───────────────────────────────────────── */

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

.page-head h1 {
  margin: 0;
}

.btn-link {
  display: inline-block;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 8px 16px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
}

.btn-link:hover {
  filter: brightness(0.94);
  text-decoration: none;
}

.back-link {
  font-size: 0.9rem;
  color: var(--muted);
}

.back-link:hover {
  color: var(--accent);
}

.finance-summary {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.95rem;
}

.finance-group {
  margin-bottom: 28px;
}

.finance-group h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.8rem;
}

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

.finance-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.finance-table th {
  padding: 9px 14px;
  background: var(--surface-2);
  text-align: left;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.finance-table th.num,
.finance-table td.num {
  text-align: right;
}

.finance-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.finance-table tbody tr:last-child td {
  border-bottom: none;
}

.finance-table tbody tr:hover td {
  background: var(--surface-2);
}

.row-inactive td {
  opacity: 0.5;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-variable {
  background: #fef3c7;
  color: #92400e;
}

.shared-badge {
  background: #dbeafe;
  color: #1e40af;
}

.muted-note {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

.aside-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.aside-panel h2 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.share-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 6px;
}

.share-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.share-form select {
  flex: 1;
}

.btn-sm {
  min-height: 28px;
  padding: 0 10px;
  font-size: 0.8rem;
}

/* ── Upcoming bills (dashboard) ──────────────────────────── */

.upcoming-bills-band {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.upcoming-bills-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.upcoming-bills-head a {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.85rem;
}

.upcoming-bills-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.upcoming-bill-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  text-decoration: none;
  color: var(--ink);
  min-width: 120px;
  transition: border-color 0.15s;
}

.upcoming-bill-chip:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.chip-urgent {
  border-color: var(--accent-2);
  background: #fef2f2;
}

.chip-name {
  font-weight: 700;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.chip-date {
  font-size: 0.78rem;
  color: var(--muted);
}

.chip-urgent .chip-date {
  color: var(--accent-2);
  font-weight: 600;
}

.chip-amt {
  font-size: 0.78rem;
  color: var(--muted);
}

.chip-more {
  justify-content: center;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: transparent;
  border-style: dashed;
}
