:root {
    --primary-color: #0d1b2a;
    /* Deep Navy */
    --secondary-color: #1b263b;
    /* Softer Navy */
    --accent-color: #415a77;
    /* Slate Blue */
    --highlight-color: #778da9;
    /* Muted Blue */
    --light-bg: #e0e1dd;
    /* Off White / Grey */
    --white: #ffffff;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #c0392b;
    --text-dark: #333;
    --text-light: #777;
    --border-radius: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f4f6f8;
    color: var(--text-dark);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

/* SIDEBAR */
.sidebar {
    width: 250px;
    background-color: var(--primary-color);
    color: var(--white);
    display: flex;
    flex-direction: column;
    padding: 20px;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.brand h2 {
    margin-bottom: 40px;
    font-size: 1.5rem;
    letter-spacing: 1px;
}

.brand .highlight {
    color: var(--highlight-color);
}

.nav-menu {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-item {
    text-decoration: none;
    color: rgba(255, 255, 255, 0.7);
    padding: 12px 15px;
    border-radius: var(--border-radius);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
}

.nav-item:hover,
.nav-item.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--white);
    transform: translateX(5px);
}

.sidebar-footer {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    margin-top: auto;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    margin-left: 250px;
    /* Sidebar width */
    padding: 30px 40px;
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.page-title h1 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.subtitle {
    color: var(--text-light);
    font-size: 0.9rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.top-link {
    font-size: 0.75rem;
    color: var(--highlight-color);
    text-decoration: none;
    transition: color 0.2s;
    margin-right: 5px;
}

.top-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.divider-vertical {
    width: 1px;
    height: 20px;
    background-color: #ddd;
    margin: 0 5px;
}

.avatar {
    width: 40px;
    height: 40px;
    background-color: var(--accent-color);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* DASHBOARD STYLES */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 30px;
}

.kpi-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.kpi-card:hover {
    transform: translateY(-5px);
}

.kpi-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
}

.icon-leads {
    background: #e3f2fd;
    color: #1565c0;
}

.icon-won {
    background: #e8f5e9;
    color: #27ae60;
}

.icon-pipeline {
    background: #fff3e0;
    color: #e67e22;
}

.kpi-info h3 {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 5px;
}

.kpi-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Charts Grid System */
.charts-grid-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    /* 2 Columns */
    gap: 20px;
    margin-bottom: 25px;
}

.chart-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    border: 1px solid #eee;
}

.chart-card h3 {
    color: var(--secondary-color);
}

.todo-section {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.todo-section h3 {
    margin-bottom: 5px;
    font-size: 1.2rem;
    color: var(--secondary-color);
}

.section-subtitle {
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* FORMS */
.form-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
    margin-bottom: 25px;
    border-left: 4px solid var(--accent-color);
}

.form-header h3 {
    margin-bottom: 20px;
    color: var(--secondary-color);
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-control {
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(65, 90, 119, 0.1);
}

textarea.form-control {
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 20px;
}

/* BUTTONS */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: transform 0.2s, background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(13, 27, 42, 0.2);
}

.btn-primary:hover {
    background-color: #000;
}

.btn-secondary {
    background-color: #f1f3f5;
    color: var(--text-dark);
}

.btn-success {
    background-color: var(--success);
    color: white;
}

.btn-warning {
    background-color: var(--warning);
    color: white;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background: var(--danger);
    color: white;
}

/* TABLES */
.table-card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 25px;
    box-shadow: var(--shadow);
}

