:root {
  --navy: #00264f; --red: #ba181d; --red2: #910c0f; --bg: #F0F5FA; --ink: #1b1f24; --muted: #6b7280; --line: #dfe6ee; --white: #fff;
  --font-head: "Oswald", "Arial Narrow", sans-serif; --font-body: "Roboto", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 14px; }
a { color: var(--navy); }
h1, h2, .brand { font-family: var(--font-head); text-transform: uppercase; letter-spacing: .02em; margin: 0; }
.top { display: flex; align-items: center; justify-content: space-between; background: var(--navy); color: var(--white); padding: 0 20px; height: 52px; }
.brand { font-size: 20px; } .brand .mark { color: #ffd166; margin-right: 6px; }
.top-right { display: flex; gap: 12px; align-items: center; }
.top-right a { color: var(--white); border-color: rgba(255,255,255,.4); background: transparent; }

.signin { display: grid; place-items: center; min-height: calc(100vh - 52px); }
.card { background: var(--white); padding: 40px 48px; border-radius: 10px; box-shadow: 0 6px 30px rgba(0,38,79,.12); text-align: center; max-width: 420px; }
.card h1 { font-size: 34px; color: var(--navy); } .card p { color: var(--muted); }

.btn { display: inline-block; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--white); color: var(--navy); text-decoration: none; font-weight: 500; cursor: pointer; font-family: var(--font-body); font-size: 13px; }
.btn.primary { background: var(--red); border-color: var(--red2); color: var(--white); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: default; }
.icon { background: none; border: 0; font-size: 26px; line-height: 1; cursor: pointer; color: var(--muted); }
.muted { color: var(--muted); } .center { text-align: center; padding: 24px; }

.app { padding: 16px 20px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; margin-bottom: 12px; }
.toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.toolbar select, .toolbar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 14px; background: var(--white); color: var(--ink); min-width: 160px; }
.toolbar .grow { flex: 1; min-width: 220px; } .toolbar .grow input { width: 100%; }
.toolbar #count { margin-left: auto; align-self: center; }

