:root {
    color-scheme: light;
    --ink: #17152d;
    --muted: #727089;
    --line: #ebeaf5;
    --soft: #f8f7ff;
    --accent: #4d3df4;
    --accent-strong: #272078;
    --accent-teal: #20c9ba;
    --accent-pink: #ef4b8b;
    --accent-orange: #ffb347;
    --nav: #1f1a5f;
    --danger: #c7364f;
    --shadow: 0 18px 46px rgba(38, 34, 95, 0.1);
    --shadow-soft: 0 8px 24px rgba(38, 34, 95, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: #f7f7fd;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

@media (min-width: 901px) {
    body {
        padding-left: 260px;
    }
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.brand {
    color: var(--accent-strong);
    font-size: 1.2rem;
    font-weight: 800;
    line-height: 1.18;
    text-decoration: none;
    overflow-wrap: anywhere;
}

.brand::after {
    content: "";
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-left: 6px;
    border-radius: 999px;
    background: linear-gradient(135deg, var(--accent-teal), var(--accent));
}

.menu-toggle {
    display: none;
}

nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px;
}

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

nav a {
    color: var(--ink);
    text-decoration: none;
}

.nav-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    margin-left: 8px;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--accent-pink);
    color: #ffffff;
    font-size: 0.78rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 18px rgba(239, 75, 139, 0.24);
}

nav a:hover,
nav a:focus {
    color: var(--accent);
}

.nav-item {
    position: relative;
}

.has-submenu > a::after {
    content: "";
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 7px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--muted);
    vertical-align: middle;
}

.submenu {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    z-index: 10;
    display: none;
    min-width: 170px;
    padding: 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.submenu::before {
    content: "";
    position: absolute;
    top: -11px;
    left: 0;
    width: 100%;
    height: 11px;
}

.submenu a {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    white-space: nowrap;
}

.submenu a:hover,
.submenu a:focus {
    background: var(--soft);
}

.has-submenu:hover .submenu,
.has-submenu:focus-within .submenu {
    display: block;
}

@media (min-width: 901px) {
    .topbar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        width: 260px;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 42px;
        padding: 36px 24px 28px;
        border: 0;
        background: var(--nav);
        box-shadow: 12px 0 32px rgba(31, 26, 95, 0.14);
    }

    .brand {
        color: #ffffff;
        font-size: 1.22rem;
        max-width: 100%;
    }

    nav {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    nav a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 44px;
        padding: 10px 14px;
        border-radius: 999px;
        color: #e9e7ff;
    }

    .nav-badge {
        margin-left: auto;
        background: #ffffff;
        color: var(--accent-strong);
        box-shadow: none;
    }

    nav a:hover,
    nav a:focus {
        color: #ffffff;
        background: rgba(77, 61, 244, 0.85);
    }

    .has-submenu > a::after {
        margin-left: auto;
        border-top-color: #bfbaff;
    }

    .submenu {
        top: 0;
        left: calc(100% + 12px);
        min-width: 210px;
        border: 0;
    }

    .submenu::before {
        top: 0;
        left: -12px;
        width: 12px;
        height: 100%;
    }

    .submenu a {
        color: var(--ink);
    }

    .submenu a:hover,
    .submenu a:focus {
        color: var(--accent);
        background: var(--soft);
    }
}

main {
    width: min(1360px, calc(100% - 48px));
    margin: 42px auto 64px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.grid > *,
.split > *,
.dashboard-lists > * {
    min-width: 0;
}

.card,
form.panel,
.panel {
    margin-top: 18px;
    border: 1px solid rgba(235, 234, 245, 0.9);
    border-radius: 8px;
    padding: 20px;
    background: #ffffff;
    box-shadow: var(--shadow-soft);
}

.card h2,
.panel h2 {
    margin-top: 0;
    letter-spacing: 0;
}

.card p:last-child,
.panel p:last-child {
    margin-bottom: 0;
}

.grid .card {
    position: relative;
    overflow: hidden;
}

.grid .card::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent-teal), var(--accent));
}

.grid .card:nth-child(3n+2)::before {
    background: linear-gradient(90deg, var(--accent-orange), var(--accent-pink));
}

.grid .card:nth-child(3n+3)::before {
    background: linear-gradient(90deg, #58c9ef, #b34dff);
}

.grid .card h2 {
    color: var(--accent-strong);
}

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.toolbar h1 {
    margin: 0;
    font-size: clamp(1.65rem, 2vw, 2.35rem);
    letter-spacing: 0;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
}

.table-scroll {
    max-width: 100%;
    overflow-x: auto;
}

.compact-table {
    min-width: max-content;
}

table,
th,
td {
    border-color: var(--line);
}

th,
td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 650;
}

.compact-table th,
.compact-table td {
    padding: 8px 10px;
}

.compact-table td:last-child,
.compact-table th:last-child {
    width: 42px;
    padding-right: 0;
    text-align: right;
}

