/* ==========================================================================
   Design system for the CRM prototype.
   Tokens first, then base, layout, components and utilities.
   Mobile-first: base styles target phones, @media (min-width) adds desktop.
   ========================================================================== */

:root {
    --bg: #f5f6fa;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --surface-hover: #f1f3f9;
    --border: #e4e7ef;
    --border-strong: #d3d8e4;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #8a94a8;

    --primary: #5046e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef0ff;
    --primary-text: #3f37c9;

    --success: #0f9f6e;
    --success-soft: #e8f8f1;
    --warning: #c27803;
    --warning-soft: #fff6e0;
    --danger: #dc3545;
    --danger-soft: #fdecee;
    --info: #0b7fc1;
    --info-soft: #e7f4fc;
    --muted-soft: #eef0f4;

    --radius-lg: 16px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, .05);
    --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 4px 12px rgba(15, 23, 42, .04);
    --shadow-lg: 0 12px 40px rgba(15, 23, 42, .16);

    --sidebar-w: 248px;
    --topbar-h: 60px;
    --bottomnav-h: 64px;

    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color-scheme: light;
}

/* Dark theme: follows the device unless the host page sets data-theme explicitly. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0b0f19;
        --surface: #121826;
        --surface-2: #161d2d;
        --surface-hover: #1b2335;
        --border: #232c40;
        --border-strong: #2f3a52;
        --text: #e8ecf4;
        --text-2: #a7b0c2;
        --text-3: #6f7a90;
        --primary: #7c74ff;
        --primary-hover: #8f88ff;
        --primary-soft: #23244a;
        --primary-text: #b4afff;
        --success-soft: #0f2a22;
        --warning-soft: #2e2410;
        --danger-soft: #331a1f;
        --info-soft: #102838;
        --muted-soft: #1d2434;
        --shadow: 0 1px 3px rgba(0, 0, 0, .4);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
        color-scheme: dark;
    }
}

:root[data-theme="dark"] {
    --bg: #0b0f19;
    --surface: #121826;
    --surface-2: #161d2d;
    --surface-hover: #1b2335;
    --border: #232c40;
    --border-strong: #2f3a52;
    --text: #e8ecf4;
    --text-2: #a7b0c2;
    --text-3: #6f7a90;
    --primary: #7c74ff;
    --primary-hover: #8f88ff;
    --primary-soft: #23244a;
    --primary-text: #b4afff;
    --success-soft: #0f2a22;
    --warning-soft: #2e2410;
    --danger-soft: #331a1f;
    --info-soft: #102838;
    --muted-soft: #1d2434;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .5);
    color-scheme: dark;
}

/* ---------- Base ---------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1.125rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1:focus { outline: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--primary-soft); }

/* ---------- App layout ---------- */

.app { min-height: 100dvh; }

.sidebar { display: none; }

.main { min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    background: color-mix(in srgb, var(--surface) 85%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}

.topbar-title { font-weight: 650; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.topbar-brand { display: flex; align-items: center; gap: 10px; }

.topbar-search {
    display: none;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 420px;
    height: 38px;
    padding: 0 12px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-3);
}

.topbar-search input { border: 0; background: transparent; outline: none; flex: 1; min-width: 0; color: var(--text); }

.content {
    padding: 16px 16px calc(var(--bottomnav-h) + 32px + env(safe-area-inset-bottom));
    max-width: 1240px;
    margin: 0 auto;
}

.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-top: 1px solid var(--border);
}

.bottom-nav a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: .7rem;
    font-weight: 550;
    color: var(--text-3);
    text-decoration: none;
}

.bottom-nav a.active { color: var(--primary); }

.bottom-nav .nav-badge { position: absolute; top: 6px; left: calc(50% + 6px); }

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 800;
    font-size: .85rem;
    background: linear-gradient(135deg, #6d5efc, #3b82f6);
    box-shadow: 0 4px 12px rgba(80, 70, 229, .35);
    flex-shrink: 0;
}

.brand-name { font-weight: 700; letter-spacing: -.01em; }
.brand-sub { font-size: .75rem; color: var(--text-3); }

@media (min-width: 960px) {
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 35;
        width: var(--sidebar-w);
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 16px 12px;
        background: var(--surface);
        border-right: 1px solid var(--border);
    }

    .main { margin-left: var(--sidebar-w); }
    .topbar { padding: 0 28px; }
    .topbar-brand { display: none; }
    .topbar-search { display: flex; }
    .topbar-title { display: none; }
    .content { padding: 28px 28px 48px; }
    .bottom-nav { display: none; }
}