.table-wrap { background: var(--white); border-radius: 10px; box-shadow: 0 2px 10px rgba(0,38,79,.06); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 5px 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { position: sticky; top: 0; background: #f6f8fb; font-family: var(--font-head); text-transform: uppercase; font-size: 12px; letter-spacing: .05em; color: var(--navy); cursor: pointer; user-select: none; }
th.sorted::after { content: " " attr(data-dir); color: var(--red); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.title { font-weight: 500; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
/* Team is free text from a lead form and occasionally holds a full paragraph instead of a
   team name; cap and ellipsize it so one long row can't blow out the table's width. Targeted
   by class, not column position, so a future table under .table-wrap doesn't inherit this cap
   on whatever its second column happens to be. */
.table-wrap td.team-cell { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
tbody tr { cursor: pointer; } tbody tr:hover { background: #f3f7fc; }
td.warn { color: var(--red); font-weight: 500; } td.bad { color: var(--red); } td.meh { color: #b45309; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #e8eef6; color: var(--navy); font-size: 12px; }

.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(560px, 100vw); background: var(--white); box-shadow: -8px 0 30px rgba(0,0,0,.18); z-index: 20; display: flex; flex-direction: column; overflow: hidden; }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px 12px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.drawer-head h2 { font-size: 22px; color: var(--navy); }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--red); font-weight: 700; }
.icon:focus-visible, .btn:focus-visible, .stage-select:focus-visible, .note-form textarea:focus-visible, .panel summary:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

/* Header contact links: quiet inline row, AC links visually distinct from tel/mailto */
.drawer-team { font-size: 15px; color: var(--muted); margin: 2px 0 4px; }
.contact-links { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; margin-top: 6px; }
.contact-links a { text-decoration: none; }
.contact-links a:hover { text-decoration: underline; }
.contact-links a:nth-last-child(-n+2) { color: var(--muted); font-size: 12px; }

/* Three key dates as compact stat tiles — glanceable, not competing with the chat below */
.dates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 12px 20px; font-size: 14px; font-weight: 500; flex-shrink: 0; }
.dates > div { background: var(--bg); border-radius: 8px; padding: 8px 10px; }
.dates .lbl { display: block; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; margin-bottom: 2px; }
.dates .muted { font-size: 11px; font-weight: 400; display: block; }

.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 0 20px 12px; flex-shrink: 0; }
.mirror-note { font-size: 12px; padding: 0 20px 10px; flex-shrink: 0; }
.stage-select { padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; background: var(--white); color: var(--navy); font-weight: 500; }
.note-form { display: flex; gap: 8px; padding: 0 20px 14px; flex-shrink: 0; }
.note-form textarea { flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px; resize: vertical; }

/* Contact details + other deals: collapsed by default so the conversation gets the room */
.panel { border-top: 1px solid var(--line); flex-shrink: 0; }
.panel[open] { max-height: 40vh; overflow: auto; }
.panel summary { cursor: pointer; padding: 10px 20px; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.panel summary .count { font-family: var(--font-body); text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; font-size: 12px; }
.panel[open] summary { border-bottom: 1px solid var(--line); }
.fields { display: grid; grid-template-columns: max-content 1fr; gap: 5px 12px; margin: 10px 20px; font-size: 13px; }
.fields dt { color: var(--muted); } .fields dd { margin: 0; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 20px 10px; }
.other { margin: 4px 20px 10px; padding-left: 18px; font-size: 13px; }
.panel .lbl { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 0 20px; }

/* Conversation: two-sided chat, newest first. This is the reason the drawer exists. */
.timeline-filter { padding: 8px 20px 0; flex-shrink: 0; }
.timeline { list-style: none; margin: 0; padding: 14px 20px 24px; overflow: auto; flex: 1; min-height: 0; border-top: 1px solid var(--line); }
.chat { background: #f6f8fb; }
.msg { max-width: 88%; margin: 0 0 10px; padding: 8px 12px; border-radius: 12px; background: var(--white); box-shadow: 0 1px 2px rgba(0,38,79,.08); }
.msg.out { margin-left: auto; background: #dfe9f6; border-bottom-right-radius: 4px; }
.msg.in { margin-right: auto; background: var(--white); border-bottom-left-radius: 4px; border-left: 3px solid var(--red); }
/* System-style rows (dir: "") always land in .msg.sys through the side class in public/drawer.js;
   the t-system/t-automation/t-campaign selectors are added so the grey, centered look is also
   reachable by type alone, which is what the "Messages only" filter below keys off of. */
.msg.sys, .t-system, .t-automation, .t-campaign { max-width: 100%; background: transparent; box-shadow: none; text-align: center; color: var(--muted); font-size: 12px; padding: 4px 0; margin: 6px 0; }
.msg-head { display: flex; gap: 8px; align-items: baseline; font-size: 11px; color: var(--muted); }
.msg.sys .msg-head, .t-system .msg-head, .t-automation .msg-head, .t-campaign .msg-head { justify-content: center; }
.ev-type { font-weight: 700; color: var(--navy); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }
.msg.sys .ev-type, .t-system .ev-type, .t-automation .ev-type, .t-campaign .ev-type { color: var(--muted); }
.msg .who { color: var(--ink); font-weight: 500; }
.msg-head time { margin-left: auto; white-space: nowrap; }
.msg.sys .msg-head time, .t-system .msg-head time, .t-automation .msg-head time, .t-campaign .msg-head time { margin-left: 0; }
.msg-title { font-weight: 500; margin-top: 2px; font-size: 13px; }
/* "Messages only" keeps the back-and-forth (sms, email, call, note) and hides everything else,
   without refetching: public/drawer.js toggles this class on the <ul> and CSS does the rest. */
.timeline.filter-messages .t-system, .timeline.filter-messages .t-automation, .timeline.filter-messages .t-campaign,
.timeline.filter-messages .t-stage, .timeline.filter-messages .t-task, .timeline.filter-messages .t-form,
.timeline.filter-messages .t-board { display: none; }
.msg-body { white-space: pre-wrap; font-size: 13px; line-height: 1.45; margin-top: 4px; overflow-wrap: anywhere; }
.msg-body summary { cursor: pointer; }
.msg-body summary::after { content: " (show all)"; color: var(--navy); font-size: 12px; }

.scrim { position: fixed; inset: 0; background: rgba(0,38,79,.25); z-index: 10; }
@media (max-width: 700px) { .dates { grid-template-columns: 1fr; } .app { padding: 10px; } .msg { max-width: 96%; } }

/* --- Task 10: filter bar + Kanban board --- */
.seg { display: flex; gap: 0; } .seg .btn { border-radius: 0; } .seg .btn:first-child { border-radius: 6px 0 0 6px; } .seg .btn:last-child { border-radius: 0 6px 6px 0; }
.sync { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: rgba(255,255,255,.12); }
.sync.ok { color: #c7f2d4; } .sync.warn { background: #b45309; color: #fff; } .sync.bad { background: var(--red); color: #fff; }
.flagbar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.flaglink { background: var(--white); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--navy); }
.flaglink.on { background: var(--navy); color: var(--white); border-color: var(--navy); }
.banner { background: var(--red); color: var(--white); padding: 8px 12px; border-radius: 6px; margin-bottom: 10px; }

.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 12px; height: calc(100vh - 175px); }
.col { display: flex; flex-direction: column; background: #e6edf5; border-radius: 10px; min-width: 250px; }
.col.over { outline: 2px dashed var(--red); outline-offset: -2px; }
.unknown-col { background: #fff4d6; border: 1px dashed #b45309; }
.unknown-col .col-head { color: #7a4b00; }
.unknown-col .col-count { background: #b45309; }
.col-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; font-family: var(--font-head); text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--navy); position: sticky; top: 0; }
.col-count { background: var(--navy); color: var(--white); border-radius: 999px; padding: 1px 8px; font-family: var(--font-body); }
.col-body { overflow-y: auto; padding: 0 8px 8px; flex: 1; }
.col-body:empty::after { content: "No deals"; display: block; text-align: center; color: var(--muted); font-size: 12px; padding: 16px 0; }
.dcard { background: var(--white); border-radius: 8px; padding: 10px 10px 8px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,38,79,.1); cursor: grab; border-left: 3px solid transparent; }
.dcard.needs { border-left-color: var(--red); }
.dcard.dragging { opacity: .5; }
.dcard:focus { outline: 2px solid var(--navy); }
.dcard-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.dcard-name { font-weight: 500; }
.owner { font-size: 11px; background: #e8eef6; color: var(--navy); border-radius: 999px; padding: 1px 7px; font-weight: 700; }
.dcard-team { color: var(--muted); font-size: 12px; margin: 2px 0 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dcard-meta { display: flex; gap: 12px; font-size: 12px; font-variant-numeric: tabular-nums; }
.dcard-badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; }
.badge.dup { background: #fde8e8; color: var(--red2); } .badge.reg { background: #e3f6ea; color: #14532d; } .badge.team { background: #fff4d6; color: #7a4b00; }
@media (max-width: 700px) { .kanban { height: auto; grid-auto-columns: 85vw; } }
