* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    overflow-x: hidden;
    max-width: 100%;
}

:root {
    --accent: #2fc6f6;
    --accent-hover: #00aff0;
    --accent-pressed: #008cc6;
    --accent-soft: #e8f7fd;
    --b24: #2fc6f6;
    --b24-dark: #00aff0;
    --green: #bbed21;
    --green-dark: #9fd70a;
    --bg: #eef2f4;
    --text: #333333;
    --text-soft: #525c69;
    --muted: #828b95;
    --line: #e6edf3;
    --line-strong: #d5dadd;
    --card: #ffffff;
    --card-soft: #f5f7f8;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 12px;
    --shadow: 0 8px 24px rgba(38, 50, 65, 0.1);
    --shadow-soft: 0 2px 6px rgba(38, 50, 65, 0.06), 0 1px 2px rgba(38, 50, 65, 0.04);
    --transition: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.layout {
    display: block;
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 10px 22px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-soft);
}

.topbar__brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    flex: 0 0 auto;
    text-decoration: none;
    min-width: 150px;
}

.topbar__logo {
    width: 142px;
    max-width: 100%;
    height: auto;
}

.topbar__brand-sub {
    font-size: 11px;
    color: var(--muted);
    white-space: nowrap;
}

.topbar__nav {
    display: flex;
    flex: 1 1 auto;
    gap: 6px;
    min-width: 0;
}

.content {
    min-width: 0;
    padding: 18px 22px 34px;
}

.topbar-contact {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 800;
}

.app {
    padding: 0;
    max-width: 1900px;
    margin: 0;
}

.header {
    background: var(--card);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    margin-bottom: 14px;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
}

.header h1 {
    margin: 0 0 6px 0;
    font-size: 24px;
    line-height: 1.18;
}

