/* Shell base styles. Consumes tokens.css — no raw colour literals here. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    color: var(--text-strong);
    background: var(--brand-surface);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

a {
    color: var(--brand-secondary-600);
}

/* Visible keyboard-focus ring (a11y) — AA-contrast orange, shown only for keyboard
   nav so it never competes with mouse use. */
a:focus-visible,
button:focus-visible,
.btn:focus-visible,
select:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--brand-secondary-600);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ---- Top bar -------------------------------------------------------- */
.app-bar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-8);
    background: var(--brand-surface);
    border-bottom: 1px solid var(--border);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--brand-primary);
    font-size: 18px;
}

.wordmark__glyph {
    width: 26px;
    height: 26px;
    border-radius: 7px;
    background: var(--brand-secondary);
    display: inline-block;
    transform: rotate(8deg);
    box-shadow: var(--shadow-sm);
}

/* DealerIQ logo lockup (icon + wordmark). Sized by height; width auto keeps the
   1027×280 aspect ratio. Orange on light surfaces (app-bar, login). */
.wordmark__img {
    display: block;
    height: 30px;
    width: auto;
}

.app-bar__spacer {
    flex: 1;
}

/* ---- Application shell (sidebar + topbar) --------------------------- */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 224px;
    flex-shrink: 0;
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    padding: var(--space-6) var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-7);
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar__brand {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--brand-on-primary);
    font-weight: 700;
    font-size: 16px;
    letter-spacing: -0.01em;
    text-decoration: none;
    padding: 0 var(--space-2);
}

/* White DealerIQ logo on the deep-indigo sidebar. */
.sidebar__logo {
    display: block;
    height: 28px;
    width: auto;
    max-width: 100%;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.sidebar__link {
    display: block;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 14px;
}

.sidebar__section {
    display: block;
    padding: var(--space-4) var(--space-3) var(--space-1);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
}

.sidebar__link:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar__link.is-active {
    background: var(--brand-secondary);
    color: var(--brand-on-secondary);
}

.app__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-8);
    border-bottom: 1px solid var(--border);
    background: var(--brand-surface);
    position: sticky;
    top: 0;
    z-index: 5;
    min-height: 56px;
}

.topbar__title {
    font-weight: 700;
    color: var(--text-strong);
}

.topbar__spacer {
    flex: 1;
}

.topbar__brand {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.topbar .logout-form,
.topbar .brand-switch {
    margin: 0;
}

.content {
    padding: var(--space-8);
    width: 100%;
    max-width: 1120px;
}

.crumb {
    margin: 0 0 var(--space-3);
    font-size: 13px;
}

.crumb a {
    color: var(--text-muted);
    text-decoration: none;
}

.crumb a:hover {
    color: var(--brand-secondary-600);
}

/* On narrow screens the sidebar collapses to a top strip. */
@media (max-width: 720px) {
    .app {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        align-items: center;
        gap: var(--space-4);
        padding: var(--space-3) var(--space-4);
    }
    .sidebar__brand {
        flex-shrink: 0;
    }
    /* Scroll the nav horizontally instead of wrapping links onto a second line;
       hide the scrollbar (swipe still works) so the strip stays clean. */
    .sidebar__nav {
        flex-direction: row;
        flex-wrap: nowrap;
        gap: var(--space-2);
        overflow-x: auto;
        scrollbar-width: none;
    }
    .sidebar__nav::-webkit-scrollbar {
        display: none;
    }
    /* Let the topbar wrap so the brand switch + sign-out drop to a second row
       cleanly rather than cramming (and breaking "Sign out" mid-word). */
    .topbar {
        flex-wrap: wrap;
        row-gap: var(--space-2);
        padding-left: var(--space-4);
        padding-right: var(--space-4);
    }
}

.tag-pill {
    font-size: 12px;
    font-weight: 600;
    color: var(--brand-primary-300);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    padding: var(--space-1) var(--space-3);
    border-radius: 999px;
}

/* ---- Hero ----------------------------------------------------------- */
.hero {
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
    background:
        radial-gradient(1200px 600px at 70% -10%, var(--brand-primary-700), transparent 60%),
        linear-gradient(160deg, var(--brand-primary) 0%, var(--brand-primary-700) 100%);
    color: var(--brand-on-primary);
    padding: var(--space-16) var(--space-8);
}

.hero__card {
    width: 100%;
    max-width: 560px;
    text-align: center;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 12px;
    font-weight: 700;
    color: var(--brand-secondary);
    margin: 0 0 var(--space-4);
}

.hero h1 {
    font-size: clamp(32px, 5vw, 52px);
    line-height: 1.08;
    margin: 0 0 var(--space-4);
    letter-spacing: -0.02em;
}

.hero h1 .accent {
    color: var(--brand-secondary);
}

.hero p {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.82);
    margin: 0 auto var(--space-8);
    max-width: 44ch;
}

