* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f5f5;
    font-family: Arial, sans-serif;
    color: #222222;
}

.page {
    max-width: 1280px;
    margin: auto;
    padding: 14px;
}

/* =========================
   Верхняя шапка
   ========================= */

.hero {
    background: #ffffff;
    border-radius: 0;
    padding: 18px 22px;
    border-bottom: 3px solid #c62828;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    margin-bottom: 14px;
}

.hero-row {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: center;
}

.hero h1 {
    margin: 0 0 4px;
    font-size: 30px;
    color: #111827;
    font-weight: 800;
}

.hero p {
    margin: 0;
    color: #6b7280;
    font-size: 14px;
}

.badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    padding: 10px 14px;
    border-radius: 10px;
    font-weight: 700;
    color: #111827;
}

.switch-user-btn {
    width: auto;
    padding: 6px 12px;
    border-radius: 8px;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
    font-size: 12px;
}

.switch-user-btn:hover {
    background: #f3f4f6;
}

/* =========================
   Основные карточки
   ========================= */

.card {
    background: #ffffff;
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 14px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.card-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
}

.card-title h2 {
    margin: 0;
    font-size: 17px;
}

.hint {
    color: #6b7280;
    font-size: 14px;
    margin-top: 6px;
}

/* =========================
   Формы
   ========================= */

label {
    display: block;
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 6px;
    font-weight: 700;
}

input,
select,
button,
textarea {
    width: 100%;
    padding: 9px 10px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    font-size: 13px;
    background: #ffffff;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

button {
    background: #1d4ed8;
    color: #ffffff;
    border: none;
    cursor: pointer;
    font-weight: 700;
    transition: 0.2s ease;
}

button:hover {
    background: #1e40af;
}

.btn-dark {
    background: #111827;
}

.btn-dark:hover {
    background: #030712;
}

.btn-light {
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #dbe4ee;
    box-shadow: none;
}

.btn-light:hover {
    background: #f3f4f6;
}

.small-btn {
    width: auto;
    padding: 10px 16px;
}

/* =========================
   Статистика сверху
   ========================= */

.stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}

.stat {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px;
}

.stat .label {
    color: #6b7280;
    font-size: 14px;
    font-weight: 700;
}

.stat .value {
    font-size: 20px;
    font-weight: 900;
    margin-top: 8px;
}

.stat .sub {
    color: #6b7280;
    font-size: 13px;
    margin-top: 4px;
}

.blue {
    border-top: 4px solid #c62828;
}

.green {
    border-top: 4px solid #16a34a;
}

.orange {
    border-top: 4px solid #ea580c;
}

.red {
    border-top: 4px solid #dc2626;
}

/* =========================
   Таблицы
   ========================= */

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #ffffff;
}

table {
    width: 100%;
    min-width: 1100px;
    border-collapse: separate;
    border-spacing: 0;
    background: #ffffff;
}

th {
    background: #f3f4f6;
    color: #374151;
    font-size: 12px;
    text-align: left;
    font-weight: 700;
    white-space: nowrap;
}

th,
td {
    border-bottom: 1px solid #f1f5f9;
    padding: 5px 6px;
    vertical-align: middle;
}

td input,
td select {
    font-weight: 500;
    margin: 0;
    min-width: 110px;
    border: none;
    background: transparent;
    padding: 6px 8px;
    border-radius: 6px;
    box-shadow: none;
}

.priority,
.priority-select {
    font-weight: 700;
    text-align: center;
    border-radius: 6px;
    padding: 5px 8px;
    display: inline-block;
    min-width: 74px;
    border: none;
    color: #ffffff !important;
}

.hot {
    background: #c62828 !important;
}

.warm {
    background: #ef6c00 !important;
}

.cold {
    background: #546e7a !important;
}

.money-cell input,
.money {
    font-weight: 800 !important;
    color: #111827;
    font-size: 14px;
}

.danger-text {
    color: #b91c1c;
    font-weight: 700;
}

/* =========================
   Дни без движения
   ========================= */

.idle-badge {
    display: inline-block;
    min-width: 34px;
    text-align: center;
    padding: 4px 8px;
    border-radius: 6px;
    background: #e5e7eb;
    color: #374151;
    font-weight: 800;
    font-size: 12px;
}

