:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-strong: #f2f2f2;
    --border: #e6e6e6;
    --text: #000000;
    --muted: #00000080;
    --primary: #000000;
    --primary-dark: #2b2b2b;
    --accent: #000000;
    --success: #4a7c59;
    --shadow: 0 12px 32px rgba(0, 0, 0, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Poppins", sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: var(--primary);
}

.eyebrow {
    color: var(--muted);
    font-size: .78rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    font-weight: 700;
}

.auth-shell {
    position: relative;
    min-height: 100vh;
    overflow: hidden;
}

.auth-gradient {
    position: absolute;
    inset: 0;
    background: #ffffff;
}

.auth-shell .container {
    position: relative;
    z-index: 1;
}

.auth-card,
.info-card,
.metric-card,
.hero-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.auth-card {
    padding: 2rem;
}

.auth-brand-logo {
    height: 34px;
    width: auto;
    display: block;
}

.auth-alert {
    max-width: 640px;
    margin: 2rem auto 0;
}

.form-control,
.form-select {
    min-height: 48px;
    border-color: var(--border);
    background: #ffffff;
    border-radius: 4px;
}

.form-control:focus,
.form-select:focus {
    border-color: #000000;
    box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.08);
}

.btn {
    border-radius: 4px;
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

.sidebar {
    width: 280px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 1040;
    transition: transform .25s ease;
    display: flex;
    flex-direction: column;
}

.sidebar nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.25) transparent;
}

.sidebar nav::-webkit-scrollbar {
    width: 6px;
}

.sidebar nav::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-brand-logo {
    height: 30px;
    width: auto;
    display: block;
}

.brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
}

.brand-mark img {
    width: 26px;
    height: auto;
    display: block;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .8rem;
    text-decoration: none;
    color: var(--text);
    padding: .8rem 1rem;
    border-radius: 8px;
    margin-bottom: .3rem;
    transition: background-color .2s ease, color .2s ease, transform .2s ease;
}

.sidebar-section {
    padding-top: .75rem;
}

.sidebar-section + .sidebar-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 0 .45rem 0;
    padding: .25rem .5rem .25rem .75rem;
    background: none;
    border: 0;
    cursor: pointer;
    color: var(--muted);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    border-radius: 6px;
}

.sidebar-section-title:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.04);
}

.sidebar-section-title .bi {
    font-size: .7rem;
    transition: transform .2s ease;
}

.sidebar-section.is-collapsed .sidebar-section-title .bi {
    transform: rotate(-90deg);
}

.sidebar-section.is-collapsed .sidebar-section-links {
    display: none;
}

.sidebar-link:hover,
.sidebar-link.active {
    background: #000000;
    color: #ffffff;
    transform: translateX(2px);
}

.sidebar-link.disabled {
    opacity: .65;
    pointer-events: none;
}

.sidebar-link small {
    margin-left: auto;
    color: var(--muted);
}

.sidebar-link:hover small,
.sidebar-link.active small {
    color: rgba(255, 255, 255, 0.7);
}

.app-content {
    flex: 1;
    min-width: 0;
    max-width: calc(100vw - 280px);
    margin-left: 280px;
}

.app-content main {
    min-width: 0;
    max-width: 100%;
    overflow-x: hidden;
}

.topbar {
    background: transparent;
}

.sidebar-toggle {
    color: var(--primary);
}

.hero-panel {
    padding: 1.75rem;
}

.metric-card {
    padding: 1.5rem;
}

.metric-card-link {
    display: block;
    height: 100%;
    color: inherit;
    text-decoration: none;
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.metric-card-link:hover,
.metric-card-link:focus {
    color: inherit;
    transform: translateY(-2px);
    border-color: #000000;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.1);
}

.metric-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: white;
    background: var(--primary);
    margin-bottom: 1rem;
}

.metric-value {
    font-size: 2rem;
    font-weight: 700;
}

.metric-label {
    color: var(--muted);
}