/* ---- Buttons -------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font: inherit;
    font-weight: 700;
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-6);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.06s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn:active {
    transform: translateY(1px);
}

/* A disabled button (e.g. the erase gate before the name is typed) must read as
   inert — dimmed, no shadow, not-allowed cursor. */
.btn:disabled,
.btn:disabled:hover {
    opacity: 0.6;
    box-shadow: none;
    cursor: not-allowed;
}

.btn:disabled:active {
    transform: none;
}

/* A disabled primary reads as a neutral chip rather than a faded orange ghost. */
.btn--primary:disabled,
.btn--primary:disabled:hover {
    background: var(--border-strong);
    color: var(--text-muted);
    opacity: 1;
}

/* Orange fill, INDIGO label (AA-safe) — never white-on-orange for text. Rests on a
   soft shadow, lifts on hover. */
.btn--primary {
    background: var(--brand-secondary);
    color: var(--brand-on-secondary);
    box-shadow: var(--shadow-sm);
}

.btn--primary:hover {
    background: #ff7a26;
    box-shadow: var(--shadow-md);
}

/* Default ghost = for LIGHT surfaces (the app-bar + every page body): dark indigo
   text on a visible border. White-on-white here was making edit/add/remove controls
   invisible. The dark hero re-lightens it below. */
.btn--ghost {
    background: transparent;
    color: var(--brand-primary);
    border-color: var(--border-strong);
}

.btn--ghost:hover {
    background: var(--surface-subtle);
}

/* Ghost button for low-stakes destructive actions (Delete note): rests as quiet
   muted text, then reveals a danger tint on hover/focus — readable as removal
   without competing with the page's primary actions. */
.btn--ghost-danger {
    color: var(--text-muted);
    border-color: var(--border-strong);
}

.btn--ghost-danger:hover,
.btn--ghost-danger:focus-visible {
    color: #b71c1c;
    border-color: #e7a39c;
    background: #fdecea;
}

/* On dark surfaces (the landing hero) the ghost button stays light. */
.hero .btn--ghost {
    color: var(--brand-on-primary);
    border-color: rgba(255, 255, 255, 0.32);
}

.hero .btn--ghost:hover {
    background: rgba(255, 255, 255, 0.08);
}

.hero__actions {
    display: flex;
    gap: var(--space-3);
    justify-content: center;
    flex-wrap: wrap;
}

.hero__meta {
    margin-top: var(--space-12);
    font-size: 12px;
    color: rgba(255, 255, 255, 0.5);
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #36d399;
    margin-right: var(--space-2);
    vertical-align: middle;
}

.btn--sm {
    padding: var(--space-2) var(--space-4);
    font-size: 13px;
}

/* ---- Login card ----------------------------------------------------- */
.wordmark--centered {
    justify-content: center;
    margin-bottom: var(--space-6);
    color: var(--brand-on-primary);
}

.wordmark--centered .wordmark__img {
    height: 44px;   /* larger, prominent on the sign-in card */
}

