/* Leadora – leads dashboard (page template). Builds on base.css. */

/* ---------- sign-in / no-access ---------- */

.auth { position: relative; display: grid; place-items: center; align-content: center; gap: 20px; min-height: 100vh; padding: 24px 16px; overflow: hidden; }
.auth__glow { position: absolute; inset: auto; width: 640px; height: 640px; border-radius: 50%; background: radial-gradient(closest-side, rgba(212, 169, 90, 0.18), transparent); filter: blur(10px); pointer-events: none; }
.auth__card {
	position: relative; width: 100%; max-width: 420px; padding: 36px 32px;
	background: color-mix(in srgb, var(--surface) 88%, transparent);
	border: 1px solid var(--border-strong); border-radius: 20px;
	box-shadow: var(--shadow-pop); backdrop-filter: blur(14px);
}
.auth__card h1 { margin-top: 28px; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.auth__lead { margin: 6px 0 24px !important; color: var(--muted); }
.auth__lead code { font-family: var(--mono); color: var(--gold-ink); }
.auth__form { display: grid; gap: 16px; }
.auth__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 13px; }
.auth__row a { color: var(--gold-ink); }
.auth__row a:hover { text-decoration: underline; }
.auth__foot { position: relative; color: var(--faint); font-size: 12px; }

.field { display: grid; gap: 6px; }
.field span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field input {
	height: 46px; padding: 0 14px; width: 100%;
	background: var(--surface-2); color: var(--text);
	border: 1px solid var(--border-strong); border-radius: 12px;
	font: 400 15px var(--font); transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--focus); }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.check input { accent-color: var(--gold); width: 16px; height: 16px; }

.notice { padding: 10px 14px; border-radius: 10px; font-size: 13px; margin-bottom: 16px !important; }
.notice--error { background: rgba(248, 113, 113, 0.12); color: var(--down); border: 1px solid rgba(248, 113, 113, 0.3); }

/* ---------- app shell ---------- */

.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; justify-content: space-between; gap: 16px;
	height: 68px; padding: 0 max(16px, calc((100vw - 1440px) / 2 + 32px));
	background: color-mix(in srgb, var(--bg) 78%, transparent);
	border-bottom: 1px solid var(--border);
	backdrop-filter: blur(14px);
}
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.user { display: flex; align-items: center; gap: 8px; padding-left: 12px; border-left: 1px solid var(--border); }
.user__name { font-weight: 600; font-size: 13px; margin-right: 4px; }


/* Scoped: WordPress also puts a `page` class on <body>. */
.app > .page { max-width: 1440px; margin: 0 auto; padding: 28px 32px 56px; display: grid; gap: 20px; }
.page__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page__head h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.page__head p { margin-top: 2px; }
.page__actions { display: flex; gap: 10px; flex-wrap: wrap; }

.card {
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); box-shadow: var(--shadow);
}
.card__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 18px; }
.card__head h2 { font-size: 15px; font-weight: 600; }
.card__head p { font-size: 12.5px; margin-top: 2px; }

/* ---------- KPIs ---------- */

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.kpi {
	position: relative; overflow: hidden; padding: 18px 20px;
	background: var(--surface); border: 1px solid var(--border);
	border-radius: var(--radius); box-shadow: var(--shadow);
}
.kpi--hero { background: linear-gradient(140deg, color-mix(in srgb, var(--gold) 16%, var(--surface)) 0%, var(--surface) 70%); border-color: rgba(212, 169, 90, 0.35); }
.kpi--hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px; border-radius: 50%; background: radial-gradient(closest-side, rgba(212, 169, 90, 0.25), transparent); }
.kpi__label { font-size: 12.5px; font-weight: 500; color: var(--muted); }
.kpi__value { margin: 6px 0 8px !important; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi--hero .kpi__value { color: var(--gold-ink); }
.kpi__foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }

/* ---------- chart + sources ---------- */

.insights { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 16px; }
.chart,
.sources { padding: 20px; }

