* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
}

.logo-container {
    margin-bottom: 25px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    position: relative;
    gap: 6px;
}

.logo-text {
    height: auto;
    max-width: 280px;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

.logo-cog {
    height: auto;
    max-width: 301px;
    transform-origin: 50% 50%;
    animation: rotate-cog 20s linear infinite;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
}

@keyframes rotate-cog {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.main-logo-unused {
    max-width: 450px;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.1));
    transition: transform 0.3s ease;
}

.main-logo:hover {
    transform: scale(1.02);
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: #f39c12;
}

.subtitle {
    color: #94a3b8;
    font-size: 1.1rem;
}

/* Auth Status */
.auth-status {
    margin-top: 10px;
    font-size: 0.9rem;
    color: #27ae60;
}

/* Login Section */
.login-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 50vh;
}

.login-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 40px 50px;
    text-align: center;
    max-width: 400px;
}

.login-card h2 {
    margin-bottom: 15px;
    color: #f39c12;
}

.login-card p {
    color: #94a3b8;
    margin-bottom: 25px;
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1rem;
}

/* Filters */
.filters {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: end;
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: 0.85rem;
    color: #94a3b8;
}

.filter-group input {
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
}

.filter-group select {
    padding: 10px 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 1rem;
    cursor: pointer;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #f39c12;
}

.service-type-select {
    min-width: 200px;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-small {
    padding: 4px 12px;
    font-size: 1.2rem;
    font-weight: bold;
    line-height: 1;
}

.btn-primary {
    background: #f39c12;
    color: #1a1a2e;
    font-weight: 600;
}

.btn-primary:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-success {
    background: #27ae60;
    color: #fff;
}

.btn-danger {
    background: #e74c3c;
    color: #fff;
}

/* Dialer Panel */
.dialer-panel {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 320px;
    background: rgba(15, 23, 42, 0.95);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    padding: 18px;
    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.dialer-panel.active {
    transform: translateX(0);
}

.dialer-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 16px;
}

.dialer-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #f8fafc;
}

.dialer-subtitle {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 4px;
}

.dialer-close {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1rem;
    cursor: pointer;
}

.dialer-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dialer-contact {
    font-size: 1.1rem;
    font-weight: 600;
    color: #f8fafc;
}

.dialer-number {
    font-size: 1rem;
    color: #e2e8f0;
}

.dialer-timer {
    font-size: 1.6rem;
    font-weight: 700;
    color: #38bdf8;
    margin-bottom: 8px;
}

.dialer-section {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 12px;
}

.dialer-section-title {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #38bdf8;
    margin-bottom: 6px;
    font-weight: 700;
}

.dialer-transcript {
    min-height: 120px;
    max-height: 220px;
    overflow-y: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 8px;
    padding: 10px;
}

.dialer-recording {
    margin-top: 8px;
    font-size: 0.8rem;
    color: #94a3b8;
}

.dialer-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 30px;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.stat-card.overdue {
    border-color: #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}

.stat-card.contacted {
    border-color: #27ae60;
    background: rgba(39, 174, 96, 0.1);
}

.stat-number {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    color: #f39c12;
}

.stat-card.overdue .stat-number {
    color: #e74c3c;
}

.stat-card.contacted .stat-number {
    color: #27ae60;
}

.stat-label {
    color: #94a3b8;
    font-size: 0.9rem;
}

/* Sales Flow Chart (Interactive) */
#callScript {
    position: relative;
    overflow: hidden;
    min-height: 380px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.flow-container {
    display: flex;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    height: 100%;
}

.flow-step {
    min-width: 100%;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.flow-header {
    font-size: 0.75rem;
    color: #3b82f6;
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flow-content {
    flex-grow: 1;
    font-size: 1.1rem;
    line-height: 1.6;
    color: #1e293b;
    margin-bottom: 20px;
}

.flow-script-line {
    background: #ffffff;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
    font-style: italic;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.flow-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: auto;
}

.flow-option-btn {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: #475569;
}

.flow-option-btn:hover {
    background: #f1f5f9;
    border-color: #3b82f6;
    color: #3b82f6;
}

.flow-back-btn {
    margin-top: 15px;
    background: transparent;
    border: none;
    color: #64748b;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
}

#callScript strong { 
    display: block; 
    margin-top: 12px; 
    color: #3b82f6; 
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#callScript hr {
    border: 0;
    border-top: 1px solid #f1f5f9;
    margin: 15px 0;
}

#callScript ul { 
    margin: 10px 0 10px 20px; 
    font-size: 0.95rem;
}

#callScript p { 
    margin: 8px 0;
    font-size: 1rem;
}

.input-with-insert select#objectionTemplate {
    max-width: calc(100% - 80px);
}

.loading {
    text-align: center;
    padding: 50px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #f39c12;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error */
.error-message {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid #e74c3c;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    color: #e74c3c;
}

/* Customer List */
.dashboard-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(320px, 1fr);
    gap: 24px;
    align-items: start;
}

.dashboard-left {
    min-width: 0;
}

.dashboard-right {
    position: sticky;
    top: 20px;
}

.sales-flow-panel {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.sales-flow-panel-header {
    margin-bottom: 16px;
}

.sales-flow-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #f8fafc;
}

.sales-flow-subtitle {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-top: 4px;
}

.sales-flow-chart {
    max-height: calc(100vh - 260px);
    overflow-y: auto;
    padding-right: 6px;
}

