/* =============================================================================
   CommonCRM — "Aurora" theme.

   The product's own look, layered on top of site.css. site.css reproduced the
   palette of a commercial CRM template (vermilion on a white rail); this file gives
   CommonCRM an identity of its own:

     - a midnight-ink sidebar with a soft aurora glow, instead of a white rail;
     - electric violet as the one strong colour, teal beside it as the second;
     - softer geometry — 10–16px corners, layered shadows with a violet cast;
     - a frosted top bar, lifted interactive cards, pill badges.

   It changes tokens first and rules second, so everything site.css already styles
   through the tokens — buttons, fields, tables, badges, alerts — follows without a
   markup change. Loaded after site.css and *before* the tenant branding partial,
   so a tenant that picked its own colours still gets them.

   Removing the <link> to this file restores the previous look exactly.
   ========================================================================== */

:root {
    /* -- surfaces: a cool lavender-grey canvas under white cards -- */
    --crm-canvas: #f4f5fa;
    --crm-surface: #ffffff;
    --crm-surface-2: #f7f7fc;
    --crm-surface-3: #eff0f8;

    /* -- ink: a blue-black, not a neutral grey -- */
    --crm-ink: #171a2c;
    --crm-ink-2: #4f5468;
    --crm-muted: #6b7086;
    --crm-faint: #9196ab;

    --crm-border: #e6e7f1;
    --crm-border-strong: #cfd1e2;
    --crm-border-soft: #eeeff6;

    /* -- electric violet: action and accent -- */
    --crm-action: #5b3df5;
    --crm-action-hover: #4a2ee0;
    --crm-action-ink: #ffffff;
    --crm-accent: #5b3df5;
    --crm-accent-hover: #4a2ee0;
    --crm-accent-ink: #4528d6;
    --crm-accent-soft: #efebff;
    --crm-accent-soft-2: #ddd4ff;
    --crm-accent-ring: rgba(91, 61, 245, 0.2);
    --crm-accent-glow: 0 0.35rem 1rem -0.35rem rgba(91, 61, 245, 0.55);

    /* -- teal: the second colour (site.css calls it "gold") -- */
    --crm-gold: #0fb5a6;
    --crm-gold-hover: #0c9a8d;
    --crm-gold-soft: #e3f8f5;

    --crm-field-border: #dfe1ee;
    --crm-field-border-hover: #c6c9de;
    --crm-field-border-focus: #5b3df5;
    --crm-field-ring: rgba(91, 61, 245, 0.16);

    /* -- the midnight rail -- */
    --crm-sidebar-bg: #13142b;
    --crm-sidebar-bg-2: #1c1e3d;
    --crm-sidebar-ink: #a8acc8;
    --crm-sidebar-ink-strong: #ffffff;
    --crm-sidebar-ink-faint: #7b80a3;
    --crm-sidebar-hover: rgba(255, 255, 255, 0.06);
    --crm-sidebar-active-bg: rgba(255, 255, 255, 0.08);
    --crm-sidebar-line: rgba(255, 255, 255, 0.07);
    --crm-sidebar-rail: #2dd4bf;
    --crm-sidebar-icon-bg: rgba(255, 255, 255, 0.06);
    --crm-sidebar-icon-ink: #c3c6de;

    /* -- softer geometry -- */
    --crm-radius-sm: 8px;
    --crm-radius: 10px;
    --crm-radius-lg: 14px;
    --crm-radius-xl: 18px;

    --crm-shadow-xs: 0 1px 2px rgba(23, 26, 44, 0.05);
    --crm-shadow-sm: 0 1px 2px rgba(23, 26, 44, 0.04), 0 4px 14px -6px rgba(60, 50, 140, 0.12);
    --crm-shadow: 0 2px 4px rgba(23, 26, 44, 0.04), 0 10px 28px -10px rgba(60, 50, 140, 0.2);
    --crm-shadow-lg: 0 4px 8px rgba(23, 26, 44, 0.05), 0 24px 56px -18px rgba(60, 50, 140, 0.28);

    --crm-aurora: radial-gradient(120% 60% at 0% 0%, rgba(91, 61, 245, 0.35) 0%, transparent 55%),
                  radial-gradient(90% 50% at 100% 10%, rgba(45, 212, 191, 0.18) 0%, transparent 60%);
}

