@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600&family=Work+Sans:wght@400;500;600;700&display=swap');

:root {
  --rose: #c39ba3;
  --rose-dark: #a97c86;
  --beige: #e8e0d9;
  --gold: #b1834b;
  --rose-light: #ecb2a9;
  --ink: #3a2f2c;
  --ink-soft: #6b5c57;
  --white: #fffdfb;
  --card: #ffffff;
  --border: #d9cec6;
  --danger: #b2483f;
  --success: #6f8f5c;
  --shadow: 0 4px 18px rgba(58, 47, 44, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--beige);
  color: var(--ink);
  font-family: 'Work Sans', sans-serif;
  font-size: 15px;
}

h1, h2, h3, h4, .display {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}

a { color: var(--gold); }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
}
button:active { transform: translateY(1px); }

.btn-primary { background: var(--rose); color: var(--white); }
.btn-primary:hover { background: var(--rose-dark); }
.btn-gold { background: var(--gold); color: var(--white); }
.btn-gold:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(0,0,0,0.03); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--white);
  color: var(--ink);
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--rose);
  outline-offset: 1px;
}
label { font-size: 12.5px; font-weight: 600; color: var(--ink-soft); display: block; margin-bottom: 4px; }
.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > .field { flex: 1; }

/* ---------- Login ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(236,178,169,0.35), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(177,131,75,0.18), transparent 40%),
    var(--beige);
}
.login-card {
  background: var(--card);
  padding: 44px 40px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  width: 380px;
  text-align: center;
}
.login-card img.logo { max-width: 180px; margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card p.subtitle { color: var(--ink-soft); font-size: 13px; margin-bottom: 24px; }
.login-card .field { text-align: left; }
.login-card button[type="submit"] { width: 100%; margin-top: 6px; padding: 12px; }
.login-error { color: var(--danger); font-size: 13px; margin-top: 10px; }
.login-links { margin-top: 16px; font-size: 13px; }

/* ---------- App Shell ---------- */
.app-shell { display: none; min-height: 100vh; }
.app-shell.active { display: flex; }

