/* ============================================================
   NEXURO — Shared Design System
   Orange / clean aesthetic · Cairo + JetBrains Mono · RTL
   Single source of truth for landing, auth & dashboard.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root{
  --orange-900:#7a2e05;
  --orange-700:#c2410c;
  --orange-600:#ea580c;
  --orange-500:#f97316;
  --orange-400:#fb923c;
  --orange-300:#fdba74;
  --orange-100:#ffe8d6;
  --orange-50:#fff6ee;

  --ink-900:#12131a;
  --ink-800:#1c1e28;
  --ink-600:#4a4d5c;
  --ink-400:#8b8e9c;
  --ink-200:#e4e5ea;
  --ink-100:#eef0f4;

  --bg:#ffffff;
  --bg-soft:#fbfbfd;
  --panel:#ffffff;
  --panel-soft:#fbfbfd;

  --green:#16a34a;
  --green-bg:#e9f9ee;
  --red:#e11d3c;
  --red-bg:#fdecee;

  --radius-lg:20px;
  --radius-md:14px;
  --radius-sm:10px;

  --shadow-sm: 0 1px 2px rgba(18,19,26,0.04), 0 1px 1px rgba(18,19,26,0.03);
  --shadow-md: 0 6px 20px -6px rgba(234,88,12,0.12), 0 2px 8px -2px rgba(18,19,26,0.06);
  --shadow-lg: 0 20px 45px -18px rgba(234,88,12,0.25), 0 8px 20px -10px rgba(18,19,26,0.08);

  --font-display:'Cairo', sans-serif;
  --font-mono:'JetBrains Mono', monospace;

  --sidebar-w:272px;
  --chat-w:340px;
}

*{margin:0;padding:0;box-sizing:border-box;}

html,body{
  background:var(--bg);
  color:var(--ink-900);
  font-family:var(--font-display);
  -webkit-font-smoothing:antialiased;
}

body{ overflow-x:hidden; }

::selection{ background:var(--orange-300); color:var(--ink-900); }

::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-track{ background:transparent; }
::-webkit-scrollbar-thumb{ background:var(--orange-300); border-radius:20px; }
::-webkit-scrollbar-thumb:hover{ background:var(--orange-500); }

a{ color:inherit; text-decoration:none; }
button{ font-family:inherit; cursor:pointer; border:none; background:none; }
img{ max-width:100%; display:block; }

.icon{ width:18px; height:18px; stroke:currentColor; stroke-width:2; fill:none; stroke-linecap:round; stroke-linejoin:round; flex-shrink:0; display:block; }

/* ============================================================
   APP SHELL  (nav sidebar | main | chat sidebar)
   ============================================================ */
.app{
  display:grid;
  grid-template-columns: var(--sidebar-w) minmax(0,1fr);
  min-height:100vh;
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--orange-50), transparent 60%),
    var(--bg);
}
.app:has(.chat){
  grid-template-columns: var(--sidebar-w) minmax(0,1fr) var(--chat-w);
}

/* ===================== SIDEBAR (main nav) ===================== */
.sidebar{
  background:var(--ink-900);
  background-image:
    radial-gradient(600px 300px at 100% 0%, rgba(249,115,22,0.18), transparent 60%),
    radial-gradient(500px 400px at 0% 100%, rgba(249,115,22,0.10), transparent 60%);
  padding:10px 20px 16px;
  display:flex;
  flex-direction:column;
  gap:6px;
  position:sticky;
  top:0;
  height:100vh;
  overflow-y:auto;
  z-index:40;
}

