:root {
    color-scheme: light;
    --ink: #101d32;
    --navy: #092444;
    --navy-deep: #071b33;
    --slate: #526177;
    --muted: #66758a;
    --canvas: #f4f6f8;
    --paper: #fff;
    --line: #dce3eb;
    --line-light: #e9eef3;
    --mint: #dcefe9;
    --mint-ink: #146455;
    --blue: #e6effb;
    --blue-ink: #24598a;
    --amber: #fff1d9;
    --amber-ink: #80521b;
    --rose: #f9e8eb;
    --rose-ink: #933f51;
    --radius: 12px;
    --field-radius: 8px;
    --sidebar-width: 15rem;
    --topbar-height: 4.25rem;
    --body-font: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
    --heading-font: "Segoe UI Variable Display", "Segoe UI", system-ui, sans-serif;
    font-family: var(--body-font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--canvas);
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
::selection { color: var(--navy-deep); background: var(--mint); }
button, input, select, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input, select, textarea { min-width: 0; caret-color: var(--blue-ink); }
img { display: block; max-width: 100%; }
a { color: var(--blue-ink); text-underline-offset: .18em; }
a:hover { color: var(--navy); }
:focus-visible { outline: 3px solid #4b89c5; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--heading-font); line-height: 1.2; }
h1 { font-size: clamp(1.75rem, 2.3vw + .5rem, 2.6rem); letter-spacing: -.035em; font-weight: 730; }
h2 { font-size: 1.175rem; letter-spacing: -.025em; font-weight: 700; }
h3 { font-size: .97rem; font-weight: 680; }
small { font-size: .79rem; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { width: 1.1rem; height: 1.1rem; flex: 0 0 auto; vertical-align: middle; }
.text-link { font-weight: 680; text-decoration-thickness: 1px; overflow-wrap: anywhere; }
.back-link { display: inline-flex; align-items: center; gap: .28rem; margin-bottom: .85rem; font-size: .82rem; font-weight: 680; text-decoration: none; }
.back-link:hover { text-decoration: underline; }
.nav-heading {
    color: var(--muted);
    font-size: .68rem;
    line-height: 1.4;
    font-weight: 730;
    letter-spacing: .13em;
    text-transform: uppercase;
}

.loading {
    display: grid;
    min-height: 100vh;
    min-height: 100dvh;
    place-content: center;
    padding: 1.5rem;
    text-align: center;
}
.availability-card { display: grid; max-width: 34rem; justify-items: start; gap: .92rem; text-align: left; }
.availability-card p { color: var(--slate); }

.button, .icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .52rem;
    min-height: 2.5rem;
    border: 1px solid transparent;
    border-radius: var(--field-radius);
    font-size: .875rem;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    white-space: nowrap;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}
.button { padding: .57rem .82rem; }
.button-primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.button-primary:hover { background: #173c63; border-color: #173c63; color: #fff; }
.button-outline { background: var(--paper); color: var(--navy); border-color: #cbd6e2; }
.button-outline:hover { background: #eef4f8; border-color: #adc0d3; color: var(--navy); }
.button-quiet, .icon-button { background: transparent; color: var(--slate); }
.button-quiet:hover, .icon-button:hover { background: #eaf0f5; color: var(--navy); }
.icon-button { width: 2.5rem; padding: 0; }
.button-danger { color: var(--rose-ink); border-color: #ebc8d0; background: #fff; }
.button-danger:hover { color: #732b3b; background: var(--rose); }
.button-destructive { color: #fff; border-color: #943a4d; background: #943a4d; }
.button-destructive:hover { color: #fff; border-color: #782b3d; background: #782b3d; }

.brand { display: flex; align-items: center; gap: .7rem; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark {
    display: grid;
    width: 2.85rem;
    height: 2.85rem;
    place-items: center;
    flex: 0 0 auto;
    background: #fff;
    object-fit: contain;
    overflow: hidden;
    border-radius: 50%;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-copy { display: grid; gap: .13rem; min-width: 0; line-height: 1.18; }
.brand-copy strong { font-size: .96rem; font-weight: 730; }
.brand-copy small, .brand-copy span { font-size: .7rem; color: var(--muted); }

.auth-layout {
    min-height: 100vh;
    min-height: 100svh;
    display: grid;
    place-items: center;
    padding: max(1.5rem, env(safe-area-inset-top)) max(1.5rem, env(safe-area-inset-right))
        max(1.5rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
}
.auth-surface {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
    width: min(100%, 60rem);
    min-height: 30rem;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 16px;
}
.auth-intro {
    display: grid;
    align-content: center;
    background: var(--navy);
    color: #fff;
    padding: clamp(1.6rem, 5vw, 3.6rem);
    border-start-end-radius: 15px;
    border-end-end-radius: 15px;
}
.auth-intro-content { display: grid; gap: 1rem; }
.auth-intro h2 {
    max-width: 17ch;
    font-size: clamp(1.85rem, 3.85vw, 3.1rem);
    line-height: 1.08;
    letter-spacing: -.035em;
    text-wrap: balance;
}
.auth-intro p { max-width: 33ch; color: #c5dbed; font-size: .99rem; }
.auth-main { display: grid; place-items: center; min-width: 0; padding: clamp(1.45rem, 4.25vw, 3.75rem); }
.auth-card { display: grid; width: min(100%, 23rem); gap: 1.45rem; }
.auth-card .brand-mark { width: 3.6rem; height: 3.6rem; border: 1px solid var(--line-light); }
.auth-card .brand-copy strong { font-size: 1.02rem; }
.auth-card .brand-copy small { font-size: .8rem; }
.auth-heading { display: grid; gap: .38rem; }
.auth-heading h1 { font-size: clamp(1.65rem, 3vw, 2.25rem); }
.auth-heading p { max-width: 40ch; color: var(--slate); font-size: .94rem; }
.auth-card form { display: grid; gap: .88rem; }
.auth-card form .field { font-size: .88rem; }
.auth-card form :is(input, select) { min-height: 3rem; font-size: 1rem; }
.auth-card .button-primary { min-height: 3rem; margin-top: .18rem; }
.auth-error { color: var(--rose-ink); font-size: .9rem; overflow-wrap: anywhere; }

.app-shell { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; min-height: 100dvh; }
.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    align-self: start;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    z-index: 12;
    color: #fff;
    background: var(--navy-deep);
}
.sidebar-header { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 5.4rem; padding: 1rem 1.15rem; border-bottom: 1px solid #ffffff18; }
.sidebar .brand:hover { color: #fff; }
.sidebar .brand-copy small, .sidebar .brand-copy span { color: #a8bfd5; }
.sidebar-nav { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 1.12rem .75rem; scrollbar-width: thin; scrollbar-color: #36516c transparent; }
.nav-group { display: grid; gap: .26rem; }
.nav-group + .nav-group { margin-top: 1.5rem; }
.nav-heading { padding: 0 .58rem .37rem; color: #a1b7cc; }
.nav-link {
    display: flex;
    width: 100%;
    align-items: center;
    gap: .7rem;
    min-height: 2.65rem;
    padding: .55rem .58rem;
    border: 1px solid transparent;
    border-inline-start: 1px solid transparent;
    border-radius: 7px;
    color: #c7d7e7;
    background: transparent;
    text-decoration: none;
    text-align: left;
    font-size: .875rem;
    transition: background .16s ease, color .16s ease;
}
.nav-link:hover { color: #fff; background: #ffffff12; }
.nav-link[aria-current="page"], .nav-link.is-active, .nav-link.active { color: #fff; background: #1a3755; border-inline-start-color: #92d4c2; font-weight: 690; }
.nav-link .icon { color: #a9c2db; }
.nav-link[aria-current="page"] .icon, .nav-link.is-active .icon, .nav-link.active .icon { color: #a3dfce; }
.sidebar :focus-visible { outline-color: #a3dfce; }
.sidebar-footer { display: grid; gap: .5rem; padding: .75rem .75rem 1rem; border-top: 1px solid #ffffff18; }
.main-shell { min-width: 0; }
.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    min-height: var(--topbar-height);
    --topbar-inline: clamp(1rem, 2.55vw, 2.8rem);
    padding: max(.55rem, env(safe-area-inset-top)) max(var(--topbar-inline), env(safe-area-inset-right))
        .55rem max(var(--topbar-inline), env(safe-area-inset-left));
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.topbar-title { display: flex; align-items: center; min-width: 0; gap: .55rem; color: var(--slate); font-weight: 650; font-size: .86rem; }
.topbar-actions, .topbar-user { display: flex; gap: .65rem; align-items: center; min-width: 0; }
.topbar-user {
    border: 0;
    border-radius: var(--field-radius);
    padding: .24rem .34rem;
    color: var(--ink);
    background: transparent;
    font-size: .84rem;
    text-align: left;
}
button.topbar-user:hover { background: var(--canvas); }
.topbar-user :is(strong, small) { display: block; }
.topbar-user small { font-size: .7rem; color: var(--muted); }
.topbar-user-copy { min-width: 0; }
.topbar-user-copy strong { max-width: 25ch; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.avatar { display: inline-grid; width: 2.15rem; height: 2.15rem; place-items: center; flex: 0 0 auto; border-radius: 50%; background: var(--blue); color: var(--navy); font-size: .75rem; font-weight: 750; }
.mobile-toggle, .mobile-overlay, .sidebar-dismiss { display: none; }

.content {
    --content-space: clamp(1rem, 2.55vw, 2.8rem);
    max-width: 105rem;
    margin-inline: auto;
    padding: var(--content-space) max(var(--content-space), env(safe-area-inset-right))
        max(var(--content-space), env(safe-area-inset-bottom)) max(var(--content-space), env(safe-area-inset-left));
}
.page-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.4rem; }
.page-header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.page-header h1 + p { color: var(--slate); margin-top: .45rem; font-size: .93rem; }
.page-actions, .inline-actions { display: flex; flex-wrap: wrap; gap: .45rem; align-items: center; }
.page-actions { flex: 0 0 auto; justify-content: flex-end; }

.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 11.25rem), 1fr)); gap: .8rem; margin-bottom: 1.08rem; }
.metric { display: grid; min-width: 0; gap: .2rem; align-content: start; padding: .95rem 1rem 1.02rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.metric-top { display: flex; justify-content: space-between; align-items: center; gap: .35rem; margin-bottom: .35rem; }
.metric-label { color: var(--slate); font-size: .82rem; font-weight: 640; }
.metric-value { font-family: var(--heading-font); font-size: clamp(1.18rem, 1.2vw + .65rem, 2rem); line-height: 1.22; font-weight: 740; letter-spacing: -.035em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-note { color: var(--muted); font-size: .74rem; }
.metric-icon { display: inline-grid; width: 2rem; height: 2rem; flex: 0 0 auto; place-items: center; color: var(--blue-ink); border-radius: 7px; background: var(--blue); }
.metric[data-tone="mint"] .metric-icon { color: var(--mint-ink); background: var(--mint); }
.metric[data-tone="amber"] .metric-icon { color: var(--amber-ink); background: var(--amber); }
.metric[data-tone="rose"] .metric-icon { color: var(--rose-ink); background: var(--rose); }

.panel { min-width: 0; padding: 1.12rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); }
.panel + .panel { margin-top: 1rem; }
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: .9rem; margin-bottom: .95rem; }
.panel-header p, .panel-subtitle { margin-top: .25rem; color: var(--muted); font-size: .82rem; }
.panel-title { color: var(--ink); }
.dashboard-grid, .record-grid { display: grid; gap: 1rem; align-items: start; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); margin-top: 1rem; }
:is(.dashboard-grid, .record-grid) > .panel { margin: 0; }
.dashboard-grid > .span-full, .record-grid > .span-full { grid-column: 1 / -1; }
.record-grid + .panel { margin-top: 1rem; }
.summary-list { display: grid; margin: 0; padding: 0; list-style: none; }
.summary-list li { display: flex; justify-content: space-between; align-items: center; gap: .65rem; padding: .67rem 0; border-top: 1px solid var(--line-light); }
.summary-list li:first-child { border-top: 0; padding-top: .2rem; }
.summary-list li:last-child { padding-bottom: .2rem; }
.summary-list li div { min-width: 0; overflow-wrap: anywhere; }
.summary-list small { display: block; margin-top: .15rem; color: var(--muted); }
.summary-list .status-pill { flex: 0 0 auto; }

.journey-strip {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(5.75rem, 1fr);
    gap: .4rem;
    margin: 0;
    padding: 3px 3px .35rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    scrollbar-color: #a7b7c8 #ebeff4;
    list-style: none;
}
.journey-step {
    --step-tone: #8fa9c0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-content: start;
    gap: .45rem;
    min-width: 0;
    padding: .72rem .55rem .65rem;
    background: #f5f8fb;
    border: 0;
    border-top: 1px solid var(--step-tone);
    border-radius: 6px;
    color: var(--ink);
    text-align: left;
    text-decoration: none;
}
.journey-step:is(a, button):hover { background: var(--blue); }
.journey-step[data-stage="qualificacao"], .journey-step:nth-child(2) { --step-tone: #658baa; }
.journey-step[data-stage="cotacao"], .journey-step:nth-child(3) { --step-tone: #4c719c; }
.journey-step[data-stage="proposta"], .journey-step:nth-child(4) { --step-tone: #526da5; }
.journey-step[data-stage="implantacao"], .journey-step:nth-child(5) { --step-tone: #518d89; }
.journey-step[data-stage="ativo"], .journey-step:nth-child(6) { --step-tone: #368d78; }
.journey-step[data-stage="perdido"], .journey-step:nth-child(7) { --step-tone: #ac6775; }
.stage-name, .journey-step > span { color: var(--slate); font-size: .76rem; font-weight: 650; overflow-wrap: anywhere; }
.journey-step > span { grid-column: 1 / -1; }
.journey-step .icon { width: .95rem; height: .95rem; color: var(--blue-ink); align-self: end; }
.stage-count, .journey-step strong { font-family: var(--heading-font); font-size: 1.24rem; line-height: 1; font-weight: 750; font-variant-numeric: tabular-nums; }

.toolbar { display: flex; flex-wrap: wrap; align-items: end; gap: .68rem; margin-bottom: 1rem; }
.toolbar .field { flex: 0 1 auto; }
.toolbar .field:has(input[type="search"]) { flex: 1 1 12rem; }
.toolbar .field > * { max-width: 100%; }
.operator-form .toolbar { margin-bottom: 0; }
.operator-form .field { flex: 0 1 25rem; }
.operator-form .notice { margin-top: .65rem; }
.toolbar .pipeline-stage-picker { display: none; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: .85rem; }
.span-full { grid-column: 1 / -1; }
.field, .form-grid > label, .auth-card form > label {
    display: grid;
    min-width: 0;
    gap: .33rem;
    color: var(--slate);
    font-size: .82rem;
    font-weight: 640;
}
.field :is(small, .muted) { font-weight: 400; }
:is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="hidden"]) {
    width: 100%;
    min-height: 2.5rem;
    padding: .52rem .64rem;
    border: 1px solid #cbd6e2;
    border-radius: var(--field-radius);
    color: var(--ink);
    background-color: var(--paper);
    font-size: .875rem;
    font-weight: 400;
    line-height: 1.35;
}
:is(input, textarea)::placeholder { color: #65758a; opacity: 1; }
:is(input, select, textarea):disabled { color: var(--muted); opacity: 1; background: var(--canvas); }
input:is([type="checkbox"], [type="radio"]) { width: 1rem; height: 1rem; margin: 0; accent-color: var(--navy); }
textarea { min-height: 5rem; resize: vertical; }
.field-inline { display: flex; align-items: center; gap: .55rem; color: var(--slate); font-size: .86rem; }

.status-pill {
    --pill-background: #edf1f5;
    --pill-color: #4c5c70;
    display: inline-flex;
    align-items: center;
    gap: .32rem;
    width: fit-content;
    max-width: 100%;
    padding: .22rem .51rem;
    color: var(--pill-color);
    background: var(--pill-background);
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 690;
    line-height: 1.2;
    overflow-wrap: anywhere;
}
.status-pill[data-tone="mint"], .status-pill.mint { --pill-background: var(--mint); --pill-color: var(--mint-ink); }
.status-pill[data-tone="blue"], .status-pill.blue { --pill-background: var(--blue); --pill-color: var(--blue-ink); }
.status-pill[data-tone="amber"], .status-pill.amber { --pill-background: var(--amber); --pill-color: var(--amber-ink); }
.status-pill[data-tone="rose"], .status-pill.rose { --pill-background: var(--rose); --pill-color: var(--rose-ink); }
.table-wrap { max-width: 100%; overflow-x: auto; }
.data-table { width: 100%; border-spacing: 0; text-align: left; font-size: .86rem; }
.data-table th { color: var(--slate); background: #f4f7fa; font-size: .73rem; font-weight: 720; white-space: nowrap; }
.data-table :is(th, td) { padding: .63rem .72rem; border-bottom: 1px solid var(--line-light); vertical-align: middle; }
.data-table th:first-child { border-radius: 7px 0 0; }
.data-table th:last-child { border-radius: 0 7px 0 0; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #f8fafc; }
.data-table :is(td.number, th.number) { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table td small { display: block; margin-top: .15rem; color: var(--muted); }
.data-table td .inline-actions { flex-wrap: nowrap; }
.data-table td .button { min-height: 2.15rem; }
.mobile-cell-label { display: none; }

.empty-state { display: grid; justify-items: start; gap: .38rem; color: var(--muted); padding: 1.05rem; border: 1px dashed #ccd7e3; border-radius: 8px; background: #f8fafc; font-size: .85rem; }
.empty-state strong { color: var(--navy); font-weight: 680; }
.empty-state .button { margin-top: .23rem; }
.notice { padding: .65rem .8rem; border: 1px solid #ccdae9; border-radius: 8px; background: #eef4fb; color: var(--blue-ink); font-size: .86rem; overflow-wrap: anywhere; }
.content > .notice { margin-bottom: 1rem; }
.notice.error, .notice[data-tone="rose"] { border-color: #eacbd1; background: var(--rose); color: var(--rose-ink); }
.notice.success, .notice[data-tone="mint"] { border-color: #bfded3; background: var(--mint); color: var(--mint-ink); }

.kanban {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(12rem, 1fr);
    align-items: start;
    gap: .65rem;
    max-width: 100%;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline proximity;
    padding: 2px 2px .62rem;
    scrollbar-width: thin;
    scrollbar-color: #a7b7c8 #ebeff4;
}
.kanban-column {
    --column-accent: #8fa9c0;
    min-width: 0;
    min-height: 13rem;
    padding: .55rem;
    background: #eaf0f5;
    border: 1px solid #dce5ee;
    border-top: 1px solid var(--column-accent);
    border-radius: 9px;
    scroll-snap-align: start;
}
.kanban-column:nth-child(2) { --column-accent: #658baa; }
.kanban-column:nth-child(3) { --column-accent: #4c719c; }
.kanban-column:nth-child(4) { --column-accent: #526da5; }
.kanban-column:nth-child(5) { --column-accent: #518d89; }
.kanban-column.is-drop-target { border-color: #428a79; background: var(--mint); }
.kanban-heading { display: flex; justify-content: space-between; align-items: center; gap: .35rem; padding: .11rem .14rem .62rem; }
.kanban-heading :is(h2, h3, .stage-name) { color: var(--ink); font-size: .84rem; font-weight: 730; }
.kanban-heading .stage-count { border-radius: 999px; background: #d9e4ee; color: #344c64; padding: .21rem .42rem; font-size: .72rem; }
.kanban-cards { display: grid; align-content: start; gap: .5rem; }
.kanban-cards .empty-state { padding: .64rem; background: #ffffff57; }
.empty-column { padding: .7rem .35rem; color: var(--muted); font-size: .75rem; text-align: center; }
.lead-card { display: grid; min-width: 0; gap: .45rem; padding: .72rem; border: 1px solid #d3dfe9; border-radius: 8px; background: #fff; box-shadow: 0 1px 2px #122d4e0b; }
.lead-card:hover { border-color: #aabfd1; }
.lead-card[draggable="true"] { cursor: grab; }
.lead-card[draggable="true"]:active { cursor: grabbing; }
.lead-card.is-dragging, .lead-card.dragging { opacity: .58; }
.lead-name { color: var(--navy); font-size: .91rem; font-weight: 720; overflow-wrap: anywhere; }
.lead-name .text-link { color: inherit; text-decoration: none; }
.lead-name .text-link:hover { text-decoration: underline; }
button.lead-name { border: 0; padding: 0; background: transparent; text-align: left; }
button.lead-name:hover { text-decoration: underline; text-underline-offset: .2em; }
.lead-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .32rem; color: var(--muted); font-size: .75rem; }
.lead-actions { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .3rem; padding-top: .43rem; border-top: 1px solid var(--line-light); }
.lead-actions :is(.button, .icon-button) { min-height: 1.85rem; font-size: .73rem; }
.lead-actions .icon-button { width: 1.85rem; }
.lead-actions .icon { width: .92rem; height: .92rem; }
.lead-card p { color: var(--slate); font-size: .8rem; overflow-wrap: anywhere; }
.lead-card p.lead-value { color: var(--navy); font-weight: 720; font-variant-numeric: tabular-nums; }
.lead-value small, .lead-actions > .muted { color: var(--muted); font-size: .72rem; font-weight: 400; overflow-wrap: anywhere; }
.lead-meta .icon { width: .86rem; height: .86rem; }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 8rem), 1fr)); gap: .88rem; margin: 0; }
.detail-grid dt { color: var(--muted); font-size: .76rem; }
.detail-grid dd { margin: .18rem 0 0; color: var(--ink); font-size: .88rem; font-weight: 620; overflow-wrap: anywhere; }
.record-notes { margin-top: 1rem; padding-top: .86rem; border-top: 1px solid var(--line-light); }
.record-notes p { margin-top: .3rem; color: var(--slate); font-size: .86rem; overflow-wrap: anywhere; white-space: pre-wrap; }
.record-tasks { margin-top: 1rem; }

.timeline { display: grid; margin: 0; padding: 0; list-style: none; }
.timeline-item { position: relative; display: grid; gap: .15rem; min-width: 0; margin-inline-start: .3rem; padding: 0 0 .95rem .88rem; border-inline-start: 1px solid #cbd8e4; overflow-wrap: anywhere; }
.timeline-item::before { position: absolute; inset-block-start: .32rem; inset-inline-start: -.24rem; width: .42rem; height: .42rem; border-radius: 50%; background: var(--blue-ink); content: ""; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item small { color: var(--muted); }
.timeline-item p { color: var(--slate); font-size: .85rem; white-space: pre-wrap; }

.dialog {
    position: fixed;
    --dialog-inset-inline: max(1rem, env(safe-area-inset-left), env(safe-area-inset-right));
    --dialog-inset-block: max(1rem, env(safe-area-inset-top), env(safe-area-inset-bottom));
    width: min(calc(100% - 2 * var(--dialog-inset-inline)), 44rem);
    max-width: 100%;
    max-height: calc(100vh - 2 * var(--dialog-inset-block));
    max-height: calc(100dvh - 2 * var(--dialog-inset-block));
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--paper);
    color: var(--ink);
    overflow-wrap: anywhere;
}
.dialog::backdrop { background: #071b337a; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; gap: .8rem; padding: .85rem 1.15rem; border-bottom: 1px solid var(--line-light); }
.dialog-header > div { min-width: 0; overflow-wrap: anywhere; }
.dialog-header > .icon-button { flex: 0 0 auto; }
.dialog-header p { color: var(--muted); font-size: .82rem; margin-top: .22rem; }
.dialog-body { display: grid; gap: .9rem; padding: 1.1rem 1.15rem; }
.dialog-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: .5rem; padding: .8rem 1.15rem; border-top: 1px solid var(--line-light); background: #f9fbfc; }
.dialog .notice { width: 100%; }

@media (max-width: 900px) {
    body:has(.app-shell.menu-open) { overflow: hidden; }
    .app-shell { display: block; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(18rem, calc(100% - 2.5rem));
        visibility: hidden;
        transform: translateX(-100%);
        transition: transform .2s ease-out, visibility .2s;
    }
    .app-shell.menu-open .sidebar { visibility: visible; transform: translateX(0); }
    .sidebar-header { padding-block-start: max(.7rem, env(safe-area-inset-top)); }
    .sidebar :is(.sidebar-header, .sidebar-nav, .sidebar-footer) { padding-inline-start: max(1rem, env(safe-area-inset-left)); }
    .sidebar-nav { overscroll-behavior: contain; }
    .sidebar-footer { padding-block-end: max(1rem, env(safe-area-inset-bottom)); }
    .sidebar-dismiss { display: inline-flex; flex: 0 0 auto; color: #c7d7e7; }
    .sidebar-dismiss:hover { color: #fff; background: #ffffff12; }
    .mobile-toggle { display: inline-flex; flex: 0 0 auto; }
    .mobile-overlay { position: fixed; z-index: 11; inset: 0; width: 100%; padding: 0; border: 0; background: #071b337a; }
    .menu-open .mobile-overlay { display: block; }
    .topbar-title { margin-inline-end: auto; }
}

@media (max-width: 760px) {
    .page-header { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: .75rem; margin-bottom: 1rem; }
    .page-actions { justify-content: flex-start; }
}

@media (max-width: 660px) {
    .auth-layout {
        padding-inline: max(1.15rem, env(safe-area-inset-left)) max(1.15rem, env(safe-area-inset-right));
        background: var(--paper);
    }
    .auth-surface { grid-template-columns: minmax(0, 1fr); min-height: 0; border: 0; }
    .auth-intro { display: none; }
    .auth-main { padding: 0; }
    .auth-card { gap: 1.25rem; }
    .auth-heading h1 { font-size: clamp(1.65rem, 6vw, 2rem); }
    .content {
        --content-space: .8rem;
        padding-block-start: 1rem;
        padding-block-end: max(1.6rem, env(safe-area-inset-bottom));
    }
    .topbar { --topbar-inline: .6rem; gap: .36rem; min-height: 3.65rem; }
    .topbar-actions { gap: .28rem; }
    .topbar-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .topbar-user { justify-content: flex-end; padding: .2rem .35rem; }
    .topbar-user small { display: none; }
    .topbar-user-copy strong { max-width: clamp(6ch, 20vw, 16ch); }
    .metrics-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 9.5rem), 1fr)); gap: .55rem; }
    .metric { padding: .72rem; }
    .panel { padding: .8rem; }
    .dashboard-grid, .record-grid { grid-template-columns: 1fr; gap: .7rem; }
    .panel-header { flex-wrap: wrap; }
    .toolbar .field { flex: 1 1 8rem; }
    .toolbar .pipeline-stage-picker { display: grid; min-width: 0; flex: 1 1 10rem; }
    .operator-form .field { flex-basis: 14rem; }
    .journey-strip {
        grid-auto-flow: row;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 7.25rem), 1fr));
        overflow: visible;
    }
    .kanban {
        grid-auto-flow: row;
        grid-template-columns: minmax(0, 1fr);
        grid-auto-columns: auto;
        overflow: visible;
        scroll-snap-type: none;
    }
    .kanban-column[data-mobile-current="false"] { display: none; }
    .kanban-column { min-height: 0; }
    .lead-card[draggable="true"], .lead-card[draggable="true"]:active { cursor: auto; }

    .table-wrap:has(> .responsive-table) { overflow: visible; }
    .responsive-table, .responsive-table :is(tbody, tr) { display: grid; }
    .responsive-table { font-size: .9rem; }
    .responsive-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }
    .responsive-table tbody tr { gap: .34rem; padding-block: .7rem; border-bottom: 1px solid var(--line); }
    .responsive-table tbody tr:first-child { padding-block-start: .18rem; }
    .responsive-table tbody tr:last-child { padding-block-end: .18rem; border-bottom: 0; }
    .responsive-table tbody tr:hover { background: transparent; }
    .responsive-table tbody td {
        display: grid;
        grid-template-columns: minmax(0, 5.6rem) minmax(0, 1fr);
        align-items: start;
        gap: .6rem;
        min-width: 0;
        padding: .12rem .08rem;
        border: 0;
        overflow-wrap: anywhere;
        text-align: left;
        white-space: normal;
    }
    .responsive-table tbody td[colspan] { display: block; }
    .responsive-table .mobile-cell-label { display: block; color: var(--slate); font-size: .79rem; font-weight: 650; }
    .responsive-table .mobile-cell-value { min-width: 0; }
    .responsive-table td .inline-actions { flex-wrap: wrap; }
    .responsive-table .mobile-actions-cell { display: block; }
    .responsive-table .mobile-actions-cell .mobile-cell-label { display: none; }
}

@media (max-width: 480px) {
    .toolbar:has(input[type="month"]) .field { flex-basis: 11rem; }
    .topbar-user-copy { display: none; }
    .form-grid { grid-template-columns: 1fr; }
    .dialog {
        --dialog-inset-inline: max(.5rem, env(safe-area-inset-left), env(safe-area-inset-right));
        --dialog-inset-block: max(.5rem, env(safe-area-inset-top), env(safe-area-inset-bottom));
    }
    .dialog-header, .dialog-body, .dialog-actions { padding-inline: .8rem; }
    .dialog-actions > .button { flex: 1 1 auto; }
}

@media (max-width: 660px), (pointer: coarse) {
    .button, .icon-button, .nav-link, .topbar-user, .back-link,
    .data-table td .button, .lead-actions :is(.button, .icon-button) { min-height: 2.75rem; }
    .icon-button, .topbar-user, .lead-actions .icon-button { min-width: 2.75rem; }
    :is(.data-table, .lead-name, .summary-list) .text-link { display: inline-flex; align-items: center; min-height: 2.75rem; }
    :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="hidden"]) { min-height: 2.75rem; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
