.sidebar {
    overflow-y: auto
}

.sidebar nav a {
    padding-top: 10px;
    padding-bottom: 10px
}

.sidebar-foot {
    flex-shrink: 0
}

.external-apps {
    margin-top: 10px;
    padding: 14px 12px 4px;
    border-top: 1px solid #d8d8d8
}

.external-apps .nav-caption {
    padding: 0 10px 9px
}

.external-app-nav {
    display: grid;
    gap: 8px;
    overflow: visible
}

.external-app-nav a {
    position: relative;
    min-width: 0;
    min-height: 58px;
    gap: 10px;
    padding: 8px 10px !important;
    border: 0;
    border-radius: 12px;
    color: #fff;
    box-shadow: 0 5px 14px rgb(29 43 65 / 16%);
    transition: transform .16s ease, box-shadow .16s ease, filter .16s ease
}

.external-app-nav a[data-external-app=telegram] {
    background: linear-gradient(135deg, #2aabee, #168acd)
}

.external-app-nav a[data-external-app=max] {
    background: linear-gradient(135deg, #238cff 0%, #7359e8 52%, #d94bc7 100%)
}

.external-app-nav a[data-external-app=rocket-chat] {
    background: linear-gradient(135deg, #f5455c, #d92f48)
}

.external-app-nav a:hover,
.external-app-nav a:focus-visible {
    color: #fff;
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgb(29 43 65 / 23%);
    filter: saturate(1.08) brightness(1.03)
}

.external-app-nav a:focus-visible {
    outline: 2px solid #292929;
    outline-offset: 2px
}

.external-app-icon {
    width: 38px;
    height: 38px;
    flex: 0 0 38px
}

.external-app-copy {
    display: grid !important;
    flex: 1 1 auto;
    gap: 3px;
    width: auto !important;
    min-width: 0;
    font-size: inherit !important;
    text-align: left
}

.external-app-name {
    display: block !important;
    width: auto !important;
    min-width: 0;
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    line-height: 1.2;
    text-overflow: ellipsis
}

.external-app-copy small {
    color: rgb(255 255 255 / 78%);
    font-size: 10px;
    line-height: 1.2
}

.external-app-launch {
    width: auto !important;
    margin-left: auto;
    color: rgb(255 255 255 / 78%);
    font-size: 14px !important
}

.external-app-status {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%)
}

.notification-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: #292929
}

.notification-count {
    background: #c4e8e4;
    border: 1px solid #9fdbd3;
    border-radius: 12px;
    font-size: 11px;
    min-width: 20px;
    padding: 3px 5px;
    text-align: center
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    padding: 16px;
    background: #fafafa;
    border-bottom: 1px solid #ddd
}

.bulk-actions label {
    display: grid;
    gap: 6px;
    font-size: 12px;
    color: #777;
    max-width: 240px
}

.bulk-actions input,
.bulk-actions select {
    max-width: 100%
}

.overdue-text {
    color: #ad3d31;
    font-weight: 600
}

.calendar-filter {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap
}

.calendar-week {
    display: flex;
    overflow: auto;
    gap: 12px;
    margin-top: 20px
}

.calendar-day {
    background: white;
    border: 1px solid #ddd;
    min-width: 195px;
    flex: 1;
    min-height: 350px;
    border-radius: 3px
}

.calendar-day>header {
    display: flex;
    justify-content: space-between;
    padding: 14px;
    border-bottom: 1px solid #ddd;
    background: #f0f0f0;
    color: #777
}

.calendar-day.is-today>header {
    background: #e2f4f1;
    color: #292929
}

.meeting-card {
    display: grid;
    gap: 7px;
    padding: 12px;
    margin: 10px;
    border: 1px solid #a3dcd4;
    border-left: 3px solid #55beb0;
    border-radius: 3px;
    background: #f3fbfa;
    color: #333;
    font-size: 13px
}

.meeting-card small {
    color: #888;
    font-size: 11px
}

.meeting-card.status-done {
    border-left-color: #779d64;
    background: #f4faf1
}

.meeting-card.status-cancelled {
    opacity: .6;
    border-left-color: #bbb;
    background: #fafafa
}

.notification-row {
    padding: 18px;
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: center;
    border-bottom: 1px solid #eee
}

.notification-row.unread {
    background: #f3faf9;
    border-left: 3px solid #9fdbd3
}

.notification-row small {
    display: block;
    color: #999;
    font-size: 12px;
    margin-top: 8px
}

.analytics-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding: 18px;
    align-items: end
}

