:root {
  --bg: #f1efe8;
  --panel: #ffffff;
  --ink: #1f2024;
  --muted: #6b6f76;
  --line: #e6e3dc;
  --line-strong: #d6d2c8;
  --accent: #d8541f;
  --accent-soft: #fdece1;
  --good: #2f7d4f;
  --warn: #b9842b;
  --danger: #c0392b;
  --col-bg: #ecead9;
  --card-bg: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 24px rgba(0,0,0,.06);
}

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

/* --- Login screen --- */
.login-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 32px 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
  text-align: center;
}
.login-logo { height: 48px; width: auto; margin-bottom: 18px; }
.login-card h2 { margin: 0 0 18px; font-size: 18px; color: var(--ink); }
.login-card form { text-align: left; }
.login-card label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.login-card input {
  width: 100%;
  margin-top: 4px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  font-size: 14px;
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-error {
  background: #fbecea;
  color: var(--danger);
  border-radius: 7px;
  padding: 8px 10px;
  margin: 4px 0 12px;
  font-size: 13px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  padding: 5px 10px;
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 999px;
}
.user-pill .link { font-size: 12px; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

button { font-family: inherit; font-size: 14px; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--accent); }

.topbar {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand .logo-img {
  height: 36px;
  width: auto;
  display: block;
}
.brand h1 { margin: 0; font-size: 17px; }
.brand .subtitle { margin: 0; color: var(--muted); font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; }

.tabs {
  display: flex;
  gap: 4px;
  background: #f1efe8;
  padding: 3px;
  border-radius: 9px;
}
.tab {
  background: transparent;
  border: 0;
  padding: 6px 14px;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}
.tab:hover { color: var(--ink); }
.tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.badge-num {
  display: inline-block;
  background: var(--accent);
  color: white;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
  min-width: 18px;
  text-align: center;
}

button.primary {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 8px 14px;
  border-radius: 7px;
  font-weight: 600;
}
button.primary:hover { background: #b9461a; }
button.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 7px 12px;
  border-radius: 7px;
  color: var(--ink);
}
button.ghost:hover { background: #faf9f5; }
button.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid #f0c5bf;
  padding: 7px 12px;
  border-radius: 7px;
}
button.danger:hover { background: #fbecea; }
button.link { background: none; border: 0; color: var(--accent); padding: 0; font-size: 13px; }
button.icon {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 2px 6px;
  font-size: 14px;
  border-radius: 5px;
}
button.icon:hover { background: rgba(0,0,0,.06); color: var(--ink); }

/* --- Board --- */
.board {
  flex: 1;
  display: flex;
  gap: 14px;
  padding: 16px 24px 24px;
  overflow-x: auto;
  align-items: flex-start;
  scroll-padding: 24px;
}

.column {
  flex: 0 0 290px;
  background: var(--col-bg);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 100px);
}
.column.drag-over { outline: 2px dashed var(--accent); outline-offset: -4px; }

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 8px;
}
.column-header .title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink);
  flex: 1;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  margin-right: 6px;
  cursor: text;
}
.column-header .title:hover,
.column-header .title:focus {
  background: rgba(255,255,255,.6);
  border-color: var(--line-strong);
  outline: none;
}
.column-header .count {
  color: var(--muted);
  font-size: 12px;
  margin-right: 6px;
  font-weight: 500;
}
.column-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  padding: 2px;
  min-height: 24px;
}
.column-footer { padding: 8px 4px 2px; }
.add-deal {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  text-align: left;
}
.add-deal:hover { background: rgba(255,255,255,.5); color: var(--ink); border-color: var(--accent); }

.add-column {
  flex: 0 0 290px;
  display: flex;
  align-items: flex-start;
}
.add-column button {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--line-strong);
  color: var(--muted);
  padding: 12px;
  border-radius: 12px;
  font-weight: 500;
}
.add-column button:hover { background: rgba(255,255,255,.5); border-color: var(--accent); color: var(--ink); }

