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

html {
    font-size: 15px;
}

body.crm-body {
    margin: 0;
    font-family: var(--font);
    color: var(--ink);
    background:
        radial-gradient(circle at top right, rgba(169, 130, 47, 0.08), transparent 34%),
        var(--paper);
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.crm-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
}

.crm-sidebar {
    background: linear-gradient(180deg, #16140f 0%, var(--sidebar) 48%, #0d0c0a 100%);
    color: var(--sidebar-text);
    padding: 1.1rem 0.9rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 40;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    border-right: 1px solid rgba(230, 208, 168, 0.08);
}

.crm-sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.crm-brand {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    padding: 0.35rem 0.5rem 0.85rem;
    border-bottom: 1px solid rgba(244, 240, 232, 0.1);
}

.crm-brand-mark {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 9px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, var(--champagne), var(--gold));
    color: #111;
    font-weight: 700;
    box-shadow: 0 0 0 1px rgba(230, 208, 168, 0.25);
}

.crm-brand strong {
    display: block;
    font-size: 0.98rem;
    letter-spacing: 0.02em;
}

.crm-brand span {
    display: block;
    color: var(--sidebar-muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.crm-sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(230, 208, 168, 0.12);
}

.crm-user-avatar {
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--champagne);
    font-weight: 700;
    flex-shrink: 0;
}

.crm-user-copy {
    min-width: 0;
    line-height: 1.25;
}

.crm-user-copy strong {
    display: block;
    font-size: 0.9rem;
}

.crm-user-copy span {
    display: block;
    color: var(--sidebar-muted);
    font-size: 0.72rem;
}

.crm-user-email {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.crm-nav {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-top: 0.15rem;
}

.crm-nav-link {
    padding: 0.62rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-muted);
    font-weight: 500;
}

.crm-nav-link:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--sidebar-text);
}

.crm-nav-link.is-active {
    background: rgba(169, 130, 47, 0.24);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--gold);
}

.crm-sidebar-footer {
    margin-top: auto;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(244, 240, 232, 0.1);
}

.crm-logout-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0.7rem 0.85rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(230, 208, 168, 0.18);
    color: var(--champagne);
    font-weight: 600;
    background: transparent;
}

.crm-logout-btn:hover {
    background: rgba(169, 130, 47, 0.16);
    color: #fff;
}

.crm-main {
    min-width: 0;
}

.crm-topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
}

.crm-topbar-title {
    min-width: 0;
    line-height: 1.2;
}

.crm-topbar-title strong {
    display: block;
    font-size: 0.95rem;
}

.crm-topbar-title span {
    display: block;
    color: var(--ink-soft);
    font-size: 0.75rem;
}

.crm-top-search {
    flex: 1;
    max-width: 28rem;
    margin-left: auto;
}

.crm-top-search input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.55rem 1rem;
    background: var(--paper);
}

.crm-content {
    padding: 1.5rem;
}

.crm-icon-btn {
    display: none;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--radius-sm);
    width: 2.25rem;
    height: 2.25rem;
    cursor: pointer;
}

.crm-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(17, 16, 14, 0.45);
    z-index: 35;
}

@media (max-width: 960px) {
    .crm-shell {
        grid-template-columns: 1fr;
    }

    .crm-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform 200ms ease;
        width: min(300px, 88vw);
    }

    .crm-shell.sidebar-open .crm-sidebar {
        transform: translateX(0);
    }

    .crm-icon-btn {
        display: inline-grid;
        place-items: center;
    }

    .crm-topbar-title span {
        display: none;
    }
}
