:root {
  --bg: #F4F5F7;
  --col-bg: #F1F2F4;
  --col-bg-hover: #E2E8F0;
  --card-bg: #FFFFFF;
  --primary: #5E3FBE;
  --primary-dark: #3F2A7E;
  --text: #1B1F23;
  --muted: #6B7280;
  --border: #E1E4E8;
  --green: #1F8B4C;
  --green-bg: #E8F5EE;
  --amber: #B7791F;
  --red: #C53030;
  --red-bg: #FDEBEC;
  --blue: #1E66D0;
  --blue-bg: #E7F0FB;
  --purple: #6F42C1;
  --purple-bg: #F0EAFB;
  --orange: #D97706;
  --orange-bg: #FEF1E1;
  --shadow: 0 1px 2px rgba(9,30,66,.08), 0 0 1px rgba(9,30,66,.12);
  --shadow-hover: 0 4px 12px rgba(9,30,66,.15);
  --shadow-drag: 0 8px 24px rgba(9,30,66,.25);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.4;
}
header.topbar {
  background: var(--primary);
  color: white;
  padding: 16px 24px;
  box-shadow: 0 1px 4px rgba(0,0,0,.1);
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap;
}
header.topbar h1 { margin: 0; font-size: 20px; font-weight: 600; }
header.topbar .sub { margin-top: 4px; font-size: 13px; opacity: .85; }
.topbar-actions { display: flex; gap: 10px; align-items: center; }
.user-badge {
  background: rgba(255,255,255,.18); color: white; padding: 5px 10px;
  border-radius: 14px; font-size: 12px; cursor: pointer;
}
.user-badge:hover { background: rgba(255,255,255,.28); }
.btn {
  background: white; color: var(--primary-dark); border: none;
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-weight: 600;
  font-size: 13px;
}
.btn:hover { background: #F0EAFB; }
.btn:disabled { opacity: .6; cursor: wait; }

.totals {
  display: flex; gap: 24px; padding: 14px 24px;
  background: white; border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.totals .stat { display: flex; flex-direction: column; }
.totals .stat .label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted);
}
.totals .stat .value { font-size: 18px; font-weight: 600; margin-top: 2px; }

.board {
  display: flex; gap: 12px; padding: 16px;
  overflow-x: auto; align-items: flex-start;
  min-height: calc(100vh - 200px);
}
.loading { padding: 40px; color: var(--muted); }
.column {
  flex: 0 0 300px;
  background: var(--col-bg);
  border-radius: 8px;
  padding: 10px;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 220px);
  transition: background .15s ease;
}
.column.drop-target { background: var(--col-bg-hover); }
.column-head {
  padding: 4px 6px 10px; border-bottom: 2px solid var(--border); margin-bottom: 10px;
}
.column-head .name {
  font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
}
.column-head .meta {
  font-size: 12px; color: var(--muted); margin-top: 4px;
  display: flex; justify-content: space-between;
}
.column-body {
  overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding-right: 2px;
  min-height: 40px;
}

.card {
  background: var(--card-bg);
  border-radius: 6px;
  padding: 12px;
  box-shadow: var(--shadow);
  border-left: 3px solid var(--primary);
  transition: box-shadow .15s ease, transform .15s ease, opacity .15s ease;
  cursor: grab;
}
.card:hover { box-shadow: var(--shadow-hover); }
.card:active { cursor: grabbing; }
.card.dragging {
  opacity: 0.4;
  box-shadow: var(--shadow-drag);
}
.card .head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 8px; margin-bottom: 8px;
}
.card .name { font-weight: 600; font-size: 14px; line-height: 1.3; }
.card .price {
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
  white-space: nowrap; padding: 2px 4px; border-radius: 4px;
}
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.badge {
  font-size: 11px; padding: 2px 7px; border-radius: 10px; font-weight: 500;
}
.badge.cat.fox { background: var(--blue-bg); color: var(--blue); }
.badge.cat.tobias { background: var(--orange-bg); color: var(--orange); }
.badge.cat.both { background: var(--purple-bg); color: var(--purple); }
.badge.owner { background: #EEF1F4; color: var(--text); }

.field { margin-top: 6px; font-size: 12px; }
.field .lbl {
  font-size: 10px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; margin-bottom: 2px;
}
.field .val { color: var(--text); line-height: 1.4; word-break: break-word; }
.field.close-field .val {
  background: var(--blue-bg); color: var(--blue); padding: 4px 6px; border-radius: 4px;
  display: inline-block; min-width: 100px;
}
.field.close-field .val.empty { color: var(--muted); background: #F4F5F7; font-style: italic; }
.field.next-field .val {
  background: var(--green-bg); color: var(--green); padding: 4px 6px; border-radius: 4px;
  border-left: 3px solid var(--green); cursor: text; min-height: 22px;
}

/* Inline edit */
[data-edit] { cursor: pointer; transition: background .1s ease; }
[data-edit]:hover { filter: brightness(.96); }
[data-edit].editing {
  outline: 2px solid var(--primary); outline-offset: 1px; cursor: text;
  background: white;
}

/* Comments */
.comments { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.comments-list { display: flex; flex-direction: column; gap: 6px; }
.comment {
  background: #FAFAFB; border-radius: 5px; padding: 6px 8px; font-size: 12px;
  position: relative;
}
.comment .meta {
  display: flex; justify-content: space-between; gap: 8px;
  font-size: 10px; color: var(--muted); margin-bottom: 2px;
}
.comment .author { font-weight: 600; color: var(--text); }
.comment .text { color: var(--text); white-space: pre-wrap; word-break: break-word; }
.comment .del {
  background: none; border: none; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px;
}
.comment .del:hover { color: var(--red); }

.comment-add { display: flex; gap: 6px; margin-top: 8px; }
.comment-input {
  flex: 1; resize: vertical; font-family: inherit; font-size: 12px;
  padding: 5px 7px; border: 1px solid var(--border); border-radius: 4px;
  min-height: 28px; max-height: 120px;
}
.comment-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: transparent; }
.btn-small {
  background: var(--primary); color: white; border: none;
  padding: 4px 10px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600;
  white-space: nowrap;
}
.btn-small:hover { background: var(--primary-dark); }

footer.legend {
  padding: 12px 24px; background: white; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
  display: flex; gap: 24px; flex-wrap: wrap;
}
footer.legend strong { color: var(--text); margin-right: 6px; }
footer.legend .muted { color: var(--muted); }

.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--text); color: white; padding: 10px 16px;
  border-radius: 6px; font-size: 13px; opacity: 0;
  transition: opacity .2s ease; pointer-events: none;
  z-index: 1000;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--red); }

@media (max-width: 1200px) { .column { flex: 0 0 280px; } }
