/* InspektAI Sales Portal — theme (brand: Canvas Black #121212, InspektAI Orange #FC5C2E) */
:root {
  --bg: #0f0f0f; --panel: #181818; --panel-2: #202020; --line: #2a2a2a; --line-2: #333;
  --text: #f2f2f2; --muted: #a3a3a3; --dim: #6b6b6b;
  --orange: #FC5C2E; --orange-soft: rgba(252, 92, 46, .14); --magenta: #DD38C8;
  --red: #ff5a5f; --red-soft: rgba(255, 90, 95, .15); --amber: #ffb547; --amber-soft: rgba(255, 181, 71, .15);
  --yellow: #ffe066; --yellow-soft: rgba(255, 224, 102, .12); --green: #3ddc84; --green-soft: rgba(61, 220, 132, .14);
  --blue: #5aa9ff; --blue-soft: rgba(90, 169, 255, .14); --purple: #b58cff; --purple-soft: rgba(181, 140, 255, .14);
  --radius: 12px; --shadow: 0 8px 30px rgba(0, 0, 0, .45);
  --font: "DM Sans", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 14px; line-height: 1.45; }
a { color: var(--orange); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 12px; } .mono { font-variant-numeric: tabular-nums; }
.orange { color: var(--orange); } .red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }
.hidden, [hidden] { display: none !important; }

/* ---------- layout ---------- */
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: rgba(18, 18, 18, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -.02em; }
.brand .star { width: 22px; height: 22px; border-radius: 6px; background: var(--orange); display: grid; place-items: center; color: #000; font-size: 13px; }
.brand small { color: var(--dim); font-weight: 500; font-size: 11px; margin-left: 2px; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { padding: 7px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; }
.nav a.active, .nav a:hover { background: var(--panel-2); color: var(--text); }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }
.userchip b { color: var(--text); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--orange-soft); color: var(--orange); display: grid; place-items: center; font-weight: 800; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.sync-dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.page { max-width: 1440px; margin: 0 auto; padding: 22px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.grid { display: grid; gap: 14px; } .grid > * { min-width: 0; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } .g-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } .g-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; } .span-3 { grid-column: span 3; }
@media (max-width: 1100px) { .g-6, .g-5 { grid-template-columns: repeat(3, 1fr); } .g-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .g-6, .g-5, .g-4, .g-3, .g-2 { grid-template-columns: 1fr 1fr; } .span-2, .span-3 { grid-column: span 2; } .nav a { padding: 6px 8px; } .page { padding: 14px 12px 60px; } .topbar { gap: 8px; padding: 8px 12px; flex-wrap: wrap; } .topbar .userchip > span:not(.avatar) { display: none; } .brand small { display: none; } .page-head .btn-row { width: 100%; } .page-head .btn-row input[type=search] { flex: 1; width: auto !important; } html, body { overflow-x: hidden; } }

