:root {
    --bg: #12151b;
    --card: #1a1f28;
    --panel-alt: #212836;
    --border: #2a3140;
    --text: #e9edf3;
    --muted: #8a94a6;
    --primary: #4c8dff;
    --primary-dark: #6ea6ff;
    --primary-dim: #4c8dff22;
    --ok: #2dd4a8;
    --warning: #e8a33d;
    --danger: #e8637a;
    --radius: 12px;
    --shadow: none;
    --input-bg: #212836;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.8;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
h1, h2, h3 { margin: 0 0 6px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
.num { font-family: 'JetBrains Mono', monospace; }

/* ---- ورود ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 36px; width: 100%; max-width: 380px; border: 1px solid var(--border);
}
.auth-card h1 { font-size: 22px; }
.auth-card label { display: block; margin: 14px 0 6px; font-size: 13px; color: var(--muted); }
.auth-card input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); }

/* ---- ساختار کلی ---- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 230px; background: var(--card); color: var(--text); display: flex; flex-direction: column;
    padding: 24px 16px; position: sticky; top: 0; height: 100vh; border-left: 1px solid var(--border); gap: 6px;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 17px; margin-bottom: 4px; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; box-shadow: 0 0 12px var(--primary); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; margin-top: 18px; }
.sidebar nav a { padding: 11px 14px; border-radius: 10px; color: var(--muted); font-size: 14px; font-weight: 500; border: 1px solid transparent; display: flex; align-items: center; gap: 10px; }
.sidebar nav a.active, .sidebar nav a:hover { background: var(--panel-alt); color: var(--text); }
.sidebar nav a.active { color: var(--primary); border-color: var(--border); }
.nav-ic { font-size: 16px; width: 20px; text-align: center; }
.logout-link { color: var(--danger); font-size: 12px; padding: 10px 14px; margin-top: auto; border-top: 1px solid var(--border); padding-top: 16px; }

.content { flex: 1; padding: 28px 34px; max-width: 1200px; }

/* ---- عناصر عمومی ---- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; gap: 10px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-ok { color: var(--ok); }

.card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px 22px; margin-bottom: 20px;
}
.card-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.card-head-row h2 { font-size: 14.5px; font-weight: 700; }
.card-head-row .muted { font-size: 11px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr .9fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(190px,1fr)); gap: 14px; margin-bottom: 24px; }
@media (max-width: 900px) { .grid-2, .grid-3, .stats-grid { grid-template-columns: 1fr; } .app { flex-direction: column; } .sidebar { width: 100%; height: auto; position: static; } .content { padding: 20px; } }

.stat-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden;
}
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 27px; font-weight: 700; color: var(--text); }
.stat-card::after { content: ''; position: absolute; bottom: 0; right: 0; left: 0; height: 3px; background: var(--border); }
.stat-card::before {
    content: ''; position: absolute; bottom: 0; right: 0; height: 3px; width: var(--bar-pct, 60%);
    background: var(--primary); z-index: 1;
}

.btn {
    display: inline-block; border: 1px solid var(--border); background: var(--panel-alt); color: var(--text);
    padding: 10px 18px; border-radius: 9px; cursor: pointer; font-weight: 700; font-size: 13.5px;
}
.btn-primary { background: var(--primary); color: #0b1220; border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-sm { padding: 8px 14px; font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; }
.btn-danger { background: #e8637a22; color: var(--danger); border-color: #e8637a44; }

.badge { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.lg { padding: 8px 16px; font-size: 13px; }
.badge-ok { background: #2dd4a822; color: var(--ok); }
.badge-warning { background: #e8a33d22; color: var(--warning); }
.badge-danger { background: #e8637a22; color: var(--danger); }
.badge-muted { background: #8a94a622; color: var(--muted); }

.progress-bar { height: 6px; background: var(--panel-alt); border-radius: 6px; overflow: hidden; margin: 8px 0; }
.progress-bar.lg { height: 10px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 6px; transition: width .3s; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 18px; flex-wrap: wrap; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; display: flex; align-items: center; gap: 6px; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel.hidden { display: none; }

/* پروژه‌ها */
.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.project-card {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px; display: block;
}
.project-card:hover { border-color: var(--primary); }
.project-card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.project-card-foot { display: flex; justify-content: space-between; font-size: 13px; margin-top: 6px; }

/* چک‌لیست */
.checklist li { display: flex; align-items: center; justify-content: space-between; padding: 10px 4px; border-top: 1px dashed var(--border); }
.checklist li:first-child { border-top: none; }
.checklist li.done span { text-decoration: line-through; color: var(--muted); }
.checklist label { display: flex; align-items: center; gap: 10px; cursor: pointer; flex: 1; }
.checklist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }
.cl-delete { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; opacity: 0; transition: opacity .2s; }
.checklist li:hover .cl-delete { opacity: 1; }

.add-item-form { display: flex; gap: 8px; margin-top: 14px; }
.add-item-form input { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text); }

/* یادداشت‌ها */
.add-note-form { display: flex; gap: 8px; margin-bottom: 16px; align-items: flex-start; }
.add-note-form textarea { flex: 1; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); resize: vertical; background: var(--input-bg); color: var(--text); }
.notes-list li { background: var(--panel-alt); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }
.note-delete { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 12px; }

/* فرم‌ها */
label { display: block; margin: 12px 0 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=number], input[type=date], input[type=password], select, textarea {
    width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--input-bg); color: var(--text);
}
.form-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-items: end; }
.form-row > div { min-width: 0; }
@media (max-width: 700px) { .form-row { grid-template-columns: 1fr; } }
.align-end { display: flex; align-items: flex-end; }
.service-check-row { display: flex; gap: 14px; flex-wrap: wrap; }
.service-check { display: flex; align-items: center; gap: 8px; background: var(--input-bg); border: 1px solid var(--border); padding: 10px 14px; border-radius: 10px; cursor: pointer; margin: 0; font-size: 14px; color: var(--text); }
.service-check input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

.summary-list li { padding: 8px 0; border-top: 1px dashed var(--border); font-size: 13.5px; }
.summary-list li:first-child { border-top: none; }
.deadline-list li { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-top: 1px dashed var(--border); }
.deadline-list li:first-child { border-top: none; }

.simple-table { width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 13px; }
.simple-table th, .simple-table td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--border); }
.simple-table th { color: var(--muted); font-weight: 600; font-size: 12px; }

.alert-error { background: #e8637a22; color: var(--danger); padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; font-size: 13.5px; }

.back-link { font-size: 13px; color: var(--primary); }

/* مودال */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); display: none; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal.open { display: flex; }
.modal-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head button { background: none; border: none; font-size: 16px; cursor: pointer; color: var(--muted); }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--panel-alt); color: var(--text); padding: 10px 20px; border-radius: 10px; font-size: 13.5px; z-index: 99; opacity: 0; transition: opacity .3s; border: 1px solid var(--border); }
.toast.show { opacity: 1; }
