:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --panel-soft: #f8fafb;
    --text: #15212b;
    --muted: #6f7d88;
    --line: #dde4e8;
    --brand: #133f3a;
    --brand-soft: #e5f0ee;
    --accent: #d59042;
    --danger: #b84444;
    --danger-soft: #fae9e9;
    --shadow: 0 18px 45px rgba(24, 45, 54, 0.08);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
}

button,
input,
select {
    font: inherit;
}

button {
    cursor: pointer;
}

.hidden {
    display: none !important;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(circle at top left, #dcebe8 0, transparent 35%),
        linear-gradient(145deg, #f8fafb 0%, #edf2f2 100%);
}

.login-card {
    width: min(440px, 100%);
    padding: 42px;
    border: 1px solid rgba(19, 63, 58, 0.1);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow);
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: var(--brand);
    color: white;
    font-size: 26px;
    font-weight: 800;
}

.brand-mark.small {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    font-size: 20px;
}

.eyebrow {
    margin: 24px 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.15em;
}

h1,
h2,
p {
    margin-top: 0;
}

.login-card h1 {
    margin-bottom: 10px;
    font-size: 34px;
}

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

form {
    margin-top: 28px;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 18px;
    color: #33434e;
    font-size: 14px;
    font-weight: 700;
}

input,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
}

input:focus,
select:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(19, 63, 58, 0.12);
}

form button,
.toolbar button {
    border: 0;
    border-radius: 12px;
    background: var(--brand);
    color: white;
    padding: 12px 18px;
    font-weight: 800;
}

form button {
    width: 100%;
}

.error-message {
    min-height: 20px;
    margin: 14px 0 0;
    color: var(--danger);
    font-size: 13px;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 28px 20px;
    background: #102f2c;
    color: white;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand span,
.user-panel span {
    display: block;
    margin-top: 3px;
    color: #abc2bf;
    font-size: 12px;
}

nav {
    margin-top: 42px;
}

.nav-item {
    width: 100%;
    border: 0;
    border-radius: 12px;
    padding: 12px 14px;
    text-align: left;
    background: rgba(255, 255, 255, 0.11);
    color: white;
    font-weight: 800;
}

.user-panel {
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.06);
}

.user-panel button {
    margin-top: 14px;
    border: 0;
    background: transparent;
    color: #f0c898;
    padding: 0;
}

.content {
    min-width: 0;
    padding: 32px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-end;
}

.topbar .eyebrow {
    margin-top: 0;
}

.topbar h1 {
    margin-bottom: 0;
    font-size: 32px;
}

.toolbar {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.tenant-picker {
    min-width: 240px;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin: 28px 0 20px;
}

.stat-card {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 8px 24px rgba(24, 45, 54, 0.04);
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
}

.stat-card.attention {
    background: var(--danger-soft);
    border-color: #efcaca;
}

.table-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--panel);
    box-shadow: 0 10px 30px rgba(24, 45, 54, 0.04);
    overflow: hidden;
}

.table-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
    padding: 22px 24px;
    border-bottom: 1px solid var(--line);
}

.table-toolbar h2 {
    margin-bottom: 4px;
}

.table-toolbar p {
    margin-bottom: 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    white-space: nowrap;
}

.checkbox-label input {
    width: auto;
}

.table-wrap {
    padding: 18px 22px 24px;
    overflow-x: auto;
}

table.dataTable {
    width: 100% !important;
}

table.dataTable thead th {
    color: #4e5f69;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

table.dataTable tbody tr {
    cursor: pointer;
}

table.dataTable tbody tr:hover {
    background: #f1f7f6;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 12px;
    font-weight: 800;
}

.status-pill.danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(8, 23, 27, 0.35);
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    z-index: 40;
    width: min(600px, 96vw);
    height: 100vh;
    transform: translateX(105%);
    transition: transform 180ms ease;
    background: white;
    box-shadow: -20px 0 55px rgba(10, 29, 35, 0.18);
    overflow-y: auto;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 24px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.97);
}

.drawer-header .eyebrow {
    margin-top: 0;
}

