/* ربات معامله‌گر هوشمند تبدیل — پنل فارسی RTL بدون وابستگی خارجی */
@font-face { font-family: 'Vazirmatn'; src: url('/static/fonts/Vazirmatn-Regular.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/static/fonts/Vazirmatn-Medium.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Vazirmatn'; src: url('/static/fonts/Vazirmatn-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --sidebar: #10202f;
  --sidebar-2: #16293a;
  --text: #1c2833;
  --muted: #6b7a87;
  --border: #dde5ec;
  --primary: #0e7bd6;
  --primary-2: #0a6ab8;
  --ok: #178a4c;
  --bad: #c62828;
  --warn: #b26a00;
  --paper: #8d6e00;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(16, 32, 47, .08), 0 8px 24px rgba(16, 32, 47, .06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Vazirmatn', Tahoma, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--text);
  font-size: 14px; line-height: 1.7;
}

/* چیدمان */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 230px; background: var(--sidebar); color: #cfe0ef;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { font-size: 26px; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.brand-sub { font-size: 11px; color: #7fa0bb; }
.nav { flex: 1; padding: 10px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 2px 0;
  color: #b9ccdc; text-decoration: none; border-radius: 8px; font-size: 13.5px;
}
.nav-item:hover { background: var(--sidebar-2); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-ic { width: 20px; text-align: center; }
.sidebar-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 22px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-left { display: flex; gap: 8px; align-items: center; }
.hamburger { display: none; border: none; background: none; font-size: 20px; cursor: pointer; }

.content { padding: 20px 22px; flex: 1; }
.footer { padding: 12px 22px; color: var(--muted); font-size: 11.5px; border-top: 1px solid var(--border); background: var(--surface); }

/* کارت‌ها */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px;
}
.card h3 { font-size: 15px; margin-bottom: 12px; }
.card h4 { font-size: 13.5px; margin: 14px 0 8px; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 18px; }
.grid .card { margin-bottom: 0; }
.card-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.card-value { font-size: 17px; font-weight: 700; }
.card-sub { color: var(--muted); font-size: 11.5px; margin-top: 4px; }
.row { display: flex; gap: 18px; margin-bottom: 18px; flex-wrap: wrap; }
.col-7 { flex: 7; min-width: 320px; }
.col-6 { flex: 6; min-width: 300px; }
.col-5 { flex: 5; min-width: 280px; }
.mini-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.mini-grid div { background: var(--bg); border-radius: 8px; padding: 10px; }
.mini-grid b { display: block; font-size: 15px; }
.mini-label { color: var(--muted); font-size: 11.5px; }
.mt { margin-top: 14px; }
.empty { color: var(--muted); text-align: center; padding: 14px; font-size: 12.5px; }
.hidden { display: none !important; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.pos, .ok { color: var(--ok); }
.neg, .bad { color: var(--bad); }
.warn-text { color: var(--warn); }

/* جدول */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; cursor: pointer; user-select: none; background: #f8fafc; }
tbody tr:hover { background: #f6f9fc; }

/* فرم */
label { display: block; margin: 10px 0 4px; font-size: 12.5px; color: #44525e; }
input, select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid rgba(14,123,214,.25); border-color: var(--primary); }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px 14px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: auto; }

/* دکمه‌ها */
.btn {
  display: inline-block; padding: 9px 18px; border-radius: 8px; border: 1px solid transparent;
  font-family: inherit; font-size: 13.5px; cursor: pointer; margin-top: 10px;
  background: #eef2f6; color: var(--text); text-decoration: none; line-height: 1.5;
}
.btn:hover { filter: brightness(.96); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); filter: none; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-warn { background: #f59e0b; color: #3a2a00; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn-block { display: block; width: 100%; }
.btn-sm { padding: 4px 10px; font-size: 12px; margin-top: 0; }

/* نشان‌ها */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px;
  background: #eef2f6; color: var(--muted); margin-inline-start: 4px;
}
.badge.mode-analysis { background: #e3f0fd; color: var(--primary-2); }
.badge.mode-paper { background: #fff6e0; color: var(--paper); }
.badge.mode-live { background: #fdeaea; color: var(--bad); }
.badge.paper { background: #fff6e0; color: var(--paper); }
.badge.live { background: #fdeaea; color: var(--bad); }

/* هشدارها */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 8px; font-size: 13px; }
.alert.ok { background: #e6f4ea; color: var(--ok); }
.alert.danger { background: #fdeaea; color: var(--bad); }
.alert.warn { background: #fff6e0; color: var(--warn); }

/* رویدادها */
.event-list { max-height: 260px; overflow-y: auto; font-size: 12px; }
.event { display: flex; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--border); align-items: baseline; }
.event .ev-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.event .ev-lvl { font-size: 10.5px; padding: 1px 7px; border-radius: 10px; background: #eef2f6; }
.event.lvl-error .ev-lvl { background: #fdeaea; color: var(--bad); }
.event.lvl-warn .ev-lvl { background: #fff6e0; color: var(--warn); }
.event.lvl-security .ev-lvl { background: #eae6fd; color: #5b3fc4; }

/* تب‌ها */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tab { border: 1px solid var(--border); background: var(--surface); padding: 8px 20px; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 13px; }
.tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* نوار ابزار */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input { width: 240px; }
.toolbar select { width: auto; }

/* تست چندمرحله‌ای */
.test-row { padding: 5px 0; font-size: 13px; border-bottom: 1px dashed var(--border); }

/* کنترل‌ها */
.controls-row { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.controls-row select { width: auto; min-width: 220px; }

/* احراز هویت */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--sidebar); }
.auth-card { background: #fff; border-radius: 14px; padding: 34px 30px; width: 380px; max-width: 92vw; box-shadow: var(--shadow); }
.auth-icon { font-size: 34px; text-align: center; }
.auth-card h2 { text-align: center; font-size: 16px; margin: 8px 0 2px; }
.auth-card .muted { text-align: center; font-size: 12.5px; margin-bottom: 8px; }
.error { background: #fdeaea; color: var(--bad); padding: 9px 12px; border-radius: 8px; margin-top: 10px; font-size: 12.5px; }
.steps { padding-right: 20px; font-size: 13px; }
.steps li { margin: 6px 0; }
.danger-zone { border-color: #f3caca; }

/* Toast */
.toast-wrap { position: fixed; bottom: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #10202f; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px;
  box-shadow: var(--shadow); animation: slideIn .25s ease; max-width: 420px;
}
.toast.ok { border-right: 4px solid var(--ok); }
.toast.error { border-right: 4px solid var(--bad); }
.toast.warn { border-right: 4px solid #f59e0b; }
@keyframes slideIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Modal */
.modal-wrap { position: fixed; inset: 0; background: rgba(16,32,47,.5); z-index: 90; display: flex; align-items: center; justify-content: center; }
.modal { background: #fff; border-radius: 12px; padding: 22px; width: 440px; max-width: 94vw; max-height: 88vh; overflow-y: auto; }
.modal h3 { margin-bottom: 10px; font-size: 15px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-start; margin-top: 14px; }

/* واکنش‌گرا */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
  .mini-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar { position: fixed; right: -240px; transition: right .25s ease; z-index: 60; height: 100vh; }
  .sidebar.open { right: 0; }
  .hamburger { display: block; }
  .col-7, .col-6, .col-5 { min-width: 100%; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .toolbar input { width: 100%; }
}