.header p {
    margin: 0;
    color: var(--muted);
    line-height: 1.35;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

.topbar .tabs {
    margin: 0;
    border-bottom: 0;
}

.tab {
    border: 0;
    padding: 10px 12px;
    border-radius: var(--radius-lg);
    background: transparent;
    color: var(--text-soft);
    font: inherit;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: none;
    transition: background var(--transition), color var(--transition);
}

.tab:hover {
    background: var(--accent-soft);
}

.tab.active {
    background: var(--accent-soft);
    color: var(--accent-pressed);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.filters-card,
.actions-card,
.table-card,
.summary-card,
.access-card {
    background: var(--card);
    border: 1px solid rgba(223, 231, 239, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.filters-card {
    padding: 14px;
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(220px, 1.4fr) minmax(140px, 0.7fr) minmax(140px, 0.7fr) auto;
    gap: 16px;
    align-items: end;
    margin-bottom: 12px;
}

.actions-card {
    padding: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    position: relative;
    z-index: 80;
    border: 1px solid rgba(223, 231, 239, 0.95);
    box-shadow: 0 6px 18px rgba(23, 43, 77, 0.08);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-soft);
}

select {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}

select:focus {
    border-color: var(--b24);
    box-shadow: 0 0 0 3px rgba(41, 182, 246, 0.16);
}

select[multiple] {
    min-height: 120px;
}

.filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn {
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
    white-space: normal;
    line-height: 1.2;
    box-shadow: 0 4px 12px rgba(23, 43, 77, 0.08);
}

.btn-primary {
    background: linear-gradient(135deg, var(--b24), var(--b24-dark));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(41, 182, 246, 0.22);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    color: var(--text);
}

.btn-secondary:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(157, 207, 0, 0.2);
}

.btn-light {
    border: 1px solid var(--line);
    background: var(--card-soft);
    color: var(--text-soft);
}

.btn-light:hover {
    background: #edf1f5;
    color: var(--text);
    transform: translateY(-1px);
}

.btn:disabled,
.btn:disabled:hover {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 14px;
}

.summary-card {
    padding: 14px;
    border-left: 4px solid var(--b24);
}

.summary-card span {
    display: block;
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 8px;
}

.summary-card b {
    font-size: 22px;
}

.summary-card.wide {
    grid-column: span 2;
}

.summary-card.blue {
    border-left-color: var(--b24);
}

.summary-card.cyan {
    border-left-color: var(--b24);
}

.summary-card.yellow {
    border-left-color: #f7c948;
}

.summary-card.orange {
    border-left-color: #ff9f1c;
}

.summary-card.red {
    border-left-color: #f04b4b;
}

.stat-line {
    font-size: 13px;
    margin-bottom: 6px;
    line-height: 1.35;
}

.table-card {
    padding: 0;
    overflow: hidden;
}

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

table {
    width: 100%;
    min-width: 1450px;
    border-collapse: collapse;
}

th {
    background: var(--card-soft);
    color: var(--text-soft);
    text-align: left;
    padding: 12px 10px;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 1;
}

td {
    padding: 11px 10px;
    border-bottom: 1px solid #edf1f3;
    vertical-align: top;
    font-size: 14px;
}

tr:hover td {
    background: #f8fbfc;
}

.row-medium td {
    background: #fffdf4;
}

.row-high td {
    background: #fff7ed;
}

.row-critical td {
    background: #fff1f1;
}

.row-medium:hover td,
.row-high:hover td,
.row-critical:hover td {
    filter: brightness(0.98);
}

.deal-title {
    min-width: 260px;
    font-weight: 700;
}

a {
    color: #087aa7;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.ai-text {
    min-width: 260px;
    line-height: 1.35;
}

.risk-badge {
    display: inline-block;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.risk-medium {
    background: #fff4cc;
    color: #8a6100;
}

.risk-high {
    background: #ffe4c2;
    color: #9a4b00;
}

.risk-critical {
    background: #ffe0e0;
    color: #b42318;
}

.empty-message {
    text-align: center;
    padding: 28px;
    color: var(--muted);
}

.empty-message.error {
    color: #b42318;
}

.access-card {
    padding: 24px;
}

.access-card h2 {
    margin-top: 0;
}

.access-card p {
    color: var(--muted);
}

.access-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-top: 18px;
}

.access-search {
    margin-bottom: 8px;
}

#accessUsersSelect,
#ropUserSelect {
    display: none;
}

.access-user-list {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
}

.access-user-group + .access-user-group {
    border-top: 1px solid var(--line);
}

.access-user-group-title {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 8px 12px;
    background: var(--card-soft);
    color: var(--text-soft);
    font-size: 12px;
    font-weight: 900;
}

.access-user-row {
    display: grid;
    grid-template-columns: 16px 34px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    cursor: pointer;
}

.access-user-row + .access-user-row {
    border-top: 1px solid #edf1f3;
}

.access-user-row:hover {
    background: #f8fbfc;
}

.access-user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--accent-soft);
    color: var(--accent-pressed);
    font-size: 12px;
    font-weight: 900;
}

.access-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.access-user-name {
    display: block;
    color: var(--text);
    font-weight: 800;
    line-height: 1.2;
    overflow-wrap: anywhere;
}