/* --- Card --- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
  transition: box-shadow .12s, transform .12s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.07); transform: translateY(-1px); }
.card.dragging { opacity: 0.4; }
.card .title { font-weight: 600; font-size: 14px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.card .footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
  gap: 8px;
  font-size: 12px;
}
.card .footer .left { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card .footer .right { color: var(--muted); }
.card .followup { color: var(--warn); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.retailer    { background: #e6f1ff; color: #1f5eb8; }
.badge.wholesaler  { background: #ece6ff; color: #5a3aae; }
.badge.influencer  { background: #fff0e0; color: #b9601f; }
.badge.customer    { background: #e2f5ec; color: #2f7d4f; }
.badge.other       { background: #eee; color: #555; }

/* --- Drawer --- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100vw);
  background: var(--panel);
  border-left: 1px solid var(--line);
  box-shadow: -10px 0 30px rgba(0,0,0,.10);
  z-index: 20;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.drawer-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  position: sticky; top: 0;
  z-index: 1;
}
.drawer-actions { display: flex; gap: 8px; }
.drawer-body { padding: 18px 22px 60px; }
.drawer-body h2 { margin: 0 0 4px; font-size: 20px; }
.drawer-body h2 input {
  width: 100%;
  font: inherit;
  font-size: 20px;
  font-weight: 700;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 6px;
  border-radius: 6px;
}
.drawer-body h2 input:hover { border-color: var(--line); }
.drawer-body h2 input:focus { border-color: var(--accent); outline: none; background: white; }

.deal-fields {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 6px 14px;
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  margin: 12px 0;
  align-items: center;
}
.deal-fields .lbl { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.deal-fields .val input,
.deal-fields .val select,
.deal-fields .val textarea {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 5px;
  font: inherit;
}
.deal-fields .val input:hover,
.deal-fields .val select:hover,
.deal-fields .val textarea:hover { border-color: var(--line); background: white; }
.deal-fields .val input:focus,
.deal-fields .val select:focus,
.deal-fields .val textarea:focus { border-color: var(--accent); outline: none; background: white; }
.deal-fields .val textarea { min-height: 60px; resize: vertical; }
.deal-fields .row-full { grid-column: 1 / -1; }

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 8px;
}
.section-title h3 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }

.timeline { display: flex; flex-direction: column; gap: 8px; }
.timeline-item {
  background: #faf9f5;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}
.timeline-item .head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}
.timeline-item .head .left { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timeline-item .body { white-space: pre-wrap; font-size: 13px; }
.timeline-item .followup { margin-top: 6px; font-size: 12px; color: var(--warn); font-weight: 600; }
.timeline-item .delete-x {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 14px;
  padding: 0;
  line-height: 1;
}
.timeline-item .delete-x:hover { color: var(--danger); }
.outcome {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: #eee;
  color: #555;
}
.outcome.interested  { background: #e6f1ff; color: #1f5eb8; }
.outcome.ordered     { background: #e2f5ec; color: #2f7d4f; }
.outcome.follow_up   { background: #fff4d6; color: #8a6210; }
.outcome.no_reply    { background: #f1efe8; color: #6b6f76; }
.outcome.declined    { background: #fbecea; color: #c0392b; }

/* --- Forms --- */
form label {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}
form label input,
form label select,
form label textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  outline: none;
}
form label input:focus,
form label select:focus,
form label textarea:focus { border-color: var(--accent); }
form .row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modal {
  position: fixed; inset: 0;
  background: rgba(20,20,25,.45);
  z-index: 50;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 20px;
  overflow-y: auto;
}
.modal-content {
  background: var(--panel);
  border-radius: 14px;
  padding: 22px 24px;
  width: min(560px, 100%);
  box-shadow: var(--shadow);
}
.modal-content h2 { margin: 0 0 14px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.muted { color: var(--muted); font-size: 13px; }

.followup-list-item {
  border-left: 3px solid var(--warn);
  padding: 6px 0 6px 10px;
  margin-bottom: 8px;
  cursor: pointer;
}
.followup-list-item:hover { background: #faf9f5; }
.followup-list-item .when { color: var(--warn); font-weight: 600; font-size: 12px; }
.followup-list-item .what { display: block; font-size: 14px; }
.followup-list-item .who { display: block; font-size: 12px; color: var(--muted); }

/* --- Agendas view --- */
.view-agendas {
  flex: 1;
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 18px;
  padding: 18px 24px 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  align-items: start;
}

.agenda-sidebar {
  position: sticky;
  top: 78px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
}
.agenda-list { display: flex; flex-direction: column; gap: 4px; }
.agenda-list-item {
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  border: 1px solid transparent;
}
.agenda-list-item:hover { background: #faf9f5; }
.agenda-list-item.active { background: var(--accent-soft); border-color: #f4c8b1; }
.agenda-list-item .date { font-weight: 600; font-size: 14px; color: var(--ink); }
.agenda-list-item .meta { color: var(--muted); font-size: 12px; }

.agenda-pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 24px 28px;
  min-height: 400px;
}

.agenda-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.agenda-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
}
.agenda-header .date-input {
  border: 1px solid transparent;
  background: transparent;
  font: inherit;
  font-size: 22px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  color: var(--ink);
  width: auto;
}
.agenda-header .date-input:hover { border-color: var(--line); }
.agenda-header .date-input:focus { border-color: var(--accent); outline: none; }
.agenda-header .agenda-actions { display: flex; gap: 8px; }

.section {
  margin-bottom: 22px;
}
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.section-name {
  font-weight: 700;
  font-size: 16px;
  color: var(--ink);
  border: 1px solid transparent;
  padding: 4px 6px;
  border-radius: 5px;
  flex: 1;
  cursor: text;
}
.section-name:hover { background: #faf9f5; border-color: var(--line); }
.section-name:focus { background: white; border-color: var(--accent); outline: none; }
.section-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.section:hover .section-actions { opacity: 1; }

.bullet-list { list-style: none; padding: 0; margin: 0 0 6px; }
.bullet-list ul { list-style: none; padding-left: 22px; margin: 4px 0 4px; }
.bullet {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 6px;
  border-radius: 6px;
  position: relative;
}
.bullet:hover { background: #faf9f5; }
.bullet .marker {
  color: var(--muted);
  margin-top: 2px;
  user-select: none;
  flex-shrink: 0;
}
.bullet-list > .bullet > .marker::before { content: '●'; font-size: 8px; }
.bullet-list ul .bullet > .marker::before { content: '○'; font-size: 8px; }
.bullet-text {
  flex: 1;
  border: 1px solid transparent;
  padding: 2px 4px;
  border-radius: 4px;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 1.2em;
  cursor: text;
}
.bullet-text:hover { border-color: var(--line); background: white; }
.bullet-text:focus { border-color: var(--accent); background: white; }
.bullet-text.empty::before {
  content: 'New item…';
  color: var(--muted);
  pointer-events: none;
}
.bullet-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity .12s;
  flex-shrink: 0;
}
.bullet:hover .bullet-actions { opacity: 1; }

.add-row {
  display: flex;
  gap: 10px;
  margin-top: 6px;
}
.add-row button {
  font-size: 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  padding: 4px 6px;
  border-radius: 5px;
}
.add-row button:hover { color: var(--accent); background: var(--accent-soft); }

.add-section {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

@media (max-width: 720px) {
  .drawer { width: 100vw; }
  .view-agendas { grid-template-columns: 1fr; }
  .agenda-sidebar { position: static; }
}
