:root {
  --bg: #10141a;
  --panel: #171d26;
  --panel-2: #1e2632;
  --line: #2b3543;
  --text: #e6ecf3;
  --muted: #8fa0b5;
  --accent: #4c9aff;
  --good: #35c58a;
  --warn: #f0a92e;
  --bad: #ef5f6b;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

header.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.85rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { font-weight: 700; letter-spacing: 0.02em; color: var(--text); }

nav.main { display: flex; gap: 0.35rem; flex-wrap: wrap; }
nav.main a {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius);
  color: var(--muted);
}
nav.main a:hover { background: var(--panel-2); text-decoration: none; }
nav.main a.active { background: var(--accent); color: #fff; }

/* ---- Cool Leads dropdown (top nav) ---- */
nav.main .nav-item { position: relative; }
nav.main .has-dropdown > .dropdown-toggle::after {
  content: "\25BE";
  margin-left: 0.4rem;
  font-size: 0.75em;
  vertical-align: middle;
}
nav.main .has-dropdown .dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 210px;
  padding: 6px;
  background: #1c222c;              /* dark grey dropdown background */
  border: 1px solid #333b47;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  display: none;                    /* hidden until the parent is hovered/focused */
  z-index: 30;
}
nav.main .has-dropdown:hover .dropdown,
nav.main .has-dropdown:focus-within .dropdown { display: block; }
nav.main .has-dropdown .dropdown a {
  display: block;                   /* stacked vertically (not side-by-side) */
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  white-space: nowrap;
  margin-bottom: 5px;
  padding: 0.5rem 0.8rem;
  background: #2e3742;              /* each item = a distinct dark-grey box */
  border: 1px solid #3d4753;
  border-radius: 8px;
  color: var(--muted);
}
nav.main .has-dropdown .dropdown a:last-child { margin-bottom: 0; }
nav.main .has-dropdown .dropdown a:hover { background: #434d5c; color: var(--text); }
nav.main .has-dropdown .dropdown a.active { background: var(--accent); border-color: var(--accent); color: #fff; }
nav.main .has-dropdown.active-parent > .dropdown-toggle { color: var(--accent); }

main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.9rem; margin: 0 0 0.5rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.grid { display: grid; gap: 1rem; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.9rem; }
.stat .value { font-size: 1.6rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
tr:last-child td { border-bottom: none; }

input, select, textarea, button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.6rem;
  width: 100%;
}

/* Checkbox styling */
input[type="checkbox"] {
    width: auto;
    height: 20px;
    margin: 0 8px 0 0;
    cursor: pointer;
    accent-color: #007bff;
}
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.field { margin-bottom: 0.7rem; }
.row { display: grid; gap: 0.7rem; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

button, .btn {
  cursor: pointer;
  width: auto;
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  display: inline-block;
}
button:hover { filter: brightness(1.1); }
button.ghost, .btn.ghost { background: var(--panel-2); color: var(--text); border-color: var(--line); font-weight: 500; }
button.danger { background: transparent; color: var(--bad); border-color: var(--line); font-weight: 500; }
.inline { display: inline; }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

/* Inline form elements in sticky-actions */
.sticky-actions form { display: inline; }
.sticky-actions .btn { width: auto; }
.sticky-actions select { width: auto; }

.pill {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}
.pill.client { color: var(--good); border-color: rgba(53,197,138,0.4); }
.pill.prospect { color: var(--accent); border-color: rgba(76,154,255,0.4); }
.pill.cool_lead { color: var(--warn); border-color: rgba(240,169,46,0.4); }
.pill.past_client, .pill.partner { color: var(--warn); border-color: rgba(240,169,46,0.4); }
.pill.won { color: var(--good); }
.pill.lost { color: var(--bad); }
.pill.overdue { color: var(--bad); border-color: rgba(239,95,107,0.5); }
.pill.hot_lead { color: var(--bad); }
.pill.warm_lead { color: var(--warn); }
.pill.chilled_lead {
    color: var(--warn);
    border-color: rgba(240,169,46,0.4);
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.right { text-align: right; }
.empty { color: var(--muted); padding: 1rem 0; }

.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 0.75rem; overflow-x: auto; padding-bottom: 0.5rem; }
.column { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem; }
.column header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 0.6rem; }
.deal { background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem; margin-bottom: 0.5rem; }
.deal .title { font-weight: 600; }
.deal select { margin-top: 0.4rem; font-size: 0.82rem; padding: 0.25rem; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 1rem 0.9rem; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.timeline .meta { color: var(--muted); font-size: 0.8rem; }
.timeline .body { white-space: pre-wrap; margin-top: 0.25rem; }

details summary { cursor: pointer; color: var(--muted); }
details[open] summary { margin-bottom: 0.75rem; }

details summary.btn { border-radius: 8px; list-style: none; }
details summary.btn::-webkit-details-marker { display: none; }
details summary.btn:hover { filter: brightness(1.1); }

.filters { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; min-width: 150px; }

/* Sticky action bar for bulk operations */
.sticky-actions {
    position: sticky;
    top: 52px; /* below the topbar */
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    padding: 0.75rem 1rem;
    z-index: 19;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Flash / success messages */
.flash {
    padding: 0.7rem 1rem;
    border-radius: 6px;
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    line-height: 1.4;
}
.flash.success {
    background: #e6f7ee;
    color: #155d32;
    border: 1px solid #b5e5c8;
}
.flash.error {
    background: #fde8e8;
    color: #8b1a1a;
    border: 1px solid #f5c2c2;
}