.table-header-actions {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.search-box input {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    width: 300px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background-color: #f8f9fa;
    border-bottom: 2px solid #e9ecef;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
}

.data-table th {
    font-weight: 600;
    color: var(--secondary-color);
}

.data-table tbody tr {
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.data-table tbody tr:hover {
    background-color: #f1f3f5;
}

/* BADGES */
.badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-prospek {
    background: #e3f2fd;
    color: #1565c0;
}

.badge-proposal {
    background: #fff3e0;
    color: #e67e22;
}

.badge-negotiasi {
    background: #f3e5f5;
    color: #8e44ad;
}

.badge-won {
    background: #e8f5e9;
    color: #27ae60;
}

.badge-lost {
    background: #ffebee;
    color: #c0392b;
}

/* MODAL */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: var(--border-radius);
    width: 50%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #aaa;
}

.modal-detail-row {
    display: flex;
    border-bottom: 1px dashed #eee;
    padding: 10px 0;
}

.modal-label {
    width: 40%;
    font-weight: 600;
    color: var(--text-light);
}

.modal-value {
    width: 60%;
    color: var(--text-dark);
}

@media (max-width: 900px) {
    .charts-grid {
        grid-template-columns: 1fr;
        /* Stack charts on smaller screens */
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 10px;
    }

    .brand h2 span,
    .nav-item span:not(.icon),
    .sidebar-footer {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 15px;
        /* Reduced padding for mobile */
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        /* Wider modal on mobile */
        padding: 20px;
    }

    /* MOBILE CARD VIEW FOR TABLES */
    /* General Reset for Tables */
    .data-table thead {
        display: none;
        /* Hide headers */
    }

    .data-table,
    .data-table tbody,
    .data-table tr,
    .data-table td {
        display: block;
        width: 100%;
    }

    .data-table tr {
        margin-bottom: 20px;
        border: 1px solid #e0e0e0;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
        background: white;
        overflow: hidden;
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        text-align: right;
        padding: 12px 15px;
        border-bottom: 1px solid #f0f0f0;
        font-size: 0.9rem;
    }

    .data-table td:last-child {
        border-bottom: none;
        justify-content: center;
        /* Center buttons */
        padding-top: 15px;
        padding-bottom: 15px;
        background: #f9f9f9;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--secondary-color);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-right: 15px;
        text-align: left;
    }

    /* SPECIFIC TABLE LABELS (Mapping Columns) */

    /* 1. MAIN DATA TABLE (Tab Data) */
    /* Cols: Tanggal, Sales, Company, Nilai, Stage, Pembayaran, Aksi */
    #sales-table-body td:nth-of-type(1)::before {
        content: "Tanggal";
    }

    #sales-table-body td:nth-of-type(2)::before {
        content: "Sales";
    }

    #sales-table-body td:nth-of-type(3)::before {
        content: "Company";
    }

    #sales-table-body td:nth-of-type(4)::before {
        content: "Nilai";
    }

    #sales-table-body td:nth-of-type(5)::before {
        content: "Stage";
    }

    #sales-table-body td:nth-of-type(6)::before {
        content: "Pembayaran";
    }

    #sales-table-body td:nth-of-type(7)::before {
        content: "";
        display: none;
    }

    /* Action row no label */

    /* 2. ACTIVITY / TO-DO TABLE */
    /* Cols: Sales, Company, Nilai, Stage, Closing, Aksi */
    #todo-table-full td:nth-of-type(1)::before {
        content: "Sales";
    }

    #todo-table-full td:nth-of-type(2)::before {
        content: "Company";
    }

    #todo-table-full td:nth-of-type(3)::before {
        content: "Nilai";
    }

    #todo-table-full td:nth-of-type(4)::before {
        content: "Stage";
    }

    #todo-table-full td:nth-of-type(5)::before {
        content: "Est. Closing";
    }

    #todo-table-full td:nth-of-type(6)::before {
        content: "";
        display: none;
    }

    /* 3. SCORECARD TABLE */
    /* Cols: Name, Leads, Won, WinRate, Revenue, Pipeline */
    #scorecard-body td:nth-of-type(1)::before {
        content: "Sales Name";
    }

    #scorecard-body td:nth-of-type(2)::before {
        content: "Total Leads";
    }

    #scorecard-body td:nth-of-type(3)::before {
        content: "Won Deals";
    }

    #scorecard-body td:nth-of-type(4)::before {
        content: "Win Rate";
    }

    #scorecard-body td:nth-of-type(5)::before {
        content: "Revenue";
    }

    #scorecard-body td:nth-of-type(6)::before {
        content: "Pipeline";
    }
}

/* ACTIVATION MODAL STYLES */
.modal-overlay {
    display: none;
    /* Default hidden, JS will show if locked */
    position: fixed;
    z-index: 10000;
    /* Highest priority */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: #0d1b2a;
    /* Solid Background */
    justify-content: center;
    align-items: center;
}

.activation-card {
    background: white;
    padding: 0;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.activation-header {
    background: linear-gradient(135deg, #0d1b2a, #1b263b);
    color: white;
    padding: 30px 20px;
    text-align: center;
}

.activation-header h2 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
}

.activation-header p {
    margin: 0;
    opacity: 0.8;
    font-size: 0.9rem;
}

.activation-body {
    padding: 30px;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    color: #555;
    font-size: 0.9rem;
}

.input-group input {
    width: 100%;
    padding: 12px;
    font-size: 1.1rem;
    letter-spacing: 2px;
    text-align: center;
    border: 2px solid #eee;
    border-radius: 6px;
    outline: none;
    font-family: monospace;
    text-transform: uppercase;
}

.input-group input:focus {
    border-color: #1b263b;
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    letter-spacing: 1px;
}

.activation-footer {
    background: #f8f9fa;
    padding: 15px;
    text-align: center;
    border-top: 1px solid #eee;
}

.activation-footer p {
    font-size: 0.85rem;
    color: #777;
    margin: 0 0 5px 0;
}

.activation-footer small {
    font-size: 0.75rem;
    color: #aaa;
}