.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }

.nav-section { font-size: .7rem; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 6px; }

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 10px;
    border-radius: 9px;
    color: var(--text-2);
    font-weight: 550;
    text-decoration: none;
}

.nav-link:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--primary-soft); color: var(--primary-text); }
.nav-link .nav-badge { margin-left: auto; }

.sidebar-footer { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--border); }

.nav-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--primary);
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: inline-grid;
    place-items: center;
}

/* ---------- Page structure ---------- */

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.page-header p { color: var(--text-2); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: .875rem; margin-bottom: 10px; }

.section { margin-top: 28px; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.grid, .grid-2, .grid-3 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 720px) {
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.layout-main-aside { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }

@media (min-width: 1100px) {
    .layout-main-aside { grid-template-columns: minmax(0, 1fr) 400px; align-items: start; }
}

.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grow { flex: 1; min-width: 0; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.card-body { padding: 16px; }
.card-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

@media (min-width: 720px) {
    .card-body { padding: 20px; }
    .card-header { padding: 16px 20px; }
}

.card-link { display: block; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card-link:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }

/* ---------- KPI ---------- */

.kpis {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(150px, 1fr);
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    margin: 0 -16px;
    padding: 2px 16px 6px;
    scrollbar-width: none;
}

.kpis::-webkit-scrollbar { display: none; }

@media (min-width: 960px) {
    .kpis { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); margin: 0; padding: 0; overflow: visible; }
}

.kpi { scroll-snap-align: start; padding: 16px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-size: .82rem; font-weight: 550; }
.kpi-value { font-size: 1.75rem; font-weight: 750; letter-spacing: -.02em; margin-top: 6px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    font-size: .875rem;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover { background: var(--surface-hover); text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(80, 70, 229, .3); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-text); }
.btn-danger { color: var(--danger); }
.btn-sm { height: 32px; padding: 0 10px; font-size: .8rem; border-radius: 8px; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm.btn-icon { width: 32px; }
.btn-block { width: 100%; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 650;
    white-space: nowrap;
    background: var(--muted-soft);
    color: var(--text-2);
}

.tone-primary { background: var(--primary-soft); color: var(--primary-text); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger { background: var(--danger-soft); color: var(--danger); }
.tone-info { background: var(--info-soft); color: var(--info); }
.tone-neutral { background: var(--muted-soft); color: var(--text-2); }
.tone-muted { background: var(--muted-soft); color: var(--text-3); }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: currentColor; }

.score {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 650;
    font-size: .8rem;
}

.score-ring {
    --value: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: .7rem;
    font-weight: 750;
    background: conic-gradient(var(--ring-color, var(--primary)) calc(var(--value) * 1%), var(--muted-soft) 0);
    position: relative;
}

.score-ring::before { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--surface); }
.score-ring span { position: relative; }
.score-ring.success { --ring-color: var(--success); }
.score-ring.warning { --ring-color: var(--warning); }
.score-ring.neutral, .score-ring.muted { --ring-color: var(--text-3); }

/* ---------- Avatars ---------- */

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    font-size: .72rem;
    font-weight: 700;
    color: var(--primary-text);
    background: var(--primary-soft);
}