.info-card {
    padding: 1.5rem;
}

.info-card.soft {
    background: var(--surface-strong);
}

.entity-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 1rem;
    padding: .45rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.entity-tab {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .62rem .9rem;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: 6px;
    font-weight: 700;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.entity-tab:hover {
    color: var(--text);
    background: rgba(0, 0, 0, 0.05);
}

.entity-tab.active {
    color: #ffffff;
    background: #000000;
    transform: translateY(-1px);
}

.list-grid {
    display: grid;
    gap: .85rem;
}

.list-grid div {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.list-grid i {
    color: var(--success);
}

.next-steps {
    padding-left: 1rem;
    color: var(--muted);
}

.dashboard-task-list {
    display: grid;
    gap: .75rem;
}

.dashboard-task-item {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    text-decoration: none;
    transition: transform .2s ease, border-color .2s ease, background-color .2s ease;
}

.dashboard-task-item:hover {
    transform: translateY(-1px);
    border-color: #000000;
    background: #ffffff;
}

.dashboard-task-item.is-overdue {
    border-color: rgba(214, 69, 69, 0.5);
    background: #fff7f5;
    box-shadow: inset 4px 0 0 rgba(214, 69, 69, 0.82);
}

.optional-panel summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    cursor: pointer;
    list-style: none;
}

.optional-panel summary::-webkit-details-marker {
    display: none;
}

.optional-panel summary span {
    display: grid;
    gap: .15rem;
}

.optional-panel summary small {
    color: var(--muted);
}

.calendar-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--muted);
    font-size: .9rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .65rem;
}

.calendar-weekday {
    padding: .5rem;
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-align: center;
    text-transform: uppercase;
}

.calendar-day {
    min-height: 170px;
    padding: .7rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.calendar-day.is-outside {
    opacity: .48;
    background: var(--surface-strong);
}

.calendar-day.is-today {
    border-color: #000000;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.06);
}

.calendar-day.is-drop-target {
    border-color: #000000;
    box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.1), 0 14px 32px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.calendar-day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    margin-bottom: .45rem;
    border-radius: 999px;
    color: var(--text);
    font-weight: 800;
}

.calendar-day-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: .5rem;
    margin-bottom: .45rem;
}

.calendar-day-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    opacity: .3;
    transition: opacity .2s ease;
}

.calendar-day:hover .calendar-day-actions,
.calendar-day:focus-within .calendar-day-actions {
    opacity: 1;
}

.calendar-day-actions a {
    padding: .18rem .42rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #ffffff;
    color: var(--text);
    font-size: .68rem;
    font-weight: 700;
    text-decoration: none;
}

.calendar-day-actions a:hover {
    background: #000000;
    color: #ffffff;
}

.calendar-day.is-today .calendar-day-number {
    background: var(--primary);
    color: white;
}

.calendar-events {
    display: grid;
    gap: .4rem;
}

.calendar-event {
    display: grid;
    gap: .12rem;
    padding: .48rem .55rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: .78rem;
    line-height: 1.25;
    text-decoration: none;
    cursor: grab;
    transition: border-color .18s ease, background .18s ease, opacity .18s ease, transform .18s ease;
}

.calendar-event:hover {
    border-color: #000000;
    background: #ffffff;
    transform: translateY(-1px);
}

.calendar-event:active {
    cursor: grabbing;
}

.calendar-event.is-dragging {
    opacity: .55;
}

.calendar-event.is-lead {
    background: #f2f6f7;
}

.calendar-event.is-overdue {
    border-color: rgba(214, 69, 69, 0.45);
    background: #fff5f2;
}

.calendar-event-head {
    display: flex;
    align-items: center;
    gap: .35rem;
}

.calendar-event small {
    color: var(--muted);
}

.calendar-more-link {
    display: inline-flex;
    justify-content: center;
    padding: .42rem .55rem;
    border: 1px dashed rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    background: #ffffff;
    color: var(--text);
    font-size: .76rem;
    font-weight: 700;
    text-decoration: none;
}