.idle-yellow {
    background: #fef3c7;
    color: #92400e;
}

.idle-orange {
    background: #fed7aa;
    color: #9a3412;
}

.idle-red {
    background: #fee2e2;
    color: #991b1b;
}

/* =========================
   Автоматический контроль
   ========================= */

.control-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.control-card {
    border: 1px solid #dddddd;
    border-radius: 10px;
    padding: 12px;
    background: #ffffff;
}

.control-card strong {
    display: block;
    font-size: 22px;
    margin-bottom: 4px;
}

.control-card span {
    color: #666666;
    font-size: 13px;
    font-weight: 700;
}

.control-card.warning {
    border-left: 4px solid #f59e0b;
}

.control-card.orange-alert {
    border-left: 4px solid #ef6c00;
}

.control-card.danger-alert {
    border-left: 4px solid #c62828;
}

.control-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 12px;
    background: #fee2e2;
    color: #991b1b;
}

/* =========================
   Блок "Деньги на сегодня" — нежно-серый
   ========================= */

.today-money-section {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-left: 6px solid #94a3b8 !important;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.06) !important;
}

.today-money-section .card-title h2 {
    color: #1f2937 !important;
}

.today-money-section .hint {
    color: #64748b !important;
}

.today-money-section .table-wrap {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 10px !important;
}

.today-money-section table {
    background: #ffffff !important;
}

.today-money-section th,
.today-money-section table thead th {
    background: #f1f5f9 !important;
    color: #334155 !important;
    border-bottom: 1px solid #e2e8f0 !important;
}

.today-money-section td {
    background: #ffffff !important;
}

.today-money-section tr:hover td {
    background: #f8fafc !important;
}

.today-money-section .small-btn {
    border-color: #cbd5e1 !important;
    color: #334155 !important;
    background: #ffffff !important;
}

.today-money-section .small-btn:hover {
    background: #f1f5f9 !important;
    border-color: #94a3b8 !important;
}

/* =========================
   Блок "Деньги в просчетах и работе"
   ========================= */

.calculation-money-section {
    background: #fff7ed !important;
    border: 1px solid #fed7aa !important;
    border-left: 6px solid #fb923c !important;
}

.calculation-money-section .card-title h2 {
    color: #9a3412 !important;
}

.calculation-money-section .hint {
    color: #c2410c !important;
}

.calculation-money-section .table-wrap {
    border-color: #fed7aa !important;
}

.calculation-money-section th {
    background: #ffedd5 !important;
    color: #7c2d12 !important;
}

/* =========================
   Блок активности
   ========================= */

.activity-section {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-left: 6px solid #64748b !important;
}

.activity-section .card-title h2 {
    color: #334155 !important;
}

.activity-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.activity-box {
    background: #f9fafb;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid #e5e7eb;
}

/* =========================
   Админка
   ========================= */

.admin-grid {
    display: grid;
    grid-template-columns: 1.3fr 0.9fr;
    gap: 18px;
}

.admin-clients-section {
    background: #fefce8 !important;
    border: 1px solid #fde68a !important;
    border-left: 6px solid #eab308 !important;
}

.admin-clients-section h2 {
    color: #713f12 !important;
}

.admin-clients-section .hint {
    color: #854d0e !important;
}

.admin-clients-section .table-wrap {
    border-color: #fde68a !important;
}

.admin-clients-section th {
    background: #fef3c7 !important;
    color: #713f12 !important;
}

.report-item {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    padding: 10px;
    border-radius: 14px;
    margin-top: 10px;
    line-height: 1.5;
}

.online-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    background: #22c55e;
    margin-right: 6px;
    vertical-align: middle;
    box-shadow: 0 0 0 4px rgba(34,197,94,0.15);
}

.online-dot.active {
    background: #2563eb;
}

.online-dot.offline {
    background: #9ca3af;
    box-shadow: none;
}

.online-dot.idle {
    background: #f59e0b;
}

/* =========================
   Логин и модальные окна
   ========================= */

.login-overlay,
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.75);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(6px);
    padding: 16px;
}

.login-overlay {
    display: flex;
}