.brand{
  display:flex;
  align-items:center;
  gap:12px;
  padding:6px 6px 14px;
  margin-bottom:10px;
  border-bottom:1px solid rgba(255,255,255,0.08);
}
.brand-mark{
  width:44px; height:44px;
  border-radius:12px;
  background:linear-gradient(140deg, var(--orange-400), var(--orange-600) 60%, var(--orange-900));
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 6px 16px -4px rgba(234,88,12,0.55);
  position:relative;
  flex-shrink:0;
}
.brand-mark svg{ width:24px; height:24px; }
.brand-logo-img{ width:28px; height:28px; object-fit:contain; display:block; border-radius:8px; }
.sidebar .brand-mark{ width:44px; height:44px; }
.sidebar .brand-logo-img{ width:40px; height:40px; border-radius:10px; }
.brand-text{ line-height:1.1; }
.brand-text .name{ font-weight:800; font-size:16.5px; color:#fff; letter-spacing:.2px; }
.brand-text .sub{ font-size:11.5px; color:var(--orange-300); font-weight:600; margin-top:3px; letter-spacing:.3px; }

.nav-section-label{
  font-size:11px; font-weight:700; color:rgba(255,255,255,0.32);
  text-transform:uppercase; letter-spacing:.08em;
  padding:16px 12px 8px;
}

.nav{ display:flex; flex-direction:column; gap:2px; }
.nav-item{
  display:flex; align-items:center; gap:12px;
  padding:11px 13px;
  border-radius:11px;
  color:rgba(255,255,255,0.62);
  font-size:14.5px; font-weight:600;
  transition:background .15s ease, color .15s ease;
  position:relative;
}
.nav-item .icon{ width:18px; height:18px; opacity:.9; }
.nav-item:hover{ background:rgba(255,255,255,0.06); color:#fff; }
.nav-item.active{
  color:#fff;
  background:linear-gradient(90deg, rgba(249,115,22,0.22), rgba(249,115,22,0.04));
}
.nav-item.active::before{
  content:"";
  position:absolute; right:-20px; top:50%; transform:translateY(-50%);
  width:4px; height:22px; border-radius:4px 0 0 4px;
  background:linear-gradient(180deg, var(--orange-400), var(--orange-600));
}
.nav-item .badge{
  margin-inline-start:auto;
  background:var(--orange-500);
  color:#fff; font-size:10.5px; font-weight:800;
  padding:2px 7px; border-radius:20px;
  box-shadow:0 3px 8px -2px rgba(234,88,12,0.6);
}

.sidebar-footer{ margin-top:auto; padding-top:16px; }
.bot-status-card{
  background:rgba(255,255,255,0.05);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:16px;
  padding:16px;
}
.bot-status-card .row{ display:flex; align-items:center; gap:10px; margin-bottom:12px; }
.pulse-dot{
  width:9px; height:9px; border-radius:50%;
  background:var(--green);
  box-shadow:0 0 0 0 rgba(22,163,74,0.6);
  animation:pulse 2s infinite;
  flex-shrink:0;
}
@keyframes pulse{
  0%{ box-shadow:0 0 0 0 rgba(22,163,74,0.55); }
  70%{ box-shadow:0 0 0 8px rgba(22,163,74,0); }
  100%{ box-shadow:0 0 0 0 rgba(22,163,74,0); }
}
.bot-status-card .title{ font-size:13px; font-weight:700; color:#fff; }
.bot-status-card .desc{ font-size:11.5px; color:rgba(255,255,255,0.45); margin-bottom:12px; line-height:1.6; }
.stop-btn{
  width:100%;
  display:flex; align-items:center; justify-content:center; gap:8px;
  padding:10px; border-radius:10px;
  background:rgba(225,29,60,0.12);
  color:#ff8a9b;
  font-weight:700; font-size:13px;
  border:1px solid rgba(225,29,60,0.25);
  transition:background .15s;
}
.stop-btn:hover{ background:rgba(225,29,60,0.22); }

/* ===================== MAIN ===================== */
.main{ padding:10px 34px 24px; max-width:none; width:100%; min-width:0; }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:26px; gap:20px; flex-wrap:wrap;
}
.topbar--fixed{
  position:sticky; top:0; z-index:25;
  background:rgba(255,255,255,0.92); backdrop-filter:blur(8px);
  margin:-10px -34px 16px; padding:10px 34px;
  border-bottom:1px solid var(--ink-100);
}
@media (max-width:860px){
  .topbar--fixed{ margin:-10px -16px 12px; padding:9px 16px; }
}
.topbar h1{ font-size:23px; font-weight:800; color:var(--ink-900); }
.topbar .date{ font-size:13px; color:var(--ink-400); font-weight:600; margin-top:3px; }
.topbar-start{ display:flex; align-items:center; gap:12px; min-width:0; }
.topbar-title{ min-width:0; }
.topbar-title h1{ font-size:22px; }
.topbar-title .date{ font-size:12.5px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-top:4px; }
.page-pill{
  background:var(--orange-100); color:var(--orange-700);
  font-weight:800; font-size:11.5px; padding:2px 9px; border-radius:20px;
}
.brand-mobile{ display:none; align-items:center; gap:9px; font-weight:800; font-size:16px; color:var(--ink-900); }
.brand-mobile .bm-mark{
  width:30px; height:30px; border-radius:9px; flex-shrink:0;
  background:linear-gradient(140deg, var(--orange-400), var(--orange-600));
  display:flex; align-items:center; justify-content:center;
  box-shadow:0 4px 10px -3px rgba(234,88,12,0.5);
}
.brand-mobile .bm-mark svg{ width:17px; height:17px; }
.brand-mobile .bm-mark .brand-logo-img{ width:22px; height:22px; border-radius:7px; }

.topbar-actions{ display:flex; align-items:center; gap:12px; flex-wrap:wrap; }

.search-box{
  display:flex; align-items:center; gap:9px;
  background:var(--panel-soft);
  border:1px solid var(--ink-100);
  border-radius:12px;
  padding:9px 14px;
  width:240px;
  color:var(--ink-400);
}
.search-box input{
  border:none; outline:none; background:none; font-family:inherit;
  font-size:13.5px; color:var(--ink-900); width:100%;
}
.search-box input::placeholder{ color:var(--ink-400); }

.icon-btn{
  width:40px; height:40px; border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  background:var(--panel-soft); border:1px solid var(--ink-100);
  color:var(--ink-600);
  position:relative;
  transition:border-color .15s, color .15s;
}
.icon-btn:hover{ border-color:var(--orange-300); color:var(--orange-600); }
.icon-btn .dot{
  position:absolute; top:8px; left:8px;
  width:7px; height:7px; border-radius:50%;
  background:var(--orange-500); border:2px solid #fff;
}

.user-chip{
  display:flex; align-items:center; gap:10px;
  padding:6px 14px 6px 6px;
  border-radius:14px;
  background:var(--panel-soft); border:1px solid var(--ink-100);
  text-decoration:none;
}
.user-avatar{
  width:32px; height:32px; border-radius:10px;
  background:linear-gradient(140deg, var(--orange-400), var(--orange-700));
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:800; font-size:13px;
}
.user-chip .u-name{ font-size:13px; font-weight:700; color:var(--ink-900); }
.user-chip .u-role{ font-size:11px; color:var(--ink-400); font-weight:600; }

/* ===================== STAT CARDS ===================== */
.stats-grid{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:18px;
  margin-bottom:22px;
}
.stat-card{
  background:var(--panel);
  border:1px solid var(--ink-100);
  border-radius:var(--radius-lg);
  padding:20px 22px;
  box-shadow:var(--shadow-sm);
  position:relative;
  overflow:hidden;
  transition:box-shadow .2s, transform .2s;
}
.stat-card:hover{ box-shadow:var(--shadow-md); transform:translateY(-2px); }
.stat-card.hero{
  background:linear-gradient(150deg, var(--orange-600), var(--orange-500) 55%, var(--orange-400));
  border:none; color:#fff;
}
.stat-card.hero::after{
  content:"";
  position:absolute; inset:0;
  background:radial-gradient(circle at 100% 0%, rgba(255,255,255,0.25), transparent 55%);
}

.stat-top{ display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:14px; }
.stat-icon-wrap{
  width:40px; height:40px; border-radius:11px;
  display:flex; align-items:center; justify-content:center;
  background:var(--orange-100); color:var(--orange-600);
}
.stat-card.hero .stat-icon-wrap{ background:rgba(255,255,255,0.22); color:#fff; }

.stat-trend{
  display:flex; align-items:center; gap:4px;
  font-size:12px; font-weight:700; padding:4px 8px; border-radius:20px;
}
.stat-trend.up{ color:var(--green); background:var(--green-bg); }
.stat-trend.down{ color:var(--red); background:var(--red-bg); }
.stat-card.hero .stat-trend.up{ color:#fff; background:rgba(255,255,255,0.22); }
.stat-trend .icon{ width:13px; height:13px; }

.stat-label{ font-size:13px; font-weight:600; color:var(--ink-400); margin-bottom:6px; }
.stat-card.hero .stat-label{ color:rgba(255,255,255,0.85); }
.stat-value{ font-size:27px; font-weight:800; font-family:var(--font-mono); letter-spacing:-.5px; }
.stat-sub{ font-size:12px; color:var(--ink-400); margin-top:6px; font-weight:500; }
.stat-card.hero .stat-sub{ color:rgba(255,255,255,0.75); }

/* ===================== MAIN GRID ===================== */
.content-grid{
  display:grid;
  grid-template-columns: 1.7fr 1fr;
  gap:18px;
  margin-bottom:18px;
  align-items:start;
}

.panel{
  background:var(--panel);
  border:1px solid var(--ink-100);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-sm);
  overflow:hidden;
}
.panel-header{
  display:flex; align-items:center; justify-content:space-between;
  padding:20px 22px 16px;
  border-bottom:1px solid var(--ink-100);
  gap:12px; flex-wrap:wrap;
}
.panel-header h2{ font-size:15.5px; font-weight:800; color:var(--ink-900); display:flex; align-items:center; gap:9px; }
.panel-header h2 .icon{ color:var(--orange-600); width:19px; height:19px; }
.panel-header .sub{ font-size:12px; color:var(--ink-400); font-weight:500; margin-top:2px; }

.tabs{ display:flex; gap:6px; background:var(--panel-soft); padding:4px; border-radius:10px; border:1px solid var(--ink-100); }
.tab{ padding:6px 13px; border-radius:7px; font-size:12.5px; font-weight:700; color:var(--ink-400); cursor:pointer; }
.tab.active{ background:#fff; color:var(--orange-600); box-shadow:var(--shadow-sm); }

/* chart panel */
.chart-body{ padding:18px 22px 22px; }
.chart-price-row{ display:flex; align-items:baseline; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.chart-price{ font-family:var(--font-mono); font-size:26px; font-weight:800; color:var(--ink-900); }
.chart-change{ font-family:var(--font-mono); font-size:14px; font-weight:700; color:var(--green); display:flex; align-items:center; gap:3px; }
.chart-change .icon{ width:14px; height:14px; }
.chart-svg-wrap{ width:100%; }
.chart-legend{ display:flex; gap:18px; margin-top:14px; padding-top:14px; border-top:1px solid var(--ink-100); flex-wrap:wrap; }
.legend-item{ display:flex; align-items:center; gap:7px; font-size:12px; font-weight:600; color:var(--ink-600); }
.legend-dot{ width:9px; height:9px; border-radius:3px; }

/* positions list */
.positions-body{ padding:14px 12px 16px; display:flex; flex-direction:column; gap:6px; }
.position-row{
  display:flex; align-items:center; gap:12px;
  padding:12px 10px; border-radius:12px;
  transition:background .15s;
}
.position-row:hover{ background:var(--panel-soft); }
.pos-icon{
  width:38px; height:38px; border-radius:10px;
  display:flex; align-items:center; justify-content:center;
  font-size:11px; font-weight:800; color:#fff; flex-shrink:0;
}
.pos-info{ flex:1; min-width:0; }
.pos-pair{ font-size:13.5px; font-weight:700; color:var(--ink-900); display:flex; align-items:center; gap:6px; }
.pos-tag{ font-size:9.5px; font-weight:800; padding:1.5px 6px; border-radius:5px; letter-spacing:.02em; }
.pos-tag.long{ background:var(--green-bg); color:var(--green); }
.pos-tag.short{ background:var(--red-bg); color:var(--red); }
.pos-meta{ font-size:11.5px; color:var(--ink-400); font-weight:500; margin-top:2px; font-family:var(--font-mono); }
.pos-pnl{ text-align:left; }
.pos-pnl .amt{ font-family:var(--font-mono); font-size:13.5px; font-weight:800; }
.pos-pnl .pct{ font-size:11px; font-weight:700; font-family:var(--font-mono); margin-top:2px; }
.amt.pos, .pct.pos{ color:var(--green); }
.amt.neg, .pct.neg{ color:var(--red); }

/* ===================== BOTTOM ROW ===================== */
.bottom-grid{ display:grid; grid-template-columns: 1fr 1fr 1fr; gap:18px; }

/* strategy cards */
.strategy-list{ padding:12px 16px 16px; display:flex; flex-direction:column; gap:12px; }
.strategy-item{ padding:14px; border-radius:14px; border:1px solid var(--ink-100); background:var(--panel-soft); }
.strategy-top{ display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.strategy-name{ font-size:13px; font-weight:700; color:var(--ink-900); display:flex; align-items:center; gap:8px; }
.strategy-dot{ width:8px; height:8px; border-radius:50%; }
.strategy-dot.on{ background:var(--green); box-shadow:0 0 0 3px var(--green-bg); }
.strategy-dot.off{ background:var(--ink-400); box-shadow:0 0 0 3px var(--ink-100); }
.toggle{
  width:38px; height:22px; border-radius:20px; background:var(--ink-100);
  position:relative; transition:background .2s; flex-shrink:0;
}
.toggle.on{ background:linear-gradient(90deg, var(--orange-500), var(--orange-600)); }
.toggle::after{
  content:""; position:absolute; top:2px; left:2px;
  width:18px; height:18px; border-radius:50%; background:#fff;
  box-shadow:0 1px 3px rgba(0,0,0,0.25);
  transition:transform .2s;
}
.toggle.on::after{ transform:translateX(-16px); }
.strategy-bar-track{ height:6px; border-radius:6px; background:var(--ink-100); overflow:hidden; margin-bottom:8px; }
.strategy-bar-fill{ height:100%; border-radius:6px; background:linear-gradient(90deg, var(--orange-400), var(--orange-600)); }
.strategy-stats{ display:flex; justify-content:space-between; font-size:11px; color:var(--ink-400); font-weight:600; font-family:var(--font-mono); }
.strategy-stats b{ color:var(--ink-900); font-weight:700; }

/* activity log */
.log-body{ padding:8px 18px 18px; display:flex; flex-direction:column; }
.log-item{ display:flex; gap:12px; padding:12px 0; border-bottom:1px solid var(--ink-100); }
.log-item:last-child{ border-bottom:none; }
.log-icon{ width:32px; height:32px; border-radius:9px; flex-shrink:0; display:flex; align-items:center; justify-content:center; }
.log-icon.buy{ background:var(--green-bg); color:var(--green); }
.log-icon.sell{ background:var(--red-bg); color:var(--red); }
.log-icon.alert{ background:var(--orange-100); color:var(--orange-600); }
.log-icon .icon{ width:15px; height:15px; }
.log-text{ font-size:12.5px; font-weight:600; color:var(--ink-900); line-height:1.5; }
.log-text b{ color:var(--orange-600); }
.log-time{ font-size:11px; color:var(--ink-400); font-weight:500; margin-top:3px; font-family:var(--font-mono); }

/* risk panel */
.risk-body{ padding:18px 22px 22px; }
.risk-gauge-wrap{ display:flex; flex-direction:column; align-items:center; padding:6px 0 18px; }
.risk-label{ font-size:12px; font-weight:700; color:var(--ink-400); margin-top:10px; }
.risk-value{ font-size:30px; font-weight:800; color:var(--ink-900); font-family:var(--font-mono); }
.risk-metrics{ display:flex; flex-direction:column; gap:12px; }
.risk-metric-row{ display:flex; align-items:center; justify-content:space-between; }
.risk-metric-label{ font-size:12.5px; color:var(--ink-600); font-weight:600; display:flex; align-items:center; gap:7px; }
.risk-metric-label .icon{ width:15px; height:15px; color:var(--orange-600); }
.risk-metric-value{ font-size:13px; font-weight:800; color:var(--ink-900); font-family:var(--font-mono); }

.btn-primary{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  background:linear-gradient(120deg, var(--orange-500), var(--orange-600));
  color:#fff; font-weight:700; font-size:13px;
  padding:11px 18px; border-radius:11px; width:100%; margin-top:16px;
  box-shadow:0 8px 18px -6px rgba(234,88,12,0.5);
  transition:transform .15s, box-shadow .15s;
}
.btn-primary:hover{ transform:translateY(-1px); box-shadow:0 10px 22px -6px rgba(234,88,12,0.6); }

/* ============================================================
   PROFILE PAGE
   ============================================================ */
.profile-wrap{ max-width:none; }
.profile-hero{
  display:flex; align-items:center; gap:18px;
  padding:24px; margin-bottom:18px;
  background:linear-gradient(135deg, var(--orange-600), var(--orange-500) 60%, var(--orange-400));
  border:none; color:#fff; position:relative; overflow:hidden;
  border-radius:var(--radius-lg); box-shadow:var(--shadow-sm);
}
.profile-hero::after{
  content:""; position:absolute; inset:0;
  background:radial-gradient(circle at 100% 0%, rgba(255,255,255,0.25), transparent 55%);
}
.profile-hero > *{ position:relative; z-index:1; }
.ph-avatar{
  width:72px; height:72px; border-radius:18px; flex-shrink:0;
  background:rgba(255,255,255,0.22); display:flex; align-items:center; justify-content:center;
  color:#fff; font-weight:800; font-size:26px; box-shadow:0 8px 20px -6px rgba(0,0,0,0.3);
}
.ph-info{ flex:1; min-width:0; }
.ph-name{ font-size:21px; font-weight:800; display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
.ph-email{ font-size:13.5px; opacity:.92; margin-top:4px; font-weight:500; }
.ph-chips{ display:flex; gap:8px; flex-wrap:wrap; margin-top:12px; }
.ph-chip{
  background:rgba(255,255,255,0.18); border:1px solid rgba(255,255,255,0.25);
  color:#fff; font-size:12px; font-weight:700; padding:4px 11px; border-radius:20px;
  display:inline-flex; align-items:center; gap:6px;
}
.ph-chip.ok{ background:rgba(34,197,94,0.28); border-color:rgba(34,197,94,0.45); }

.profile-grid{ display:grid; grid-template-columns:1.6fr 1fr; gap:18px; align-items:start; }
.side-card .row{ display:flex; align-items:center; justify-content:space-between; gap:12px; padding:11px 0; border-bottom:1px solid var(--ink-100); }
.side-card .row:last-child{ border-bottom:none; }
.side-card .row .k{ font-size:13px; color:var(--ink-400); font-weight:600; }
.side-card .row .v{ font-size:13.5px; color:var(--ink-900); font-weight:700; text-align:left; }
.danger-card{ border-color:rgba(225,29,60,0.25); }

.form-actions{ display:flex; gap:10px; flex-wrap:wrap; margin-top:4px; }
.form-actions .btn-primary,
.form-actions .auth-btn,
.form-actions .stop-btn{ width:auto; margin-top:0; }

.nx-modal{
  display:none; position:fixed; inset:0; background:rgba(18,19,26,0.5);
  backdrop-filter:blur(4px); z-index:80; align-items:center; justify-content:center; padding:16px;
}
.nx-modal.show{ display:flex; }
.nx-modal .card{
  background:var(--panel); border:1px solid rgba(225,29,60,0.3);
  border-radius:var(--radius-lg); max-width:420px; width:100%; padding:26px;
  box-shadow:var(--shadow-lg);
}

@media (max-width:860px){
  .profile-grid{ grid-template-columns:1fr; }
}
@media (max-width:560px){
  .profile-hero{ flex-direction:column; text-align:center; align-items:center; }
  .ph-name{ justify-content:center; }
  .ph-chips{ justify-content:center; }
  .form-actions .btn-primary,
  .form-actions .auth-btn,
  .form-actions .stop-btn{ width:100%; }
}

/* ============================================================
   CHAT SIDEBAR  (second sidebar, inside dashboard)
   ============================================================ */
.chat{
  background:var(--panel);
  border-inline-start:1px solid var(--ink-100);
  display:flex; flex-direction:column;
  position:sticky; top:0; height:100vh;
  z-index:40;
}
.chat-header{
  display:flex; align-items:center; gap:12px;
  padding:20px 18px 16px;
  border-bottom:1px solid var(--ink-100);
}
.chat-bot-avatar{
  width:42px; height:42px; border-radius:12px;
  background:linear-gradient(140deg, var(--orange-400), var(--orange-600));
  display:flex; align-items:center; justify-content:center;
  color:#fff; flex-shrink:0;
  box-shadow:0 6px 14px -4px rgba(234,88,12,0.5);
}
.chat-header .title{ font-size:14.5px; font-weight:800; color:var(--ink-900); display:flex; align-items:center; gap:7px; }
.chat-header .status{ font-size:11.5px; color:var(--green); font-weight:600; display:flex; align-items:center; gap:5px; margin-top:2px; }
.chat-header .status .pulse-dot{ width:7px; height:7px; }

.chat-body{
  flex:1; overflow-y:auto;
  padding:18px 16px;
  display:flex; flex-direction:column; gap:14px;
}
.msg{ display:flex; gap:10px; max-width:100%; align-items:flex-end; }
.msg .avatar{
  width:30px; height:30px; border-radius:9px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; color:#fff;
}
.msg.bot .avatar{ background:linear-gradient(140deg, var(--orange-400), var(--orange-600)); }
.msg.user{ flex-direction:row-reverse; }
.msg.user .avatar{ background:var(--ink-800); }
.bubble{
  padding:11px 14px; border-radius:14px; font-size:13px; line-height:1.7;
  font-weight:500; max-width:78%;
}
.msg.bot .bubble{
  background:var(--orange-50); border:1px solid var(--orange-100);
  color:var(--ink-900); border-bottom-right-radius:4px;
}
.msg.user .bubble{
  background:linear-gradient(120deg, var(--orange-500), var(--orange-600));
  color:#fff; border-bottom-left-radius:4px;
}
.bubble b{ color:var(--orange-700); }
.msg.user .bubble b{ color:#fff; }

.chat-suggest{
  display:flex; flex-wrap:wrap; gap:8px; padding:0 16px 12px;
}
.chip{
  font-size:11.5px; font-weight:700; color:var(--orange-700);
  background:var(--orange-50); border:1px solid var(--orange-100);
  padding:6px 12px; border-radius:20px; cursor:pointer;
  transition:background .15s, color .15s;
}
.chip:hover{ background:var(--orange-100); color:var(--orange-900); }

.chat-input{
  display:flex; align-items:center; gap:10px;
  padding:14px 16px; border-top:1px solid var(--ink-100);
  background:var(--panel-soft);
}
.chat-input input{
  flex:1; border:1px solid var(--ink-100); border-radius:12px;
  padding:10px 14px; font-family:inherit; font-size:13px; color:var(--ink-900);
  background:#fff; outline:none; transition:border-color .15s;
}
.chat-input input:focus{ border-color:var(--orange-300); }
.chat-input input::placeholder{ color:var(--ink-400); }
.chat-send{
  width:42px; height:42px; border-radius:12px; flex-shrink:0;
  background:linear-gradient(120deg, var(--orange-500), var(--orange-600));
  color:#fff; display:flex; align-items:center; justify-content:center;
  box-shadow:0 8px 18px -6px rgba(234,88,12,0.5);
  transition:transform .15s;
}
.chat-send:hover{ transform:translateY(-1px); }

.typing{ display:flex; gap:4px; align-items:center; padding:4px 2px; }
.typing span{
  width:7px; height:7px; border-radius:50%; background:var(--orange-400);
  animation:typing 1.1s infinite ease-in-out;
}
.typing span:nth-child(2){ animation-delay:.18s; }
.typing span:nth-child(3){ animation-delay:.36s; }
@keyframes typing{ 0%,60%,100%{ transform:translateY(0); opacity:.5 } 30%{ transform:translateY(-5px); opacity:1 } }

/* ============================================================
   AUTH  (orange system)
   ============================================================ */
.auth-shell{
  min-height:100vh;
  display:flex; flex-direction:column;
  align-items:center; justify-content:center;
  padding:32px 18px;
  background:
    radial-gradient(900px 500px at 85% -10%, var(--orange-50), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(234,88,12,0.06), transparent 60%),
    var(--bg);
  position:relative;
}
.auth-shell::before{
  content:""; position:fixed; inset:0;
  background-image:radial-gradient(rgba(234,88,12,0.04) 1px, transparent 1.5px);
  background-size:18px 18px; pointer-events:none;
}
.auth-brand{
  display:flex; align-items:center; gap:12px; margin-bottom:22px;
  text-decoration:none;
}
.auth-brand .brand-mark{ width:46px; height:46px; }
.auth-brand .brand-logo-img{ width:42px; height:42px; border-radius:11px; }
.auth-brand .name{
  font-size:22px; font-weight:800; color:var(--ink-900); letter-spacing:.2px;
}
.auth-brand .name span{ color:var(--orange-600); }

.auth-card{
  width:100%; max-width:440px;
  background:var(--panel);
  border:1px solid var(--ink-100);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-lg);
  padding:30px 28px;
  position:relative;
  overflow:hidden;
  z-index:1;
}
.auth-card::before{
  content:""; position:absolute; top:0; left:0; right:0; height:5px;
  background:linear-gradient(90deg, var(--orange-400), var(--orange-600));
}
.auth-head{ text-align:center; margin-bottom:22px; }
.auth-head h1{ font-size:21px; font-weight:800; color:var(--ink-900); }
.auth-head p{ font-size:13px; color:var(--ink-400); margin-top:6px; font-weight:500; }

.field{ margin-bottom:16px; }
.field label{
  display:block; font-size:13px; font-weight:700; color:var(--ink-600);
  margin-bottom:7px;
}
.auth-input{
  width:100%; border:1px solid var(--ink-100); border-radius:12px;
  padding:11px 14px; font-family:inherit; font-size:14px; color:var(--ink-900);
  background:var(--panel-soft); outline:none; transition:border-color .15s, box-shadow .15s;
}
.auth-input:focus{ border-color:var(--orange-300); box-shadow:0 0 0 3px var(--orange-50); background:#fff; }
.auth-input::placeholder{ color:var(--ink-400); }
.field .error{ color:var(--red); font-size:12px; font-weight:600; margin-top:6px; }

.auth-btn{
  width:100%; display:flex; align-items:center; justify-content:center; gap:8px;
  background:linear-gradient(120deg, var(--orange-500), var(--orange-600));
  color:#fff; font-weight:700; font-size:14.5px;
  padding:12px; border-radius:12px; margin-top:6px;
  box-shadow:0 8px 18px -6px rgba(234,88,12,0.5);
  transition:transform .15s, box-shadow .15s;
}
.auth-btn:hover{ transform:translateY(-1px); box-shadow:0 10px 22px -6px rgba(234,88,12,0.6); }

.auth-row{ display:flex; align-items:center; justify-content:space-between; margin:14px 0; gap:12px; }
.auth-check{ display:flex; align-items:center; gap:8px; font-size:13px; color:var(--ink-600); font-weight:600; cursor:pointer; }
.auth-check input{ width:16px; height:16px; accent-color:var(--orange-600); }
.auth-link{ color:var(--orange-600); font-weight:700; font-size:13px; transition:color .15s; }
.auth-link:hover{ color:var(--orange-700); }

.auth-foot{ text-align:center; font-size:13px; color:var(--ink-400); margin-top:20px; font-weight:500; }
.auth-foot a{ color:var(--orange-600); font-weight:700; }
.auth-foot a:hover{ color:var(--orange-700); }

.auth-back{
  display:inline-flex; align-items:center; gap:7px; margin-top:18px;
  color:var(--ink-400); font-size:13px; font-weight:600; z-index:1;
}
.auth-back:hover{ color:var(--orange-600); }

@media (max-width:560px){
  .auth-shell{ padding:16px 14px; justify-content:flex-start; }
  .auth-card{ padding:24px 18px; border-radius:18px; }
  .auth-brand{ margin-bottom:18px; }
  .auth-brand .name{ font-size:20px; }
  .auth-head{ margin-bottom:18px; }
  .auth-head h1{ font-size:19px; }
}

/* ============================================================
   MOBILE CONTROLS
   ============================================================ */
.menu-toggle, .chat-toggle{ display:none; }
.scrim{ display:none; }

@media (max-width:1200px){
  .content-grid{ grid-template-columns:1fr; }
  .bottom-grid{ grid-template-columns:1fr; }
  .stats-grid{ grid-template-columns:repeat(2,1fr); }
}

@media (max-width:1080px){
  .app{ grid-template-columns: var(--sidebar-w) minmax(0,1fr); }
  .chat{
    position:fixed; top:0; bottom:0; left:0; width:min(360px, 88vw);
    transform:translateX(-105%); transition:transform .25s ease;
    box-shadow:var(--shadow-lg); z-index:60;
  }
  body.chat-open .chat{ transform:translateX(0); }
  .chat-toggle{ display:flex; }
}

@media (max-width:860px){
  .app{ grid-template-columns:1fr; }
  .sidebar{
    position:fixed; top:0; bottom:0; right:0; width:min(280px, 84vw);
    transform:translateX(105%); transition:transform .25s ease; z-index:70;
  }
  body.nav-open .sidebar{ transform:translateX(0); }
  .menu-toggle{ display:flex; }
  .main{ padding:10px 16px 28px; }
  .stats-grid{ grid-template-columns:1fr 1fr; }
  .search-box{ display:none; }
  .topbar-actions{ gap:8px; }
  .topbar{ flex-wrap:nowrap; }
  .topbar-title{ display:none; }
  .brand-mobile{ display:flex; }
  .user-chip .u-name, .user-chip .u-role{ display:none; }
  .user-chip{ padding:6px; }
}

@media (max-width:560px){
  .stats-grid{ grid-template-columns:1fr; }
  .topbar-actions{ gap:6px; }
  .ib-extra{ display:none; }
  .topbar-title h1{ font-size:18px; }
}

/* scrim for drawers */
body.nav-open .scrim, body.chat-open .scrim{
  display:block; position:fixed; inset:0; background:rgba(18,19,26,0.45);
  z-index:55; backdrop-filter:blur(2px);
}

/* ============================================================
   CHAT BOT PAGE (Telegram-style)
   ============================================================ */
.chat-page{
  display:grid;
  grid-template-columns:320px minmax(0,1fr);
  gap:18px;
  height:calc(100vh - 80px);
  min-height:520px;
  width:100%;
}

.chat-list{
  background:var(--panel);
  border:1px solid var(--ink-100);
  border-radius:var(--radius-lg);
  overflow:hidden;
  display:flex; flex-direction:column;
  box-shadow:var(--shadow-sm);
}
.chat-list-head{
  padding:16px 18px; border-bottom:1px solid var(--ink-100);
  font-weight:800; font-size:15px; color:var(--ink-900);
  display:flex; align-items:center; gap:9px;
}
.chat-list-head .icon{ color:var(--orange-600); }
.chat-search{
  display:flex; align-items:center; gap:9px;
  margin:12px 14px; background:var(--panel-soft);
  border:1px solid var(--ink-100); border-radius:12px; padding:9px 13px;
  color:var(--ink-400);
}
.chat-search input{ border:none; outline:none; background:none; font-family:inherit; font-size:13px; color:var(--ink-900); width:100%; }
.chat-search input::placeholder{ color:var(--ink-400); }
.chat-convs{ overflow-y:auto; flex:1; }
.conv{
  display:flex; gap:12px; padding:13px 16px; align-items:center;
  border-bottom:1px solid var(--ink-100); cursor:pointer; transition:background .15s;
}
.conv:hover{ background:var(--panel-soft); }
.conv.active{ background:var(--orange-50); }
.conv .avatar{
  width:44px; height:44px; border-radius:13px; flex-shrink:0;
  display:flex; align-items:center; justify-content:center; color:#fff;
}
.conv .c-body{ flex:1; min-width:0; }
.conv .c-name{ font-weight:700; font-size:14px; color:var(--ink-900); }
.conv .c-last{ font-size:12px; color:var(--ink-400); margin-top:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.conv .c-meta{ margin-inline-start:auto; display:flex; flex-direction:column; align-items:flex-end; gap:6px; flex-shrink:0; }
.conv .c-time{ font-size:11px; color:var(--ink-400); font-family:var(--font-mono); }
.conv .c-badge{ background:var(--orange-500); color:#fff; border-radius:20px; font-size:10px; font-weight:800; padding:2px 7px; }

.chat-panel{
  background:var(--panel);
  border:1px solid var(--ink-100);
  border-radius:var(--radius-lg);
  display:flex; flex-direction:column; overflow:hidden;
  box-shadow:var(--shadow-sm);
}
.chat-panel-head{
  display:flex; align-items:center; gap:12px; padding:15px 18px;
  border-bottom:1px solid var(--ink-100);
}
.chat-panel-head .title{ font-size:15px; font-weight:800; color:var(--ink-900); }
.chat-panel-head .status{ font-size:11.5px; color:var(--green); font-weight:600; display:flex; align-items:center; gap:5px; margin-top:2px; }
.chat-panel-body{ flex:1; overflow-y:auto; padding:18px 16px; display:flex; flex-direction:column; gap:14px; }
.chat-panel-body .day-sep{ text-align:center; font-size:11px; color:var(--ink-400); font-weight:600; margin:4px 0; }

.chat-back{ display:none; }
@media (max-width:860px){
  .main:has(.chat-page){ padding:0; }
  .main:has(.chat-page) .topbar--fixed{ margin:0 0 12px; padding:12px 16px; }
  .chat-page{ grid-template-columns:1fr; height:calc(100dvh - 76px); display:flex; flex-direction:column; min-height:0; }
  .chat-list{ flex:1; min-height:0; overflow-y:auto; max-height:none; border-radius:0; }
  .chat-panel{ display:none; flex-direction:column; min-height:0; overflow:hidden; border-radius:0; }
  .chat-page.chat-open-view .chat-list{ display:none; }
  .chat-page.chat-open-view .chat-panel{ display:flex; flex:1; }
  .chat-panel-body{ flex:1; min-height:0; overflow-y:auto; }
  .chat-panel .chat-input{ position:sticky; bottom:0; background:var(--panel); z-index:2; flex-shrink:0; }
  .chat-back{ display:flex; }
}

/* Markdown rendering inside chat bubbles */
.bubble strong{ color:var(--green); font-weight:800; }
.bubble code{
  background:var(--ink-100); color:var(--orange-600);
  padding:1px 6px; border-radius:7px; font-family:var(--font-mono); font-size:12px;
}
.bubble a{ color:var(--orange-600); text-decoration:underline; }
.bubble-col .chat-img{ cursor:pointer; }
.reply-markup .chip{ border:1px solid var(--orange-300); }
.reply-markup .chip:hover{ background:var(--orange-500); color:#fff; }