.sidebar {
  width: 232px;
  background: linear-gradient(180deg, #fff 0%, var(--beige) 220%);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; margin-bottom: 26px; padding: 0 6px; }
.sidebar .brand img { width: 42px; height: 42px; object-fit: contain; }
.sidebar .brand-name { font-family: 'Fraunces', serif; font-size: 15px; line-height: 1.2; color: var(--ink); }
.sidebar nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.sidebar nav a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar nav a:hover { background: rgba(195,155,163,0.15); }
.sidebar nav a.active { background: var(--rose); color: var(--white); }
.sidebar .logout-btn { margin-top: auto; }

.main {
  flex: 1;
  padding: 28px 34px;
  overflow-y: auto;
  height: 100vh;
}
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h2 { font-size: 24px; }
.page-header .actions { display: flex; gap: 10px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kanban-col {
  background: rgba(255,255,255,0.55);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 250px;
  max-width: 250px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 150px);
}
.kanban-col-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.kanban-col-body { padding: 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.kanban-col-body.drag-over { background: rgba(195,155,163,0.12); }

.lead-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 11px 12px;
  cursor: grab;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.lead-card:active { cursor: grabbing; }

/* ---------- Tasks columns ---------- */
.tasks-columns { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.tasks-col { flex: 1; min-width: 300px; display: flex; flex-direction: column; max-height: calc(100vh - 190px); }
.tasks-col-header { display: flex; align-items: center; gap: 8px; padding-bottom: 12px; margin-bottom: 12px; border-bottom: 2px solid var(--border); }
.tasks-col-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.tasks-col-dot.overdue { background: var(--danger); }
.tasks-col-dot.today { background: var(--gold); }
.tasks-col-dot.future { background: var(--success); }
.tasks-col-count { margin-left: auto; background: var(--beige); color: var(--ink-soft); font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; }
.tasks-col-body { overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.task-item { background: var(--white); border: 1px solid var(--border); border-radius: 11px; padding: 10px 12px; display: flex; align-items: flex-start; gap: 10px; width: 100%; box-sizing: border-box; }
.task-item input[type="checkbox"] { flex-shrink: 0; flex-grow: 0; width: 16px; min-width: 16px; max-width: 16px; height: 16px; margin-top: 2px; padding: 0; }
.task-item.is-overdue { border-left: 3px solid var(--danger); }
.task-item.is-done { opacity: .55; }
.task-item .ti-body { flex: 1 1 0%; min-width: 0; overflow-wrap: break-word; }
.task-item .ti-title { font-weight: 600; font-size: 13.5px; margin-bottom: 2px; overflow-wrap: break-word; }
.task-item .ti-title.done { text-decoration: line-through; color: var(--ink-soft); }
.task-item .ti-meta { font-size: 12px; color: var(--ink-soft); display: flex; gap: 8px; flex-wrap: wrap; min-width: 0; }
.task-item .ti-meta a { color: var(--ink-soft); text-decoration: underline; }
.task-item .ti-del { flex-shrink: 0; background: transparent; border: none; color: var(--ink-soft); font-size: 15px; padding: 2px 6px; cursor: pointer; line-height: 1; }
.task-item .ti-del:hover { color: var(--danger); }
.tasks-col-empty { color: var(--ink-soft); font-size: 13px; padding: 10px 2px; }
.lead-card.dragging { opacity: .4; }
.lead-card .lc-name { font-weight: 600; font-size: 13.5px; margin-bottom: 3px; }
.lead-card .lc-meta { font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 2px; }
.lead-card .lc-badges { margin-top: 6px; display: flex; gap: 5px; flex-wrap: wrap; }
.tag-pill.sm { padding: 2px 8px; font-size: 10.5px; margin: 0; }
.lead-card .lc-tags { margin-top: 5px; display: flex; gap: 4px; flex-wrap: wrap; }
.badge { font-size: 10.5px; padding: 2px 8px; border-radius: 20px; background: var(--beige); color: var(--ink-soft); font-weight: 600; }
.badge.stale { background: var(--danger); color: white; }
.badge.channel { background: var(--rose-light); color: var(--ink); }
.badge.cadence-missing { background: #f4d9a8; color: #7a4a12; font-weight: 700; }
.badge.cadence-ok { background: #dfe9d6; color: var(--success); }

/* ---------- Tables / lists ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 10px; color: var(--ink-soft); font-weight: 600; border-bottom: 2px solid var(--border); font-size: 12.5px; text-transform: uppercase; letter-spacing: .03em; }
td { padding: 10px; border-bottom: 1px solid var(--border); }
tr:hover td { background: rgba(195,155,163,0.05); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(58,47,44,0.4);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--card); border-radius: 18px; width: 560px; max-width: 100%;
  padding: 26px 28px; box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.modal.wide { width: 720px; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-header h3 { font-size: 19px; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--ink-soft); padding: 4px 8px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- Misc ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.stat-card .label { font-size: 12px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat-card .value { font-family: 'Fraunces', serif; font-size: 26px; margin-top: 4px; }
.stat-card .delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.stat-card.locked { cursor: pointer; position: relative; user-select: none; }
.stat-card.locked .value { filter: blur(6px); }
.stat-card.locked .lock-hint { font-size: 11px; color: var(--ink-soft); margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.stat-card.locked:hover { box-shadow: 0 0 0 2px var(--gold) inset; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.delta.neutral { color: var(--ink-soft); font-weight: 600; }

.chip-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border); font-size: 12.5px;
  cursor: pointer; background: var(--white); user-select: none;
}
.chip.selected { background: var(--rose); color: var(--white); border-color: var(--rose); }

.tag-pill { display: inline-flex; align-items: center; gap: 6px; background: var(--rose-light); color: var(--ink); padding: 4px 10px; border-radius: 20px; font-size: 12px; margin: 2px 4px 2px 0; }

.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: white;
  padding: 12px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow);
  z-index: 200; opacity: 0; transform: translateY(10px); transition: all .25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab-btn { background: none; border: none; padding: 10px 16px; font-weight: 600; color: var(--ink-soft); border-bottom: 2px solid transparent; border-radius: 0; }
.tab-btn.active { color: var(--rose-dark); border-bottom-color: var(--rose); }

.list-manager-row { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-manager-row span { flex: 1; }

@media (max-width: 900px) {
  .app-shell.active { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar nav { flex-direction: row; }
  .sidebar .logout-btn { margin-top: 0; }
  .main { height: auto; padding: 18px; }
  .modal { width: 100%; }
}

@media print {
  .sidebar, .page-header .actions, .no-print { display: none !important; }
  .main { padding: 0; }
}
