:root {
    --bg-base: #0f111a;
    --bg-glass: rgba(255, 255, 255, 0.05);
    --border-glass: rgba(255, 255, 255, 0.1);
    
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --shadow-glass: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --blur-glass: blur(12px);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Outfit', sans-serif;
}

.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: var(--blur-glass);
    -webkit-backdrop-filter: var(--blur-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    box-shadow: var(--shadow-glass);
}

.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    border-radius: 0;
    border-right: 1px solid var(--border-glass);
    position: fixed;
    height: 100vh;
}

.sidebar-header h2 {
    font-weight: 800;
    font-size: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Language Matcher */
.lang-switcher {
    display: flex;
    gap: 0.5rem;
    padding: 0 1.25rem;
    margin-bottom: 0.5rem;
}
.lang-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}
.lang-btn:hover { background: rgba(255,255,255,0.1); }
.lang-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    transition: var(--transition);
}

.nav-links a i {
    font-size: 1.2rem;
    width: 24px;
}

.nav-links a:hover, .nav-links a.active {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem 3rem;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

.view.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.view-header {
    margin-bottom: 2rem;
}

.view-header h1 {
    font-size: 2.2rem;
    margin-bottom: 0.5rem;
}

.view-header p {
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    border-color: rgba(255,255,255,0.2);
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 1.1rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.income-card .stat-value { color: var(--success); }
.expense-card .stat-value { color: var(--danger); }
.profit-card .stat-value { color: var(--primary); }

.table-container {
    overflow-x: auto;
    padding: 1px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th, .data-table td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.data-table th {
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    background: rgba(0,0,0,0.2);
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: rgba(255,255,255,0.02);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.form-container {
    padding: 2rem;
}

.form-container h3 {
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.data-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    align-items: flex-end;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

input, select {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    transition: var(--transition);
    width: 100%;
    color-scheme: dark;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0,0,0,0.4);
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
}

.btn-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.btn-success:hover {
    background: var(--success);
    color: white;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.mb-4 { margin-bottom: 2rem; }
.mt-4 { margin-top: 2rem; }

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge.paid {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge.unpaid {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.modal {
    display: none;
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.active { display: flex; }

.modal-content {
    width: 100%;
    max-width: 450px;
    padding: 2.5rem;
    animation: scaleIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes scaleIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.space-between {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-top: 1rem;
}

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

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

/* ─── Customer Area Assignment Modal ─────────────────────────────── */

.area-assign-row {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.area-assign-row:hover {
    border-color: rgba(99,102,241,0.35);
    background: rgba(99,102,241,0.06);
}

.area-assign-header {
    display: flex;
    align-items: center;
}

.area-assign-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 1rem;
    width: 100%;
}

.area-assign-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    flex-shrink: 0;
    cursor: pointer;
}

.area-assign-config {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 0.85rem;
    padding-top: 0.85rem;
    border-top: 1px solid var(--border-glass);
    flex-wrap: wrap;
}

.area-assign-config input[type="number"] {
    max-width: 140px;
}

.area-assign-config .form-group label {
    font-size: 0.8rem;
}

.area-assign-config input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--warning);
    cursor: pointer;
}

/* Badge: area count on Manage Areas button */
.badge-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
}

/* Badge: workers count inside area row */
.badge-workers {
    margin-left: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

/* ─── Period Selector Sidebar Widget ─────────────────────────────── */

.period-selector {
    padding: 0 0.25rem;
    margin-bottom: 0.5rem;
}

.period-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
}

.period-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.period-controls input[type="month"] {
    flex: 1;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border-glass);
    border-radius: 8px;
    color: var(--text-main);
    color-scheme: dark;
    width: auto;
}

.period-controls input[type="month"]:focus {
    border-color: var(--primary);
    outline: none;
}

.btn-clear-period {
    background: rgba(255,255,255,0.08);
    border: 1px solid var(--border-glass);
    color: var(--text-muted);
    border-radius: 8px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-clear-period:hover {
    background: rgba(239,68,68,0.2);
    color: var(--danger);
    border-color: rgba(239,68,68,0.3);
}

/* Period banner pill in dashboard header */
.period-banner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.3);
    color: var(--primary);
    border-radius: 20px;
    padding: 0.3rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    margin-top: 0.75rem;
}

/* ─── Login Overlay ───────────────────────────────────────────────── */

#login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    background-color: var(--bg-base);
    background-image: 
        radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.2) 0, transparent 50%), 
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.2) 0, transparent 50%);
}

.login-card {
    padding: 2.5rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-card h2 {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: -1rem;
}

.login-card form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.login-card .btn {
    width: 100%;
    margin-top: 0.5rem;
}

.login-error {
    color: var(--danger);
    font-size: 0.9rem;
    min-height: 1.2em;
    display: block;
}

/* ─── Sidebar User Info ───────────────────────────────────────────── */

.user-info-block {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.role-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    width: fit-content;
}

.role-admin {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary);
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.role-viewer {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-muted);
    border: 1px solid rgba(148, 163, 184, 0.3);
}

.role-editor {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.logout-btn {
    margin-top: 0.25rem;
    width: 100%;
    justify-content: center;
}
