:root{
    --bg:#f4f6f9;
    --surface:#ffffff;
    --border:#e3e7ee;
    --text:#1f2937;
    --text-muted:#6b7280;
    --primary:#2f6feb;
    --primary-dark:#1f4fbf;
    --accent-green:#16a34a;
    --accent-amber:#d97706;
    --accent-red:#dc2626;
    --radius:14px;
    --shadow:0 1px 3px rgba(20,25,40,.06), 0 8px 24px rgba(20,25,40,.05);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
    background:var(--bg);
    color:var(--text);
    font-family:"Vazirmatn",Tahoma,sans-serif;
    font-size:15px;
    line-height:1.8;
    min-height:100vh;
    display:flex;
    flex-direction:column;
}

.topbar{
    background:var(--surface);
    border-bottom:1px solid var(--border);
    padding:16px 28px;
    position:sticky;
    top:0;
    z-index:20;
}
.brand{
    font-weight:700;
    font-size:18px;
    color:var(--primary-dark);
    text-decoration:none;
}

.container{
    width:100%;
    max-width:1180px;
    margin:0 auto;
    padding:28px 20px 60px;
    flex:1;
}

.footer{
    text-align:center;
    color:var(--text-muted);
    font-size:13px;
    padding:18px;
}

/* ---------- Project grid ---------- */
.page-title{
    font-size:22px;
    font-weight:700;
    margin:0 0 20px;
}
.project-grid{
    display:grid;
    grid-template-columns:repeat(auto-fill, minmax(220px, 1fr));
    gap:16px;
}
.project-card{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:22px 18px;
    text-decoration:none;
    color:var(--text);
    box-shadow:var(--shadow);
    transition:transform .15s ease, box-shadow .15s ease;
    display:flex;
    flex-direction:column;
    gap:8px;
}
.project-card:hover{
    transform:translateY(-3px);
    box-shadow:0 4px 10px rgba(20,25,40,.08), 0 16px 32px rgba(20,25,40,.08);
}
.project-card .icon{
    width:40px;height:40px;border-radius:10px;
    background:linear-gradient(135deg,var(--primary),#6ea1ff);
    display:flex;align-items:center;justify-content:center;
    color:#fff;font-weight:700;font-size:16px;
}
.project-card .name{font-weight:600;font-size:16px;}

/* ---------- Tabs (project detail) ---------- */
.detail-header{
    display:flex;align-items:center;justify-content:space-between;
    margin-bottom:18px;flex-wrap:wrap;gap:10px;
}
.back-link{color:var(--text-muted);text-decoration:none;font-size:14px;}
.back-link:hover{color:var(--primary);}

.tabs{
    display:flex;
    gap:6px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:12px;
    padding:6px;
    margin-bottom:18px;
    width:fit-content;
}
.tab-btn{
    border:none;background:transparent;
    padding:10px 20px;
    border-radius:8px;
    font-family:inherit;font-size:14px;font-weight:600;
    color:var(--text-muted);
    cursor:pointer;
    transition:background .15s, color .15s;
}
.tab-btn.active{
    background:var(--primary);
    color:#fff;
}
.tab-panel{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    padding:20px;
    box-shadow:var(--shadow);
    min-height:200px;
}

/* ---------- Editable tables ---------- */
.table-wrap{overflow-x:auto;}
table.data-table{
    width:100%;
    border-collapse:collapse;
    font-size:14px;
}
table.data-table th, table.data-table td{
    border:1px solid var(--border);
    padding:8px 10px;
    text-align:center;
    white-space:nowrap;
}
table.data-table thead th{
    background:#f0f3f9;
    font-weight:700;
    color:var(--text);
    position:sticky;
    top:0;
}
table.data-table td.title-cell, table.data-table th.title-cell{
    text-align:right;
    white-space:normal;
    min-width:150px;
    font-weight:600;
}
table.data-table td.unit-cell{color:var(--text-muted);}
table.data-table input[type=number]{
    width:64px;
    padding:6px 4px;
    border:1px solid var(--border);
    border-radius:6px;
    font-family:inherit;
    text-align:center;
    font-size:14px;
}
table.data-table input[type=number]:focus{
    outline:2px solid var(--primary);
    outline-offset:1px;
}
table.data-table td.chart-cell a{
    display:inline-flex;
    align-items:center;
    gap:4px;
    color:var(--primary);
    text-decoration:none;
    font-size:13px;
    font-weight:600;
}
table.data-table td.chart-cell a:hover{color:var(--primary-dark);}

.table-actions{
    display:flex;justify-content:space-between;align-items:center;
    margin-bottom:14px;flex-wrap:wrap;gap:10px;
}
.btn{
    background:var(--primary);
    color:#fff;
    border:none;
    padding:10px 22px;
    border-radius:8px;
    font-family:inherit;
    font-size:14px;
    font-weight:600;
    cursor:pointer;
}
.btn:hover{background:var(--primary-dark);}
.saved-badge{
    color:var(--accent-green);
    font-size:13px;
    font-weight:600;
    display:flex;align-items:center;gap:4px;
}

/* ---------- Chart page ---------- */
.chart-card{
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    box-shadow:var(--shadow);
    padding:24px;
}
.chart-title{font-size:18px;font-weight:700;margin:0 0 4px;}
.chart-sub{color:var(--text-muted);font-size:13px;margin:0 0 18px;}
.month-filter{
    display:flex;flex-wrap:wrap;gap:6px;margin-bottom:18px;
}
.month-filter button{
    border:1px solid var(--border);
    background:#fff;
    padding:6px 14px;
    border-radius:20px;
    font-family:inherit;
    font-size:13px;
    cursor:pointer;
}
.month-filter button.active{
    background:var(--primary);
    color:#fff;
    border-color:var(--primary);
}

@media (max-width:640px){
    .container{padding:18px 12px 40px;}
    .tabs{width:100%;}
    .tab-btn{flex:1;padding:10px 8px;}
}
