* { box-sizing: border-box; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; background: #eef3f8; color: #102033; }
a { color: var(--brand-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { min-height: 88px; padding: 16px 30px; display: flex; justify-content: space-between; align-items: center; gap: 24px; background: linear-gradient(135deg, var(--brand-secondary), var(--brand-primary)); color: #fff; box-shadow: 0 10px 28px rgba(15,23,42,.2); }
.brand-block { display: flex; align-items: center; gap: 16px; min-width: 260px; }
.brand-block span { display: block; opacity: .76; font-size: .85rem; }
.logo { width: clamp(120px, 13vw, 220px); height: 54px; object-fit: contain; object-position: left center; background: transparent; border-radius: 0; padding: 0; }
.nav { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 12px; }
.nav a, .link-button { color: #fff; background: rgba(255,255,255,.12); padding: 8px 10px; border-radius: 999px; border: 1px solid rgba(255,255,255,.18); font: inherit; cursor: pointer; }
.nav form { margin: 0; }
.page { width: min(1480px, calc(100% - 36px)); margin: 28px auto; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 20px; }
h1, h2, h3 { margin-top: 0; color: #0f172a; }
.muted { color: #64748b; }
.role-pill { background: #fff; color: var(--brand-primary); border: 1px solid #dce5ef; border-radius: 999px; padding: 10px 16px; font-weight: 700; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.metric { background: #fff; border-radius: 20px; padding: 20px; box-shadow: 0 10px 30px rgba(15,23,42,.08); border-top: 5px solid var(--brand-accent); }
.metric span { color: #64748b; display: block; margin-bottom: 8px; }
.metric strong { font-size: clamp(1.4rem, 2vw, 2.3rem); color: var(--brand-secondary); }
.metric.danger { border-top-color: #ef4444; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; margin-bottom: 18px; }
.three-col { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 18px; }
.wide-left { grid-template-columns: 2fr 1fr; }
.panel, .auth-card { background: #fff; border-radius: 22px; padding: 22px; box-shadow: 0 12px 35px rgba(15,23,42,.08); border: 1px solid #e2e8f0; }
.narrow { max-width: 840px; margin: 0 auto; }
.auth-card { max-width: 460px; margin: 70px auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 10px; text-align: left; border-bottom: 1px solid #e2e8f0; vertical-align: top; }
th { color: #475569; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
.form-card p { margin: 0 0 14px; }
.form-card label { display: block; margin-bottom: 6px; color: #475569; font-weight: 700; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 12px; padding: 10px 12px; font: inherit; background: #f8fafc; }
textarea { min-height: 100px; }
.btn, .small-btn { display: inline-block; background: var(--brand-primary); color: #fff; border: 0; border-radius: 14px; padding: 11px 16px; font-weight: 800; cursor: pointer; }
.small-btn { padding: 7px 10px; font-size: .85rem; }
.inline-form { display: flex; gap: 8px; max-width: 520px; margin-bottom: 16px; }
.messages { margin-bottom: 16px; }
.message { background: #e0f2fe; border-left: 5px solid var(--brand-accent); padding: 12px 14px; border-radius: 12px; margin-bottom: 8px; }
.message.success { background: #dcfce7; border-left-color: #22c55e; }
.message.warning { background: #fef9c3; border-left-color: #eab308; }
.display-body { background: #020617; color: #e2e8f0; }
.display-page { width: min(1700px, calc(100% - 48px)); margin: 24px auto; }
.display-hero { display: flex; align-items: center; gap: 22px; background: linear-gradient(135deg, var(--brand-secondary), var(--brand-primary)); border-radius: 28px; padding: 26px; margin-bottom: 22px; }
.display-hero h1 { color: #fff; font-size: clamp(2.2rem, 4vw, 4.5rem); margin-bottom: 0; }
.display-hero p { color: rgba(255,255,255,.75); font-size: 1.4rem; }
.display-logo { width: clamp(180px, 18vw, 320px); height: 110px; object-fit: contain; object-position: left center; background: transparent; border-radius: 0; padding: 0; }
.display-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 18px; margin-bottom: 20px; }
.display-metrics div { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.13); border-radius: 26px; padding: 26px; }
.display-metrics span { display:block; color:#94a3b8; font-size:1.2rem; }
.display-metrics strong { display:block; color:#fff; font-size: clamp(2rem, 4vw, 4.2rem); }
.display-panel { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.12); color: #e2e8f0; }
.display-panel h2 { color:#fff; font-size:2rem; }
.display-panel th, .display-panel td { border-bottom-color: rgba(255,255,255,.12); font-size:1.25rem; }
@media (max-width: 1000px) { .metric-grid { grid-template-columns: repeat(2,1fr); } .two-col, .three-col, .wide-left { grid-template-columns: 1fr; } .topbar { align-items:flex-start; flex-direction: column; } .logo { width: min(220px, 70vw); } }
@media (max-width: 650px) { .metric-grid, .display-metrics { grid-template-columns: 1fr; } .page { width: calc(100% - 18px); } }

.guide-card { background: #fff; border: 1px solid #dbe5ef; border-left: 6px solid var(--brand-accent); border-radius: 18px; padding: 0; margin: 0 0 18px; box-shadow: 0 10px 28px rgba(15,23,42,.07); overflow: hidden; }
.guide-card summary { cursor: pointer; padding: 15px 18px; font-weight: 900; color: var(--brand-secondary); list-style: none; }
.guide-card summary::-webkit-details-marker { display: none; }
.guide-card summary:after { content: '+'; float: right; color: var(--brand-primary); font-size: 1.2rem; }
.guide-card[open] summary:after { content: '−'; }
.guide-content { border-top: 1px solid #e2e8f0; padding: 16px 20px 18px; color: #334155; }
.guide-content p { margin: 0 0 12px; }
.guide-content ol, .guide-content ul { margin: 8px 0 12px 22px; padding: 0; }
.guide-content li { margin-bottom: 6px; }
.guide-link { margin-top: 14px; font-weight: 700; }
.guide-main h2, .guide-side h2 { margin-top: 24px; }
.guide-main h2:first-child, .guide-side h2:first-child { margin-top: 0; }
.large-steps li { margin-bottom: 10px; }
.guide-flow { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 14px 0 20px; }
.guide-flow div { border: 1px solid #dbe5ef; border-radius: 16px; padding: 16px; background: #f8fafc; }
.guide-flow strong { display: block; color: var(--brand-primary); font-size: 1.1rem; margin-bottom: 5px; }
.guide-flow span { color: #475569; }
.guide-side table th, .guide-side table td { text-transform: none; letter-spacing: 0; font-size: .95rem; }
code { background: #e2e8f0; border-radius: 6px; padding: 2px 5px; }
@media (max-width: 900px) { .guide-flow { grid-template-columns: 1fr; } }

/* Patch 006: full-size colour pickers */
input[type="color"] {
    width: 88px;
    min-width: 88px;
    height: 48px;
    padding: 4px;
    border-radius: 14px;
    cursor: pointer;
    background: #fff;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; border-radius: 10px; }
input[type="color"]::-moz-color-swatch { border: 0; border-radius: 10px; }
.colour-picker-row {
    display: grid;
    grid-template-columns: 92px minmax(130px, 170px) minmax(140px, 1fr);
    gap: 12px;
    align-items: center;
    margin-top: 4px;
}
.colour-hex-input {
    height: 48px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
    background: #ffffff;
}
.colour-preview-card {
    height: 48px;
    border-radius: 14px;
    border: 1px solid #cbd5e1;
    display: flex;
    align-items: center;
    padding: 0 14px;
    font-size: .86rem;
    font-weight: 800;
    overflow: hidden;
}
.colour-preview-card .colour-preview-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 2px rgba(0,0,0,.18);
}
.colour-picker-row + .helptext,
.colour-picker-row ~ .helptext { margin-top: 6px; }
.form-card .colour-picker-row input { margin: 0; }
@media (max-width: 700px) {
    .colour-picker-row { grid-template-columns: 92px 1fr; }
    .colour-preview-card { grid-column: 1 / -1; }
}

/* Patch 007: pricing, quote workflow, spares and calendar screens */
.topbar { gap: 18px; }
.nav { flex-wrap: wrap; }
.hero.compact { align-items: flex-start; }
.panel-heading { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.button-row form { margin: 0; }
.btn.secondary { background: #475569; }
.btn.success { background: #16a34a; }
.btn.warning { background: #f59e0b; color: #111827; }
.metric.warning { border-top-color: #f59e0b; }
.status-pill { display: inline-block; border-radius: 999px; padding: 5px 9px; background: #e0f2fe; color: #075985; font-weight: 800; font-size: .82rem; }
.approval-pending { color: #b45309; font-weight: 900; }
.approval-approved { color: #15803d; font-weight: 900; }
.approval-rejected { color: #b91c1c; font-weight: 900; }
.approval-not_required { color: #475569; }
.calendar-list { display: flex; flex-direction: column; gap: 12px; }
.calendar-item { display: grid; grid-template-columns: 74px 1fr auto; gap: 16px; align-items: start; border: 1px solid #e2e8f0; border-left: 6px solid var(--brand-accent); border-radius: 18px; padding: 14px; background: #f8fafc; }
.calendar-item.status-completed { border-left-color: #22c55e; }
.calendar-item.status-cancelled { border-left-color: #ef4444; opacity: .75; }
.datebox { text-align: center; border-radius: 16px; background: #fff; box-shadow: 0 8px 24px rgba(15,23,42,.08); padding: 8px; }
.datebox strong { display: block; color: var(--brand-primary); font-size: 1.7rem; line-height: 1; }
.datebox span { color: #64748b; font-weight: 800; text-transform: uppercase; font-size: .82rem; }
.calendar-main h3 { margin-bottom: 5px; }
.form-card .helptext { display: block; color: #64748b; font-size: .86rem; margin-top: 4px; }
.errorlist { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; border-radius: 10px; padding: 8px 10px; margin: 0 0 10px 0; list-style: none; }
@media (max-width: 800px) { .calendar-item { grid-template-columns: 1fr; } .button-row { justify-content: flex-start; } }

/* Patch 008: office display monthly sales performance */
.display-metrics-compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.display-chart-grid { align-items: stretch; }
.display-chart-panel { min-height: 460px; }
.display-chart-panel canvas { width: 100% !important; height: 340px !important; }
.display-subtitle { color: #94a3b8; margin-top: -12px; margin-bottom: 18px; font-size: 1.05rem; }
.display-leaderboard td, .display-leaderboard th { font-size: 1.15rem; }
.display-bar-wrap { width: 100%; height: 12px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; margin-bottom: 7px; }
.display-bar { height: 100%; border-radius: 999px; background: var(--brand-accent); min-width: 2px; }
.display-bar-wrap.leads { height: 10px; }
.lead-bar { background: #fff; opacity: .9; }
.muted-display { color: #94a3b8; }
@media (max-width: 1200px) { .display-metrics-compact { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 700px) { .display-metrics-compact { grid-template-columns: 1fr; } .display-chart-panel { min-height: 380px; } .display-chart-panel canvas { height: 270px !important; } }

/* Patch 010: left navigation and consolidated hub layout */
body { background: #eef3f8; }
.app-shell { min-height: 100vh; display: flex; }
.sidebar {
    width: 292px;
    flex: 0 0 292px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px 16px;
    background: linear-gradient(180deg, var(--brand-secondary), #071326 74%, #020617);
    color: #fff;
    box-shadow: 10px 0 30px rgba(15,23,42,.18);
    z-index: 40;
}
.sidebar-brand { min-width: 0; padding: 4px 2px 12px; border-bottom: 1px solid rgba(255,255,255,.12); }
.sidebar-brand .logo { width: 178px; max-width: 100%; height: 54px; }
.sidebar-brand strong { display: block; color: #fff; line-height: 1.2; }
.sidebar-brand span { color: rgba(255,255,255,.68); }
.side-nav { display: flex; flex-direction: column; gap: 6px; overflow-y: auto; padding-right: 3px; }
.nav-section-label {
    margin: 14px 8px 5px;
    color: rgba(255,255,255,.52);
    font-size: .72rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: .12em;
}
.side-nav-link {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 11px;
    border-radius: 14px;
    color: rgba(255,255,255,.84);
    background: transparent;
    border: 1px solid transparent;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}
.side-nav-link:hover { text-decoration: none; background: rgba(255,255,255,.10); border-color: rgba(255,255,255,.12); transform: translateX(2px); }
.side-nav-link.active { color: #fff; background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.22); box-shadow: inset 4px 0 0 var(--brand-accent); }
.side-nav-link.compact { font-size: .9rem; padding: 8px 11px; color: rgba(255,255,255,.72); }
.nav-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(255,255,255,.12);
    color: #fff;
    font-weight: 900;
    font-size: .9rem;
    line-height: 1;
}
.side-nav-link.active .nav-icon { background: var(--brand-accent); color: #06111f; }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.12); padding-top: 12px; }
.sidebar-footer form { margin: 0; }
.logout-link { font: inherit; }
.main-wrap { flex: 1 1 auto; min-width: 0; }
.mobile-topbar { display: none; }
.page { width: min(1460px, calc(100% - 44px)); margin: 30px auto 42px; }
.topbar { display: none; }

.hub-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.hub-card {
    display: block;
    background: #fff;
    border: 1px solid #dbe5ef;
    border-radius: 22px;
    padding: 18px;
    box-shadow: 0 10px 30px rgba(15,23,42,.07);
    color: #102033;
}
.hub-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 16px 38px rgba(15,23,42,.11); }
.hub-card-icon { width: 42px; height: 42px; display: inline-flex; align-items: center; justify-content: center; border-radius: 15px; background: color-mix(in srgb, var(--brand-accent) 28%, white); color: var(--brand-secondary); font-weight: 950; margin-bottom: 12px; }
.hub-card strong { display: block; color: #0f172a; font-size: 1.08rem; margin-bottom: 5px; }
.hub-card span { display: block; color: #64748b; font-size: .94rem; line-height: 1.35; }
.flow-strip { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; }
.flow-step { flex: 1 1 135px; min-width: 135px; border-radius: 18px; background: #fff; border: 1px solid #dbe5ef; padding: 14px; position: relative; }
.flow-step strong { display: block; color: var(--brand-primary); }
.flow-step span { color: #64748b; font-size: .88rem; }
.flow-step:not(:last-child)::after { content: '›'; position: absolute; right: -10px; top: 50%; transform: translateY(-50%); color: var(--brand-primary); font-size: 1.8rem; font-weight: 900; }
.mini-stat-row { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 10px; margin-bottom: 14px; }
.mini-stat { border: 1px solid #e2e8f0; background: #f8fafc; border-radius: 16px; padding: 12px; }
.mini-stat span { display: block; color: #64748b; font-size: .82rem; font-weight: 800; }
.mini-stat strong { display: block; font-size: 1.35rem; color: #0f172a; }
.setup-list { display: grid; gap: 12px; }
.setup-row { display: flex; justify-content: space-between; gap: 14px; align-items: center; border: 1px solid #e2e8f0; border-radius: 18px; padding: 14px; background: #f8fafc; }
.setup-row strong { display: block; color: #0f172a; }
.setup-row span { color: #64748b; font-size: .92rem; }

@media (max-width: 1180px) {
    .sidebar { width: 250px; flex-basis: 250px; }
    .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
    .app-shell { display: block; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        transform: translateX(-105%);
        transition: transform .2s ease;
        width: min(292px, 86vw);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .mobile-topbar {
        display: flex;
        align-items: center;
        gap: 12px;
        min-height: 64px;
        padding: 12px 16px;
        color: #fff;
        background: linear-gradient(135deg, var(--brand-secondary), var(--brand-primary));
        box-shadow: 0 8px 24px rgba(15,23,42,.16);
        position: sticky;
        top: 0;
        z-index: 30;
    }
    .sidebar-toggle { border: 1px solid rgba(255,255,255,.25); border-radius: 12px; color: #fff; background: rgba(255,255,255,.12); font-size: 1.2rem; width: 42px; height: 40px; cursor: pointer; }
    .page { width: calc(100% - 20px); margin: 18px auto 32px; }
    .metric-grid, .display-metrics { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 650px) {
    .hub-grid, .mini-stat-row { grid-template-columns: 1fr; }
    .flow-step:not(:last-child)::after { display: none; }
    .setup-row { align-items: flex-start; flex-direction: column; }
}

/* Patch 011: admin-selectable visual themes and softer graphical effects */
body {
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --text-main: #102033;
    --text-muted: #64748b;
    --line-soft: #e2e8f0;
    --card-radius: 22px;
    --control-radius: 14px;
    --card-shadow: 0 12px 35px rgba(15,23,42,.08);
}
body.theme-industrial_dark {
    --surface: #101923;
    --surface-soft: #161f2b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --line-soft: #23324a;
    --card-radius: 8px;
    --control-radius: 6px;
    --card-shadow: 0 16px 40px rgba(0,0,0,.35);
    background: radial-gradient(circle at top right, rgba(56,189,248,.14), transparent 34%), #08111d;
    color: var(--text-main);
}
body.theme-saas_clean {
    --surface: #ffffff;
    --surface-soft: #f1f5f9;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --line-soft: #e6edf5;
    --card-radius: 28px;
    --control-radius: 16px;
    --card-shadow: 0 8px 24px rgba(15,23,42,.055);
    background: #f7f9fc;
}
body.theme-nordic_frost {
    --surface: rgba(255,255,255,.72);
    --surface-soft: rgba(240,249,255,.70);
    --text-main: #0f2938;
    --text-muted: #52708a;
    --line-soft: rgba(255,255,255,.62);
    --card-radius: 30px;
    --control-radius: 18px;
    --card-shadow: 0 22px 55px rgba(15,58,89,.13);
    background: radial-gradient(circle at top left, rgba(186,230,253,.85), transparent 34%), radial-gradient(circle at bottom right, rgba(224,242,254,.95), transparent 38%), #eef8ff;
}
body.theme-fintech_dense {
    --surface: #111827;
    --surface-soft: #0b1220;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --line-soft: #293447;
    --card-radius: 2px;
    --control-radius: 3px;
    --card-shadow: none;
    background: #05070c;
    color: var(--text-main);
}
body.theme-corporate_steel {
    --surface: #ffffff;
    --surface-soft: #f4f7fb;
    --text-main: #102033;
    --text-muted: #64748b;
    --line-soft: #d5dee9;
    --card-radius: 14px;
    --control-radius: 10px;
    --card-shadow: 0 10px 28px rgba(15,23,42,.075);
    background: linear-gradient(180deg, #eef3f8 0%, #f8fafc 44%, #eef2f7 100%);
}

body.theme-industrial_dark h1,
body.theme-industrial_dark h2,
body.theme-industrial_dark h3,
body.theme-fintech_dense h1,
body.theme-fintech_dense h2,
body.theme-fintech_dense h3 { color: var(--text-main); }
body.theme-industrial_dark .muted,
body.theme-fintech_dense .muted { color: var(--text-muted); }

body.theme-industrial_dark .panel,
body.theme-industrial_dark .auth-card,
body.theme-industrial_dark .metric,
body.theme-industrial_dark .hub-card,
body.theme-industrial_dark .flow-step,
body.theme-industrial_dark .mini-stat,
body.theme-industrial_dark .setup-row,
body.theme-industrial_dark .guide-card,
body.theme-industrial_dark .form-card,
body.theme-fintech_dense .panel,
body.theme-fintech_dense .auth-card,
body.theme-fintech_dense .metric,
body.theme-fintech_dense .hub-card,
body.theme-fintech_dense .flow-step,
body.theme-fintech_dense .mini-stat,
body.theme-fintech_dense .setup-row,
body.theme-fintech_dense .guide-card,
body.theme-fintech_dense .form-card {
    background: var(--surface);
    color: var(--text-main);
    border-color: var(--line-soft);
    box-shadow: var(--card-shadow);
}
body.theme-industrial_dark .panel,
body.theme-industrial_dark .metric,
body.theme-industrial_dark .hub-card,
body.theme-industrial_dark .flow-step,
body.theme-industrial_dark .mini-stat,
body.theme-industrial_dark .setup-row,
body.theme-industrial_dark .guide-card,
body.theme-fintech_dense .panel,
body.theme-fintech_dense .metric,
body.theme-fintech_dense .hub-card,
body.theme-fintech_dense .flow-step,
body.theme-fintech_dense .mini-stat,
body.theme-fintech_dense .setup-row,
body.theme-fintech_dense .guide-card,
body.theme-corporate_steel .panel,
body.theme-corporate_steel .metric,
body.theme-corporate_steel .hub-card,
body.theme-corporate_steel .flow-step,
body.theme-corporate_steel .mini-stat,
body.theme-corporate_steel .setup-row,
body.theme-corporate_steel .guide-card,
body.theme-saas_clean .panel,
body.theme-saas_clean .metric,
body.theme-saas_clean .hub-card,
body.theme-saas_clean .flow-step,
body.theme-saas_clean .mini-stat,
body.theme-saas_clean .setup-row,
body.theme-saas_clean .guide-card,
body.theme-nordic_frost .panel,
body.theme-nordic_frost .metric,
body.theme-nordic_frost .hub-card,
body.theme-nordic_frost .flow-step,
body.theme-nordic_frost .mini-stat,
body.theme-nordic_frost .setup-row,
body.theme-nordic_frost .guide-card { border-radius: var(--card-radius); box-shadow: var(--card-shadow); }

body.theme-nordic_frost .panel,
body.theme-nordic_frost .metric,
body.theme-nordic_frost .hub-card,
body.theme-nordic_frost .flow-step,
body.theme-nordic_frost .mini-stat,
body.theme-nordic_frost .setup-row,
body.theme-nordic_frost .guide-card {
    background: var(--surface);
    border-color: rgba(255,255,255,.7);
    backdrop-filter: blur(14px);
}
body.theme-nordic_frost .sidebar { backdrop-filter: blur(20px); }

body.theme-fintech_dense .page { width: min(1680px, calc(100% - 28px)); margin-top: 18px; }
body.theme-fintech_dense .panel,
body.theme-fintech_dense .metric,
body.theme-fintech_dense .hub-card,
body.theme-fintech_dense .flow-step,
body.theme-fintech_dense .mini-stat,
body.theme-fintech_dense .setup-row,
body.theme-fintech_dense .guide-card { padding: 14px; }
body.theme-fintech_dense th,
body.theme-fintech_dense td { padding: 7px 8px; border-bottom-color: var(--line-soft); }
body.theme-fintech_dense .sidebar { width: 244px; flex-basis: 244px; }
body.theme-fintech_dense .side-nav-link { border-radius: 2px; padding: 8px; }
body.theme-fintech_dense .nav-icon { border-radius: 2px; }
body.theme-fintech_dense .metric strong { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

body.theme-corporate_steel .sidebar {
    background: linear-gradient(180deg, #0b2545, #122d4f 58%, #111827);
}
body.theme-corporate_steel .metric { border-top-color: #b45309; }
body.theme-corporate_steel .side-nav-link.active { box-shadow: inset 4px 0 0 #b45309; }
body.theme-corporate_steel .side-nav-link.active .nav-icon { background: #b45309; color: #fff; }

body.theme-saas_clean .sidebar { background: linear-gradient(180deg, #172554, #1d4ed8 72%, #172554); }
body.theme-saas_clean input,
body.theme-saas_clean select,
body.theme-saas_clean textarea { background: #ffffff; }

body.theme-industrial_dark th,
body.theme-industrial_dark td,
body.theme-fintech_dense th,
body.theme-fintech_dense td { border-bottom-color: var(--line-soft); }
body.theme-industrial_dark th,
body.theme-industrial_dark .metric span,
body.theme-industrial_dark .hub-card span,
body.theme-industrial_dark .flow-step span,
body.theme-industrial_dark .mini-stat span,
body.theme-industrial_dark .setup-row span,
body.theme-fintech_dense th,
body.theme-fintech_dense .metric span,
body.theme-fintech_dense .hub-card span,
body.theme-fintech_dense .flow-step span,
body.theme-fintech_dense .mini-stat span,
body.theme-fintech_dense .setup-row span { color: var(--text-muted); }
body.theme-industrial_dark .metric strong,
body.theme-industrial_dark .hub-card strong,
body.theme-industrial_dark .mini-stat strong,
body.theme-industrial_dark .setup-row strong,
body.theme-fintech_dense .metric strong,
body.theme-fintech_dense .hub-card strong,
body.theme-fintech_dense .mini-stat strong,
body.theme-fintech_dense .setup-row strong { color: var(--text-main); }
body.theme-industrial_dark input,
body.theme-industrial_dark select,
body.theme-industrial_dark textarea,
body.theme-fintech_dense input,
body.theme-fintech_dense select,
body.theme-fintech_dense textarea {
    color: var(--text-main);
    background: var(--surface-soft);
    border-color: var(--line-soft);
}

body.effects-none * { transition: none !important; box-shadow: none !important; backdrop-filter: none !important; }
body.effects-subtle .panel,
body.effects-subtle .metric,
body.effects-subtle .hub-card,
body.effects-subtle .guide-card { transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
body.effects-enhanced:not(.display-body)::before {
    content: '';
    pointer-events: none;
    position: fixed;
    inset: 0;
    z-index: -1;
    background: radial-gradient(circle at 80% 6%, color-mix(in srgb, var(--brand-accent) 20%, transparent), transparent 26%), radial-gradient(circle at 8% 92%, color-mix(in srgb, var(--brand-primary) 14%, transparent), transparent 30%);
}
body.effects-enhanced .panel,
body.effects-enhanced .metric,
body.effects-enhanced .hub-card,
body.effects-enhanced .guide-card {
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
body.effects-enhanced .hub-card:hover,
body.effects-enhanced .metric:hover,
body.effects-enhanced .panel:hover {
    transform: translateY(-3px);
    box-shadow: 0 18px 46px rgba(15,23,42,.14);
}
body.effects-enhanced.theme-industrial_dark .hub-card:hover,
body.effects-enhanced.theme-industrial_dark .metric:hover,
body.effects-enhanced.theme-industrial_dark .panel:hover,
body.effects-enhanced.theme-fintech_dense .hub-card:hover,
body.effects-enhanced.theme-fintech_dense .metric:hover,
body.effects-enhanced.theme-fintech_dense .panel:hover {
    box-shadow: 0 18px 46px rgba(0,0,0,.42), 0 0 0 1px color-mix(in srgb, var(--brand-accent) 28%, transparent);
}

/* Patch 012: hover tooltips and contextual field help */
[data-tooltip] { position: relative; }
[data-tooltip]::before,
[data-tooltip]::after {
    position: absolute;
    left: 50%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
    z-index: 9999;
}
[data-tooltip]::before {
    content: '';
    bottom: calc(100% + 4px);
    transform: translate(-50%, 4px);
    border: 7px solid transparent;
    border-top-color: #0f172a;
}
[data-tooltip]::after {
    content: attr(data-tooltip);
    bottom: calc(100% + 17px);
    transform: translate(-50%, 6px);
    width: max-content;
    max-width: min(320px, 80vw);
    padding: 10px 12px;
    border-radius: 12px;
    background: #0f172a;
    color: #fff;
    font-size: .84rem;
    line-height: 1.35;
    font-weight: 750;
    text-align: left;
    white-space: normal;
    box-shadow: 0 14px 34px rgba(15,23,42,.28);
    border: 1px solid rgba(255,255,255,.12);
}
[data-tooltip]:hover::before,
[data-tooltip]:hover::after,
[data-tooltip]:focus-visible::before,
[data-tooltip]:focus-visible::after {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}
.side-nav-link[data-tooltip]::before {
    left: calc(100% + 5px);
    top: 50%;
    bottom: auto;
    transform: translate(-6px, -50%);
    border: 7px solid transparent;
    border-right-color: #0f172a;
}
.side-nav-link[data-tooltip]::after {
    left: calc(100% + 18px);
    top: 50%;
    bottom: auto;
    transform: translate(-6px, -50%);
    max-width: 300px;
}
.side-nav-link[data-tooltip]:hover::before,
.side-nav-link[data-tooltip]:focus-visible::before { transform: translate(0, -50%); }
.side-nav-link[data-tooltip]:hover::after,
.side-nav-link[data-tooltip]:focus-visible::after { transform: translate(0, -50%); }
.tooltip-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 7px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--brand-accent) 26%, #ffffff);
    color: var(--brand-secondary);
    border: 1px solid color-mix(in srgb, var(--brand-accent) 55%, #cbd5e1);
    font-size: .75rem;
    font-weight: 950;
    line-height: 1;
    vertical-align: middle;
    cursor: help;
}
.tooltip-help:hover,
.tooltip-help:focus-visible { outline: none; background: var(--brand-accent); color: #06111f; }
.form-card .helptext.helptext-collapsed {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}
.form-card label { display: flex; align-items: center; gap: 0; }
.hub-card[data-tooltip]::after { min-width: 220px; }
.tooltip-help[data-tooltip] { cursor: help; }
.btn[data-tooltip], .small-btn[data-tooltip], .hub-card[data-tooltip], .side-nav-link[data-tooltip] { cursor: pointer; }
.btn[data-tooltip], .small-btn[data-tooltip] { text-decoration: none; }
body.theme-industrial_dark [data-tooltip]::after,
body.theme-fintech_dense [data-tooltip]::after {
    background: #020617;
    color: #e2e8f0;
    border-color: color-mix(in srgb, var(--brand-accent) 35%, rgba(255,255,255,.14));
    box-shadow: 0 16px 42px rgba(0,0,0,.54);
}
body.theme-industrial_dark [data-tooltip]::before,
body.theme-fintech_dense [data-tooltip]::before { border-top-color: #020617; }
body.theme-industrial_dark .side-nav-link[data-tooltip]::before,
body.theme-fintech_dense .side-nav-link[data-tooltip]::before { border-top-color: transparent; border-right-color: #020617; }
body.theme-industrial_dark .tooltip-help,
body.theme-fintech_dense .tooltip-help {
    background: color-mix(in srgb, var(--brand-accent) 20%, #020617);
    color: var(--text-main);
    border-color: color-mix(in srgb, var(--brand-accent) 45%, var(--line-soft));
}
@media (max-width: 900px) {
    .side-nav-link[data-tooltip]::before,
    .side-nav-link[data-tooltip]::after { display: none; }
}
@media (hover: none) {
    [data-tooltip]::before,
    [data-tooltip]::after { display: none; }
}

/* Patch 013: remove distracting sidebar scrollbars and tidy sales matrix/free-item UI */
html, body { max-width: 100%; overflow-x: hidden; }
.sidebar {
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar { width: 0; height: 0; display: none; }
.side-nav {
    overflow: visible;
    padding-right: 0;
}
.sidebar-brand {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}
.sidebar-brand .logo {
    width: min(178px, 100%);
    height: auto;
    max-height: 58px;
    object-fit: contain;
}
.sidebar-brand div { min-width: 0; }
.sidebar-brand strong,
.sidebar-brand span {
    overflow-wrap: anywhere;
}
.sidebar-footer { padding-bottom: 8px; }
.status-pill.free {
    background: #dcfce7;
    color: #166534;
}
.small-note {
    margin-top: 14px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft, #e2e8f0);
    border-radius: 14px;
    background: var(--surface-soft, #f8fafc);
    color: var(--text-muted, #64748b);
    font-size: .9rem;
    line-height: 1.45;
}
.compact-form textarea {
    min-height: 92px;
}
.compact-form p:has(input[type="checkbox"]) {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 10px;
}
.compact-form p:has(input[type="checkbox"]) label { margin: 0; }
@supports not selector(:has(*)) {
    .compact-form input[type="checkbox"] { width: auto; min-height: auto; }
}
@media (max-height: 760px) and (min-width: 901px) {
    .sidebar { gap: 8px; padding-top: 12px; padding-bottom: 12px; }
    .sidebar-brand .logo { max-height: 46px; }
    .nav-section-label { margin-top: 8px; }
    .side-nav-link { padding-top: 8px; padding-bottom: 8px; }
    .side-nav-link.compact { padding-top: 7px; padding-bottom: 7px; }
}

/* Patch 016: table actions for generated PDFs and CRM email sends */
table .inline-form { display: inline; margin: 0; max-width: none; }
table .link-button { color: var(--brand-primary); background: transparent; border: 0; padding: 0; border-radius: 0; font: inherit; font-weight: 700; cursor: pointer; }
table .link-button:hover { text-decoration: underline; }
