/* Panel theme — layered ON TOP of Tabler (tabler.min.css). Tabler provides the
   reboot, typography (Inter), navbar + .page/.page-wrapper/.page-body shell and
   the colour tokens; this file restyles the app's existing component classes to
   match Tabler's palette so the server-rendered panels keep working unchanged.
   Loaded AFTER tabler.min.css, so these rules win where they overlap. */

:root {
  --navy: #1d273b;        /* headings */
  --accent: #066fd1;      /* Tabler primary */
  --accent-dark: #055cb0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --line: #e6e7e9;        /* Tabler border */
  --text: #1d273b;
  --muted: #667382;
  --error: #d63939;
  --radius: 6px;
}

[hidden] { display: none !important; }

/* The Tabler page-body already pads; keep cards tidy inside it. */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.875rem 1rem;            /* compact, matches Tabler density */
  margin-top: 0.75rem;
  box-shadow: 0 1px 2px rgba(20, 34, 58, 0.04);
}
.card:first-child { margin-top: 0; }
/* Cards built with Tabler's real structure (card-header / card-table) provide
   their own internal spacing, so drop the wrapper padding to sit flush. */
.card:has(> .card-header),
.card:has(> .table-responsive),
.card:has(> .empty) { padding: 0; }
.card-header { padding: 0.625rem 1rem; }
.card-body { padding: 1rem; }
.card h2 { margin: 0 0 4px; color: var(--navy); font-size: 1.125rem; }
.card h3 { margin: 0 0 4px; color: var(--navy); font-size: 1rem; }
.card .card-title { color: var(--navy); }
.card.center { text-align: center; }
/* Denser table rows (Tabler default is roomier). */
.table.card-table th, .table.card-table td { padding-top: 0.45rem; padding-bottom: 0.45rem; }
.table thead th { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

.muted { color: var(--muted); }
.lead { font-size: 17px; }
.error {
  background: #fdeceb; color: var(--error); border: 1px solid #f5c6c4;
  border-radius: var(--radius); padding: 10px 12px; margin: 12px 0;
}
.notice { background: #e9f7ef; color: #1f7a4d; border: 1px solid #b8e6cd; border-radius: var(--radius); padding: 8px 12px; }

/* Forms */
.quote-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.quote-form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 14px; }
.quote-form .row { display: flex; gap: 14px; }
.quote-form .row label { flex: 1; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.quote-form input, .quote-form select, .quote-form textarea {
  font: inherit; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); background: #fff; font-weight: 400; color: var(--text);
}
.quote-form input:focus, .quote-form select:focus, .quote-form textarea:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(6, 111, 209, 0.15);
}
fieldset.contact { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; }
fieldset.contact legend { font-weight: 700; font-size: 14px; padding: 0 6px; }
label.check { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; font-size: 14px; }
label.check input { margin-top: 3px; }
label .opt { color: var(--muted); font-weight: 400; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 16px; }
@media (max-width: 560px) { .checks { grid-template-columns: 1fr; } }

