:root {
  --bg: #f4f3fb;
  --surface: #ffffff;
  --text: #191733;
  --muted: #5e5c7a;
  --border: #dddaee;
  --accent: #6b46e5;
  --accent-text: #ffffff;
  --accent-soft: #eee9ff;
  --danger: #c53030;
  --ok: #18794e;
  --ok-soft: #e3f6ec;
  --warn: #9a4a12;
  --warn-soft: #fff0e6;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #070e1f;
    --surface: #0e1830;
    --text: #eef1ff;
    --muted: #9ea8cf;
    --border: #22305a;
    --accent: #9d82ff;
    --accent-text: #0a0f22;
    --accent-soft: #241d4d;
    --danger: #ff7b7b;
    --ok: #5fd39a;
    --ok-soft: #12302a;
    --warn: #ffb68f;
    --warn-soft: #33201c;
  }
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

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

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.ghost { background: transparent; }
button.icon { padding: 4px 9px; font-size: 18px; line-height: 1; background: transparent; border-color: transparent; color: var(--muted); }
button.icon:hover { color: var(--danger); border-color: var(--border); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 17px; }
.tagline { color: var(--muted); font-size: 13px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.actions select { width: auto; border: 1px solid var(--border); border-radius: 8px; padding: 7px 8px; background: var(--surface); }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 18px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.card h2 small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid .wide { grid-column: 1 / -1; }

label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 9px;
  background: var(--bg);
  font-size: 14px;
}
textarea { resize: vertical; min-height: 70px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); height: 28px; }
input[type="color"] { padding: 2px; height: 36px; cursor: pointer; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

dialog {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  padding: 20px 22px;
  width: min(560px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(7, 14, 31, .55); }
dialog h2 { margin: 0 0 14px; font-size: 18px; }
dialog .buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 18px; }
dialog .buttons .left { margin-right: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 50;
  pointer-events: none;
}

.site-footer { padding: 8px 24px 28px; color: var(--muted); font-size: 13px; text-align: center; }
.site-footer a { color: var(--accent); }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
}

/* ---------- page ---------- */

.page { padding: 20px 24px 24px; max-width: 1900px; margin: 0 auto; }

.sample {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  background: var(--accent-soft); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: grid; gap: 1px; }
.stat span { font-size: 13px; color: var(--muted); }
.stat strong { font-size: 24px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat small { font-size: 12px; color: var(--muted); }
.stat.won strong { color: var(--ok); }
.stat.stat-due strong { color: var(--warn); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-bottom: 14px; }
.filters input[type="search"] { max-width: 360px; background: var(--surface); }

/* ---------- board ---------- */

.board { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.col {
  background: color-mix(in srgb, var(--surface) 55%, var(--bg));
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 220px;
  display: flex; flex-direction: column; gap: 8px; transition: border-color .15s, background .15s;
}
.col.over { border-color: var(--accent); background: var(--accent-soft); }
.col header { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; padding: 2px 4px 4px; border-bottom: 3px solid var(--stage); }
.col h2 { font-size: 14px; margin: 0; }
.count { display: inline-block; min-width: 20px; text-align: center; font-size: 12px; color: var(--muted); background: var(--bg); border-radius: 99px; padding: 0 6px; margin-left: 4px; }
.sum { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col-new { --stage: #3d9bff; }
.col-contacted { --stage: #9d82ff; }
.col-offer { --stage: #f0a63a; }
.col-won { --stage: #2fb67c; }
.col-lost { --stage: #9a9fb8; }

.cards { display: grid; gap: 8px; }
.lead {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 3px; justify-items: start; text-align: left; white-space: normal;
  padding: 10px 12px; border-radius: 9px; background: var(--surface); cursor: grab;
  box-shadow: 0 1px 2px rgba(10, 15, 34, .06);
}
.lead:hover { border-color: var(--stage); }
.lead.dragging { opacity: .45; }
.lead-top { display: flex; justify-content: space-between; gap: 8px; width: 100%; }
.lead strong { font-size: 14px; }
.val { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.co { font-size: 13px; color: var(--muted); }
.note { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.due { margin-top: 4px; font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.due.today { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.due.late { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); font-weight: 600; }
.col-won .lead, .col-lost .lead { opacity: .85; }
.drop-hint { margin: 6px 0; text-align: center; font-size: 13px; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; padding: 18px 8px; }
.add-here { color: var(--muted); border-style: dashed; }
.add-here:hover { color: var(--accent); }

button.danger { color: var(--danger); }
button.danger:hover { border-color: var(--danger); }

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

@media (max-width: 600px) {
  .page { padding: 14px 12px; }
  .board { grid-template-columns: repeat(5, 82vw); scroll-snap-type: x mandatory; }
  .col { scroll-snap-align: start; }
  .stat strong { font-size: 20px; }
}