/* ---------- cards & tiles ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; position: relative; overflow: hidden; }
.tile .lbl { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.tile .val { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-top: 4px; line-height: 1.1; }
.tile .sub { font-size: 12px; color: var(--dim); margin-top: 4px; }
.tile.alert-red { border-color: rgba(255, 90, 95, .5); background: linear-gradient(180deg, var(--red-soft), var(--panel)); }
.tile.alert-red .val { color: var(--red); }
.tile.alert-amber { border-color: rgba(255, 181, 71, .45); background: linear-gradient(180deg, var(--amber-soft), var(--panel)); }
.tile.alert-amber .val { color: var(--amber); }
.tile.ok { border-color: rgba(61, 220, 132, .35); } .tile.ok .val { color: var(--green); }
.tile.accent .val { color: var(--orange); }
.tile.clickable { cursor: pointer; } .tile.clickable:hover { border-color: var(--orange); }
.delta { font-size: 12px; font-weight: 600; margin-left: 6px; } .delta.up { color: var(--green); } .delta.down { color: var(--red); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.b-new, .b-overdue { background: var(--red-soft); color: var(--red); border-color: rgba(255, 90, 95, .35); }
.b-today { background: var(--amber-soft); color: var(--amber); border-color: rgba(255, 181, 71, .35); }
.b-nodate { background: var(--yellow-soft); color: var(--yellow); border-color: rgba(255, 224, 102, .3); }
.b-soon { background: var(--blue-soft); color: var(--blue); }
.b-scheduled { background: var(--green-soft); color: var(--green); }
.b-closed { background: var(--panel-2); color: var(--dim); }
.b-hot { background: var(--orange-soft); color: var(--orange); } .b-warm { background: var(--amber-soft); color: var(--amber); }
.b-cold { background: var(--blue-soft); color: var(--blue); } .b-dead { background: var(--panel-2); color: var(--dim); }
.b-stage { background: var(--panel-2); color: var(--muted); font-weight: 600; }
.b-paid { background: var(--magenta); color: #fff; font-size: 10px; padding: 2px 6px; }
.b-outline { background: transparent; border-color: var(--line-2); color: var(--muted); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; transition: .12s; }
.btn:hover { border-color: var(--orange); } .btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #000; } .btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; } .btn-danger { color: var(--red); border-color: rgba(255, 90, 95, .4); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; } .btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 6px; }
.btn-wa { background: #1f7a4a; border-color: #1f7a4a; color: #fff; } .btn-call { background: #24507a; border-color: #24507a; color: #fff; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip { padding: 5px 10px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel-2); font-size: 12px; font-weight: 600; cursor: pointer; color: var(--muted); }
.chip.active, .chip:hover { border-color: var(--orange); color: var(--orange); background: var(--orange-soft); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; }
.field label .req { color: var(--orange); }
input[type=text], input[type=tel], input[type=number], input[type=date], input[type=password], input[type=url], input[type=search], select, textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line-2); border-radius: 9px; padding: 9px 11px; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px var(--orange-soft); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 30px; }
select option { background: var(--panel); }
textarea { min-height: 80px; resize: vertical; }
input[type=date] { color-scheme: dark; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; } .form-grid .full { grid-column: 1 / -1; }
@media (max-width: 720px) { .form-grid { grid-template-columns: 1fr 1fr; } }
.help { font-size: 12px; color: var(--dim); }
.tip { padding: 10px 12px; border-radius: 9px; background: var(--orange-soft); border: 1px solid rgba(252, 92, 46, .3); color: var(--text); font-size: 13px; }
.tip b { color: var(--orange); }

/* ---------- lead cards (rep view) ---------- */
.lead-card { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line-2); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: 1fr auto; gap: 10px 16px; transition: .12s; }
.lead-card:hover { border-color: var(--line-2); border-left-color: var(--orange); }
.lead-card.s-new, .lead-card.s-overdue { border-left-color: var(--red); } .lead-card.s-today { border-left-color: var(--amber); }
.lead-card.s-nodate { border-left-color: var(--yellow); } .lead-card.s-soon { border-left-color: var(--blue); } .lead-card.s-scheduled { border-left-color: var(--green); }
.lead-card .name { font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lead-card .meta { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.lead-card .meta span::before { content: ""; }
.lead-card .note { margin-top: 8px; font-size: 13px; color: var(--muted); white-space: pre-line; max-height: 40px; overflow: hidden; }
.lead-card .actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.lead-card .actions .btn-row { justify-content: flex-end; }
@media (max-width: 720px) { .lead-card { grid-template-columns: 1fr; min-width: 0; } .lead-card .actions .badge { align-self: flex-start; } .lead-card .meta { row-gap: 2px; } .lead-card .actions { align-items: stretch; } .lead-card .actions .btn-row { justify-content: stretch; } .lead-card .actions .btn { flex: 1; } }
.section-title { display: flex; align-items: center; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; } .section-title h2 { white-space: nowrap; }
.section-title .count { background: var(--panel-2); border-radius: 999px; padding: 2px 9px; font-size: 12px; color: var(--muted); font-weight: 700; }
.empty { padding: 30px; text-align: center; color: var(--dim); border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--panel-2); position: sticky; top: 0; cursor: pointer; user-select: none; }
th.sorted::after { content: " ▾"; color: var(--orange); } th.sorted.asc::after { content: " ▴"; }
tr.row-click { cursor: pointer; } tr.row-click:hover td { background: rgba(255, 255, 255, .03); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.r-new td:first-child, tr.r-overdue td:first-child { box-shadow: inset 3px 0 0 var(--red); }
tr.r-today td:first-child { box-shadow: inset 3px 0 0 var(--amber); } tr.r-nodate td:first-child { box-shadow: inset 3px 0 0 var(--yellow); }
tfoot td { font-weight: 700; background: var(--panel-2); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 140px; padding: 7px 10px; }
.filters input[type=search] { min-width: 220px; }

/* ---------- charts (pure CSS/SVG) ---------- */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 200px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.bar-row .lbl { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .track { height: 14px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.bar-row .fill { height: 100%; background: var(--orange); border-radius: 4px; min-width: 2px; transition: width .4s; }
.bar-row .fill.green { background: var(--green); } .bar-row .fill.blue { background: var(--blue); } .bar-row .fill.red { background: var(--red); } .bar-row .fill.purple { background: var(--purple); } .bar-row .fill.amber { background: var(--amber); }
.bar-row .v { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .bar-row { grid-template-columns: 110px 1fr 50px; } }
.funnel { display: flex; flex-direction: column; gap: 6px; }
.funnel .step { display: grid; grid-template-columns: 170px 1fr 90px; gap: 10px; align-items: center; }
.funnel .step .bar { height: 26px; border-radius: 6px; background: linear-gradient(90deg, var(--orange), #ff8a5c); display: flex; align-items: center; padding-left: 10px; font-weight: 800; color: #000; min-width: 34px; }
.funnel .step .conv { font-size: 12px; color: var(--muted); text-align: right; }
svg.line { width: 100%; height: 160px; display: block; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }
.leader { display: flex; flex-direction: column; gap: 8px; }
.leader .row { display: grid; grid-template-columns: 28px 1fr auto auto auto; gap: 12px; align-items: center; padding: 8px 10px; border-radius: 9px; background: var(--panel-2); }
.leader .rank { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--line-2); font-size: 12px; }
.leader .row:first-child .rank { background: var(--orange); color: #000; }
.leader .stat { text-align: right; font-size: 12px; color: var(--muted); } .leader .stat b { display: block; font-size: 15px; color: var(--text); }
.leader .stat.bad b { color: var(--red); }

/* ---------- drawer / modal ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; display: none; }
.overlay.open { display: block; }
.drawer { position: fixed; top: 0; right: 0; height: 100%; width: min(720px, 100%); background: var(--panel); border-left: 1px solid var(--line); z-index: 60; transform: translateX(100%); transition: transform .2s ease; overflow-y: auto; display: flex; flex-direction: column; }
.drawer.open { transform: translateX(0); }
.drawer-head { position: sticky; top: 0; background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; z-index: 2; }
.drawer-body { padding: 18px; display: flex; flex-direction: column; gap: 18px; }
.drawer-foot { position: sticky; bottom: 0; background: var(--panel); border-top: 1px solid var(--line); padding: 12px 18px; display: flex; gap: 8px; justify-content: flex-end; }
.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 16px; }
.modal.open { display: flex; }
.modal .box { background: var(--panel); border: 1px solid var(--line-2); border-radius: 14px; width: min(640px, 100%); max-height: 92vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal .box-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal .box-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal .box-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.x { background: none; border: 0; color: var(--muted); font-size: 20px; cursor: pointer; line-height: 1; }
.timeline { display: flex; flex-direction: column; gap: 0; border-left: 2px solid var(--line-2); margin-left: 6px; padding-left: 14px; }
.timeline .ev { position: relative; padding: 6px 0 10px; font-size: 13px; }
.timeline .ev::before { content: ""; position: absolute; left: -20px; top: 11px; width: 8px; height: 8px; border-radius: 50%; background: var(--orange); }
.timeline .ev .when { color: var(--dim); font-size: 12px; }
.outcome-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.outcome-grid button { text-align: left; padding: 9px 11px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; font-size: 13px; }
.outcome-grid button.active { border-color: var(--orange); background: var(--orange-soft); }
.outcome-grid button.nc { border-style: dashed; }
@media (max-width: 720px) { .outcome-grid { grid-template-columns: 1fr; } }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #222; border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); opacity: 0; transition: .2s; pointer-events: none; }
.toast.show { opacity: 1; }
.kbd { font-family: ui-monospace, monospace; font-size: 11px; background: var(--panel-2); border: 1px solid var(--line-2); padding: 1px 5px; border-radius: 4px; color: var(--muted); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(800px 400px at 20% 0%, rgba(252, 92, 46, .16), transparent 60%), var(--bg); }
.login-box { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.login-box .brand { font-size: 22px; margin-bottom: 4px; }
.login-box p { color: var(--muted); margin: 0 0 20px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.role-pick button { padding: 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg); cursor: pointer; text-align: left; }
.role-pick button.active { border-color: var(--orange); background: var(--orange-soft); }
.role-pick b { display: block; } .role-pick small { color: var(--muted); }
.err { color: var(--red); font-size: 13px; min-height: 18px; }

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 12px; }
  .topbar, .no-print, .filters, .btn { display: none !important; }
  .card, .tile, .table-wrap { border-color: #ccc; background: #fff; break-inside: avoid; }
  .tile .val { color: #000 !important; } .muted, .dim { color: #555; }
  th { background: #eee; color: #000; } td { border-color: #ddd; }
  .bar-row .track { background: #eee; } .bar-row .fill { background: #FC5C2E !important; }
  .page { max-width: none; padding: 0; }
}