.analytics-filters label {
    display: grid;
    gap: 7px;
    font-size: 12px;
    color: #777
}

.analytics-filters input,
.analytics-filters select {
    width: 100%
}

.analytics-stages {
    padding: 14px 18px
}

.analytics-stages>div {
    display: grid;
    grid-template-columns: 1fr 30px 100px 150px;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid #eee;
    align-items: center;
    font-size: 12px
}

.analytics-stages small {
    color: #888
}

.analytics-stages meter {
    width: 100%;
    accent-color: #55beb0
}

.report-explanation {
    font-size: 12px;
    color: #888;
    line-height: 1.7;
    margin-bottom: 20px
}

.draft-status {
    padding: 10px 18px;
    border-bottom: 1px solid #eee;
    color: #888;
    font-size: 12px
}

.draft-restore {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 12px 18px;
    background: #daf1ee;
    border-bottom: 1px solid #9edad2;
    font-size: 13px
}

.draft-restore button {
    font-size: 12px
}

.integration-account,
.integration-link-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap
}

.integration-actions,
.integration-link-row form {
    display: flex;
    align-items: center;
    gap: 9px;
    flex-wrap: wrap
}

.integration-actions form {
    margin: 0
}

.danger-button {
    color: #a63030;
    border-color: #d6aaa6
}

@media(max-width:1000px) {
    .analytics-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }

    .analytics-stages>div {
        grid-template-columns: 1fr 30px
    }

    .analytics-stages small,
    .analytics-stages meter {
        grid-column: auto
    }
}

@media(max-width:700px) {
    .analytics-filters {
        grid-template-columns: 1fr
    }

    .sidebar nav a {
        padding: 12px
    }

    .external-apps {
        margin: 0;
        padding: 8px 12px;
        border-top: 1px solid #d8d8d8
    }

    .external-app-nav {
        display: flex;
        justify-content: flex-start;
        gap: 8px;
        overflow-x: auto;
        padding: 2px
    }

    .external-app-nav a {
        flex: 0 0 auto;
        min-height: 44px;
        padding: 6px 10px !important
    }

    .external-app-icon {
        display: block;
        width: 30px;
        height: 30px;
        flex-basis: 30px
    }

    .external-app-copy small {
        display: none
    }

    .external-app-launch {
        display: inline !important
    }

    .account .notification-link span {
        display: inline-block
    }

    .notification-row {
        align-items: start
    }

    .account {
        gap: 8px
    }

    .analytics-stages>div {
        grid-template-columns: 1fr 30px
    }

    .dashboard-grid {
        min-width: 0
    }

    .dashboard-grid>.panel {
        min-width: 0;
        overflow: auto
    }

    .details {
        overflow-wrap: anywhere
    }
}

/* UI polish: layout fixes without behavior changes */
.sidebar {
    scrollbar-width: thin
}

.sidebar>nav a {
    padding-right: 12px
}

.bulk-actions label {
    grid-template-columns: minmax(0, 1fr)
}

.bulk-actions label select,
.bulk-actions label input {
    width: 100%;
    min-width: 0
}

.calendar-day {
    min-width: 140px
}

.panel>.kanban {
    padding: 16px;
    min-height: 0
}

.kanban-column>h3 {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin: 0;
    padding: 13px;
    font-size: 13px;
    font-weight: 600;
    border-top: 3px solid var(--yellow);
    border-bottom: 1px solid #ddd
}

.kanban-column>h3 span {
    font-weight: 400
}

.kanban-column>.empty {
    padding: 25px 12px;
    font-size: 12px
}