.access-user-meta {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.access-user-empty {
    padding: 18px 12px;
    color: var(--muted);
    text-align: center;
}

.access-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.access-message {
    margin-top: 14px;
    padding: 12px;
    border-radius: 8px;
    background: var(--card-soft);
    color: var(--text-soft);
}

.access-message.success {
    background: #e9f9d0;
    color: #497000;
}

.access-message.error {
    background: #ffe0e0;
    color: #b42318;
}

.access-denied {
    background: white;
    border-radius: 8px;
    padding: 32px;
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.access-denied h2 {
    margin-top: 0;
    color: #b42318;
}

.about-layout {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.about-card {
    background: var(--card);
    border: 1px solid rgba(223, 231, 239, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    padding: 22px;
}

.about-card-main {
    grid-column: 1 / -1;
    border-left: 4px solid var(--b24);
}

.about-kicker {
    display: inline-flex;
    margin-bottom: 10px;
    color: #087aa7;
    font-size: 12px;
    font-weight: 900;
}

.about-card h2,
.about-card h3 {
    margin: 0 0 12px;
}

.about-card p {
    margin: 0 0 12px;
    color: var(--text-soft);
    line-height: 1.5;
}

.about-list {
    margin: 0;
    padding-left: 18px;
    color: var(--text-soft);
    line-height: 1.5;
}

.about-list li + li {
    margin-top: 7px;
}

.contact-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.contact-grid span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.contact-grid b,
.contact-grid a {
    font-weight: 800;
    overflow-wrap: anywhere;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

@media (max-width: 1300px) {
    .filters-card {
        grid-template-columns: repeat(2, 1fr);
    }

    .filter-actions {
        flex-direction: row;
        grid-column: span 2;
    }

    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .summary-card.wide {
        grid-column: span 2;
    }
}

@media (max-width: 760px) {
    .content {
        padding: 12px;
    }

    .header {
        flex-direction: column;
        align-items: flex-start;
    }

    .filters-card,
    .access-grid {
        grid-template-columns: 1fr;
    }

    .about-layout,
    .contact-grid {
        grid-template-columns: 1fr;
    }

    .filter-actions {
        flex-direction: column;
        grid-column: auto;
    }

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

    .summary-card.wide {
        grid-column: auto;
    }

    .actions-card {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

@media (max-width: 860px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
        padding: 10px 14px;
    }

    .topbar__nav {
        flex-wrap: wrap;
        width: 100%;
    }

    .topbar-contact {
        display: none;
    }

    .content {
        padding: 14px;
    }
}
input[type="text"],
input[type="search"] {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    outline: none;
    font-size: 14px;
}

input[type="text"]:focus,
input[type="search"]:focus {
    border-color: var(--b24);
    box-shadow: 0 0 0 3px rgba(41, 182, 246, 0.16);
}

.clients-filters {
    grid-template-columns: minmax(220px, 1.4fr) minmax(220px, 1.3fr) minmax(130px, 0.6fr) minmax(140px, 0.7fr) minmax(130px, 0.6fr) auto;
}

.checkbox-list {
    min-height: 42px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
}

.checkbox-list label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text);
}

#clientsTable {
    min-width: 1550px;
}

@media (max-width: 1500px) {
    .clients-filters {
        grid-template-columns: repeat(3, 1fr);
    }

    .clients-filters .filter-actions {
        flex-direction: row;
        grid-column: span 3;
    }
}

@media (max-width: 900px) {
    .clients-filters {
        grid-template-columns: 1fr;
    }

    .clients-filters .filter-actions {
        flex-direction: column;
        grid-column: auto;
    }
}

.progress-card {
    background: white;
    border: 1px solid rgba(223, 231, 239, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    padding: 16px;
    margin-bottom: 18px;
}

.progress-card.hidden {
    display: none;
}

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

.progress-head b {
    display: block;
    margin-bottom: 4px;
}

.progress-head span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.progress-bar {
    height: 10px;
    background: #e7edf2;
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--b24), var(--green));
    border-radius: 999px;
    transition: width 0.25s ease;
}

input[type="text"], input[type="number"], input[type="search"] {
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 9px 10px;
    background: #fff;
    color: var(--text);
    outline: none;
}

input[type="text"]:focus, input[type="number"]:focus, input[type="search"]:focus {
    border-color: var(--b24);
    box-shadow: 0 0 0 3px rgba(41, 182, 246, 0.16);
}

.developer-badge {
    display: inline-flex;
    margin-top: 10px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #e9f8fd;
    border: 1px solid #c8eef9;
    color: #087aa7;
    font-size: 12px;
    font-weight: 700;
}

.saved-session-card {
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    padding: 14px 16px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border: 1px solid rgba(223, 231, 239, 0.9);
    border-left: 5px solid var(--b24);
}

.saved-session-card span {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

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

.hidden {
    display: none !important;
}

.app-dialog-overlay {
    position: absolute;
    inset: 0;
    z-index: 300;
    min-height: 100%;
    background: rgba(23, 43, 77, 0.26);
    padding: 16px;
}

.app-dialog {
    width: min(440px, calc(100vw - 32px));
    margin: 16px auto 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(38, 50, 65, 0.16);
    padding: 20px;
    position: relative;
}

.app-dialog h3 {
    margin: 0 34px 10px 0;
    font-size: 18px;
    line-height: 1.25;
}

.app-dialog-text {
    color: var(--text-soft);
    line-height: 1.5;
    white-space: pre-line;
}

.app-dialog-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 8px;
    background: var(--card-soft);
    color: var(--muted);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.app-dialog-close:hover {
    background: #edf1f5;
    color: var(--text);
}

.app-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

@media (max-width: 760px) {
    .saved-session-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .saved-session-actions {
        width: 100%;
    }
}

.native-multiselect-hidden {
    display: none !important;
}

.modern-multiselect {
    position: relative;
    width: 100%;
}

.modern-multiselect-control {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: #fff;
    padding: 6px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    cursor: pointer;
    text-align: left;
}

.modern-multiselect.open .modern-multiselect-control,
.modern-multiselect-control:focus {
    border-color: var(--b24);
    box-shadow: 0 0 0 3px rgba(41, 182, 246, 0.16);
    outline: none;
}

.modern-multiselect-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
}

.modern-multiselect-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 240px;
    padding: 6px 9px;
    border-radius: 999px;
    background: #dff5ff;
    color: #087aa7;
    font-size: 13px;
    font-weight: 700;
}

.modern-multiselect-tag span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.modern-multiselect-tag button {
    border: none;
    background: transparent;
    color: #087aa7;
    font-size: 15px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
}

.modern-multiselect-placeholder {
    color: #8a94a6;
    font-size: 14px;
    padding-left: 3px;
}

.modern-multiselect-plus {
    color: #087aa7;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
    padding: 4px 6px;
}

.modern-multiselect-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    box-shadow: 0 14px 34px rgba(23, 43, 77, 0.16);
    z-index: 120;
    padding: 6px;
}