/* ---------- dark ---------- */

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --crm-canvas: #0b0c18;
        --crm-surface: #12142a;
        --crm-surface-2: #171a33;
        --crm-surface-3: #1d2040;
        --crm-ink: #e4e5f5;
        --crm-ink-2: #b2b5cf;
        --crm-muted: #8f93b1;
        --crm-faint: #6f7392;
        --crm-border: #23264a;
        --crm-border-strong: #31355f;
        --crm-border-soft: #1b1e3b;
        --crm-action: #6e52ff;
        --crm-action-hover: #8169ff;
        --crm-accent: #9a86ff;
        --crm-accent-hover: #ae9eff;
        --crm-accent-ink: #b3a5ff;
        --crm-accent-soft: rgba(110, 82, 255, 0.18);
        --crm-accent-soft-2: rgba(110, 82, 255, 0.32);
        --crm-accent-ring: rgba(110, 82, 255, 0.45);
        --crm-gold: #2dd4bf;
        --crm-gold-soft: rgba(45, 212, 191, 0.16);
        --crm-field-border-focus: #8169ff;
        --crm-sidebar-bg: #090a17;
        --crm-sidebar-bg-2: #111329;
        --crm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px -8px rgba(0, 0, 0, 0.6);
        --crm-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 30px -10px rgba(0, 0, 0, 0.7);
    }
}

:root[data-theme="dark"] {
    --crm-canvas: #0b0c18;
    --crm-surface: #12142a;
    --crm-surface-2: #171a33;
    --crm-surface-3: #1d2040;
    --crm-ink: #e4e5f5;
    --crm-ink-2: #b2b5cf;
    --crm-muted: #8f93b1;
    --crm-faint: #6f7392;
    --crm-border: #23264a;
    --crm-border-strong: #31355f;
    --crm-border-soft: #1b1e3b;
    --crm-action: #6e52ff;
    --crm-action-hover: #8169ff;
    --crm-accent: #9a86ff;
    --crm-accent-hover: #ae9eff;
    --crm-accent-ink: #b3a5ff;
    --crm-accent-soft: rgba(110, 82, 255, 0.18);
    --crm-accent-soft-2: rgba(110, 82, 255, 0.32);
    --crm-accent-ring: rgba(110, 82, 255, 0.45);
    --crm-gold: #2dd4bf;
    --crm-gold-soft: rgba(45, 212, 191, 0.16);
    --crm-field-border-focus: #8169ff;
    --crm-sidebar-bg: #090a17;
    --crm-sidebar-bg-2: #111329;
    --crm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 18px -8px rgba(0, 0, 0, 0.6);
    --crm-shadow: 0 2px 4px rgba(0, 0, 0, 0.4), 0 12px 30px -10px rgba(0, 0, 0, 0.7);
}

/* ---------- canvas ---------- */

body.crm-app {
    background:
        radial-gradient(60rem 30rem at 100% -10%, color-mix(in srgb, var(--crm-action) 7%, transparent), transparent 70%),
        var(--crm-canvas);
    background-attachment: fixed;
}

/* ---------- sidebar: the midnight rail ---------- */

.crm-sidebar {
    background: var(--crm-aurora), linear-gradient(180deg, var(--crm-sidebar-bg) 0%, var(--crm-sidebar-bg-2) 100%);
    border-right: none;
    box-shadow: 1px 0 0 var(--crm-sidebar-line), 6px 0 24px -12px rgba(19, 20, 43, 0.35);
}

.crm-brand {
    background: transparent;
    border-bottom-color: var(--crm-sidebar-line);
    padding: 1.15rem 1.15rem 1.05rem;
}

.crm-brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: conic-gradient(from 210deg, #5b3df5, #2dd4bf, #8b5cf6, #5b3df5);
    font-size: 1.05rem;
    letter-spacing: 0;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14) inset, 0 8px 20px -8px rgba(91, 61, 245, 0.8);
}

.crm-brand-text strong {
    font-weight: 700;
    letter-spacing: -0.02em;
}

.crm-brand-text span {
    color: var(--crm-sidebar-rail);
    font-weight: 600;
}

.crm-nav {
    padding: 0.75rem 0.7rem 2rem;
}

/* Entries are soft pills; the icon sits bare, without a tile, so the rail reads as
   one calm column on the dark ground. */
.crm-nav-link {
    border-radius: var(--crm-radius);
    padding: 0.5rem 0.7rem;
    margin: 0.12rem 0;
    font-weight: 500;
}