.chart__plot { position: relative; height: 200px; margin-left: 28px; }
.chart__grid { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.chart__grid span { position: relative; border-top: 1px dashed var(--border); }
.chart__grid span:last-child { border-top: 1px solid var(--border-strong); }
.chart__grid span::before { content: attr(data-v); position: absolute; right: calc(100% + 8px); top: -8px; font-size: 11px; color: var(--faint); font-variant-numeric: tabular-nums; }
.chart__bars {
	position: absolute; inset: 0; margin: 0; padding: 0; list-style: none;
	display: grid; grid-template-columns: repeat(var(--days), minmax(0, 1fr)); align-items: end; gap: 2px;
}
.chart__col { position: relative; height: 100%; display: flex; align-items: flex-end; justify-content: center; cursor: default; outline-offset: 0 !important; }
.chart__bar { display: block; width: 100%; max-width: 22px; min-height: 0; border-radius: 4px 4px 0 0; background: var(--bar); transition: background-color 0.12s; }
.chart__col:hover .chart__bar,
.chart__col:focus-visible .chart__bar { background: var(--bar-hover); }
.chart__col:hover,
.chart__col:focus-visible { background: var(--gold-soft); border-radius: 6px 6px 0 0; }
.chart__axis { display: flex; justify-content: space-between; margin: 8px 0 0 28px; font-size: 11px; color: var(--faint); }

.chart-tip {
	position: fixed; z-index: 60; pointer-events: none; transform: translate(-50%, calc(-100% - 10px));
	padding: 6px 10px; border-radius: 8px; white-space: nowrap;
	background: var(--text); color: var(--bg); font-size: 12px; font-weight: 600;
	box-shadow: var(--shadow-pop);
}

.sources__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.source {
	display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
	padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; transition: background-color 0.15s, border-color 0.15s;
}
.source:hover { background: var(--surface-hover); }
.source.is-active { border-color: rgba(212, 169, 90, 0.45); background: var(--gold-soft); }
.source__name { font-weight: 600; font-size: 13.5px; }
.source__count { font-weight: 700; font-variant-numeric: tabular-nums; }
.source__count small { margin-left: 4px; font-weight: 500; color: var(--faint); }
.meter { grid-column: 1 / -1; height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 999px; background: var(--bar); }

/* ---------- filters ---------- */

.table-card { overflow: hidden; }
.filters { display: grid; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.filters__row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.search { position: relative; flex: 1 1 320px; display: flex; align-items: center; }
.search svg { position: absolute; left: 13px; color: var(--faint); pointer-events: none; }
.search input,
.select select,
.dates input {
	height: var(--control); width: 100%;
	background: var(--surface-2); color: var(--text);
	border: 1px solid var(--border-strong); border-radius: 10px;
	font: 400 13.5px var(--font); transition: border-color 0.15s, box-shadow 0.15s;
}
.search input { padding: 0 14px 0 40px; }
.search input::placeholder { color: var(--faint); }
.select { flex: 0 1 200px; position: relative; }
.select select { appearance: none; padding: 0 36px 0 14px; cursor: pointer; }
.select::after { content: ""; position: absolute; right: 15px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border: solid var(--muted); border-width: 0 1.6px 1.6px 0; transform: rotate(45deg); pointer-events: none; }
.select select option { background: var(--surface); color: var(--text); }
.search input:focus,
.select select:focus,
.dates input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--focus); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 500; color: var(--muted); cursor: pointer; transition: color 0.15s, background-color 0.15s; }
.chip span:hover { color: var(--text); }
.chip input:checked + span { background: var(--gold-gradient); color: var(--on-gold); font-weight: 600; box-shadow: 0 4px 12px rgba(212, 169, 90, 0.25); }
.chip input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 1px; }

.dates { display: flex; gap: 8px; }
.dates label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dates input { width: auto; padding: 0 10px; height: 36px; }
.link-reset { color: var(--gold-ink) !important; font-size: 13px; font-weight: 500; }
.link-reset:hover { text-decoration: underline; }
.js .filters [type="submit"] { display: none; }
.js .filters .dates:not([hidden]) ~ [type="submit"] { display: inline-flex; }

/* ---------- table ---------- */

.table-meta { padding: 12px 20px; font-size: 12.5px; color: var(--muted); }
.table-meta strong { color: var(--text); font-weight: 600; }
.table-wrap { overflow-x: auto; }

