/* RoboVision design system — Persian / RTL / dark */
:root {
  --bg: #0b0f16;
  --bg2: #111826;
  --panel: #151d2e;
  --panel2: #1b2438;
  --line: #26314a;
  --text: #e7ecf6;
  --muted: #93a0b8;
  --accent: #3b82f6;
  --accent2: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --sim: #a855f7;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #16233d 0%, var(--bg) 55%);
  color: var(--text);
  font-family: Vazirmatn, Tahoma, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------------- topbar ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 18px; background: rgba(13, 18, 30, .85);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; letter-spacing: .4px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center; font-size: 16px;
}
.brand small { display: block; font-weight: 500; color: var(--muted); font-size: 11px; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px;
  border: 1px solid var(--line); background: var(--panel);
  border-radius: 999px; font-size: 12.5px; color: var(--muted);
}
.pill b { color: var(--text); font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; box-shadow: 0 0 0 3px rgba(100,116,139,.18); }
.dot.on { background: var(--accent2); box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(239,68,68,.2); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(245,158,11,.2); }

/* ---------------- layout ---------------- */
.container { max-width: 1280px; margin: 0 auto; padding: 18px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 980px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card h3 { font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.card .value { font-size: 26px; font-weight: 800; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.card.ok { border-color: rgba(34,197,94,.45); }
.card.bad { border-color: rgba(239,68,68,.5); }
.card.warn { border-color: rgba(245,158,11,.45); }

.section-title { margin: 18px 0 10px; font-size: 16px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* ---------------- buttons ---------------- */
.btn {
  border: 1px solid var(--line); background: var(--panel2); color: var(--text);
  padding: 9px 16px; border-radius: 11px; cursor: pointer; font-weight: 700;
  transition: .15s; display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.btn.primary { background: linear-gradient(180deg, #3b82f6, #2563eb); border-color: #2563eb; }
.btn.success { background: linear-gradient(180deg, #22c55e, #16a34a); border-color: #16a34a; }
.btn.danger {
  background: linear-gradient(180deg, #ef4444, #dc2626); border-color: #dc2626;
  font-size: 17px; padding: 14px 26px; border-radius: 14px;
}
.btn.ghost { background: transparent; }
.btn.big { font-size: 16px; padding: 13px 22px; }
.btn.block { width: 100%; justify-content: center; }

/* ---------------- tabs ---------------- */
.tabs { display: flex; gap: 8px; padding: 10px 18px; overflow-x: auto;
  border-bottom: 1px solid var(--line); background: rgba(13,18,30,.6); position: sticky; top: 59px; z-index: 40; }
.tab {
  border: 1px solid transparent; background: transparent; color: var(--muted);
  padding: 8px 15px; border-radius: 10px; cursor: pointer; font-weight: 700; white-space: nowrap;
}
.tab:hover { color: var(--text); background: var(--panel); }
.tab.active { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ---------------- badges ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px;
  border-radius: 999px; font-size: 12px; font-weight: 700;
  border: 1px solid var(--line); background: var(--panel2); color: var(--muted);
}
.badge.ok { color: #86efac; border-color: rgba(34,197,94,.5); background: rgba(34,197,94,.12); }
.badge.bad { color: #fca5a5; border-color: rgba(239,68,68,.5); background: rgba(239,68,68,.12); }
.badge.warn { color: #fcd34d; border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.12); }
.badge.sim { color: #d8b4fe; border-color: rgba(168,85,247,.55); background: rgba(168,85,247,.14); }
.badge.real { color: #7dd3fc; border-color: rgba(56,189,248,.5); background: rgba(56,189,248,.12); }
.badge.synth { color: #f0abfc; border-color: rgba(217,70,239,.5); background: rgba(217,70,239,.14); }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 640px; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); }
th { background: var(--bg2); color: var(--muted); font-size: 12.5px; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tr:hover td { background: rgba(59,130,246,.05); }
td.num { font-variant-numeric: tabular-nums; }

/* ---------------- forms ---------------- */
.field { margin-bottom: 13px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none; color: var(--text);
}
.input:focus { border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.range-head { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }

/* ---------------- login ---------------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .logo-big {
  width: 58px; height: 58px; border-radius: 16px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center; font-size: 26px;
}

/* ---------------- camera page ---------------- */
.video-wrap {
  position: relative; background: #000; border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); aspect-ratio: 4/3;
  display: grid; place-items: center;
}
.video-wrap video { width: 100%; height: 100%; object-fit: cover; }
.start-card {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
  background: radial-gradient(600px 300px at 50% 20%, #1a2744, rgba(11,15,22,.92));
  padding: 24px; z-index: 5;
}
.start-card .big-icon { font-size: 54px; margin-bottom: 8px; }
.hud {
  position: absolute; top: 10px; left: 10px; right: 10px;
  display: flex; gap: 8px; flex-wrap: wrap; z-index: 6; pointer-events: none;
}
.hud .chip {
  background: rgba(8, 12, 20, .72); border: 1px solid rgba(255,255,255,.14);
  padding: 4px 10px; border-radius: 999px; font-size: 12px; backdrop-filter: blur(4px);
}
.chip b { color: #7dd3fc; }
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: #ef4444; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .25; } }

/* ---------------- control pad ---------------- */
.pad { display: grid; grid-template-columns: repeat(3, 74px); gap: 8px; justify-content: center; }
.pad .btn { justify-content: center; height: 64px; font-size: 22px; padding: 0; }
.pad .btn.stop { grid-column: 2; background: rgba(239,68,68,.2); border-color: var(--danger); }
.estop-wrap { display: flex; gap: 14px; align-items: stretch; flex-wrap: wrap; }
.estop-wrap .btn.danger { flex: 1; min-width: 220px; }

/* ---------------- feed ---------------- */
.feed { display: flex; flex-direction: column; gap: 8px; max-height: 340px; overflow-y: auto; }
.feed-item {
  background: var(--bg2); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
  display: flex; justify-content: space-between; gap: 10px; align-items: center;
}
.feed-item .time { color: var(--muted); font-size: 11.5px; direction: ltr; }
.feed-item.danger { border-color: rgba(239,68,68,.5); }
.feed-item.warn { border-color: rgba(245,158,11,.45); }

/* ---------------- toasts ---------------- */
#toasts { position: fixed; bottom: 18px; left: 18px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, 90vw); }
.toast {
  background: var(--panel2); border: 1px solid var(--line); border-right: 4px solid var(--accent);
  padding: 11px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: 13.5px;
  animation: slidein .2s ease;
}
.toast.ok { border-right-color: var(--accent2); }
.toast.err { border-right-color: var(--danger); }
.toast.warn { border-right-color: var(--warn); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } }

/* ---------------- live view ---------------- */
.live-frame {
  position: relative; background: #000; border-radius: var(--radius);
  border: 1px solid var(--line); overflow: hidden; min-height: 240px;
  display: grid; place-items: center;
}
.live-frame img { width: 100%; display: block; image-rendering: auto; }
.live-frame .placeholder { position: absolute; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }
.state-banner {
  display: inline-flex; align-items: center; gap: 9px; padding: 9px 18px;
  border-radius: 12px; font-weight: 800; font-size: 17px;
  background: rgba(59,130,246,.15); border: 1px solid rgba(59,130,246,.5);
}
.state-banner.danger { background: rgba(239,68,68,.15); border-color: rgba(239,68,68,.55); color: #fca5a5; }
.state-banner.ok { background: rgba(34,197,94,.13); border-color: rgba(34,197,94,.5); color: #86efac; }

/* ---------------- 3d ---------------- */
.scene-wrap {
  position: relative; height: min(60vh, 520px); border-radius: var(--radius);
  overflow: hidden; border: 1px solid var(--line); background: #070a12;
}
.scene-wrap canvas { width: 100% !important; height: 100% !important; display: block; }
.scene-legend {
  position: absolute; bottom: 10px; right: 10px; display: flex; gap: 8px; flex-wrap: wrap;
  background: rgba(8,12,20,.7); padding: 8px 10px; border-radius: 10px; font-size: 12px;
}
.scene-note { position: absolute; top: 10px; right: 10px; font-size: 12px; color: var(--muted);
  background: rgba(8,12,20,.7); padding: 6px 10px; border-radius: 8px; }

/* ---------------- misc ---------------- */
.hidden { display: none !important; }
.ltr { direction: ltr; text-align: left; }
.sep { height: 1px; background: var(--line); margin: 14px 0; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 13.5px; padding: 5px 0; border-bottom: 1px dashed rgba(38,49,74,.7); }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.bench-result { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.bench-result img { max-width: 340px; border-radius: 10px; border: 1px solid var(--line); }
.voice-btn.listening { background: rgba(239,68,68,.25) !important; border-color: var(--danger) !important; animation: blink 1s infinite; }