.auth-card {
    background: var(--brand-surface);
    color: var(--text-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-8);
    text-align: left;
    max-width: 380px;
    margin: 0 auto;
}

.auth-card__title {
    margin: 0 0 var(--space-6);
    font-size: 22px;
}

.auth-card__error {
    background: #fff0eb;
    color: var(--brand-secondary-600);
    border: 1px solid #ffd5c2;
    border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3);
    font-size: 14px;
    margin: 0 0 var(--space-4);
}

.field {
    display: block;
    margin-bottom: var(--space-6);
}

.field__label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}

/* Marks a required field; the input itself also carries `required`. */
.field__req {
    color: var(--brand-secondary-600);
    margin-left: 2px;
    font-weight: 700;
}

.field__hint {
    display: block;
    margin-top: var(--space-2);
    font-size: 12px;
    color: var(--text-muted);
}

.field__input {
    width: 100%;
    font: inherit;
    padding: var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.field__input::placeholder {
    color: var(--text-muted);
    opacity: 1;
}

.field__input:focus,
.field__input:focus-visible {
    outline: none;
    border-color: var(--brand-secondary-600);
    box-shadow: 0 0 0 3px rgba(184, 71, 0, 0.18);
}

.auth-card__submit {
    width: 100%;
    margin-top: var(--space-2);
}

.auth-card__hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    margin: var(--space-4) 0 0;
}

/* ---- Dashboard ------------------------------------------------------ */
.brand-switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin-right: var(--space-4);
}

.brand-switch__label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
}

.brand-switch__select {
    font: inherit;
    font-weight: 600;
    color: var(--brand-primary);
    padding: var(--space-2) var(--space-3);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
}

.logout-form {
    display: inline;
}

.page {
    max-width: 920px;
    margin: 0 auto;
    padding: var(--space-12) var(--space-8);
}

.eyebrow--dark {
    color: var(--brand-secondary-600);
}

.page__title {
    margin: 0 0 var(--space-8);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
}

/* Section rhythm for the shell content area. (The old `main.page section` rule
   below never matches the shell's <main class="content">; this is the live one.) */
.content section {
    margin-top: var(--space-8);
}

.section__heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 0 0 var(--space-4);
}

.muted {
    color: var(--text-muted);
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-12);
}

.nav-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    background: var(--brand-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: var(--brand-primary);
    font-weight: 700;
    transition: box-shadow 0.15s ease, transform 0.06s ease, border-color 0.15s ease;
}

.nav-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.nav-card__arrow {
    color: var(--brand-secondary);
    font-size: 18px;
}

.admin {
    margin-top: var(--space-8);
    padding-top: var(--space-8);
    border-top: 1px solid var(--border);
}

.module-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.module-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-6);
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.module-row__name {
    font-weight: 700;
    color: var(--brand-primary);
    margin-right: var(--space-3);
}