.crm-nav-link .crm-icon {
    padding: 0;
    background: transparent;
    color: var(--crm-sidebar-icon-ink);
    opacity: 0.85;
}

.crm-nav-link:hover,
.crm-nav-link:focus-visible {
    background: var(--crm-sidebar-hover);
    color: var(--crm-sidebar-ink-strong);
}

.crm-nav-link:hover .crm-icon,
.crm-nav-link:focus-visible .crm-icon {
    background: transparent;
    color: var(--crm-sidebar-ink-strong);
    opacity: 1;
}

/* The active entry is a filled pill in the brand colour. Filled — not tinted — so it
   reads on the dark rail and on whatever sidebar colour a tenant picks: the brand
   fill and its ink are always a readable pair. */
.crm-nav-link.active {
    background: linear-gradient(135deg, var(--crm-action), color-mix(in srgb, var(--crm-action) 72%, #2dd4bf));
    color: var(--crm-action-ink);
    font-weight: 600;
    box-shadow: 0 8px 18px -10px color-mix(in srgb, var(--crm-action) 85%, transparent);
}

.crm-nav-link.active::before {
    display: none;
}

.crm-nav-link.active .crm-icon {
    background: transparent;
    color: var(--crm-action-ink);
    opacity: 1;
}

.crm-nav-group {
    margin-top: 1.2rem;
}

.crm-nav-group-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--crm-sidebar-ink-faint);
    padding: 0.4rem 0.7rem 0.35rem;
}

.crm-nav-group-title .crm-icon {
    display: none;
}

.crm-nav-group.is-active > .crm-nav-group-title {
    color: var(--crm-sidebar-rail);
}

.crm-nav-group.is-active > ul {
    box-shadow: none;
}

.crm-nav-sublink {
    padding-left: 0.7rem;
}

.crm-nav-badge {
    background: rgba(45, 212, 191, 0.14);
    color: var(--crm-sidebar-rail);
    border-color: transparent;
}

/* The rail scrolls on long menus; a thin, dark thumb rather than the system bar. */
.crm-sidebar::-webkit-scrollbar { width: 8px; }
.crm-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

/* ---------- topbar: frosted ---------- */

.crm-topbar {
    background: color-mix(in srgb, var(--crm-surface) 72%, transparent);
    border-bottom: 1px solid color-mix(in srgb, var(--crm-border) 70%, transparent);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.4) inset;
}

.crm-icon-btn {
    border-radius: 12px;
}

/* ---------- page header ---------- */

.crm-page-intro h2 {
    font-size: 1.55rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    color: var(--crm-ink);
    display: inline-block;
    position: relative;
    padding-bottom: 0.35rem;
}

/* A short aurora underline under every page title: the product's signature. */
.crm-page-intro h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 2.25rem;
    height: 3px;
    border-radius: 3px;
    background: linear-gradient(90deg, var(--crm-action), #2dd4bf);
}

/* ---------- cards ---------- */

.crm-card {
    border-color: var(--crm-border-soft);
    border-radius: var(--crm-radius-lg);
    box-shadow: var(--crm-shadow-sm);
}

.crm-card-title {
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* A card that is a link lifts when pointed at, so it reads as something to press. */
a.crm-card {
    transition: transform var(--crm-medium) var(--crm-ease),
                box-shadow var(--crm-medium) var(--crm-ease),
                border-color var(--crm-medium) var(--crm-ease);
}

a.crm-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--crm-shadow);
    border-color: var(--crm-accent-soft-2);
}

/* ---------- buttons ---------- */

.btn {
    border-radius: var(--crm-radius);
    font-weight: 600;
}

.btn-primary {
    background-image: linear-gradient(135deg, var(--crm-action), color-mix(in srgb, var(--crm-action) 80%, #8b5cf6));
    border-color: transparent;
    box-shadow: var(--crm-accent-glow);
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background-image: linear-gradient(135deg, var(--crm-action-hover), var(--crm-action-hover));
}

.btn-sm {
    border-radius: var(--crm-radius-sm);
}

/* ---------- fields ---------- */

.form-control,
.form-select {
    border-radius: var(--crm-radius);
}

/* ---------- tables ---------- */

.table > thead th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--crm-muted);
    background: var(--crm-surface-2);
}

.table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: color-mix(in srgb, var(--crm-action) 4%, transparent);
}

/* ---------- badges, tabs, pager ---------- */

.badge {
    border-radius: 999px;
    font-weight: 600;
    padding: 0.35em 0.7em;
}