.login-box,
.modal-box {
    width: 620px;
    max-width: 100%;
    background: #ffffff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}

.login-box {
    width: 360px;
    text-align: center;
}

.login-box h2 {
    margin: 0 0 8px;
    font-size: 24px;
}

.login-box p {
    margin: 0 0 20px;
    color: #6b7280;
    font-size: 14px;
}

.login-box select,
.login-box input {
    margin-bottom: 12px;
    height: 46px;
}

.login-box button {
    height: 46px;
    font-size: 15px;
}

.modal-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.modal-title h2 {
    margin: 0;
    font-size: 20px;
}

.modal-close {
    width: 34px;
    height: 34px;
    padding: 0;
    background: #f3f4f6;
    color: #111827;
    border: 1px solid #e5e7eb;
    font-size: 22px;
    line-height: 1;
}

.modal-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.modal-full {
    grid-column: 1 / -1;
}

.modal-full textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.report-modal-box {
    width: 920px;
}

.report-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin: 14px 0;
}

.summary-mini {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px;
}

.summary-mini span {
    color: #6b7280;
    font-size: 12px;
    font-weight: 700;
}

.summary-mini strong {
    display: block;
    font-size: 19px;
    margin-top: 6px;
}

.summary-mini.danger {
    border-left: 5px solid #dc2626;
}

/* =========================
   Редактирование строк
   ========================= */

.edit-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 10px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    font-size: 15px;
    font-weight: 700;
}

.edit-btn:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.readonly-row input:not(.deal-complete),
.readonly-row select {
    pointer-events: none;
    background: transparent;
    color: #374151;
}

.readonly-row .deal-complete {
    pointer-events: auto;
    cursor: pointer;
}

.editing-row {
    background: #f8fbff !important;
}

.editing-row input,
.editing-row select {
    background: #ffffff;
    border: 1px solid #dbe4ee;
}

/* =========================
   Нижнее меню
   ========================= */

.actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    position: sticky;
    bottom: 0;
    background: #ffffff;
    padding: 12px;
    border-top: 1px solid #e5e7eb;
    z-index: 20;
}

/* =========================
   Мобильная версия
   ========================= */

@media (max-width: 950px) {
    .hero {
        position: sticky;
        top: 0;
        z-index: 50;
        border-radius: 0 0 12px 12px;
    }

    .hint {
        font-size: 12px;
        line-height: 1.4;
    }

    body {
        padding-bottom: 86px;
    }

    .page {
        padding: 10px;
    }

    .hero-row,
    .stats,
    .control-grid,
    .activity-grid,
    .admin-grid,
    .actions {
        grid-template-columns: 1fr;
        display: grid;
    }

    .hero h1 {
        font-size: 20px;
    }

    .hero p {
        font-size: 12px;
    }

    .badge {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }

    .card {
        padding: 12px;
        border-radius: 10px;
    }

    .card-title {
        display: grid;
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .small-btn {
        width: 100%;
        min-height: 46px;
        font-size: 15px;
    }

    button,
    input,
    select,
    textarea {
        min-height: 46px;
        font-size: 15px;
    }

    .table-wrap {
        border: none;
        overflow: visible;
        background: transparent;
    }

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
        width: 100%;
        min-width: 0;
    }

    thead {
        display: none;
    }

    tr {
        background: #ffffff;
        border: 1px solid #dddddd;
        border-radius: 12px;
        padding: 10px;
        margin-bottom: 10px;
        box-shadow: 0 1px 4px rgba(0,0,0,0.05);
    }

    td {
        border: none;
        padding: 9px 0;
        display: grid;
        grid-template-columns: 110px 1fr;
        gap: 8px;
        align-items: center;
    }

    td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #666666;
        font-size: 12px;
    }

    td input,
    td select {
        width: 100%;
        min-width: 0;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
    }

    .modal-box,
    .report-modal-box {
        border-radius: 16px;
        width: 100%;
        max-height: 92vh;
        overflow-y: auto;
    }

    .modal-grid,
    .report-summary-grid,
    .modal-actions {
        grid-template-columns: 1fr;
    }

    .actions {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9997;
        background: #ffffff;
        border-top: 1px solid #dddddd;
        padding: 8px;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        box-shadow: 0 -8px 24px rgba(0,0,0,0.12);
    }

    .actions button {
        min-height: 56px;
        padding: 8px 6px;
        font-size: 12px;
        line-height: 1.15;
        border-radius: 8px;
    }
}