.badge {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    padding: 3px var(--space-2);
    border-radius: 999px;
    vertical-align: middle;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.badge--on {
    background: #e7f8f0;
    color: #0a7a4f;
}

.badge--off {
    background: var(--surface-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.badge--system {
    background: var(--surface-subtle);
    color: var(--brand-primary-300);
    border: 1px solid var(--border-strong);
}

/* Due-date urgency — colour signals triage at a glance: overdue (red),
   due within 30 days (amber), or later (neutral grey). */
.badge--due-overdue {
    background: #fdecea;
    color: #b71c1c;
}

.badge--due-soon {
    background: #fff8e1;
    color: #6b5300;
}

.badge--due-later {
    background: var(--surface-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-strong);
}

.add-form {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
    max-width: 520px;
}

.add-form .field__input {
    flex: 1;
}

/* The add-vehicle row carries three inputs + a button; let it wrap on narrow
   screens, give the registration field room, and a clear gap from the cards above. */
.add-form--vehicle {
    flex-wrap: wrap;
    max-width: 640px;
    margin-top: var(--space-5);
}

.add-form--vehicle .field__input {
    flex: 1 1 7rem;
}

.field__input--reg {
    flex: 2 1 9rem;
    text-transform: uppercase;
}

/* ---- CRM ------------------------------------------------------------ */
.toolbar {
    margin: 0 0 var(--space-6);
}

.form-narrow {
    max-width: 420px;
}

/* "Needs attention" line in the customer header — soonest open due, up top. */
.attention {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-6);
    flex-wrap: wrap;
}

.attention__label {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}

.kv {
    display: grid;
    grid-template-columns: 96px 1fr;
    gap: var(--space-3) var(--space-6);
    margin: 0 0 var(--space-8);
}

.kv dt {
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    line-height: 1.5;
}

.kv dd {
    margin: 0;
    color: var(--text-strong);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.5;
    font-variant-numeric: tabular-nums;
}

.tag-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: 0 0 var(--space-4);
}

.badge--tag {
    background: var(--surface-subtle);
    color: var(--brand-primary);
    border: 1px solid var(--border-strong);
}

/* Inside a removable chip the .tag-chip pill provides the surface, so the
   inner label badge goes borderless to avoid a double-pill outline. */
.tag-chip .badge--tag {
    background: none;
    border-color: transparent;
}

/* ---- Due-date lifecycle controls ----------------------------------- */
.due-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}

.due-item:last-child {
    border-bottom: 0;
}

.due-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

.due-controls form {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

/* Push the date-edit to the end of the row so it reads as a separate, secondary
   action from the status verbs (Booked/Completed/Dismiss). */
.due-controls__edit {
    margin-left: auto;
}

/* Date inputs size to content instead of stretching full-width in a flex row. */
.field__input--date {
    width: auto;
}

/* Add-a-due form: labelled controls that wrap (and never collapse the type select
   to a bare caret on mobile). */
.add-due {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
}

.add-due .field {
    margin-bottom: 0;
}

.add-due .field__input {
    min-width: 9rem;
}

.row-with-action {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.row-with-action .nav-card {
    flex: 1;
}

/* Vehicle card: keep the name and its due/tag badges on one baseline-aligned row. */
.nav-card > span:first-child {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}

/* ---- tag chips with remove ----------------------------------------- */
/* The chip is ONE visual pill: label + remove (×) must never split across
   lines. flex-wrap:nowrap keeps the inner form on the chip; the shared
   background/border (moved here off .badge--tag) binds the two together. */
.tag-chip {
    display: inline-flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 2px;
    background: var(--surface-subtle);
    color: var(--brand-primary);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding-right: 2px;
}

.tag-chip form {
    display: inline-flex;
    flex: 0 0 auto;
    margin: 0;
}

.tag-x {
    background: none;
    border: 0;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    padding: 0 4px;
}

.tag-x:hover {
    color: #b71c1c;
}

/* ---- note rows with lifecycle controls ----------------------------- */
.note-row {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}

.note-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3);
}

.note-actions {
    display: inline-flex;
    gap: var(--space-2);
}

.note-actions form {
    display: inline-flex;
    margin: 0;
}

.note-edit {
    margin-top: var(--space-2);
    margin-bottom: 0;
}

/* ---- list page (search + data rows) -------------------------------- */
.page-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
}

/* In a page-head the heading sits on one row with its actions, so it must NOT
   carry the 32px bottom margin a standalone .page__title uses — that trailing
   space was what made a lone action button (Campaigns, + New campaign) float
   well below the title. The .page-head's own margin handles the gap to content. */
.page-head .page__title {
    margin-bottom: 0;
}

.page-head .eyebrow,
.page-head .eyebrow--dark {
    margin-bottom: var(--space-1);
}

.count {
    font-size: 13px;
    font-weight: 700;
    color: var(--brand-primary-300);
    background: var(--surface-subtle);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    padding: 2px var(--space-2);
    vertical-align: 6px;
}