.drawer-header h2 {
    margin-bottom: 0;
}

.drawer-header button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: white;
    font-size: 24px;
}

.drawer-content {
    padding: 24px;
}

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

.detail-item {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel-soft);
}

.detail-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.detail-item strong,
.detail-item pre {
    margin: 0;
    font-size: 13px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.timeline {
    margin-top: 26px;
}

.timeline-item {
    position: relative;
    margin-left: 8px;
    padding: 0 0 22px 22px;
    border-left: 2px solid var(--line);
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
}

.timeline-item time {
    color: var(--muted);
    font-size: 12px;
}

.timeline-item p {
    margin: 7px 0 0;
    line-height: 1.5;
}

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

    .sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        align-items: center;
    }

    .sidebar nav,
    .user-panel span {
        display: none;
    }

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

@media (max-width: 680px) {
    .content {
        padding: 20px 14px;
    }

    .topbar,
    .toolbar,
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .tenant-picker {
        min-width: 0;
    }

    .stats-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}


/* CRM table refinements V1.5.1 */
.table-wrap {
    overflow-x: auto;
}

#leadsTable {
    min-width: 920px;
}

table.dataTable tbody td {
    vertical-align: middle;
    line-height: 1.35;
}

table.dataTable tbody td:first-child {
    min-width: 150px;
    max-width: 220px;
}

.lead-name {
    display: block;
    font-weight: 800;
    color: var(--text);
    overflow-wrap: anywhere;
}

.nowrap,
.nowrap-cell {
    white-space: nowrap;
}

.status-pill.neutral {
    background: var(--brand-soft);
    color: var(--brand);
}

.status-pill.info {
    background: #e8f0fb;
    color: #285d9c;
}

.status-pill.success {
    background: #e5f3eb;
    color: #246b46;
}

.status-pill.warning {
    background: #fff0dd;
    color: #9a5a13;
}

.status-pill.muted {
    background: #edf0f2;
    color: #66747e;
}

@media (max-width: 900px) {
    #leadsTable {
        min-width: 820px;
    }
}


/* CRM lead drawer V1.6 */
.date-cell {
    white-space: nowrap;
    color: #51616c;
    font-size: 13px;
}

.lead-overview {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background:
        linear-gradient(
            145deg,
            var(--panel-soft),
            #ffffff
        );
}

.lead-avatar {
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: var(--brand);
    color: white;
    font-size: 20px;
    font-weight: 900;
}

.lead-overview-copy {
    min-width: 0;
}

.lead-overview-copy strong,
.lead-overview-copy span {
    display: block;
}

.lead-overview-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 16px;
}

.lead-overview-copy span {
    margin-top: 4px;
    color: var(--muted);
    font-size: 13px;
}

.drawer-section {
    margin-top: 28px;
}

.section-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 14px;
    margin-bottom: 14px;
}

.section-heading .eyebrow {
    margin: 0 0 4px;
}

.section-heading h3 {
    margin: 0;
    font-size: 18px;
}