.leads { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.leads th {
	position: sticky; top: 0; padding: 10px 16px; text-align: left; white-space: nowrap;
	background: var(--surface-2); border-block: 1px solid var(--border);
	font-size: 11.5px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; color: var(--faint);
}
.leads th.num,
.leads td.num { text-align: right; font-variant-numeric: tabular-nums; }
.th-sort { display: inline-flex; align-items: center; gap: 5px; }
.th-sort:hover { color: var(--text); }
.th-sort svg { width: 8px; height: 11px; fill: currentColor; stroke: none; opacity: 0.35; }
.th-sort.is-asc,
.th-sort.is-desc { color: var(--gold-ink); }
.th-sort.is-asc svg,
.th-sort.is-desc svg { opacity: 1; }
.th-sort.is-asc svg path:last-child,
.th-sort.is-desc svg path:first-child { opacity: 0.25; }

.leads td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.leads tbody tr { cursor: pointer; transition: background-color 0.12s; }
.leads tbody tr:hover,
.leads tbody tr:focus-visible { background: var(--surface-hover); outline: none; }
.leads tbody tr:hover .person__name { color: var(--gold-ink); }
.leads tbody tr:last-child td { border-bottom: 0; }

.person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.person > span:last-child { display: flex; flex-direction: column; }
.person__name { font-weight: 600; transition: color 0.12s; }
.person__ref { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.contact { display: block; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact:hover { color: var(--gold-ink); }
.contact--phone { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: left; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border-strong); font-size: 12px; font-weight: 500; white-space: nowrap; }
.campaign { display: flex; flex-direction: column; }
.campaign span { text-transform: capitalize; }
.campaign small { color: var(--faint); font-size: 11.5px; }
.leads time { display: flex; flex-direction: column; white-space: nowrap; }
.leads time small { color: var(--faint); font-size: 11.5px; }


.pager { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; padding: 16px 20px; border-top: 1px solid var(--border); }
.pager__btn { min-width: 36px; height: 36px; padding: 0 12px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--border); font-weight: 500; font-size: 13px; font-variant-numeric: tabular-nums; }
a.pager__btn:hover { border-color: var(--gold); color: var(--gold-ink); }
.pager__btn.is-current { background: var(--gold-gradient); border-color: transparent; color: var(--on-gold); font-weight: 700; }
.pager__gap { color: var(--faint); padding: 0 4px; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 56px 20px; text-align: center; }
.empty svg { width: 40px; height: 40px; padding: 8px; border-radius: 12px; color: var(--gold-ink); background: var(--gold-soft); }
.empty h3 { font-size: 16px; margin-top: 6px; }
.empty .btn { margin-top: 8px; }

/* ---------- lead drawer ---------- */

.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer__scrim { position: absolute; inset: 0; background: rgba(4, 9, 22, 0.55); backdrop-filter: blur(3px); animation: fade 0.2s ease; }
.drawer__panel {
	position: absolute; top: 0; right: 0; bottom: 0; width: min(460px, 100%);
	display: flex; flex-direction: column;
	background: var(--surface); border-left: 1px solid var(--border-strong);
	box-shadow: var(--shadow-pop); animation: slide 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.drawer__head { display: flex; align-items: flex-start; gap: 14px; padding: 24px 24px 16px; }
.drawer__head > div { flex: 1; min-width: 0; }
.drawer__head h2 { font-size: 19px; font-weight: 700; overflow-wrap: anywhere; }
.drawer__head p { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.drawer__actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 20px; border-bottom: 1px solid var(--border); }
.drawer__body { flex: 1; overflow-y: auto; padding: 8px 24px 32px; }
.drawer__body section { padding: 16px 0; border-bottom: 1px solid var(--border); }
.drawer__body section:last-child { border-bottom: 0; }
.drawer__body h3 { margin-bottom: 10px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold-ink); }
.drawer__body dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; font-size: 13.5px; }
.drawer__body dt { color: var(--muted); }
.drawer__body dd { margin: 0; overflow-wrap: anywhere; text-align: left; }
.drawer__body dd.small { font-size: 12px; color: var(--muted); }
.drawer__body dd:empty::before { content: "—"; color: var(--faint); }

@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
	.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
	.insights { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
	.topbar { height: 60px; padding: 0 16px; }
	.user__name,
	.brand__text small { display: none; }
	.app > .page { padding: 20px 16px 40px; gap: 16px; }
	.page__head h1 { font-size: 24px; }
	.page__actions { width: 100%; }
	.page__actions .btn { flex: 1; }
	.kpis { gap: 10px; }
	.kpi { padding: 14px; }
	.kpi__value { font-size: 26px; }
	.chart,
	.sources,
	.filters { padding: 16px; }
	.chart__plot { height: 160px; }
	.select { flex: 1 1 140px; }
	.chips { border-radius: 14px; }
	.dates { width: 100%; }
	.dates label { flex: 1; }
	.dates input { width: 100%; }

	/* Table rows become cards. */
	.leads thead { display: none; }
	.leads,
	.leads tbody,
	.leads tr,
	.leads td { display: block; width: 100%; }
	.leads tbody { display: grid; gap: 10px; padding: 0 12px 12px; }
	.leads tr { padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
	.leads td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; border: 0; text-align: right; }
	.leads td::before { content: attr(data-label); flex: none; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--faint); }
	.leads td:first-child { padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
	.leads td:first-child::before { display: none; }
	.leads td.num { text-align: right; }
	.leads td > .contact { max-width: 60%; }
	.leads td:nth-child(2) { flex-wrap: wrap; }
	.leads td:nth-child(2) .contact { flex-basis: 100%; max-width: 100%; text-align: right; }
	.leads td:nth-child(2)::before { flex-basis: 100%; text-align: left; }
	.campaign,
	.leads time { align-items: flex-end; }
	.person { min-width: 0; }
	.person > span:last-child { align-items: flex-start; text-align: left; }
	.drawer__body dl { grid-template-columns: 100px 1fr; }
}

