:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-soft: #f9fafc;
    --text: #171a23;
    --muted: #73798a;
    --border: #e8eaf0;

    --primary: #5b5ce2;
    --primary-hover: #4d4ed0;
    --primary-soft: #eeeeff;

    --danger: #e64b5d;
    --danger-soft: #fff0f2;

    --sidebar-width: 250px;
    --radius: 16px;

    --shadow: 0 10px 30px rgba(20, 25, 40, .05);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: Inter, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}


/* LOGIN */

.login-page {
    min-height: 100vh;
    background: #fff;
}

.login-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.05fr .95fr;
}

.login-brand {
    position: relative;
    overflow: hidden;
    padding: 70px;
    display: flex;
    align-items: center;
    color: #fff;
    background: linear-gradient(145deg, #4c4ed7, #7068ec);
}

.login-brand-content {
    position: relative;
    z-index: 2;
    max-width: 570px;
}

.brand-logo {
    margin-bottom: 100px;
    font-size: 25px;
    font-weight: 800;
}

.login-brand h1 {
    margin: 0 0 24px;
    font-size: clamp(48px, 5vw, 78px);
    line-height: .98;
    letter-spacing: -4px;
}

.login-brand p {
    max-width: 500px;
    margin: 0;
    font-size: 19px;
    line-height: 1.6;
    color: rgba(255,255,255,.76);
}

.login-decoration {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
}

.decoration-one {
    width: 520px;
    height: 520px;
    right: -180px;
    top: -150px;
}

.decoration-two {
    width: 400px;
    height: 400px;
    left: -170px;
    bottom: -180px;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.login-card {
    width: 100%;
    max-width: 430px;
}

.login-card h2 {
    margin: 0 0 10px;
    font-size: 34px;
}

.login-subtitle {
    margin: 0 0 40px;
    color: var(--muted);
    line-height: 1.5;
}

.login-mobile-logo {
    display: none;
    margin-bottom: 60px;
    color: var(--primary);
    font-size: 25px;
    font-weight: 800;
}

.form-group {
    margin-bottom: 22px;
}

.form-group label {
    display: block;
    margin-bottom: 9px;
    font-size: 14px;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 14px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: #fff;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(91,92,226,.08);
}

.button {
    min-height: 46px;
    padding: 0 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.button-primary {
    background: var(--primary);
    color: #fff;
}

.button-primary:hover {
    background: var(--primary-hover);
}

.button-full {
    width: 100%;
}

.alert {
    margin-bottom: 25px;
    padding: 14px 16px;
    border-radius: 10px;
    font-size: 14px;
}

.alert-error {
    background: var(--danger-soft);
    color: #bf3043;
}

.alert-success {
    background: #edf9f3;
    color: #14734a;
}

.simple-center {
    min-height: 100vh;
    padding: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* CRM */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    padding: 28px 18px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-right: 1px solid var(--border);
    z-index: 100;
}

.sidebar-logo {
    padding: 7px 13px 34px;
    font-size: 22px;
    font-weight: 800;
    color: var(--primary);
}

.sidebar-nav,
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-bottom {
    margin-top: auto;
}

.nav-item {
    min-height: 45px;
    padding: 0 13px;
    display: flex;
    align-items: center;
    gap: 13px;
    border-radius: 9px;
    color: #626879;
    font-size: 14px;
    font-weight: 500;
}

.nav-item span {
    width: 20px;
    text-align: center;
}

.nav-item:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}

.main-content {
    min-height: 100vh;
    margin-left: var(--sidebar-width);
}

.topbar {
    height: 74px;
    padding: 0 38px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,.9);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(15px);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.icon-button {
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 10px;
    background: var(--surface-soft);
    cursor: pointer;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 11px;
}

.avatar {
    width: 39px;
    height: 39px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 13px;
    font-weight: 700;
}

.user-menu-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.user-menu-text strong {
    font-size: 13px;
}

.user-menu-text span {
    font-size: 11px;
    color: var(--muted);
}

.topbar-mobile-logo {
    display: none;
    color: var(--primary);
    font-weight: 800;
}

.content {
    max-width: 1600px;
    margin: auto;
    padding: 45px 45px 80px;
}

.welcome {
    margin-bottom: 35px;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 25px;
}

.eyebrow {
    margin: 0 0 10px;
    color: var(--primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.4px;
}

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

.welcome > div > p:last-child {
    margin: 10px 0 0;
    color: var(--muted);
}

.stats-grid {
    margin-bottom: 22px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.stat-card {
    min-height: 135px;
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border-radius: 13px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 21px;
    font-weight: 700;
}

.stat-danger .stat-icon {
    background: var(--danger-soft);
    color: var(--danger);
}

.stat-label {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 13px;
}

.stat-number {
    display: block;
    font-size: 29px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0,1fr) 310px;
    gap: 22px;
}

.panel {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel-header {
    min-height: 90px;
    padding: 22px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    margin: 0 0 5px;
    font-size: 17px;
}

.panel-header p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.panel-header > a {
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
}

.task-list {
    padding: 8px;
}

.task-row {
    min-height: 72px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 13px;
    border-radius: 11px;
}

.task-row:hover {
    background: var(--surface-soft);
}

.task-check {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: 2px solid #d8dae3;
    border-radius: 6px;
}

.task-main {
    min-width: 0;
    flex: 1;
}

.task-main strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.task-meta {
    margin-top: 5px;
    color: var(--muted);
    font-size: 11px;
}

.priority {
    padding: 5px 9px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
}

.priority-normal {
    color: #606779;
    background: #f0f1f5;
}

.priority-high {
    color: #b86912;
    background: #fff4e5;
}

.priority-urgent {
    color: #c33143;
    background: #fff0f2;
}

.priority-low {
    color: #38755e;
    background: #edf8f3;
}

.empty-state {
    padding: 55px 30px;
    text-align: center;
}

.empty-icon {
    width: 52px;
    height: 52px;
    margin: 0 auto 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 22px;
}

.empty-state h3 {
    margin: 0 0 7px;
}

.empty-state p {
    margin: auto;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}

.today-summary {
    padding: 40px 25px;
}

.today-big {
    margin-bottom: 8px;
    font-size: 52px;
    font-weight: 700;
}

.today-summary p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

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

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

@media (max-width: 800px) {
    .login-layout {
        display: block;
    }

    .login-brand {
        display: none;
    }

    .login-panel {
        min-height: 100vh;
        padding: 30px 22px;
    }

    .login-mobile-logo {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .topbar {
        height: 66px;
        padding: 0 20px;
    }

    .topbar-mobile-logo {
        display: block;
    }

    .content {
        padding: 30px 20px 60px;
    }

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

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

@media (max-width: 500px) {
    .user-menu-text {
        display: none;
    }

    .welcome .button {
        width: 100%;
    }

    .priority {
        display: none;
    }
}

/* USERS / ADMIN */

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

.crm-table {
    width: 100%;
    border-collapse: collapse;
}

.crm-table th {
    padding: 15px 22px;

    text-align: left;

    color: var(--muted);

    font-size: 11px;
    font-weight: 600;

    border-bottom: 1px solid var(--border);

    background: var(--surface-soft);
}

.crm-table td {
    padding: 17px 22px;

    border-bottom: 1px solid var(--border);

    font-size: 13px;
}

.crm-table tbody tr:last-child td {
    border-bottom: 0;
}

.crm-table tbody tr:hover {
    background: #fafbfc;
}

.table-user {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-user > div:last-child {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.table-user strong {
    font-size: 13px;
}

.table-user span {
    color: var(--muted);
    font-size: 11px;
}

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

.table-actions {
    text-align: right;
}

.table-action {
    color: var(--primary);

    font-weight: 600;
    font-size: 12px;
}

.table-action:hover {
    text-decoration: underline;
}


.role-badge,
.status-badge {
    display: inline-flex;

    padding: 6px 9px;

    border-radius: 30px;

    font-size: 10px;
    font-weight: 600;
}

.role-admin {
    color: #5b42c7;
    background: #f0edff;
}

.role-manager {
    color: #9a6611;
    background: #fff6df;
}

.role-user {
    color: #536072;
    background: #f0f2f5;
}

.status-active {
    color: #207854;
    background: #eaf8f1;
}

.status-inactive {
    color: #a13d48;
    background: #fff0f2;
}


.form-content {
    max-width: 1100px;
}

.form-panel {
    overflow: hidden;
}

.crm-form {
    padding: 28px;
}

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

.form-span-2 {
    grid-column: span 2;
}

.form-group small {
    display: block;

    margin-top: 7px;

    color: var(--muted);

    font-size: 11px;
    line-height: 1.5;
}

.form-actions {
    margin-top: 15px;
    padding-top: 25px;

    display: flex;
    justify-content: flex-end;
    gap: 10px;

    border-top: 1px solid var(--border);
}

.button-secondary {
    background: #f1f2f6;
    color: var(--text);
}

.button-secondary:hover {
    background: #e8eaf0;
}

.back-link {
    color: var(--muted);

    font-size: 13px;
    font-weight: 500;
}

.back-link:hover {
    color: var(--primary);
}


.checkbox-row {
    display: flex !important;
    align-items: flex-start;
    gap: 12px;

    padding: 16px;

    cursor: pointer;

    border: 1px solid var(--border);
    border-radius: 10px;
}

.checkbox-row input {
    width: 18px !important;
    height: 18px;

    margin: 1px 0 0;

    flex-shrink: 0;
}

.checkbox-row span {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.checkbox-row strong {
    font-size: 13px;
}

.checkbox-row small {
    margin: 0;
}


@media (max-width: 700px) {

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

    .form-span-2 {
        grid-column: span 1;
    }

    .crm-form {
        padding: 20px;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

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

}
/* TASKS */

.tasks-toolbar {
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
}

.task-filters {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-pill {
    padding: 8px 12px;

    border-radius: 30px;

    color: var(--muted);
    background: #f4f5f8;

    font-size: 12px;
    font-weight: 600;
}

.filter-pill:hover {
    color: var(--text);
}

.filter-pill.active {
    color: var(--primary);
    background: var(--primary-soft);
}

.clickable-row {
    cursor: pointer;
}

.task-title-cell {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.task-title-cell strong {
    font-size: 13px;
}

.task-title-cell span {
    color: var(--muted);
    font-size: 11px;
}

.task-status {
    display: inline-flex;

    padding: 6px 9px;

    border-radius: 30px;

    font-size: 10px;
    font-weight: 600;
}

.task-status-new {
    color: #536072;
    background: #eff1f5;
}

.task-status-in_progress {
    color: #4a50b7;
    background: #eeeeff;
}

.task-status-waiting {
    color: #9b6813;
    background: #fff4dc;
}

.task-status-completed {
    color: #247955;
    background: #e9f8f0;
}

.task-status-cancelled {
    color: #9d4853;
    background: #fff0f2;
}

.due-overdue {
    color: var(--danger);
    font-weight: 600;
}


/* TASK DETAIL */

.task-detail-header {
    margin-bottom: 30px;
}

.task-detail-header h1 {
    margin: 12px 0 8px;

    font-size: 34px;
    letter-spacing: -1px;
}

.task-detail-header p {
    margin: 0;

    color: var(--muted);
    font-size: 13px;
}

.task-detail-badges {
    display: flex;
    gap: 8px;
}

.task-detail-grid {
    display: grid;

    grid-template-columns:
        minmax(0, 1fr)
        340px;

    gap: 22px;
}

.task-description {
    padding: 28px;

    min-height: 220px;

    font-size: 14px;
    line-height: 1.75;
}

.task-info-list {
    padding: 10px 24px;
}

.task-info-row {
    padding: 16px 0;

    display: flex;
    justify-content: space-between;
    gap: 20px;

    border-bottom: 1px solid var(--border);
}

.task-info-row span {
    color: var(--muted);

    font-size: 12px;
}

.task-info-row strong {
    text-align: right;

    font-size: 12px;
}

.task-status-form {
    margin: 10px 24px 24px;
    padding-top: 20px;

    border-top: 1px solid var(--border);
}

.task-status-form label {
    display: block;

    margin-bottom: 8px;

    font-size: 12px;
    font-weight: 600;
}

.task-status-form select {
    width: 100%;

    margin-bottom: 12px;

    padding: 12px;

    border: 1px solid var(--border);
    border-radius: 9px;

    background: white;
}

@media (max-width: 900px) {

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

}

@media (max-width: 700px) {

    .tasks-table th:nth-child(2),
    .tasks-table td:nth-child(2),
    .tasks-table th:nth-child(3),
    .tasks-table td:nth-child(3) {
        display: none;
    }

}