.activity-count {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.detail-grid-main {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-item-main {
    min-height: 88px;
}

.detail-item-main span {
    color: #71808b;
}

.conversation-section {
    padding-top: 6px;
}

.collapsible-section {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    overflow: hidden;
}

.collapsible-section-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    cursor: pointer;
    list-style: none;
}

.collapsible-section-summary::-webkit-details-marker {
    display: none;
}

.collapsible-section-title {
    display: grid;
    gap: 4px;
}

.collapsible-section-title .eyebrow {
    margin: 0;
}

.collapsible-section-title strong {
    font-size: 18px;
}

.collapsible-section-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.collapsible-section-arrow {
    color: var(--brand);
    font-size: 26px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.collapsible-section[open] .collapsible-section-arrow {
    transform: rotate(90deg);
}

.collapsible-section-body {
    padding: 0 18px 18px;
}

.appointment-section {
    padding: 20px;
    border: 1px solid #cfe4dc;
    border-radius: 18px;
    background: #f5fbf8;
}

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

.appointment-grid article {
    display: grid;
    gap: 6px;
    padding: 14px;
    border: 1px solid #dce9e4;
    border-radius: 12px;
    background: white;
}

.appointment-grid span {
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.appointment-link {
    display: inline-flex;
    margin-top: 14px;
    color: var(--brand);
    font-weight: 900;
}

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

.conversation-list {
    display: grid;
    gap: 16px;
}

.conversation-event {
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #f7f9fa;
}

.conversation-event > header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    color: var(--muted);
    font-size: 11px;
}

.chat-row {
    display: flex;
    margin-top: 9px;
}

.chat-row.customer {
    justify-content: flex-start;
}

.chat-row.bot {
    justify-content: flex-end;
}

.chat-bubble {
    width: fit-content;
    max-width: 86%;
    padding: 11px 13px;
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(24, 45, 54, 0.05);
}

.chat-bubble.customer {
    border-bottom-left-radius: 5px;
    background: white;
    border: 1px solid var(--line);
}

.chat-bubble.bot {
    border-bottom-right-radius: 5px;
    background: #dff2e7;
    border: 1px solid #c7e4d3;
}

.chat-author {
    display: block;
    margin-bottom: 4px;
    color: var(--brand);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.chat-bubble p {
    margin: 0;
    line-height: 1.5;
    white-space: pre-wrap;
}

.technical-details {
    margin-top: 30px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel-soft);
}

.technical-details summary {
    cursor: pointer;
    padding: 15px 17px;
    color: #53636e;
    font-size: 13px;
    font-weight: 900;
}

.technical-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 0 14px 14px;
}

.technical-item {
    padding: 12px;
    border-radius: 10px;
    background: white;
    border: 1px solid var(--line);
}

.technical-item span {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.technical-item strong,
.technical-item pre {
    display: block;
    margin: 0;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    font-size: 12px;
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 620px) {
    .lead-overview {
        grid-template-columns: auto minmax(0, 1fr);
    }

    .lead-overview > .status-pill {
        grid-column: 1 / -1;
        justify-self: start;
    }

    .detail-grid-main {
        grid-template-columns: 1fr;
    }

    .conversation-event > header {
        flex-direction: column;
    }
}


/* CRM drawer refinements V1.6.2 */
.technical-item pre {
    max-height: 320px;
    overflow: auto;
    padding: 10px;
    border-radius: 8px;
    background: #f7f9fa;
    line-height: 1.45;
}

.detail-item-main strong {
    line-height: 1.45;
}

.conversation-event time {
    white-space: nowrap;
}


/* CRM filters V1.7 */
.lead-filter-bar {
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.compact-field {
    min-width: 150px;
    margin: 0;
    gap: 5px;
    font-size: 12px;
}

.compact-field select {
    min-height: 42px;
    padding: 9px 12px;
}

.attention-filter {
    min-height: 42px;
    padding: 0 6px;
}

.secondary-button {
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: white;
    color: var(--text);
    padding: 9px 14px;
    font-weight: 800;
}

.secondary-button:hover {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
}

@media (max-width: 1050px) {
    .table-toolbar {
        align-items: stretch;
        flex-direction: column;
    }

    .lead-filter-bar {
        justify-content: flex-start;
    }
}

@media (max-width: 680px) {
    .lead-filter-bar {
        display: grid;
        grid-template-columns: 1fr;
    }

    .compact-field,
    .secondary-button {
        width: 100%;
    }

    .attention-filter {
        padding: 8px 0;
    }
}


/* CRM CSV export V1.8 */
.export-button {
    min-height: 42px;
    border: 0;
    border-radius: 11px;
    background: var(--brand);
    color: white;
    padding: 9px 15px;
    font-weight: 900;
}

.export-button:hover {
    filter: brightness(1.06);
}

.export-button:disabled {
    cursor: wait;
    opacity: 0.65;
}


/* CRM lead management V2.0 */
.management-section {
    padding: 20px;
    border: 1px solid #d9e4e2;
    border-radius: 18px;
    background: #f7fbfa;
}

.management-section .section-heading {
    margin-bottom: 18px;
}

.management-form {
    margin: 0;
}

.management-form label {
    margin-bottom: 16px;
}

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

.management-form textarea {
    width: 100%;
    resize: vertical;
    min-height: 118px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    font: inherit;
    line-height: 1.5;
}

.management-form textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(19, 63, 58, 0.12);
}

.management-form small {
    color: var(--muted);
    font-weight: 500;
}

.management-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-top: 6px;
}

.management-form-status {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.management-form-status.success {
    color: #246b46;
    font-weight: 800;
}

.management-form-status.error {
    color: var(--danger);
    font-weight: 800;
}

.management-save-button {
    flex: 0 0 auto;
    min-height: 44px;
    border: 0;
    border-radius: 12px;
    background: var(--brand);
    color: white;
    padding: 11px 18px;
    font-weight: 900;
}

.management-save-button:hover {
    filter: brightness(1.06);
}

.management-save-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.management-button-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.management-clear-button,
.management-history-edit {
    min-height: 42px;
    border: 1px solid #d7a8a8;
    border-radius: 12px;
    background: #fff;
    color: #a83c3c;
    padding: 10px 14px;
    font: inherit;
    font-weight: 800;
}

.management-history-edit {
    margin-top: 14px;
    border-color: var(--line);
    color: var(--brand);
}

.management-clear-button:hover,
.management-history-edit:hover {
    background: #f7fbfa;
}

.management-clear-button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.management-history-section {
    padding: 0;
}

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

.management-history-item {
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    overflow: hidden;
}

.management-history-item summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    cursor: pointer;
    color: var(--brand);
    font-weight: 800;
}

.management-history-item summary > span:first-child {
    display: grid;
    gap: 2px;
}

.management-history-item summary small {
    color: var(--muted);
    font-weight: 600;
}

.management-history-body {
    padding: 0 16px 16px;
}

.management-history-change {
    display: grid;
    grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.7fr);
    gap: 12px;
    padding: 10px 0;
    border-top: 1px solid var(--line);
}