article.kanban-card p {
    margin: 9px 0 12px;
    font-size: 13px
}

article.kanban-card .button {
    white-space: normal
}

.pipeline-editor {
    border-top: 1px solid var(--line)
}

.pipeline-editor>.panel-title {
    border-top: 0
}

.pipeline-editor>p {
    margin: 0;
    padding: 12px 24px;
    font-size: 13px
}

.pipeline-editor [data-stage-list] {
    display: grid;
    gap: 8px;
    padding: 0 24px 20px
}

.pipeline-editor [data-stage-list]:empty {
    display: none
}

.stage-editor-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px
}

.stage-editor-row input[type=text] {
    flex: 1 1 240px;
    min-width: 0
}

.stage-editor-row label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer
}

.stage-editor-row label input {
    margin: 0
}

.communication-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid #eee
}

.communication-actions .inline-form {
    display: contents
}

.communication-actions button:disabled {
    color: #9a9a9a;
    background: #f6f6f6;
    cursor: not-allowed
}

.panel-form {
    border-top: 1px solid #eee
}

.panel-form .form-grid {
    padding: 18px 20px
}

.panel-form .form-footer {
    padding: 12px 20px
}

.panel-list>p {
    margin: 0;
    padding: 12px 18px;
    border-bottom: 1px solid #eee;
    font-size: 13px
}

.panel-list>p:last-child {
    border-bottom: 0
}

.panel>.form-footer {
    flex-wrap: wrap
}

.panel>.form-footer .button {
    white-space: normal;
    text-align: left
}

.response p,
.avito-chat form {
    margin-bottom: 0
}

.avito-chat form {
    display: grid;
    gap: 10px;
    margin-top: 14px
}

.avito-chat form label {
    display: grid;
    gap: 6px;
    font-size: 13px
}

.avito-chat form button {
    justify-self: start
}

@media(max-width:700px) {
    .panel-form .form-grid {
        grid-template-columns: 1fr
    }

    .communication-actions {
        padding: 12px
    }
}

.panel-list>p.empty {
    padding: 28px 20px;
    border-bottom: 1px solid #eee
}

.resume-card-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.resume-card-heading > strong { font-size: 16px; color: #294f78; }
.resume-card-heading .button { margin-left: auto; font-size: 12px; }
.resume-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 16px 0; }
.resume-facts > div { padding: 10px 12px; background: #f3f7fc; border: 1px solid #e0e8f2; border-radius: 6px; }
.resume-facts dt { color: #6b7a8e; font-size: 11px; margin-bottom: 5px; }
.resume-facts dd { margin: 0; color: #30445d; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.resume-description { padding-top: 12px; border-top: 1px solid #e5eaf0; line-height: 1.6; white-space: normal; }
/* Header controls are navigation, not inline text links. Keep their geometry. */
:is(body, body.service-admin, body.window-frame) .topbar :is(a, button.plain) {
    text-decoration: none;
    border-radius: 6px;
    color: #1b453f;
    transition: background-color .16s ease, box-shadow .16s ease, color .16s ease;
}

:is(body, body.service-admin, body.window-frame) .topbar button.plain {
    background-color: transparent;
    background-image: none;
    box-shadow: none;
}

:is(body, body.service-admin, body.window-frame) .topbar :is(a, button.plain):hover {
    text-decoration: none;
    color: #14332f;
    background-color: rgb(255 255 255 / 30%);
    background-image: none;
    box-shadow: 0 0 0 5px rgb(255 255 255 / 30%);
}

:is(body, body.service-admin, body.window-frame) .topbar :is(a, button.plain):focus-visible {
    text-decoration: none;
    outline: 2px solid #315f93;
    outline-offset: 5px;
}

:is(body, body.service-admin, body.window-frame) .topbar :is(a, button.plain):active {
    background-color: rgb(255 255 255 / 45%);
    box-shadow: inset 0 1px 3px rgb(27 69 63 / 14%);
}

@media (prefers-reduced-motion: reduce) {
    :is(body, body.service-admin, body.window-frame) .topbar :is(a, button.plain) { transition: none; }
}
