:root {
  --bg: #f3efe6;
  --paper: #fffdf8;
  --ink: #1d1a16;
  --muted: #5e584e;
  --line: #e4dccf;
  --accent: #1f6f5b;
  --warn: #9a3b2f;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  border-top: 4px solid var(--accent);
}

h1, h2, h3, p { margin: 0; }

h1 { font-size: 1.75rem; letter-spacing: -0.03em; }

h2 { font-size: 1rem; }

h3 { font-size: 1.02rem; }

a { color: inherit; }

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

button { cursor: pointer; }

button:disabled { opacity: 0.55; cursor: default; }

.screen {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: 1.1rem 1.15rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: inherit;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 1.8rem;
  height: 1.8rem;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #f6f3ec;
  border-radius: 0.55rem;
}

.nav { display: flex; flex-wrap: wrap; gap: 0.25rem; }

.nav-link {
  text-decoration: none;
  color: inherit;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
}

.nav-link:hover { background: #e7e0d4; }

.nav-link[aria-current="page"],
.nav-link[aria-current="page"]:hover {
  background: var(--ink);
  color: var(--paper);
}

.lede, .muted, .meta, .stat-label, .stat-hint { color: var(--muted); }

.lede { margin-top: 0.3rem; }

.meta { font-size: 0.92rem; }

.panel, .card, .column, a.stat {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.panel { padding: 1rem; }

.panel h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.narrow { max-width: 42rem; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

a.stat {
  display: block;
  text-decoration: none;
  padding: 0.9rem 1rem;
}

a.stat:hover { border-color: #c9bfae; }

.stat-value {
  font-size: 1.6rem;
  letter-spacing: -0.03em;
  margin: 0.15rem 0;
}

.stat-hint { font-size: 0.82rem; }

.split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 0.75rem;
  align-items: start;
}

.fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
}

.span-2 { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; }

.field input, .field select, .field textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid #ddd4c4;
  border-radius: 10px;
  background: #fff;
  color: inherit;
}

.field.check { flex-direction: row; align-items: center; }

.field.check input { width: auto; }

textarea { resize: vertical; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 0.75rem;
}

.card, .deal, .item { min-width: 0; overflow-wrap: break-word; }

.card { display: flex; flex-direction: column; gap: 0.35rem; padding: 1rem; }

.clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: start;
}

.column { padding: 0.75rem; }

.column-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.65rem;
}

.column-head h2 { margin: 0; }

.stage-lead { box-shadow: inset 0 3px 0 #8a8175; }
.stage-qualified { box-shadow: inset 0 3px 0 #1f6f5b; }
.stage-proposal { box-shadow: inset 0 3px 0 #b07d2a; }
.stage-won { box-shadow: inset 0 3px 0 #2d7a46; }
.stage-lost { box-shadow: inset 0 3px 0 #a24b3c; }

.deal {
  background: #f7f4ee;
  border-radius: 12px;
  padding: 0.7rem;
  margin-bottom: 0.5rem;
}

.deal-actions, .item { gap: 0.5rem; }

.deal-actions { display: flex; flex-wrap: wrap; margin-top: 0.55rem; }

.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }

.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.8rem 1rem;
}

.item[data-state="done"] .task-title { text-decoration: line-through; color: var(--muted); }

.money { font-variant-numeric: tabular-nums; font-weight: 650; }

.stage-line {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.75rem;
  padding: 0.4rem 0;
  border-top: 1px solid var(--line);
}

.overdue { color: var(--warn); }

.text-link, .back { color: var(--accent); text-decoration: none; font-weight: 650; }

.text-link:hover, .back:hover, .card a:hover, a.meta:hover { text-decoration: underline; }
a.small:hover { text-decoration: none; }

.card a.small, a.small { color: var(--ink); text-decoration: none; font-weight: 500; }

a.small, button.small, button.primary, button.danger {
  border-radius: 999px;
  text-decoration: none;
}

a.small, button.small {
  background: transparent;
  border: 1px solid #d9d0c2;
  color: var(--ink);
  padding: 0.25rem 0.6rem;
}

button.primary {
  background: var(--accent);
  color: #f6f3ec;
  border: 0;
  padding: 0.6rem 1rem;
  font-weight: 650;
}

button.danger {
  background: transparent;
  color: var(--warn);
  border: 1px solid #e3c2bc;
  padding: 0.55rem 0.9rem;
}

.empty { color: var(--muted); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#toast {
  position: fixed;
  z-index: 5;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #f6f3ec;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
}

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

@media (max-width: 800px) {
  .stats, .split { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .screen { padding: 0.9rem 0.85rem 2.5rem; }
  .fields, .stats { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr; }
  .item { flex-direction: column; align-items: stretch; }
}
