:root {
    --bg-body: #f4f7f9;          
    --card-bg: #ffffff;          
    
    --text-main: #334155;        
    --text-muted: #64748b;       
    --text-headers: #0f172a;     
    
    --primary-navy: #0f172a;     
    --primary-navy-hover: #1e293b; 
    
    --accent-blue: #2563eb;      
    --accent-blue-hover: #1d4ed8;
    
    --accent-green: #059669;     
    --accent-red: #dc2626;       
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.05);
    --shadow-lg: 0 12px 30px -4px rgba(15, 23, 42, 0.08);
    
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; }
body { background-color: var(--bg-body); color: var(--text-main); margin: 0; padding: 30px 15px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
.container { max-width: 1100px; margin: 0 auto; width: 100%; }

h1, h2, h3, h4 { color: var(--text-headers); margin-top: 0; letter-spacing: -0.02em; font-weight: 700; }
h1 { font-size: 26px; margin: 0; }

.auth-container { max-width: 420px; margin: 80px auto; width: 100%; }
.auth-box { background: var(--card-bg); padding: 40px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); text-align: center; border: 1px solid rgba(15, 23, 42, 0.03); }
.auth-box input { width: 100%; padding: 14px; margin-bottom: 15px; border: 1px solid #cbd5e1; border-radius: var(--radius-md); font-size: 15px; transition: var(--transition); background: #f8fafc; color: var(--text-headers); }
.auth-box input:focus { outline: none; border-color: var(--primary-navy); box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1); background: #fff; }
.auth-box button { width: 100%; padding: 14px; background: var(--primary-navy); color: white; border: none; border-radius: var(--radius-md); font-size: 16px; cursor: pointer; font-weight: 600; transition: var(--transition); letter-spacing: 0.02em; }
.auth-box button:hover { background: var(--primary-navy-hover); transform: translateY(-2px); box-shadow: var(--shadow-md); }
.auth-links { margin-top: 25px; font-size: 14px; color: var(--text-muted); }
.auth-links a { color: var(--accent-blue); text-decoration: none; font-weight: 600; }
.auth-links a:hover { color: var(--primary-navy); text-decoration: underline; }

.error { color: var(--accent-red); background: #fef2f2; padding: 12px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 14px; font-weight: 600; border: 1px solid #fee2e2; }
.success { color: var(--accent-green); background: #ecfdf5; padding: 12px; border-radius: var(--radius-md); margin-bottom: 20px; font-size: 14px; font-weight: 600; border: 1px solid #d1fae5; }

.header-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; background: var(--primary-navy); padding: 18px 25px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.header-bar h1 { color: #ffffff; }
.user-info { display: flex; align-items: center; gap: 15px; }
.user-badge { background: rgba(255, 255, 255, 0.1); color: #f8fafc; padding: 6px 14px; border-radius: 20px; font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border: 1px solid rgba(255,255,255,0.05); }
.logout-btn { background: transparent; color: #94a3b8; text-decoration: none; font-weight: 600; font-size: 14px; transition: var(--transition); padding: 6px 12px; border-radius: var(--radius-sm); }
.logout-btn:hover { color: #ffffff; background: rgba(255, 255, 255, 0.1); }

.dashboard { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; }
.card { background: var(--card-bg); padding: 25px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); flex: 1; min-width: 250px; display: flex; flex-direction: column; justify-content: center; border: 1px solid rgba(15, 23, 42, 0.03); transition: var(--transition); }
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-3px); }
.card h3 { margin: 0 0 10px 0; font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.card p { margin: 0; font-size: 34px; font-weight: 800; letter-spacing: -0.03em; color: var(--text-headers); }
.dashboard .card:first-child { background: var(--primary-navy); box-shadow: 0 10px 25px rgba(15, 23, 42, 0.2); border: none; }
.dashboard .card:first-child h3 { color: #94a3b8; }
.dashboard .card:first-child p { color: #ffffff !important; }
.dashboard .card:first-child .sub-text { color: #cbd5e1 !important; opacity: 0.8; }

.charts-container, .forms-container { display: flex; gap: 20px; margin-bottom: 30px; flex-wrap: wrap; align-items: stretch; }
.chart-card, .form-section, .list-section { background: var(--card-bg); padding: 25px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); border: 1px solid rgba(15, 23, 42, 0.03); flex: 1; }
.chart-card { min-width: 320px; display: flex; justify-content: center; align-items: center; min-height: 300px; }
.form-section { min-width: 320px; display: flex; flex-direction: column; }
.list-section { width: 100%; margin-bottom: 30px; }

.section-header, .form-section h3, .list-section h3 { margin-bottom: 20px; font-size: 18px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; border-bottom: 1px solid #f1f5f9; padding-bottom: 15px; }

/* Супер фини бутони за периода на графиката */
.period-btn { background: transparent; color: #94a3b8; border: none; padding: 4px 8px; font-size: 12px; font-weight: 600; cursor: pointer; transition: var(--transition); letter-spacing: 0.02em; border-radius: var(--radius-sm); }
.period-btn:hover { color: var(--text-headers); }
.period-btn.active { color: var(--primary-navy); background: #e2e8f0; }

.form-group { display: flex; gap: 12px; margin-bottom: 15px; flex-wrap: wrap; }
input, select { padding: 12px 14px; border: 1px solid #cbd5e1; border-radius: var(--radius-md); font-size: 14px; flex: 1; min-width: 140px; color: var(--text-headers); background: #f8fafc; transition: var(--transition); font-weight: 500; }
input:focus, select:focus { outline: none; border-color: var(--primary-navy); box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1); background: #fff; }

button { padding: 14px; color: white; border: none; cursor: pointer; font-weight: 600; font-size: 14px; border-radius: var(--radius-md); transition: var(--transition); width: 100%; margin-top: auto; background-color: var(--primary-navy); letter-spacing: 0.02em; }
button:hover { background-color: var(--primary-navy-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }

.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; background: #f8fafc; padding: 15px; border-radius: var(--radius-md); border: 1px solid #f1f5f9; }
.filter-bar input, .filter-bar select { background: #fff; border-color: #e2e8f0; }
.fx-rate { font-size: 12px; font-weight: 700; color: var(--text-muted); background: #f1f5f9; padding: 6px 12px; border-radius: 20px; }
.category-badge { display: inline-block; font-size: 10px; background: #f1f5f9; color: var(--text-headers); padding: 3px 8px; border-radius: 12px; margin-left: 8px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; vertical-align: middle; border: 1px solid #e2e8f0; }

.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; text-align: left; min-width: 750px; }
th, td { padding: 14px 12px; border-bottom: 1px solid #f1f5f9; font-size: 14px; color: var(--text-main); }
th { color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; border-bottom: 2px solid #e2e8f0; }
tr:hover td { background-color: #f8fafc; }
.total-row td { background: #f8fafc; border-top: 2px solid #e2e8f0; border-bottom: none; color: var(--text-headers); }

/* Елементи за групираните партиди */
.toggle-icon { display: inline-block; cursor: pointer; color: var(--text-muted); width: 20px; height: 20px; text-align: center; font-size: 10px; line-height: 20px; margin-right: 5px; transition: transform 0.2s; background: #f1f5f9; border-radius: 50%; }
.toggle-icon:hover { color: var(--primary-navy); background: #e2e8f0; }
.lot-row td { border-bottom: 1px dashed #e2e8f0; font-size: 13px; }
.lot-row:last-of-type td { border-bottom: 2px solid #f1f5f9; }

.transaction-list { list-style-type: none; padding: 0; margin: 0; max-height: 400px; overflow-y: auto; padding-right: 5px; }
.transaction-list::-webkit-scrollbar { width: 6px; }
.transaction-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.transaction-item { display: flex; justify-content: space-between; padding: 15px 10px; border-bottom: 1px solid #f1f5f9; align-items: center; transition: var(--transition); gap: 10px; }
.transaction-item:hover { background: #f8fafc; border-radius: var(--radius-sm); }
.transaction-item:last-child { border-bottom: none; }

.amt-inc { color: var(--accent-green); font-weight: 700; }
.amt-exp { color: var(--text-main); font-weight: 700; }
.amt-red { color: var(--accent-red); font-weight: 700; }
.amt-exp-dash { color: var(--text-headers); } 
.sub-text { font-size: 12px; color: var(--text-muted); display: inline-block; font-weight: 500; }

.action-btns { display: flex; gap: 5px; justify-content: flex-start; }
.delete-btn, .edit-btn { background: transparent; padding: 6px; border: none; font-size: 15px; cursor: pointer; border-radius: var(--radius-sm); width: auto; margin: 0; font-weight: bold; box-shadow: none; }
.delete-btn { color: #cbd5e1; }
.delete-btn:hover { background: #fee2e2; color: var(--accent-red); transform: scale(1.05); }
.edit-btn { color: var(--text-muted); }
.edit-btn:hover { background: #eff6ff; color: var(--accent-blue); transform: scale(1.05); }

@media (max-width: 768px) {
    body { padding: 15px 10px; }
    .header-bar { flex-direction: column; text-align: center; gap: 15px; padding: 20px; }
    .dashboard { gap: 15px; }
    .card { min-width: 100%; padding: 20px; }
    .charts-container, .forms-container { flex-direction: column; gap: 15px; }
    .chart-card, .form-section { min-width: 100%; padding: 20px; }
    .form-group { flex-direction: column; gap: 10px; }
}