:root {
    --paper: #f8f5ee;
    --ink: #1f2937;
    --brand: #0f766e;
    --accent: #b45309;
    --muted: #6b7280;
    --card: rgba(255, 255, 255, 0.92);
    --line: rgba(15, 23, 42, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background:
        radial-gradient(
            circle at 0% 0%,
            rgba(15, 118, 110, 0.12),
            transparent 35%
        ),
        radial-gradient(
            circle at 100% 100%,
            rgba(180, 83, 9, 0.14),
            transparent 35%
        ),
        var(--paper);
    color: var(--ink);
}

.grid-paper {
    background-image:
        linear-gradient(to right, rgba(31, 41, 55, 0.06) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(31, 41, 55, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
    mask-image: linear-gradient(
        to bottom,
        transparent,
        black 10%,
        black 90%,
        transparent
    );
}

.app-shell {
    position: relative;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
}

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.62);
    backdrop-filter: blur(8px);
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(15, 118, 110, 0.22);
    background: rgba(15, 118, 110, 0.08);
    color: #115e59;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.sidebar-link {
    display: block;
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    color: #334155;
    transition: all 0.2s ease;
}

.sidebar-link:hover {
    background: rgba(15, 118, 110, 0.08);
}

.sidebar-link.active {
    color: #f8fafc;
    background: linear-gradient(135deg, #0f766e, #134e4a);
}

.content-wrap {
    padding: 24px;
}

.page-title {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1.15;
}

.page-subtitle {
    color: var(--muted);
    margin-top: 6px;
}

.crm-panel {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 14px 32px rgba(15, 23, 42, 0.06);
}

.crm-chip {
    border: 1px solid rgba(15, 118, 110, 0.24);
    color: #115e59;
    background: rgba(15, 118, 110, 0.1);
    border-radius: 999px;
    font-size: 12px;
    line-height: 1;
    padding: 8px 12px;
    font-weight: 700;
}

.crm-chip-warn {
    border: 1px solid rgba(180, 83, 9, 0.22);
    color: #9a3412;
    background: rgba(249, 115, 22, 0.12);
}

.card-lift {
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

.card-lift:hover {
    transform: translateY(-3px);
    box-shadow: 0 20px 30px rgba(15, 23, 42, 0.09);
}

.status-pill {
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.status-new {
    background: rgba(2, 132, 199, 0.12);
    color: #0c4a6e;
}

.status-ok {
    background: rgba(16, 185, 129, 0.14);
    color: #064e3b;
}

.status-pending {
    background: rgba(245, 158, 11, 0.14);
    color: #7c2d12;
}

.status-stop {
    background: rgba(239, 68, 68, 0.12);
    color: #7f1d1d;
}

.status-invite {
    background: rgba(59, 130, 246, 0.14);
    color: #1e3a8a;
}

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

.metric-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.metric-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin-top: 6px;
}

.table-wrap {
    overflow-x: auto;
}

.table-ui {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table-ui thead tr {
    color: #64748b;
    border-bottom: 1px solid rgba(148, 163, 184, 0.34);
}

.table-ui tbody tr {
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.table-ui th,
.table-ui td {
    text-align: left;
    vertical-align: top;
    padding: 12px 10px;
}

.kanban-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(220px, 1fr));
    gap: 12px;
    min-width: 1450px;
}

.kanban-col {
    border-radius: 14px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.78);
    padding: 10px;
}

.kanban-card {
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: rgba(255, 255, 255, 0.95);
    padding: 10px;
}

.lock-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(254, 226, 226, 0.75);
    color: #991b1b;
    font-size: 12px;
    font-weight: 700;
    padding: 7px 12px;
}

.lock-chip.unlocked {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(209, 250, 229, 0.8);
    color: #065f46;
}

.action-btn {
    border-radius: 10px;
    border: 1px solid rgba(15, 23, 42, 0.12);
    background: #ffffff;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 700;
}

.action-btn.ok {
    border-color: rgba(16, 185, 129, 0.25);
    background: rgba(236, 253, 245, 0.95);
    color: #065f46;
}

.action-btn.stop {
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(254, 242, 242, 0.95);
    color: #991b1b;
}

.action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.history-item {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.45);
    font-size: 13px;
}

.history-item:last-child {
    border-bottom: 0;
}

.history-date {
    color: #64748b;
    font-weight: 700;
}

.message-user {
    background: rgba(15, 118, 110, 0.1);
    border: 1px solid rgba(15, 118, 110, 0.2);
}

.message-bot {
    background: rgba(148, 163, 184, 0.13);
    border: 1px solid rgba(15, 23, 42, 0.1);
}

.tab-btn {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(255, 255, 255, 0.8);
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 700;
}

.tab-btn.active {
    background: linear-gradient(135deg, #0f766e, #134e4a);
    border-color: transparent;
    color: #f8fafc;
}

.role-switch {
    display: grid;
    gap: 6px;
}

.role-btn {
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(255, 255, 255, 0.9);
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 700;
    text-align: left;
    transition: all 0.2s ease;
}

.role-btn.active {
    background: linear-gradient(135deg, #0f766e, #134e4a);
    color: #f8fafc;
    border-color: transparent;
}

.info-strip {
    border-radius: 12px;
    border: 1px dashed rgba(15, 23, 42, 0.2);
    background: rgba(241, 245, 249, 0.65);
    padding: 10px 12px;
    font-size: 13px;
    color: #334155;
}

.hidden-role {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.modal-card {
    width: min(760px, 100%);
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: #ffffff;
    box-shadow: 0 24px 40px rgba(15, 23, 42, 0.24);
    padding: 18px;
}

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.4);
    background: #ffffff;
    color: #475569;
    font-size: 22px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 50;
    background: #0f172a;
    color: #f8fafc;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 13px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.toast.show {
    opacity: 1;
}

.fade-up {
    animation: fadeUp 0.5s ease both;
}

.stagger > * {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeUp 0.55s ease forwards;
}

.stagger > *:nth-child(2) {
    animation-delay: 0.06s;
}

.stagger > *:nth-child(3) {
    animation-delay: 0.12s;
}

.stagger > *:nth-child(4) {
    animation-delay: 0.18s;
}

.stagger > *:nth-child(5) {
    animation-delay: 0.24s;
}

@keyframes fadeUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

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

@media (max-width: 700px) {
    .content-wrap {
        padding: 16px;
    }

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