.modern-multiselect.open .modern-multiselect-dropdown {
    display: block;
}

.modern-multiselect-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 8px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.modern-multiselect-group {
    padding: 10px 8px 5px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 900;
}

.modern-multiselect-option:hover {
    background: #dff5ff;
}

.modern-multiselect-option input {
    width: 16px;
    height: 16px;
    margin: 0;
}


/* === Clean layout fix for modern filters === */
.deals-filters {
    grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(360px, 1.35fr);
    align-items: end;
}

.deals-filters .filter-group,
.clients-filters .filter-group {
    min-width: 0;
}

.deals-filters .filter-group.small {
    max-width: none;
}

.deals-filters .filter-actions {
    flex-direction: row;
    align-items: end;
    justify-content: flex-end;
}

.deals-filters .filter-actions .btn {
    min-width: 150px;
}

.clients-filters {
    grid-template-columns: minmax(260px, 1.1fr) minmax(360px, 1.35fr) minmax(180px, 0.8fr);
    align-items: end;
}

.clients-filters .filter-actions {
    flex-direction: row;
    align-items: end;
    justify-content: flex-end;
}

.clients-filters .filter-actions .btn {
    min-width: 150px;
}

@media (min-width: 1201px) {
    .deals-filters #categoryFilter,
    .deals-filters #stageFilter,
    .deals-filters #managerFilter,
    .clients-filters #clientManagerFilter {
        min-height: 44px;
    }
}

@media (max-width: 1200px) {
    .deals-filters,
    .clients-filters {
        grid-template-columns: 1fr 1fr;
    }

    .deals-filters .filter-actions,
    .clients-filters .filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-start;
    }
}

@media (max-width: 760px) {
    .deals-filters,
    .clients-filters {
        grid-template-columns: 1fr;
    }

    .deals-filters .filter-actions,
    .clients-filters .filter-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