.compact-table .muted {
    display: block;
    max-width: 160px;
}

.compact-table td {
    max-width: 180px;
    overflow-wrap: anywhere;
}

.compact-table td:last-child {
    max-width: 42px;
}

label {
    display: block;
    margin: 12px 0 5px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 650;
}

.check-option {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0;
    color: var(--ink);
    font-weight: 500;
}

.check-option input {
    width: auto;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 11px;
    background: #ffffff;
    font: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(77, 61, 244, 0.14);
    border-color: var(--accent);
}

.editable-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
    white-space: nowrap;
}

.editable-table input,
.editable-table select {
    min-width: 112px;
    padding: 7px 8px;
    font-size: 0.92rem;
}

.editable-table [data-editable-row]:not(.is-editing) input,
.editable-table [data-editable-row]:not(.is-editing) select,
.editable-table [data-editable-row]:not(.is-editing) .save-row-button {
    display: none;
}

.editable-table [data-editable-row].is-editing .edit-display,
.editable-table [data-editable-row].is-editing .edit-row-button {
    display: none;
}

.editable-table .edit-display {
    display: inline-block;
    min-height: 34px;
    padding-top: 7px;
}

.editable-table input[type="file"] {
    min-width: 150px;
}

.editable-table .actions {
    flex-wrap: nowrap;
    gap: 6px;
}

.editable-table button {
    min-height: 34px;
    padding: 6px 10px;
}

.icon-button {
    width: 34px;
    min-width: 34px;
    min-height: 34px;
    padding: 0;
}

.icon-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tag-autocomplete {
    position: relative;
}

.tag-suggestions {
    position: absolute;
    right: 0;
    left: 0;
    z-index: 12;
    display: none;
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 6px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.tag-autocomplete.is-open .tag-suggestions {
    display: grid;
    gap: 4px;
}

.tag-suggestions button {
    justify-content: flex-start;
    min-height: 34px;
    border: 0;
    border-radius: 6px;
    padding: 7px 9px;
    color: var(--ink);
    background: transparent;
    box-shadow: none;
    font-weight: 650;
    text-align: left;
}

.tag-suggestions button:hover,
.tag-suggestions button:focus {
    color: var(--accent);
    background: var(--soft);
    transform: none;
}

.mail-designer {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.75fr);
    gap: 16px;
    margin-top: 12px;
}

.mail-editor,
.mail-preview {
    min-width: 0;
}

.mail-designer-body {
    min-height: 260px;
}

.placeholder-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.placeholder-tools button {
    min-height: 32px;
    padding: 5px 9px;
    font-size: 0.88rem;
}

.mail-preview {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, var(--soft));
}

.mail-preview h3 {
    margin: 0;
}

.mail-preview-subject {
    display: block;
    margin: 12px 0;
    color: var(--accent-strong);
    font-size: 1.05rem;
}

.mail-preview-body {
    min-height: 180px;
    border-top: 1px solid var(--line);
    padding-top: 12px;
    overflow-wrap: anywhere;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

details {
    margin-top: 8px;
}

summary {
    color: var(--accent);
    cursor: pointer;
    font-weight: 650;
}

details textarea {
    min-height: 180px;
    margin-top: 8px;
    font-size: 0.92rem;
}

.large-textarea {
    min-height: 620px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.agenda-list {
    display: grid;
    gap: 14px;
}

.agenda-row {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: linear-gradient(180deg, #ffffff, var(--soft));
}

.agenda-row h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 39px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    padding: 8px 13px;
    color: #ffffff;
    background: linear-gradient(135deg, var(--accent), #6f4dff);
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(77, 61, 244, 0.18);
}

button:hover,
.button:hover,
button:focus,
.button:focus {
    transform: translateY(-1px);
}

button.menu-toggle {
    display: none;
}

.button.secondary,
button.secondary {
    color: var(--accent-strong);
    background: #ffffff;
    box-shadow: none;
}

.button.danger,
button.danger {
    border-color: var(--danger);
    color: var(--danger);
    background: #ffffff;
    box-shadow: none;
}

.flash {
    margin-bottom: 18px;
    border-radius: 8px;
    padding: 12px 14px;
    background: #effcf9;
    border: 1px solid #b7eee4;
    box-shadow: var(--shadow-soft);
}

.flash.error {
    background: #fff1ef;
    border-color: #efc4bd;
}

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

.tag {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    margin: 2px 3px 2px 0;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--accent-strong);
    background: #f1efff;
    font-size: 0.86rem;
    font-weight: 650;
}

.rank-list {
    display: grid;
    gap: 10px;
}

.rank-list p {
    margin: 0;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.rank-list p:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.bar-list {
    display: grid;
    gap: 15px;
    min-width: 0;
}

.bar-row {
    min-width: 0;
}

.bar-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 7px;
}

.bar-meta strong {
    font-size: 1.05rem;
}

.bar-meta span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.bar-track {
    width: 100%;
    height: 12px;
    overflow: hidden;
    border-radius: 999px;
    background: #f0eefb;
}

.bar-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    --bar-start: var(--accent-teal);
    --bar-end: var(--accent);
    background: linear-gradient(90deg, var(--bar-start), var(--bar-end));
    box-shadow: 0 4px 12px rgba(32, 201, 186, 0.2);
}

.bar-row:nth-child(3n+2) .bar-track span {
    --bar-start: var(--accent-orange);
    --bar-end: var(--accent-pink);
}

.bar-row:nth-child(3n+3) .bar-track span {
    --bar-start: #58c9ef;
    --bar-end: #b34dff;
}

.split {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
    gap: 18px;
}

.dashboard-lists {
    margin-top: 18px;
}

.event-teasers {
    display: grid;
    gap: 12px;
}

.event-teaser {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(235, 234, 245, 0.9);
}

.event-teaser:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.event-rsvp-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    min-width: 150px;
    color: var(--muted);
    font-size: 0.88rem;
}