.avatar-lg { width: 48px; height: 48px; font-size: 1rem; border-radius: 14px; }
.avatar-org { border-radius: 10px; background: linear-gradient(135deg, #eef0ff, #e7f4fc); color: var(--primary-text); }

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .avatar-org { background: linear-gradient(135deg, #23244a, #102838); }
}

:root[data-theme="dark"] .avatar-org { background: linear-gradient(135deg, #23244a, #102838); }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: .8rem; font-weight: 600; color: var(--text-2); }
.hint { font-size: .78rem; color: var(--text-3); }

.input, .select, .textarea {
    width: 100%;
    min-height: 40px;
    padding: 8px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: var(--surface);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    font-size: 16px; /* prevents zoom on iOS */
}

@media (min-width: 720px) {
    .input, .select, .textarea { font-size: .9rem; }
}

.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }
.textarea-mail { min-height: 280px; font-size: .92rem; }
.select { appearance: none; padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238a94a8' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }

.search-input { position: relative; }
.search-input .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search-input .input { padding-left: 38px; }

.check { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* ---------- Chips and segmented controls ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-2);
    font-weight: 600;
    font-size: .82rem;
    white-space: nowrap;
    cursor: pointer;
}

.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .count { font-size: .72rem; opacity: .7; }

.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }

@media (min-width: 720px) {
    .filters { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
    .filters .select { width: auto; min-width: 160px; }
}

/* Fit / interest / next contact on the organisation page: 2 + 1 on phones, 3 across from tablet. */
.score-grid { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.score-grid > :last-child { grid-column: 1 / -1; }

@media (min-width: 720px) {
    .score-grid { gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .score-grid > :last-child { grid-column: auto; }
}

/* ---------- Tabs ---------- */

.tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tab {
    position: relative;
    height: 42px;
    padding: 0 12px;
    border: 0;
    background: none;
    color: var(--text-2);
    font-weight: 600;
    font-size: .875rem;
    white-space: nowrap;
    cursor: pointer;
}

.tab.active { color: var(--text); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; border-radius: 2px; background: var(--primary); }
.tab .count { color: var(--text-3); font-weight: 600; margin-left: 4px; }

/* ---------- Recommendation cards (Sales Inbox) ---------- */

.rec-list { display: flex; flex-direction: column; gap: 10px; }

.rec {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 14px;
    animation: fade-in .2s ease;
}

.rec-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rec-name { font-weight: 650; color: var(--text); }
.rec-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: 4px; font-size: .8rem; color: var(--text-3); }
.rec-reason { margin-top: 8px; color: var(--text-2); font-size: .9rem; }
.rec-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

@media (min-width: 720px) {
    .rec { padding: 16px 18px; grid-template-columns: auto auto minmax(0, 1fr); align-items: start; }
}

@keyframes fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Lists and tables ---------- */

.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-hover); text-decoration: none; }
.list-title { font-weight: 600; }
.list-sub { font-size: .8rem; color: var(--text-3); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { text-align: left; font-size: .72rem; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover { background: var(--surface-hover); }

/* ---------- Timeline ---------- */

.timeline { position: relative; display: flex; flex-direction: column; gap: 4px; }

.tl-item { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 10px 0; }
.tl-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.tl-title { font-weight: 600; }
.tl-meta { font-size: .78rem; color: var(--text-3); }
.tl-body { margin-top: 6px; color: var(--text-2); font-size: .9rem; white-space: pre-line; }
.tl-mail { margin-top: 8px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); white-space: pre-line; font-size: .88rem; color: var(--text-2); }

/* ---------- Analysis blocks ---------- */

.knowledge { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); }
.knowledge:last-child { border-bottom: 0; }
.knowledge-mark { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex-shrink: 0; font-size: .8rem; font-weight: 800; margin-top: 1px; }
.knowledge-source { font-size: .75rem; color: var(--text-3); }

.criteria { display: flex; flex-direction: column; gap: 8px; }
.criterion { display: flex; align-items: flex-start; gap: 10px; font-size: .9rem; }
.criterion .evidence { font-size: .78rem; color: var(--text-3); }

/* ---------- Progress ---------- */

.progress { height: 8px; border-radius: 99px; background: var(--muted-soft); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; }
.progress .p-primary { background: var(--primary); }
.progress .p-success { background: var(--success); }
.progress .p-warning { background: var(--warning); }
.progress .p-info { background: var(--info); }
.progress .p-muted { background: var(--text-3); }
.progress .p-danger { background: var(--danger); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .78rem; color: var(--text-2); margin-top: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Callouts ---------- */

.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: .875rem; align-items: flex-start; }
.callout .icon { flex-shrink: 0; margin-top: 1px; }

/* ---------- Mail composer ---------- */

.composer { position: relative; }

.composer-mobile-header { display: none; }

@media (max-width: 1099px) {
    .composer {
        position: fixed;
        inset: 0;
        z-index: 60;
        display: flex;
        flex-direction: column;
        border-radius: 0;
        border: 0;
        transform: translateY(100%);
        transition: transform .25s ease;
        visibility: hidden;
    }

    .composer.open { transform: none; visibility: visible; }
    .composer .card-body { flex: 1; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
    .composer-mobile-header { display: flex; }
    .composer-desktop-header { display: none; }
}

@media (min-width: 1100px) {
    .composer { position: sticky; top: calc(var(--topbar-h) + 20px); }
}

.fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom));
    z-index: 45;
    height: 52px;
    padding: 0 20px;
    border-radius: 999px;
    box-shadow: var(--shadow-lg);
}

@media (min-width: 1100px) { .fab { display: none; } }

/* ---------- Modal / bottom sheet ---------- */

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, .45);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    animation: fade .15s ease;
}