/* Buttons (our classes don't use Bootstrap's .btn base, so style them fully) */
.btn-primary {
  display: inline-block; background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius); padding: 9px 16px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn-primary:hover { background: var(--accent-dark); color: #fff; }
.btn-secondary, .btn-ghost {
  display: inline-block; background: #fff; color: var(--accent); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 8px 14px; font: inherit; font-weight: 600;
  cursor: pointer; text-decoration: none; line-height: 1.4;
}
.btn-secondary:hover, .btn-ghost:hover { border-color: var(--accent); background: #f1f7ff; }

/* Data tables */
table.data { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
table.data td.muted { color: var(--muted); }
table.data td a.ext { word-break: break-all; }
table.data tbody tr:hover { background: #f6f8fb; }
/* Tabler card-table sits flush inside a .card. */
.card > .table-responsive { margin: 0; }
.card-table { margin-bottom: 0; }

/* Stat chips */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 0; }
.stat { background: #eef3f9; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px; }
.stat b { color: var(--navy); font-size: 18px; display: block; }
.stat span { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }

/* Badges (override Tabler's .badge so our variants render) */
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; margin-right: 4px; }
.badge.caa { background: #e6f0ff; color: #1a5fd0; }
.badge.ins { background: #e9f7ef; color: #1f7a4d; }
.badge.rating { background: #fff4e0; color: #8a5a00; }
.chip { display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #eef3f9; color: var(--navy); margin-right: 4px; }

/* Pagination */
.pager { display: flex; gap: 8px; align-items: center; margin-top: 16px; font-size: 14px; }
.pager a, .pager span.cur { padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--accent); }
.pager span.cur { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager .muted { border: none; padding: 7px 4px; }

/* Directory toolbar */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.toolbar input[type="search"] { font: inherit; padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); min-width: 240px; }
.toolbar label.check { font-size: 14px; white-space: nowrap; }
.toolbar .clear { font-size: 14px; color: var(--muted); text-decoration: none; }

/* Credit packs */
.packs { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; }
.pack { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; min-width: 140px; display: flex; flex-direction: column; gap: 8px; }
.pack-credits { font-weight: 700; font-size: 18px; color: var(--navy); }
.pack-price { color: var(--muted); }

/* Pipeline board */
.board { display: flex; gap: 14px; margin-top: 20px; overflow-x: auto; padding-bottom: 12px; align-items: flex-start; }
.board-col { flex: 0 0 260px; background: #eef3f9; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.board-col.side { background: #f9eef0; border-color: #e6ccd0; }
.board-col-head { display: flex; align-items: center; justify-content: space-between; }
.board-col-head .col-title { font-weight: 700; color: var(--navy); font-size: 14px; }
.board-col-head .col-count { background: var(--navy); color: #fff; font-size: 12px; font-weight: 700; border-radius: 999px; min-width: 22px; text-align: center; padding: 1px 7px; }
.board-col.side .col-count { background: #9b3b4b; }
.col-hint { color: var(--muted); font-size: 11px; margin: 0 0 4px; line-height: 1.3; }
.board-col-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: var(--radius); padding: 2px; }
.board-col-body.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: #e3ecfb; }
.col-empty { color: #a9b3c5; text-align: center; font-size: 13px; margin: 8px 0; }
.lead-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; text-decoration: none; color: var(--text); cursor: grab; box-shadow: 0 1px 2px rgba(20, 34, 58, 0.05); display: block; }
.lead-card:hover { border-color: var(--accent); }
.lead-card.dragging { opacity: 0.5; }
.lead-card-cat { font-weight: 700; font-size: 14px; color: var(--navy); }
.lead-card-area { color: var(--muted); font-size: 13px; margin-top: 2px; }
.lead-card-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.lead-card-date { color: var(--muted); font-size: 11px; margin-left: auto; }
.lead-card-task { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; border-radius: var(--radius); padding: 2px 7px; display: inline-block; }

/* Stage badge + move controls */
.stage-badge { display: inline-block; background: var(--navy); color: #fff; font-weight: 700; font-size: 13px; padding: 4px 12px; border-radius: 999px; }
.stage-move { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.stage-move form { display: inline; margin: 0; }
.stage-btn { font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; background: #fff; color: var(--accent); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 12px; text-decoration: none; }
.stage-btn:hover { border-color: var(--accent); background: #f1f7ff; }
.stage-btn.danger { color: #d63939; }
.stage-btn.danger:hover { border-color: #f0b9b9; background: #fdeeee; }

/* Timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; }
.timeline .tl-item { display: flex; gap: 12px; padding: 0 0 14px; position: relative; }
.timeline .tl-item:not(:last-child)::before { content: ""; position: absolute; left: 5px; top: 14px; bottom: 0; width: 2px; background: var(--line); }
.tl-dot { flex: 0 0 12px; width: 12px; height: 12px; border-radius: 999px; background: var(--accent); margin-top: 3px; position: relative; z-index: 1; }
.tl-body { flex: 1; }
.tl-head { display: flex; align-items: baseline; gap: 8px; justify-content: space-between; }
.tl-head strong { color: var(--navy); font-size: 14px; }
.tl-time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.tl-text { font-size: 14px; margin-top: 1px; }
.tl-actor { color: var(--muted); font-size: 12px; margin-top: 1px; }
.note-form { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }

/* In-page tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 16px; flex-wrap: wrap; }
.tab-btn { font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; background: none; border: none; color: var(--muted); padding: 9px 14px; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.is-active { color: var(--navy); border-bottom-color: var(--accent); }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* Email-template previews (Stack tab) */
.email-tpl { border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; }
.email-tpl > summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; list-style: none; }
.email-tpl > summary::-webkit-details-marker { display: none; }
.email-tpl > summary::before { content: "▸"; color: var(--muted); }
.email-tpl[open] > summary::before { content: "▾"; }
.email-tpl-name { font-weight: 700; color: var(--navy); white-space: nowrap; }
.email-tpl-id { font-size: 12px; background: #eef3f9; color: var(--muted); border-radius: 6px; padding: 2px 7px; white-space: nowrap; }
.email-tpl-meta { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.email-copy { margin-left: auto; flex: 0 0 auto; }
.email-tpl-frame { width: 100%; height: 380px; border: 0; border-top: 1px solid var(--line); background: #fff; }

/* Responder cards + message threads + live chat */
.responder { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 10px 0; }
.responder-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.thread-wrap { margin: 6px 0; }
.thread { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
/* Tabler-style chat bubbles. */
.thread li {
  background: #f1f5f9; border-radius: 14px; padding: 8px 12px; font-size: 14px;
  max-width: 80%; align-self: flex-start; line-height: 1.4;
}
.thread li .muted { display: block; font-size: 11px; font-weight: 600; margin-bottom: 1px; }
.thread li.me { background: var(--accent); color: #fff; align-self: flex-end; }
.thread li.me .muted { color: rgba(255, 255, 255, 0.85); }
#chat-messages { max-height: 50vh; overflow-y: auto; padding-right: 4px; }

/* Live self-test */
.pipeline-strip { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.pl-stage { padding: 6px 12px; border-radius: 999px; font-size: 13px; font-weight: 600; background: #f0f2f6; color: #6b7686; border: 1px solid var(--line); }
.pl-stage.done { background: #e6f7ee; color: #1c7a47; border-color: #b8e6cd; }
.pl-stage.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pl-stage.fail { background: #fdeaea; color: #b42318; border-color: #f4c7c2; }
.selftest-steps { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.selftest-step { display: flex; align-items: baseline; gap: 10px; padding: 9px 12px; border-radius: var(--radius); background: #f7f8fa; border: 1px solid var(--line); }
.selftest-step .st-icon { font-weight: 700; width: 16px; flex: 0 0 16px; text-align: center; }
.selftest-step .st-name { font-weight: 600; }
.selftest-step .st-detail { font-size: 13px; }
.selftest-step.pending { color: #98a1b0; }
.selftest-step.pending .st-icon { color: #c2c9d4; }
.selftest-step.ok { background: #f1faf5; border-color: #cdeedd; }
.selftest-step.ok .st-icon { color: #1c7a47; }
.selftest-step.fail { background: #fdeeed; border-color: #f4c7c2; }
.selftest-step.fail .st-icon { color: #b42318; }

/* Company-facing lead tiles */
.lead-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-top: 12px; }
.lead-tile { display: block; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; text-decoration: none; color: var(--text); background: #fff; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.lead-tile:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(20, 34, 58, 0.1); transform: translateY(-1px); }
.lead-tile-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.lead-tile-cat { font-weight: 700; color: var(--navy); }
.lead-tile-area { color: var(--muted); font-size: 14px; margin-top: 2px; }
.lead-tile-sum { font-size: 14px; margin: 8px 0; color: var(--text); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lead-tile-foot { display: flex; justify-content: space-between; align-items: center; font-size: 13px; margin-top: 6px; }
.lead-tile-cta { color: var(--accent); font-weight: 700; }
.review-stars { color: #b8860b; letter-spacing: 1px; }

@media (max-width: 560px) { .quote-form .row { flex-direction: column; gap: 14px; } }