.management-history-change span {
    overflow-wrap: anywhere;
}

.management-history-change b {
    margin: 0 6px;
    color: var(--muted);
}

.management-activity-event {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    padding: 15px;
    border: 1px solid #d7e7e2;
    border-radius: 14px;
    background: #eef7f4;
}

.management-activity-icon {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--brand);
    color: white;
    font-weight: 900;
}

.management-activity-event time,
.management-activity-event strong {
    display: block;
}

.management-activity-event time {
    margin-bottom: 3px;
    color: var(--muted);
    font-size: 11px;
}

.management-activity-event strong {
    color: var(--brand);
    font-size: 12px;
    text-transform: uppercase;
}

.management-activity-event p {
    margin: 5px 0 0;
    line-height: 1.45;
}

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

    .management-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .management-button-group {
        display: grid;
        grid-template-columns: 1fr;
    }

    .management-clear-button,
    .management-save-button {
        width: 100%;
    }

    .management-history-change {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .management-save-button {
        width: 100%;
    }
}


/* CRM semantics and follow-up V2.1 */
.stats-grid {
    grid-template-columns:
        repeat(auto-fit, minmax(175px, 1fr));
}

.stat-card.follow-up {
    background: #eef5fb;
    border-color: #d2e2f1;
}

.stat-card.overdue {
    background: #fff2e3;
    border-color: #f1d4af;
}

.management-actions {
    min-width: 0;
}