.sheet {
    width: 100%;
    max-height: 92dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-lg);
    animation: slide-up .22s ease;
    padding-bottom: env(safe-area-inset-bottom);
}

.sheet-handle { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.sheet-body { padding: 16px; overflow-y: auto; }
.sheet-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); }

@media (min-width: 720px) {
    .backdrop { align-items: center; padding: 24px; }
    .sheet { max-width: 560px; border-radius: 18px; }
    .sheet-handle { display: none; }
    .sheet-body { padding: 20px; }
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }

/* ---------- Menu (details/summary) ---------- */

.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }

.menu-list {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    z-index: 50;
    min-width: 200px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
}

.menu-list button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: none;
    text-align: left;
    font-size: .875rem;
    cursor: pointer;
}

.menu-list button:hover { background: var(--surface-hover); }
.menu-list .danger { color: var(--danger); }
.menu-left .menu-list { left: 0; right: auto; }

/* ---------- Toasts ---------- */

.toasts {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom));
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

@media (min-width: 960px) {
    .toasts { left: auto; right: 24px; bottom: 24px; width: 360px; }
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--text);
    color: var(--surface);
    box-shadow: var(--shadow-lg);
    font-size: .875rem;
    font-weight: 550;
    pointer-events: auto;
    animation: slide-up .2s ease;
}

/* ---------- Stepper ---------- */

.stepper { display: flex; gap: 6px; margin-bottom: 20px; }
.step { flex: 1; height: 4px; border-radius: 4px; background: var(--muted-soft); }
.step.done { background: var(--primary); }

/* ---------- Empty states ---------- */

.empty { text-align: center; padding: 40px 16px; color: var(--text-2); }
.empty .icon-wrap { width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 16px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); }

/* ---------- Demo banner ---------- */

.demo-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 16px;
    border-radius: 10px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: .8rem;
    font-weight: 600;
}

/* ---------- Inline help ---------- */

.help { margin-bottom: 20px; padding: 16px; background: linear-gradient(180deg, var(--primary-soft), var(--surface) 70%); border-color: color-mix(in srgb, var(--primary) 25%, var(--border)); }
.help-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.help-head h2 { font-size: 1rem; min-width: 0; overflow-wrap: break-word; }
.help-head .btn { flex-shrink: 0; }
.help-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--primary); color: #fff; flex-shrink: 0; }
.help-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); font-size: .875rem; color: var(--text-2); }
.help-grid p { line-height: 1.55; }
.help-grid ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.help-label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--primary-text); margin-bottom: 4px; }
.help-prototype { display: flex; align-items: flex-start; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border-strong); font-size: .8rem; color: var(--text-2); }
.help-prototype .badge { flex-shrink: 0; }
.help-closed { display: flex; justify-content: flex-end; margin: -8px 0 12px; }
.help-toggle { margin-top: 8px; padding-left: 0; color: var(--primary-text); }

/* On phones the box opens short: what the page shows and the next step. The rest is behind "Vis mere". */
@media (max-width: 899px) {
    .help:not(.expanded) .help-more { display: none; }
}

@media (min-width: 900px) {
    .help { padding: 18px 20px; }
    .help-grid { grid-template-columns: 1.1fr 1fr 1fr; gap: 24px; }
    .help-toggle { display: none; }
}

.status-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; font-size: .875rem; color: var(--text-2); }

/* ---------- Utilities ---------- */

.muted { color: var(--text-2); }
.text-info { color: var(--info); }
.subtle { color: var(--text-3); }
.small { font-size: .82rem; }
.xsmall { font-size: .75rem; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.icon { display: inline-block; flex-shrink: 0; vertical-align: middle; }

@media (max-width: 719px) { .hide-sm { display: none !important; } }
@media (min-width: 720px) { .show-sm { display: none !important; } }
@media (max-width: 959px) { .hide-md { display: none !important; } }

/* ---------- Blazor ---------- */

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 12px;
}

.blazor-error-boundary::after { content: "Der opstod en fejl."; }

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 1000;
    width: 100%;
    padding: .6rem 1.25rem .7rem;
    background: #fff4d6;
    color: #5c4400;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, .2);
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* Loading state for the browser-only demo (Crm.Demo). */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; }

/* ---------- Organisations found in an uploaded document ---------- */
.found-list { margin: 4px 0 4px 30px; }
.found-list > summary { cursor: pointer; color: var(--primary); width: fit-content; }
.found-list ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.found-list li { border-left: 2px solid var(--border); padding-left: 10px; }

