@font-face {
    font-family: 'Vazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Regular.woff2') format('woff2');
    font-weight: 400; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Medium.woff2') format('woff2');
    font-weight: 500; font-display: swap;
}
@font-face {
    font-family: 'Vazirmatn';
    src: url('https://cdn.jsdelivr.net/gh/rastikerdar/vazirmatn@v33.003/fonts/webfonts/Vazirmatn-Bold.woff2') format('woff2');
    font-weight: 700; font-display: swap;
}

:root {
    --bg: #0a0e17;
    --bg-soft: #0e1420;
    --glass: rgba(255,255,255,0.045);
    --glass-border: rgba(255,255,255,0.09);
    --text: #e9ecf3;
    --text-dim: #929cb3;
    --accent: #6c7cff;
    --accent-2: #f2b84b;
    --danger: #ef6a6a;
    --ok: #58c896;
    --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    background: radial-gradient(ellipse at top left, #10182b 0%, var(--bg) 55%);
    color: var(--text);
    direction: rtl;
    min-height: 100vh;
}

a { color: inherit; }
input, select, textarea, button { font-family: inherit; }

.glass {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-radius: var(--radius);
}

.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 10px 18px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: rgba(255,255,255,0.06);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    transition: transform .12s ease, background .15s ease;
}
.btn:hover { background: rgba(255,255,255,0.11); }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #5c6cf0; }
.btn-danger { background: rgba(239,106,106,0.15); border-color: rgba(239,106,106,0.4); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--text-dim); }
.field input, .field select, .field textarea {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 14px;
    outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }

.card { padding: 20px; margin-bottom: 16px; }
.card h3 { margin: 0 0 14px; font-size: 16px; font-weight: 500; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--glass-border); }
th { color: var(--text-dim); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: none; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; }
.badge-ok { background: rgba(88,200,150,0.15); color: var(--ok); }
.badge-warn { background: rgba(242,184,75,0.15); color: var(--accent-2); }
.badge-off { background: rgba(255,255,255,0.08); color: var(--text-dim); }
.badge-danger { background: rgba(239,106,106,0.15); color: var(--danger); }

.toast {
    position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
    padding: 12px 22px; border-radius: 10px; z-index: 999;
    font-size: 14px; animation: fadeIn .2s ease;
}
.toast.err { background: #4a1f22; color: #ffb3b3; border: 1px solid #7a3438; }
.toast.ok { background: #1f4a34; color: #b3ffd9; border: 1px solid #34785a; }
@keyframes fadeIn { from { opacity: 0; transform: translate(-50%, -8px); } to { opacity: 1; transform: translate(-50%, 0); } }

.modal-backdrop {
    position: fixed; inset: 0; background: rgba(0,0,0,0.55);
    display: flex; align-items: center; justify-content: center; z-index: 500;
}
.modal { width: min(520px, 92vw); max-height: 88vh; overflow-y: auto; padding: 24px; }
.modal h3 { margin-top: 0; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; flex-shrink: 0; padding: 24px 18px;
    border-left: 1px solid var(--glass-border);
    display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { font-weight: 700; font-size: 18px; margin-bottom: 22px; color: var(--accent-2); }
.sidebar .nav-item {
    padding: 10px 14px; border-radius: 10px; cursor: pointer; color: var(--text-dim); font-size: 14px;
}
.sidebar .nav-item.active { background: rgba(108,124,255,0.15); color: var(--text); }
.sidebar .nav-item:hover { background: rgba(255,255,255,0.05); }
.sidebar .spacer { flex: 1; }

.main { flex: 1; padding: 28px 32px; max-width: 1100px; }
.main h1 { font-size: 22px; font-weight: 500; margin: 0 0 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; margin-bottom: 20px; }
.stat-grid .card { margin-bottom: 0; }
.stat-grid .num { font-size: 26px; font-weight: 700; color: var(--accent-2); }
.stat-grid .label { font-size: 13px; color: var(--text-dim); margin-top: 4px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: min(380px, 92vw); padding: 34px; }
.login-card .brand { text-align: center; font-size: 20px; font-weight: 700; margin-bottom: 6px; color: var(--accent-2); }
.login-card .sub { text-align: center; color: var(--text-dim); font-size: 13px; margin-bottom: 26px; }

@media (max-width: 720px) {
    .app-shell { flex-direction: column; }
    .sidebar { width: 100%; flex-direction: row; overflow-x: auto; border-left: none; border-bottom: 1px solid var(--glass-border); padding: 12px; }
    .sidebar .brand, .sidebar .spacer { display: none; }
    .main { padding: 18px; }
}