.search {
    display: flex;
    gap: var(--space-2);
    max-width: 560px;
    margin-bottom: var(--space-6);
}

.search .field__input {
    flex: 1;
}

.data-list {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-list > p {
    margin: 0;
    padding: var(--space-5) var(--space-6);
}

.data-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-6);
    border-bottom: 1px solid var(--border-strong);
    text-decoration: none;
    color: var(--text-strong);
    transition: background 0.12s ease, box-shadow 0.12s ease;
}

.data-row:last-child {
    border-bottom: 0;
}

.data-row:hover {
    background: var(--surface-subtle);
    box-shadow: inset 3px 0 0 var(--brand-secondary);
}

.data-row__main {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.data-row__name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: -0.01em;
    color: var(--text-strong);
}

.data-row__sub {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    font-size: 13px;
    color: var(--text-muted);
}

.data-row__meta {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--text-muted);
}

/* Triage inbox: the row is a flex container; its main area is a link, with action
   forms (Claim) living in the meta beside the badges — so we keep the row's look
   without nesting a form inside an anchor. */
a.data-row__main,
a.data-row__main:hover {
    text-decoration: none;
    color: var(--text-strong);
    flex: 1;
}
.data-row__meta form {
    margin: 0;
}

/* Customer 360 activity timeline. */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
}
.timeline__item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-strong);
}
.timeline__item:last-child {
    border-bottom: 0;
}
.timeline__summary {
    color: var(--text-strong);
}
.timeline__meta {
    color: var(--text-muted);
    font-size: 13px;
    white-space: nowrap;
}

/* Performance stat cards. */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.stat {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-5);
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.stat__num {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-strong);
}
.stat__label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Campaign editor: one step block per follow-up message. */
.step-block {
    border-top: 1px solid var(--border-strong);
    padding-top: var(--space-4);
    margin-top: var(--space-4);
}
.data-row__meta a.nav-card__arrow {
    text-decoration: none;
}

/* ---- outreach 3-pane chat ------------------------------------------ */
.chat {
    display: grid;
    grid-template-columns: 260px 1fr 280px;
    gap: var(--space-4);
    align-items: start;
}

.chat__queue {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden auto;
    max-height: 72vh;
}

.chat__empty {
    padding: var(--space-4);
}

.chat__qrow {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text-strong);
}

.chat__qrow:last-child {
    border-bottom: 0;
}

.chat__qrow:hover {
    background: var(--surface-subtle);
}

.chat__qrow.is-active {
    background: var(--surface-subtle);
    box-shadow: inset 3px 0 0 var(--brand-secondary);
}

.chat__qname {
    font-weight: 600;
    font-size: 14px;
}

.chat__qmeta {
    font-size: 12px;
    color: var(--text-muted);
}

.chat__thread {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    min-height: 52vh;
}

.chat__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.chat__title {
    font-size: 18px;
    margin: 0;
}

.chat__messages {
    padding: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.msg {
    display: flex;
    flex-direction: column;
    max-width: 78%;
}

.msg--out {
    align-self: flex-end;
    align-items: flex-end;
}

.msg--in {
    align-self: flex-start;
    align-items: flex-start;
}

.msg__bubble {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-lg);
    font-size: 14px;
    line-height: 1.4;
}

.msg--out .msg__bubble {
    background: var(--brand-primary);
    color: var(--brand-on-primary);
    border-bottom-right-radius: var(--radius-sm);
}

.msg--in .msg__bubble {
    background: var(--surface-subtle);
    border: 1px solid var(--border-strong);
    border-bottom-left-radius: var(--radius-sm);
}

.msg__meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* An outbound message that never actually went out (blocked by consent / carrier error).
   Dim the bubble and tag it so an advisor isn't misled into thinking it was delivered. */
.msg--undelivered .msg__bubble {
    opacity: 0.55;
    border: 1px dashed var(--border-strong);
}