.event-rsvp-meta span,
.event-rsvp-meta strong {
    border-radius: 999px;
    padding: 5px 8px;
    background: #f2f1fb;
    white-space: nowrap;
}

.event-rsvp-meta strong {
    color: #d63d5b;
    background: #fff0f4;
}

.pipeline-board {
    display: grid;
    grid-template-columns: repeat(5, minmax(220px, 1fr));
    gap: 14px;
    align-items: start;
    overflow-x: auto;
    padding-bottom: 8px;
}

.pipeline-column {
    min-width: 220px;
    border: 1px solid rgba(235, 234, 245, 0.9);
    border-radius: 8px;
    padding: 12px;
    background: #f8f9fc;
}

.pipeline-column h2 {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 0.95rem;
}

.pipeline-column h2 span {
    color: var(--ink);
}

.prospect-card {
    margin-top: 10px;
    padding: 14px;
}

.prospect-card h3 {
    margin: 0 0 8px;
    font-size: 1rem;
}

@media (max-width: 980px) {
    .split {
        grid-template-columns: 1fr;
    }

    .event-teaser {
        grid-template-columns: 1fr;
    }

    .event-rsvp-meta {
        justify-content: flex-start;
    }

    .mail-designer {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    body {
        background: #f7f7fd;
    }

    main {
        width: min(1180px, calc(100% - 24px));
        margin: 76px auto 48px;
    }

    .topbar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 20;
        width: min(82vw, 310px);
        height: 100dvh;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        gap: 28px;
        overflow-y: auto;
        padding: 82px 20px 28px;
        border-bottom: 0;
        background: var(--nav);
        box-shadow: 0 12px 28px rgba(31, 26, 95, 0.12);
        transform: translateX(-105%);
        transition: transform 0.22s ease;
    }

    body.menu-open .topbar {
        transform: translateX(0);
        box-shadow: 18px 0 42px rgba(31, 26, 95, 0.2);
    }

    body.menu-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 15;
        background: rgba(23, 21, 45, 0.32);
    }

    button.menu-toggle {
        position: fixed;
        top: 16px;
        left: 16px;
        z-index: 30;
        display: inline-flex;
        width: 48px;
        min-height: 48px;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 5px;
        border: 1px solid rgba(255, 255, 255, 0.62);
        border-radius: 999px;
        padding: 0;
        background: linear-gradient(135deg, var(--accent), #6f4dff);
        box-shadow: 0 14px 32px rgba(38, 34, 95, 0.22);
    }

    .menu-toggle span {
        display: block;
        width: 20px;
        height: 2px;
        border-radius: 999px;
        background: #ffffff;
        transition: transform 0.2s ease, opacity 0.2s ease;
    }

    body.menu-open .menu-toggle span:nth-child(1) {
        transform: translateY(7px) rotate(45deg);
    }

    body.menu-open .menu-toggle span:nth-child(2) {
        opacity: 0;
    }

    body.menu-open .menu-toggle span:nth-child(3) {
        transform: translateY(-7px) rotate(-45deg);
    }

    .brand {
        color: #ffffff;
    }

    nav a {
        color: #e9e7ff;
    }

    nav a:hover,
    nav a:focus {
        color: #ffffff;
    }

    nav {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        margin-top: 0;
        overflow-x: visible;
        padding-bottom: 0;
    }

    nav a {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        min-height: 44px;
        padding: 10px 14px;
        border-radius: 999px;
    }

    .nav-item {
        margin-top: 8px;
    }

    .submenu {
        position: static;
        display: block;
        margin-top: 8px;
        padding: 7px;
        border: 0;
        background: rgba(255, 255, 255, 0.1);
        box-shadow: none;
    }

    .submenu a {
        color: #ffffff;
    }

    .submenu::before {
        display: none;
    }
}

@media (max-width: 760px) {
    .toolbar {
        display: block;
    }
}