.calendar-more-link:hover {
    background: rgba(0, 0, 0, 0.06);
}

.calendar-dot {
    width: .55rem;
    height: .55rem;
    display: inline-block;
    border-radius: 999px;
    background: var(--primary);
    margin-right: .25rem;
}

.calendar-dot.is-task {
    background: #000000;
}

.calendar-dot.is-lead {
    background: #4f7c8a;
}

.calendar-dot.is-overdue {
    background: #d64545;
}

.users-table th {
    font-size: .82rem;
    letter-spacing: .04em;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom-color: var(--border);
}

.users-table td {
    background: transparent;
    border-bottom-color: var(--border);
}

.kanban-hint {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: .55rem .8rem;
    color: var(--muted);
    font-size: .9rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.kanban-frame {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding: .75rem;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow);
}

.kanban-frame-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
    display: block;
    overflow-x: auto;
    overflow-y: hidden;
    padding: .1rem .1rem .9rem;
    scroll-snap-type: x proximity;
    scrollbar-color: rgba(0, 0, 0, 0.3) var(--surface-strong);
    scrollbar-width: thin;
}

.kanban-frame-scroll::-webkit-scrollbar {
    height: .7rem;
}

.kanban-frame-scroll::-webkit-scrollbar-track {
    background: var(--surface-strong);
    border-radius: 999px;
}

.kanban-frame-scroll::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid var(--surface);
    border-radius: 999px;
}

.kanban-board {
    display: inline-flex;
    width: auto;
    min-width: 100%;
    gap: 1rem;
}

.kanban-column {
    flex: 0 0 320px;
    width: 320px;
    min-height: 520px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: none;
    scroll-snap-align: start;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.kanban-column.is-drop-target {
    border-color: #000000;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

.kanban-column-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem;
    border-top: .35rem solid var(--accent);
    border-radius: 10px 10px 0 0;
    border-bottom: 1px solid var(--border);
}

.kanban-column-title {
    color: var(--text);
    font-weight: 700;
    line-height: 1.25;
}

.kanban-column-amount {
    white-space: nowrap;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

.kanban-column-body {
    display: flex;
    flex-direction: column;
    gap: .85rem;
    padding: 1rem;
}

.kanban-card {
    display: block;
    padding: 1rem;
    color: inherit;
    text-decoration: none;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    cursor: grab;
}

.kanban-card:hover,
.kanban-card:focus {
    color: inherit;
    transform: translateY(-2px);
    border-color: #000000;
    box-shadow: 0 12px 26px rgba(0, 0, 0, 0.1);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.is-dragging {
    opacity: .55;
    transform: rotate(1deg) scale(.98);
}

.kanban-card-title {
    color: var(--text);
    font-weight: 700;
    line-height: 1.25;
}

.kanban-card-meta {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    color: var(--muted);
    font-size: .86rem;
}

.kanban-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-top: .85rem;
    padding-top: .75rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: .86rem;
}

.kanban-card-footer strong {
    color: var(--text);
}

.kanban-priority {
    width: .72rem;
    height: .72rem;
    flex: 0 0 .72rem;
    margin-top: .25rem;
    border-radius: 999px;
    background: #adb5bd;
    box-shadow: 0 0 0 .25rem rgba(173, 181, 189, 0.18);
}

.kanban-priority-low {
    background: #6c9f6f;
    box-shadow: 0 0 0 .25rem rgba(108, 159, 111, 0.16);
}

.kanban-priority-medium {
    background: #c8a14a;
    box-shadow: 0 0 0 .25rem rgba(200, 161, 74, 0.18);
}

.kanban-priority-high {
    background: #d47b45;
    box-shadow: 0 0 0 .25rem rgba(212, 123, 69, 0.18);
}

.kanban-priority-urgent {
    background: #c84f4f;
    box-shadow: 0 0 0 .25rem rgba(200, 79, 79, 0.18);
}

.kanban-empty {
    padding: 1rem;
    color: var(--muted);
    font-size: .9rem;
    text-align: center;
    border: 1px dashed rgba(0, 0, 0, 0.25);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.6);
}

.color-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    min-width: 120px;
    padding: .42rem .7rem;
    border: 2px solid var(--primary);
    border-radius: 6px;
    color: var(--text);
    font-size: .82rem;
    font-weight: 700;
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.2);
}