.sales-flow-empty {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    border: 1px dashed rgba(148, 163, 184, 0.4);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.sales-flow-step {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.sales-flow-step.active {
    border-color: #38bdf8;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

.sales-step-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #38bdf8;
    font-weight: 700;
    margin-bottom: 10px;
}

.sales-step-script {
    color: #e2e8f0;
    line-height: 1.6;
    font-size: 0.95rem;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
}

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

.sales-step-actions button {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.18);
    color: #e2e8f0;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sales-step-actions button:hover {
    border-color: #38bdf8;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.1);
}

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

    .dashboard-right {
        position: static;
    }

    .sales-flow-chart {
        max-height: none;
    }
}

.customer-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 20px;
    justify-content: center;
    padding: 10px 0;
}

.customer-card {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.customer-card:hover {
    border-color: #f39c12;
    transform: translateY(-4px);
    box-shadow: 0 10px 25px rgba(243, 156, 18, 0.15);
}

.customer-card.overdue {
    border-left: 4px solid #e74c3c;
}

.customer-card.contacted {
    opacity: 0.6;
    border-left: 4px solid #27ae60;
}

.customer-card.test-customer {
    background: #fef08a;
    border-color: #f59e0b;
    color: #1f2937;
}

.customer-card.test-customer .customer-name,
.customer-card.test-customer .detail-item,
.customer-card.test-customer .customer-job-info,
.customer-card.test-customer .customer-details span {
    color: #1f2937;
}

.customer-card.test-customer .customer-badge {
    background-color: rgba(15, 23, 42, 0.9);
    color: #fef08a;
}

.customer-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
}

.customer-name {
    font-size: 1.3rem;
    font-weight: 600;
    color: #fff;
}

.customer-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-overdue {
    background: #e74c3c;
    color: #fff;
}

.badge-due-soon {
    background: #f39c12;
    color: #1a1a2e;
}

.badge-contacted {
    background: #27ae60;
    color: #fff;
}

.customer-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #94a3b8;
    font-size: 0.9rem;
}

.detail-item span {
    color: #fff;
}

.customer-job-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-size: 0.85rem;
    color: #94a3b8;
}

.customer-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.customer-actions .btn {
    flex: 1;
    min-width: 100px;
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin: 20px 0 10px;
    flex-wrap: wrap;
}

.pagination-controls span {
    font-size: 0.9rem;
    color: #94a3b8;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #1a1a2e;
    padding: 30px;
    border-radius: 16px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    cursor: pointer;
    color: #94a3b8;
}

.close:hover {
    color: #fff;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: #f39c12;
}

#customerInfo {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

/* Tabs */
.contact-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.tab-btn.active {
    background: #f39c12;
    color: #1a1a2e;
    border-color: #f39c12;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Form */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #94a3b8;
    font-size: 0.9rem;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: #f39c12;
}

.char-count {
    display: block;
    text-align: right;
    font-size: 0.8rem;
    color: #94a3b8;
    margin-top: 5px;
}

/* Input with Insert Dropdown */
.input-with-insert {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.input-with-insert input {
    flex: 1;
}

.insert-dropdown {
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
    font-size: 0.85rem;
    cursor: pointer;
    min-width: 160px;
}

.insert-dropdown:hover {
    background: rgba(243, 156, 18, 0.3);
    border-color: #f39c12;
}

.insert-dropdown:focus {
    outline: none;
    border-color: #f39c12;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .customer-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .customer-actions {
        flex-direction: column;
    }
    
    .customer-actions .btn {
        width: 100%;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: #fff;
}

/* Success notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: #fff;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    z-index: 2000;
}

.notification.success {
    background: #27ae60;
}

.notification.error {
    background: #e74c3c;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Template Select */
.template-select {
    width: 100%;
    padding: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 1rem;
    margin-bottom: 10px;
}

.template-select option {
    background: #1a1a2e;
    color: #fff;
}

/* Modal Large */
.modal-large {
    max-width: 700px;
}

/* Template Tabs */
.template-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.template-type-btn {
    flex: 1;
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.template-type-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.template-type-btn.active {
    background: #f39c12;
    color: #1a1a2e;
    border-color: #f39c12;
}

/* Templates List */
.templates-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.template-item:last-child {
    border-bottom: none;
}

.template-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.template-item-name {
    font-weight: 500;
}

.template-item-default {
    background: #27ae60;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-left: 10px;
}

.template-item-actions {
    display: flex;
    gap: 8px;
}

.template-item-actions button {
    padding: 5px 10px;
    font-size: 0.8rem;
}

/* Template Form */
.template-form {
    background: rgba(255, 255, 255, 0.03);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.template-form h3 {
    margin-bottom: 15px;
    color: #f39c12;
}

.checkbox-group {
    display: flex;
    align-items: center;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f39c12;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

/* History List */
.history-list {
    max-height: 500px;
    overflow-y: auto;
}

.history-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 15px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    gap: 15px;
}

.history-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.history-info {
    flex: 1;
}

.history-customer {
    font-weight: 600;
    color: #fff;
    margin-bottom: 5px;
}

.history-type {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-right: 10px;
}

.history-type.sms {
    background: #3498db;
    color: #fff;
}

.history-type.email {
    background: #9b59b6;
    color: #fff;
}

.history-type.phone {
    background: #27ae60;
    color: #fff;
}

.history-date {
    color: #94a3b8;
    font-size: 0.85rem;
}

.history-preview {
    color: #94a3b8;
    font-size: 0.85rem;
    margin-top: 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