.msg__tag {
    color: var(--orange, #ff6600);
    font-weight: 600;
}

.chat__context {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: var(--space-5);
}

.chat__reply {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: var(--space-4);
    display: flex;
    gap: var(--space-2);
}

.chat__reply .field__input {
    flex: 1;
}

@media (max-width: 900px) {
    .chat {
        grid-template-columns: 1fr;
    }
    .chat__queue {
        max-height: 30vh;
    }
}

/* ---- import wizard tables ------------------------------------------ */
.map-table {
    width: 100%;
    max-width: 820px;
    border-collapse: collapse;
    margin-bottom: var(--space-6);
}

.map-table th,
.map-table td {
    text-align: left;
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.map-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

/* ---- dedupe / merge ------------------------------------------------- */
.dedupe-group {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-6);
    max-width: 640px;
}

.dedupe-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) 0;
    cursor: pointer;
}

/* ---- GDPR / data & privacy ----------------------------------------- */
.actions {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
    align-items: center;
}

.actions form {
    display: inline-flex;
    margin: 0;
}

.callout {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    padding: var(--space-4) var(--space-5);
    background: var(--surface-subtle);
    margin: 0 0 var(--space-6);
    max-width: 640px;
}

.callout--warn {
    border-color: #e6b800;
    background: #fff8e1;
    color: #6b5300;
}

.callout--ok {
    border-color: #0a7a4f;
    background: #e7f8f0;
    color: #0a7a4f;
}

.btn--danger {
    background: #c0392b;
    color: #fff;
    box-shadow: var(--shadow-md);
}

.btn--danger:hover {
    background: #a93226;
}

.badge--danger {
    background: #fdecea;
    color: #b71c1c;
}

.codeblock {
    display: block;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--surface-subtle);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    max-width: 760px;
    overflow-x: auto;
}

/* ---- Design once-over refinements ---------------------------------- */

/* Stacked filter/segment groups (outreach Today: status row + assignee row).
   Without a wrapper the two .actions rows touched; this gives them a clear
   vertical rhythm and one consistent gap down to the list below. */
.filters {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    margin: 0 0 var(--space-6);
}

/* Stat/metric variant of the key-value list: the label column sizes to its
   widest label instead of a fixed 96px, so multi-word labels ("Messages sent
   today / last 7 days") stop wrapping onto 3–4 lines. The default .kv (96px)
   stays for short-label uses like the customer 360 header. */
.kv--stat {
    grid-template-columns: minmax(0, max-content) 1fr;
    column-gap: var(--space-8);
}

/* A callout that should line up with a full-width grid (the Performance SLA
   alert above the stat cards) rather than the 640px reading measure. */
.callout--wide {
    max-width: none;
}

/* Airbag "simulate inbound call" row: the inputs carry longer placeholders than
   the reg/make/model vehicle form, so give them room to show their full text
   instead of clipping ("Caller number (sim…", "Captured respons…"). */
.add-form--sim {
    flex-wrap: wrap;
    max-width: 760px;
    margin-top: var(--space-5);
}
.add-form--sim .field__input {
    flex: 1 1 12rem;
}
.add-form--sim .field__input--reg {
    flex: 1 1 8rem;
}
.add-form--sim .add-form__grow {
    flex: 2 1 16rem;
}

@media (max-width: 720px) {
    /* The collapsed sidebar is a horizontal strip; vertical section labels
       (OPERATIONS / CONFIGURATION) read as stray nav items there — hide them. */
    .sidebar__section {
        display: none;
    }

    /* Stack each list row: the name+contact take the full width and the
       badges/arrow drop onto their own line, instead of the meta overlapping
       the phone/email when horizontal space runs out. */
    .data-row {
        flex-wrap: wrap;
        row-gap: var(--space-2);
    }
    .data-row__main {
        flex-basis: 100%;
    }
    .data-row__meta {
        width: 100%;
    }
}
