/* ==========================================================================
   vBizz-Hub OneID / Admin / Portal UI. Same language as the public card
   (card.css): Barlow Condensed headings, Inter body, warm grey ground.
   ========================================================================== */

:root {
    --ink: #141414;
    --ink-2: #2A2A2A;
    --muted: #5E5E5E;
    --bg: #F4F4F2;
    --surface: #FFFFFF;
    --chip: #F4F4F2;
    --line: #ECECEA;
    --border: #D6D6D3;
    --accent: #028482;
    --accent-ink: #FFFFFF;
    --danger: #B42318;
    --danger-bg: #FDECEA;
    --ok: #145C32;
    --ok-bg: #E7F4EC;
    --warn: #6B4100;
    --warn-bg: #FFF4E0;
    --info: #0B4A6F;
    --info-bg: #E6F1F8;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; }
a { color: inherit; }
img { max-width: 100%; display: block; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* --- Wordmark ----------------------------------------------------------- */
.wordmark { font-family: var(--font-display); font-weight: 700; font-size: 24px; letter-spacing: .01em; text-decoration: none; white-space: nowrap; }
.wordmark span { color: var(--accent); }
.wordmark small { font-family: var(--font-body); font-weight: 600; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; margin-left: 8px; opacity: .7; }

/* --- Auth (OneID) ------------------------------------------------------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 48px 16px 32px; }
.auth__card { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius-lg); padding: 32px 28px; display: flex; flex-direction: column; gap: 20px; box-shadow: 0 1px 0 rgba(20,20,20,.04), 0 12px 40px rgba(20,20,20,.06); }
.auth__brand { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-bottom: 24px; }
.auth__brand p { font-size: 13px; color: var(--muted); }
.auth h1 { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.05; }
.auth__links { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 14px; }
.auth__links a, .link { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.auth__foot { margin-top: 24px; font-size: 12px; color: var(--muted); text-align: center; }

/* --- App shell (admin / portal) ----------------------------------------- */
.app { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.sidebar { background: var(--ink); color: #FFFFFF; display: flex; flex-direction: column; }
.sidebar__top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 12px 0 20px; height: 64px; }
.sidebar__burger { cursor: pointer; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: var(--radius-sm); }
.sidebar__burger:hover { background: rgba(255,255,255,.08); }
.nav-toggle:focus-visible + .sidebar__top .sidebar__burger { outline: 3px solid #FFFFFF; outline-offset: 2px; }
.sidebar__nav { display: none; flex-direction: column; gap: 2px; padding: 8px 12px 16px; }
.nav-toggle:checked ~ .sidebar__nav, .nav-toggle:checked ~ .sidebar__user { display: flex; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: #9A9A9A; padding: 16px 12px 6px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: #D6D6D3; font-size: 14px; font-weight: 500; }
.nav-link:hover { background: rgba(255,255,255,.08); color: #FFFFFF; }
.nav-link[aria-current="page"] { background: rgba(255,255,255,.12); color: #FFFFFF; box-shadow: inset 3px 0 0 var(--accent); }
.nav-link svg { flex-shrink: 0; opacity: .9; }
.sidebar__user { margin-top: auto; padding: 16px 20px 20px; border-top: 1px solid rgba(255,255,255,.1); display: none; flex-direction: column; gap: 10px; font-size: 13px; }
.sidebar__user strong { display: block; font-size: 14px; color: #FFFFFF; }
.sidebar__user span { color: #B5B5B5; overflow-wrap: anywhere; }
.sidebar__user .row a, .sidebar__user button { color: #FFFFFF; background: none; border: 0; padding: 0; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }

@media (min-width: 960px) {
    .app { grid-template-columns: 252px minmax(0, 1fr); }
    .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; }
    .sidebar__burger { display: none; }
    .sidebar__nav, .sidebar__user { display: flex; }
}

.main { min-width: 0; padding: 24px 16px 48px; }
@media (min-width: 720px) { .main { padding: 32px 32px 64px; } }
.main__inner { max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--font-display); font-weight: 700; font-size: 34px; line-height: 1.05; }
.page-head p { color: var(--muted); margin-top: 4px; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.crumbs a { color: var(--muted); }

/* --- Panels ------------------------------------------------------------- */
.panel { background: var(--surface); border-radius: var(--radius-lg); padding: 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (min-width: 720px) { .panel { padding: 24px; } }
.panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.panel h2 { font-family: var(--font-display); font-weight: 700; font-size: 24px; line-height: 1.1; }
.panel h3 { font-size: 15px; font-weight: 600; }
.panel--flush { padding: 0; gap: 0; overflow: hidden; }
.panel--flush > .panel__head { padding: 20px 20px 12px; }

.grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid--main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); } }

.stats { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 900px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border-radius: var(--radius-lg); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; }
.stat__value { font-family: var(--font-display); font-weight: 700; font-size: 38px; line-height: 1; }
.stat__label { font-size: 13px; color: var(--muted); }
a.stat:hover { box-shadow: inset 0 0 0 1.5px var(--border); }

.dl { display: grid; grid-template-columns: minmax(110px, 34%) minmax(0, 1fr); gap: 0; }
.dl dt, .dl dd { margin: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.dl dt { color: var(--muted); font-size: 13px; padding-right: 12px; }
.dl dd { overflow-wrap: anywhere; }

/* --- Tables ------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFAF8; }
.table a.strong { font-weight: 600; text-decoration: none; }
.table a.strong:hover { text-decoration: underline; }
.cell-person { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: 15px; flex-shrink: 0; overflow: hidden; background: #E9E4E2; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--lg { width: 96px; height: 96px; font-size: 34px; }
.swatch { width: 16px; height: 16px; border-radius: 4px; display: inline-block; vertical-align: middle; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); }

/* --- Badges ------------------------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 12px; font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--chip); color: var(--ink-2); }
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--info { background: var(--info-bg); color: var(--info); }

/* --- Buttons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--radius-sm); border: 1.5px solid transparent; background: var(--ink); color: #FFFFFF; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--ink-2); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--accent:hover { filter: brightness(.95); background: var(--accent); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--border); }
.btn--ghost:hover { background: var(--chip); }
.btn--danger { background: var(--surface); color: var(--danger); border-color: #F1B8B2; }
.btn--danger:hover { background: var(--danger-bg); }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn--block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline-form { display: inline; margin: 0; }

/* --- Forms -------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: 16px; }
.fields { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .span-2 { grid-column: span 2; } .span-all { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field__label { font-size: 13px; font-weight: 600; }
.field .req { color: var(--danger); }
.help { font-size: 12px; color: var(--muted); }
.error { font-size: 13px; color: var(--danger); }
.input { width: 100%; min-width: 0; min-height: 44px; border-radius: var(--radius-sm); border: 1.5px solid var(--border); background: var(--surface); padding: 0 12px; font-size: 15px; }
textarea.input { min-height: 120px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
textarea.input.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; min-height: 220px; }
select.input { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235E5E5E' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(20,20,20,.12); }
.input[aria-invalid="true"] { border-color: var(--danger); }
input[type="color"].input { padding: 4px; width: 64px; cursor: pointer; }
input[type="file"].input { padding: 9px 12px; }
.color-field { display: flex; gap: 8px; align-items: center; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 44px; padding: 10px 0; cursor: pointer; font-size: 14px; }
.check input { width: 20px; height: 20px; margin: 0; flex-shrink: 0; accent-color: var(--ink); }
.check small { display: block; color: var(--muted); font-size: 12px; }
.checks { display: grid; gap: 0 20px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 720px) { .checks--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding-top: 4px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filters .field { min-width: 160px; flex: 1; }
.filters .field--grow { flex: 3; min-width: 220px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; }

/* --- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.tabs a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; text-decoration: none; font-size: 14px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

/* --- Alerts ------------------------------------------------------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-md); font-size: 14px; font-weight: 500; }
.alert--success { background: var(--ok-bg); color: var(--ok); }
.alert--error { background: var(--danger-bg); color: var(--danger); }
.alert--warning { background: var(--warn-bg); color: var(--warn); }
.alert--info { background: var(--info-bg); color: var(--info); }
.alert a { font-weight: 700; }

/* --- Pagination & empty ------------------------------------------------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.empty { padding: 32px 20px; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* --- Danger zone -------------------------------------------------------- */
.danger-zone { border: 1.5px solid #F1B8B2; }
.danger-zone h2 { color: var(--danger); }

/* --- Lead detail -------------------------------------------------------- */
.lead-section + .lead-section { margin-top: 8px; }
.lead-section h3 { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin-bottom: 4px; }

/* Audit log: field changes (old -> new) */
.changes { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 12px; }
.changes th, .changes td { padding: 4px 8px; border: 1px solid var(--line); text-align: left; vertical-align: top; overflow-wrap: anywhere; }
.changes th { background: var(--chip); font-weight: 600; color: var(--ink-2); }
.changes td:first-child { white-space: nowrap; font-weight: 600; }

/* Banner preview (branding / card media) */
.banner-preview { border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 1; background: var(--chip); }
.banner-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }


/* --- OneID: sidebar badge, notifications, app tiles ---------------------- */
.nav-badge { margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--accent); color: #FFFFFF; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.stat__value--text { font-size: 30px; }
.plain-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }

.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.note { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.note:first-child { border-top: 0; padding-top: 0; }
.note__icon { flex-shrink: 0; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: var(--chip); color: var(--ink-2); }
.note__icon--lead { background: var(--ok-bg); color: var(--ok); }
.note__icon--access { background: var(--info-bg); color: var(--info); }
.note__icon--security { background: var(--warn-bg); color: var(--warn); }
.note__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.note__title { font-size: 14px; font-weight: 500; color: var(--ink-2); overflow-wrap: anywhere; }
.note--unread .note__title { font-weight: 700; color: var(--ink); }
.note__title a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.note__body { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.note__meta { font-size: 12px; color: var(--muted); }
.note__dot { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.note__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 18px; border-radius: var(--radius-md); border: 1.5px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; min-height: 150px; }
a.tile:hover { border-color: var(--ink); }
a.tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.tile__icon { width: 42px; height: 42px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; background: var(--chip); color: var(--ink); }
.tile__name { font-weight: 700; font-size: 15px; overflow-wrap: anywhere; }
.tile__sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.tile__open { margin-top: auto; font-size: 13px; font-weight: 600; }
.tile--soon { background: var(--chip); color: var(--muted); border-style: dashed; }
.tile--soon .tile__icon { background: var(--surface); color: var(--muted); }

/* --- E-mail template editor ---------------------------------------------- */
.email-preview { width: 100%; min-height: 560px; border: 1px solid var(--line); border-radius: var(--radius-md); background: #F4F4F2; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; background: var(--chip); padding: 1px 5px; border-radius: 4px; }