/* ---------- Project fit criteria ---------- */
.fit-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: space-between; }
.fit-row > .input { flex: 1 1 200px; min-width: 0; }

/* ---------- Guided tour ---------- */
.tour-spot {
    position: fixed;
    z-index: 85;
    border-radius: 12px;
    box-shadow: 0 0 0 3px var(--primary), 0 0 0 9999px rgba(15, 23, 42, .5);
    pointer-events: none;
    transition: top .25s ease, left .25s ease, width .25s ease, height .25s ease;
}

.tour-spot.no-target { box-shadow: 0 0 0 9999px rgba(15, 23, 42, .5); }

.tour-pop {
    position: fixed;
    z-index: 95;
    top: 16px;
    left: 16px;
    width: min(380px, calc(100vw - 32px));
    padding: 18px;
    display: grid;
    gap: 10px;
    box-shadow: var(--shadow-lg);
    transition: top .25s ease, left .25s ease;
}

.tour-pop h2 { font-size: 1.05rem; }
.tour-pop p { margin: 0; color: var(--text-2); font-size: .9rem; line-height: 1.5; }
.tour-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .75rem; color: var(--text-3); }
.tour-chapter { display: inline-flex; align-items: center; gap: 6px; color: var(--primary-text); font-weight: 600; }
.tour-progress { height: 4px; }
.tour-note { display: flex; gap: 8px; align-items: baseline; color: var(--text-2); }
.tour-actions { display: flex; align-items: center; gap: 6px; margin-top: 4px; }

/* On phones the explanation is a sheet above the bottom navigation, or at the top when the element is low on the screen. */
.tour-pop.docked {
    top: auto !important;
    left: 0 !important;
    right: 0;
    bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
    width: 100%;
    max-height: 50vh;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
}

.tour-pop.docked.docked-top {
    top: 0 !important;
    bottom: auto;
    border-radius: 0 0 16px 16px;
}

.tour-reminder {
    position: fixed;
    z-index: 50;
    left: 16px;
    bottom: calc(var(--bottomnav-h) + 84px + env(safe-area-inset-bottom));
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 8px 8px 14px;
    max-width: calc(100vw - 32px);
    box-shadow: var(--shadow-lg);
}

.tour-reminder-icon { color: var(--primary); flex-shrink: 0; }

.tour-offer { flex-direction: column; align-items: stretch; width: 340px; padding: 14px; gap: 12px; }

@media (min-width: 960px) {
    .tour-reminder { left: calc(var(--sidebar-w) + 24px); bottom: 24px; }
}

.tour-chapters { list-style: none; margin: 0; padding: 0; }
.tour-chapters li { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); }
.tour-chapters li:first-child { border-top: 0; }
.tour-chapters .num {
    width: 28px; height: 28px; border-radius: 99px; flex-shrink: 0;
    display: grid; place-items: center; font-size: .8rem; font-weight: 600;
    background: var(--muted-soft); color: var(--text-2);
}
.tour-chapters .num.done { background: var(--success-soft); color: var(--success); }
.tour-chapters .num.current { background: var(--primary); color: #fff; }

/* ---------- Server pages: login and operations ---------- */
.account-page { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.account-card { width: min(420px, 100%); padding: 28px; display: grid; gap: 16px; box-shadow: var(--shadow-lg); }
.account-card h1 { font-size: 1.4rem; margin: 8px 0 0; }
.account-card p { margin: 0; }
.account-dev { border-top: 1px dashed var(--border-strong); padding-top: 16px; margin-top: 4px; }
.btn-lg { height: 48px; font-size: 1rem; }
.table-static tbody tr { cursor: default; }
.table-static tbody tr:hover { background: none; }

/* Radio choices as rows, fx "Kør forfra" */
.options { display: grid; gap: 8px; }
.option { display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: .875rem; }
.option:hover { border-color: var(--border-strong, var(--border)); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option input { margin-top: 3px; accent-color: var(--primary); flex: none; }
.option > span { display: grid; gap: 2px; min-width: 0; }
.option .muted { font-size: .8rem; }

/* A button that looks like a link, fx "Se vurderingen" */
.link-btn { background: none; border: 0; padding: 0; color: var(--primary-text, var(--primary)); font-weight: 600; cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* The project's mail guide keeps its line breaks */
.guide-text { white-space: pre-line; }