.nav-tabs {
    border-bottom-color: var(--crm-border);
    gap: 0.25rem;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    color: var(--crm-muted);
    font-weight: 600;
}

.nav-tabs .nav-link.active {
    background: transparent;
    color: var(--crm-accent-ink);
    border-bottom-color: var(--crm-action);
}

.progress-bar {
    background-image: linear-gradient(90deg, var(--crm-action), #2dd4bf);
}

/* ---------- dashboard hero ---------- */

.crm-hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--crm-radius-xl);
    padding: 1.6rem 1.75rem;
    margin-bottom: 1.5rem;
    color: #ffffff;
    background:
        radial-gradient(70% 120% at 100% 0%, rgba(45, 212, 191, 0.45) 0%, transparent 60%),
        radial-gradient(60% 120% at 0% 100%, rgba(139, 92, 246, 0.55) 0%, transparent 60%),
        linear-gradient(135deg, #1c1747 0%, #3a24b8 55%, #5b3df5 100%);
    box-shadow: var(--crm-shadow-lg);
}

.crm-hero::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px);
    background-size: 18px 18px;
    mask-image: linear-gradient(90deg, transparent 30%, #000 100%);
    pointer-events: none;
}

.crm-hero > * {
    position: relative;
    z-index: 1;
}

.crm-hero-date {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    opacity: 0.75;
}

.crm-hero h2 {
    font-size: 1.7rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    margin: 0.3rem 0 0.35rem;
}

.crm-hero p {
    opacity: 0.85;
    margin-bottom: 1.1rem;
    max-width: 60ch;
}

.crm-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.crm-hero-action {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.22);
    color: #ffffff;
    text-decoration: none;
    font-size: 0.86rem;
    font-weight: 600;
    backdrop-filter: blur(6px);
    transition: background-color var(--crm-fast) var(--crm-ease), transform var(--crm-fast) var(--crm-ease);
}

.crm-hero-action:hover {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
    transform: translateY(-1px);
}

.crm-hero-action .crm-icon {
    width: 16px;
    height: 16px;
}

/* ---------- stat tiles on the dashboard ---------- */

.crm-stat {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.crm-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    flex: 0 0 auto;
    color: #ffffff;
    background: linear-gradient(135deg, var(--crm-action), #8b5cf6);
    box-shadow: 0 8px 18px -10px var(--crm-action);
}

.crm-stat-icon.is-teal { background: linear-gradient(135deg, #0fb5a6, #2dd4bf); box-shadow: 0 8px 18px -10px #0fb5a6; }
.crm-stat-icon.is-amber { background: linear-gradient(135deg, #f59e0b, #fbbf24); box-shadow: 0 8px 18px -10px #f59e0b; }
.crm-stat-icon.is-rose { background: linear-gradient(135deg, #e11d74, #f472b6); box-shadow: 0 8px 18px -10px #e11d74; }

.crm-stat-icon .crm-icon {
    width: 20px;
    height: 20px;
}

.crm-stat-label {
    display: block;
    font-size: 0.78rem;
    color: var(--crm-muted);
    font-weight: 600;
}

.crm-stat-value {
    display: block;
    font-size: 1.6rem;
    font-weight: 750;
    letter-spacing: -0.03em;
    line-height: 1.15;
    color: var(--crm-ink);
}

/* ---------- motion ---------- */

@media (prefers-reduced-motion: reduce) {
    a.crm-card,
    .crm-hero-action {
        transition: none;
    }

    a.crm-card:hover,
    .crm-hero-action:hover {
        transform: none;
    }
}

/* ---------- sign-in panel ---------- */

/* The same midnight-to-violet sky as the dashboard hero, so the first screen
   and the first page after it read as one product. */
.crm-auth-aside {
    background:
        radial-gradient(60% 50% at 85% 10%, rgba(45, 212, 191, 0.35) 0%, transparent 70%),
        linear-gradient(160deg, #13142b 0%, #2a1f7a 55%, #5b3df5 100%);
    color: rgba(255, 255, 255, 0.86);
}

.crm-auth-aside::before {
    background: rgba(139, 92, 246, 0.45);
}

.crm-auth-aside::after {
    background: rgba(45, 212, 191, 0.35);
}

.crm-auth-aside h2 {
    background: linear-gradient(90deg, #ffffff 0%, #c4b5fd 60%, #5eead4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.crm-auth-points .crm-icon {
    color: #5eead4;
}