.management-form-status {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

.management-save-button {
    width: auto;
    min-width: 165px;
    max-width: 100%;
}

.follow-up-cell {
    display: grid;
    gap: 5px;
    justify-items: start;
    min-width: 145px;
}

.follow-up-cell small {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.bot-alert-help {
    margin: 14px 0 0;
    padding: 12px 14px;
    border-left: 3px solid var(--accent);
    border-radius: 8px;
    background: #fff8ef;
    color: #5d6870;
    font-size: 12px;
    line-height: 1.5;
}

.bot-alert-help strong {
    color: var(--text);
}

@media (max-width: 620px) {
    .management-save-button {
        width: 100%;
        min-width: 0;
    }
}


/* CRM intervention workflow V2.2.1 */
.stats-grid {
    grid-template-columns:
        repeat(4, minmax(0, 1fr));
}

.stat-card.intervention {
    background: var(--danger-soft);
    border-color: #efcaca;
}

.stat-card.follow-up {
    background: #eef5fb;
    border-color: #d2e2f1;
}

.stat-card.overdue {
    background: #fff2e3;
    border-color: #f1d4af;
}

.follow-up-cell {
    display: grid;
    gap: 4px;
    justify-items: start;
    min-width: 135px;
}

.follow-up-cell small {
    color: var(--muted);
    font-size: 11px;
    white-space: nowrap;
}

.management-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-width: 0;
}

.management-form-status {
    min-width: 0;
    overflow-wrap: anywhere;
}

.management-save-button {
    width: auto;
    min-width: 165px;
    max-width: 100%;
}

.intervention-section {
    padding: 20px;
    border: 1px solid #ecd7d7;
    border-radius: 18px;
    background: #fffafa;
}

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

.intervention-card {
    padding: 17px;
    border: 1px solid #ebd1d1;
    border-radius: 15px;
    background: white;
}

.intervention-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.intervention-card h4 {
    margin: 4px 0 0;
    font-size: 16px;
}

.intervention-type {
    color: var(--danger);
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.intervention-reason {
    margin: 13px 0;
    color: #475761;
    line-height: 1.5;
}

.intervention-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0 0 15px;
}

.intervention-meta div {
    padding: 10px 12px;
    border-radius: 10px;
    background: #f7f9fa;
}

.intervention-meta dt {
    color: var(--muted);
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.intervention-meta dd {
    margin: 4px 0 0;
    font-size: 13px;
    font-weight: 700;
}

.intervention-resolution-field {
    margin-bottom: 12px;
}

.intervention-resolution-field textarea {
    width: 100%;
    resize: vertical;
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 11px 12px;
    font: inherit;
    line-height: 1.45;
}

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

.intervention-action-button {
    min-height: 40px;
    border: 0;
    border-radius: 10px;
    padding: 9px 13px;
    font-weight: 900;
}

.intervention-action-button.resolve {
    background: var(--brand);
    color: white;
}

.intervention-action-button.dismiss {
    background: #edf0f2;
    color: #53636e;
}

.intervention-action-status {
    min-height: 18px;
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 12px;
}

.intervention-action-status.error {
    color: var(--danger);
    font-weight: 800;
}

.intervention-empty {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    padding: 16px;
    border: 1px solid #cce4d5;
    border-radius: 14px;
    background: #eef8f2;
}

.intervention-empty-icon {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: #246b46;
    color: white;
    font-weight: 900;
}

.intervention-empty p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.intervention-history {
    margin-top: 15px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: white;
}

.intervention-history-only .intervention-history {
    margin-top: 0;
}

.intervention-history summary {
    cursor: pointer;
    padding: 13px 15px;
    color: #53636e;
    font-size: 13px;
    font-weight: 900;
}

.intervention-history-list {
    display: grid;
    gap: 10px;
    padding: 0 13px 13px;
}

.intervention-history-item {
    padding: 13px;
    border: 1px solid var(--line);
    border-radius: 11px;
    background: var(--panel-soft);
}

.intervention-history-item > div {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.intervention-history-item p {
    margin: 9px 0;
    line-height: 1.45;
}

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

.intervention-history-item blockquote {
    margin: 10px 0 0;
    padding: 9px 11px;
    border-left: 3px solid var(--brand);
    background: white;
}

@media (max-width: 1050px) {
    .stats-grid {
        grid-template-columns:
            repeat(2, minmax(0, 1fr));
    }
}

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

    .management-actions {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .management-save-button {
        width: 100%;
        min-width: 0;
    }

    .intervention-card-header,
    .intervention-history-item > div {
        flex-direction: column;
    }

    .intervention-meta {
        grid-template-columns: 1fr;
    }

    .intervention-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .intervention-actions button {
        width: 100%;
    }
}