.color-pill::before {
    content: "";
    width: .65rem;
    height: .65rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid rgba(0, 0, 0, 0.18);
}

.color-pill.is-stage {
    font-weight: 600;
    border-style: solid;
    box-shadow: inset 0 0 0 999px rgba(255, 255, 255, 0.06);
}

.color-dot {
    --dot-color: var(--primary);
    width: .72rem;
    height: .72rem;
    display: inline-block;
    border-radius: 999px;
    background: var(--dot-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot-color) 18%, transparent);
    margin-right: .35rem;
    vertical-align: -1px;
}

.user-stage-option-hidden {
    display: none !important;
}

.user-form-grid {
    display: grid;
    gap: 1.25rem;
}

.role-grid {
    display: grid;
    gap: .9rem;
}

.role-option {
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    padding: 1rem 1.1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
}

.role-option input {
    margin-top: .25rem;
}

.role-option-body {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.audit-details summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
}

.audit-json pre {
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .85rem;
    margin-bottom: .75rem;
    font-size: .78rem;
    color: var(--text);
}

.autocomplete-field {
    position: relative;
}

.autocomplete-results {
    position: absolute;
    z-index: 1050;
    inset: calc(100% + .35rem) 0 auto 0;
    max-height: 280px;
    overflow-y: auto;
    padding: .45rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.autocomplete-item,
.autocomplete-empty {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    padding: .75rem .85rem;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    text-align: left;
}

.autocomplete-item:hover,
.autocomplete-item:focus {
    background: rgba(0, 0, 0, 0.06);
}

.autocomplete-item span,
.autocomplete-empty {
    color: var(--muted);
    font-size: .86rem;
}

.selected-items-grid {
    display: flex;
    flex-wrap: wrap;
    gap: .65rem;
}

.selected-item {
    display: inline-flex;
    align-items: center;
    gap: .75rem;
    padding: .65rem .8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.selected-item span {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.selected-item small {
    color: var(--muted);
}

.selected-item button {
    width: 26px;
    height: 26px;
    border: 0;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    color: var(--text);
    line-height: 1;
}

.selection-summary {
    margin-top: .75rem;
    padding: .85rem 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface-strong);
}

.rich-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .5rem;
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 10px 10px 0 0;
    background: var(--surface-strong);
}

.rich-editor-toolbar button {
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    padding: .35rem .65rem;
}

.rich-editor {
    min-height: 150px;
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 0 0 10px 10px;
    background: #ffffff;
    outline: none;
}

.rich-editor:focus {
    border-color: #000000;
    box-shadow: 0 0 0 0.25rem rgba(0, 0, 0, 0.08);
}

.lead-timeline {
    display: grid;
    gap: 1rem;
}

.lead-timeline-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.lead-timeline-item.is-system {
    background: var(--surface-strong);
}

.lead-note-content {
    color: var(--text);
}

.lead-note-content p:last-child,
.lead-note-content ul:last-child,
.lead-note-content ol:last-child {
    margin-bottom: 0;
}

.lead-note-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
        box-shadow: 0 0 44px rgba(0, 0, 0, 0.28);
    }

    .app-content {
        margin-left: 0;
        max-width: 100vw;
    }

    .calendar-grid {
        grid-template-columns: 1fr;
    }

    .calendar-weekday {
        display: none;
    }

    .calendar-day {
        min-height: auto;
    }
}
