/* ==========================================================================
   BOT LBC — Application (SaaS) shell + pages
   ========================================================================== */

/* ------------------------------ Shell ----------------------------------- */
.app-shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; background: var(--bg); }

.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 20px 16px; background: var(--surface); border-right: 1px solid var(--border); z-index: 100; }
.sidebar .brand { padding: 6px 8px 22px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 11px 13px; border-radius: var(--r-sm); font-weight: 600; font-size: .92rem; color: var(--slate-600); transition: all .16s var(--ease); position: relative; }
.side-link svg { flex: none; color: var(--slate-400); transition: color .16s; }
.side-link:hover { background: var(--slate-50); color: var(--ink); }
.side-link:hover svg { color: var(--slate-600); }
.side-link.active { background: var(--orange-50); color: var(--orange-700); }
.side-link.active svg { color: var(--orange-600); }
.side-link.active::before { content: ""; position: absolute; left: -16px; top: 50%; transform: translateY(-50%); width: 3px; height: 22px; background: var(--orange-500); border-radius: 0 3px 3px 0; }
.side-badge { margin-left: auto; background: var(--orange-500); color: #fff; font-size: .68rem; font-weight: 800; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center; }
.side-foot { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.plan-card { background: linear-gradient(150deg, var(--orange-50), #fff); border: 1px solid var(--orange-100); border-radius: var(--r-md); padding: 13px; margin-bottom: 6px; }
.side-up { font-size: .76rem; font-weight: 800; color: var(--orange-600); }
.plan-meta { font-size: .74rem; margin-top: 8px; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 90; display: flex; align-items: center; gap: 16px; padding: 13px 28px; background: rgba(255,255,255,.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.topsearch { flex: 1; max-width: 520px; }
.topsearch .input { background: var(--slate-50); border-color: transparent; }
.topsearch .input:focus { background: #fff; }
.live-pill { cursor: default; }
.topbell { position: relative; }
.bell-badge { position: absolute; top: 4px; right: 4px; background: var(--orange-500); color: #fff; font-size: .62rem; font-weight: 800; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; display: grid; place-items: center; border: 2px solid #fff; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 5px 10px 5px 5px; border-radius: var(--r-pill); border: 1px solid var(--border); transition: all .16s; }
.user-chip:hover { background: var(--slate-50); border-color: var(--slate-300); }
.user-name { font-weight: 700; font-size: .9rem; }
.user-chip svg { color: var(--slate-400); }
.app-content { padding: 28px; max-width: 1320px; width: 100%; margin: 0 auto; }
.mobile-only { display: none; }
.side-scrim { display: none; }

.page-loading { height: 60vh; display: grid; place-items: center; }
.page-loading::after { content: ""; width: 34px; height: 34px; border: 3px solid var(--slate-200); border-top-color: var(--orange-500); border-radius: 50%; animation: spin .8s linear infinite; }

/* ------------------------------ Page header ----------------------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 1.9rem; }
.page-head .sub { color: var(--slate-500); margin-top: 4px; }
.page-head-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ------------------------------ Grids ----------------------------------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 18px; }
.mb-18 { margin-bottom: 18px; } .mb-24 { margin-bottom: 24px; } .mt-18 { margin-top: 18px; } .mt-24 { margin-top: 24px; }

/* ------------------------------ Stat card ------------------------------- */
.statcard { display: flex; flex-direction: column; gap: 4px; }
.statcard-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; }
.statcard-val { font-family: var(--font-display); font-weight: 800; font-size: 1.85rem; letter-spacing: -.02em; margin-top: 12px; }
.statcard-label { font-size: .88rem; }
.statcard-sub { font-size: .76rem; margin-top: 4px; }

/* ------------------------------ Listing card ---------------------------- */
.lcard { position: relative; overflow: hidden; display: flex; flex-direction: column; }
.thumb { position: relative; display: grid; place-items: center; overflow: hidden; }
.thumb::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 70% 20%, rgba(255,255,255,.25), transparent 55%); }
.thumb-ic { color: rgba(255,255,255,.92); position: relative; z-index: 1; filter: drop-shadow(0 4px 10px rgba(0,0,0,.18)); }
.thumb-brand { position: absolute; bottom: 10px; left: 12px; color: #fff; font-weight: 800; font-size: .8rem; letter-spacing: .02em; text-shadow: 0 1px 6px rgba(0,0,0,.3); z-index: 1; }
.thumb-drop, .thumb-urgent { position: absolute; top: 10px; display: inline-flex; align-items: center; gap: 4px; font-size: .7rem; font-weight: 800; padding: 4px 8px; border-radius: var(--r-pill); z-index: 1; }
.thumb-drop { right: 10px; background: var(--green-500); color: #fff; }
.thumb-urgent { left: 10px; background: var(--red-500); color: #fff; }
.lcard-fav { position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,.92); color: var(--slate-500); display: grid; place-items: center; z-index: 2; transition: all .16s; box-shadow: var(--sh-xs); }
.lcard-fav:hover { color: var(--red-500); transform: scale(1.1); }
.lcard-fav.on { color: var(--red-500); }
.lcard-fav.on svg { fill: var(--red-500); }
.lcard-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.lcard-title { font-size: 1.02rem; font-weight: 700; }
.lcard-sub { font-size: .8rem; }
.lcard-price { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lcard-price .price { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; }
.price-was { text-decoration: line-through; color: var(--slate-400); font-size: .9rem; font-weight: 600; }
.lcard-analysis { background: var(--slate-50); border-radius: var(--r-sm); padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.lcard-margin { font-size: .82rem; font-weight: 600; color: var(--green-600, #0c8c51); display: flex; align-items: center; gap: 6px; }
.lcard-margin svg { color: var(--green-500); }
.lcard-meta { display: flex; align-items: center; gap: 12px; font-size: .78rem; flex-wrap: wrap; }
.lcard-meta span { display: inline-flex; align-items: center; gap: 4px; }
.lcard-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 4px; }

/* Listing grid */
.lgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 18px; }

/* ------------------------------ Price meter ----------------------------- */
.meter { margin: 4px 0; }
.meter-track { position: relative; height: 8px; border-radius: 999px; overflow: visible; display: flex; }
.meter-zone { height: 100%; }
.meter-zone.good { flex: 1; background: var(--green-500); border-radius: 999px 0 0 999px; }
.meter-zone.mid { flex: 1; background: var(--amber-500); }
.meter-zone.high { flex: 1; background: var(--red-500); border-radius: 0 999px 999px 0; }
.meter-mark { position: absolute; top: 50%; transform: translate(-50%, -50%); }
.meter-mark.market { width: 2px; height: 16px; background: var(--ink); border-radius: 2px; }
.meter-mark.price { width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 3px solid var(--slate-500); box-shadow: var(--sh-sm); cursor: help; }
.meter-mark.price.is-good { border-color: var(--green-500); }
.meter-mark.price.is-bad { border-color: var(--red-500); }
.meter-legend { display: flex; justify-content: space-between; font-size: .68rem; color: var(--slate-400); margin-top: 8px; }

/* ------------------------------ Search page ----------------------------- */
.search-layout { display: grid; grid-template-columns: 290px 1fr; gap: 22px; align-items: start; }
.filters { position: sticky; top: 88px; }
.filters-body { display: flex; flex-direction: column; gap: 18px; max-height: calc(100vh - 140px); overflow-y: auto; padding-right: 4px; }
.filter-group { display: flex; flex-direction: column; gap: 9px; }
.filter-group > .label { display: flex; align-items: center; justify-content: space-between; }
.cond-list { display: flex; flex-direction: column; gap: 8px; }
.price-inputs { display: flex; align-items: center; gap: 8px; }
.price-inputs .input { text-align: center; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.results-count { font-weight: 700; }
.results-count span { color: var(--orange-600); }
.search-summary { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.sum-pill { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 14px; font-size: .86rem; font-weight: 600; }
.sum-pill svg { color: var(--orange-500); }
.sum-pill strong { font-family: var(--font-display); }

/* ------------------------------ Deals page ------------------------------ */
.deal-rank { display: flex; align-items: center; gap: 16px; padding: 16px; border-radius: var(--r-md); }
.rank-num { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; color: var(--slate-300); width: 32px; text-align: center; }
.rank-thumb { width: 64px; height: 64px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; flex: none; }

/* ------------------------------ Dashboard ------------------------------- */
.dash-deal { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-sm); transition: background .15s; cursor: pointer; }
.dash-deal:hover { background: var(--slate-50); }
.dash-deal-thumb { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; }
.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.mini-row:last-child { border-bottom: none; }

/* ------------------------------ Kanban (CRM) ---------------------------- */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 280px; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kcol { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 200px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px; }
.kcol-head .dot { width: 9px; height: 9px; border-radius: 50%; }
.kcol-head strong { font-size: .9rem; }
.kcol-count { font-size: .76rem; font-weight: 800; color: var(--slate-500); background: var(--slate-100); padding: 2px 8px; border-radius: 999px; }
.kcard { background: #fff; border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; cursor: grab; transition: box-shadow .15s, transform .15s; box-shadow: var(--sh-xs); }
.kcard:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }
.kcard.dragging { opacity: .5; }
.kcard-top { display: flex; align-items: center; gap: 9px; margin-bottom: 8px; }
.kcard-thumb { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; flex: none; font-size: .72rem; font-weight: 800; }
.kcard-title { font-weight: 700; font-size: .86rem; line-height: 1.25; }
.kcard-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; font-size: .78rem; }
.kcol.drag-over { outline: 2px dashed var(--orange-400); outline-offset: -2px; }

/* ------------------------------ Messaging ------------------------------- */
.msg-layout { display: grid; grid-template-columns: 320px 1fr; gap: 0; border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; background: var(--surface); height: calc(100vh - 180px); min-height: 520px; }
.msg-list { border-right: 1px solid var(--border); overflow-y: auto; }
.msg-list-head { padding: 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.thread-item { display: flex; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .14s; }
.thread-item:hover { background: var(--slate-50); }
.thread-item.active { background: var(--orange-50); }
.thread-thumb { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: #fff; flex: none; }
.thread-main { min-width: 0; flex: 1; }
.thread-name { font-weight: 700; font-size: .9rem; display: flex; justify-content: space-between; gap: 8px; }
.thread-time { font-size: .72rem; color: var(--slate-400); font-weight: 600; flex: none; }
.thread-preview { font-size: .82rem; color: var(--slate-500); }
.thread-unread { width: 8px; height: 8px; border-radius: 50%; background: var(--orange-500); flex: none; align-self: center; }
.msg-thread { display: flex; flex-direction: column; }
.msg-thread-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.msg-body { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 12px; background: var(--canvas); }
.bubble { max-width: 72%; padding: 11px 15px; border-radius: 16px; font-size: .9rem; line-height: 1.5; white-space: pre-wrap; }
.bubble.them { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 5px; align-self: flex-start; }
.bubble.me { background: var(--orange-500); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
.bubble-time { font-size: .68rem; opacity: .7; margin-top: 5px; display: block; }
.msg-compose { border-top: 1px solid var(--border); padding: 14px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.compose-row { display: flex; gap: 10px; align-items: flex-end; }
.tpl-bar { display: flex; gap: 6px; flex-wrap: wrap; }

/* ------------------------------ AutoBuy --------------------------------- */
.ab-rule { display: flex; align-items: center; gap: 16px; padding: 18px; }
.ab-rule-ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; flex: none; background: var(--ink); color: #fff; }
.ab-log-row { display: grid; grid-template-columns: auto 1fr auto auto auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.ab-log-row:last-child { border-bottom: none; }
.ab-speed { font-family: ui-monospace, monospace; font-weight: 700; }

/* ------------------------------ Templates ------------------------------- */
.tpl-card { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.tpl-preview { background: var(--slate-50); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px; font-size: .84rem; color: var(--slate-600); white-space: pre-wrap; line-height: 1.5; max-height: 130px; overflow: hidden; position: relative; }
.tpl-preview::after { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 30px; background: linear-gradient(transparent, var(--slate-50)); }

/* ------------------------------ Analyse --------------------------------- */
.analyse-search { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.value-box { display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: var(--r-md); background: var(--slate-50); border: 1px solid var(--border); }
.value-box .big { font-family: var(--font-display); font-weight: 800; font-size: 1.7rem; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.sm { height: 200px; }

/* ------------------------------ Settings -------------------------------- */
.set-grid { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.set-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 88px; }
.set-nav a { padding: 10px 14px; border-radius: var(--r-sm); font-weight: 600; font-size: .9rem; color: var(--slate-600); }
.set-nav a.active { background: var(--orange-50); color: var(--orange-700); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: none; }
.set-row .set-label strong { display: block; }
.set-row .set-label span { font-size: .84rem; color: var(--slate-500); }
.account-row { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 10px; }

/* ------------------------------ Detail modal ---------------------------- */
.detail-thumb { height: 200px; border-radius: var(--r-md); display: grid; place-items: center; color: #fff; margin-bottom: 18px; position: relative; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 18px 0; }
.detail-stat { background: var(--slate-50); border-radius: var(--r-sm); padding: 14px; }
.detail-stat .lab { font-size: .76rem; color: var(--slate-500); }
.detail-stat .val { font-family: var(--font-display); font-weight: 800; font-size: 1.3rem; margin-top: 4px; }

/* ------------------------------ Responsive ------------------------------ */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
  .search-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .filters-body { max-height: none; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .28s var(--ease); box-shadow: var(--sh-lg); width: 260px; }
  .app-shell.nav-open .sidebar { transform: none; }
  .app-shell.nav-open .side-scrim { display: block; position: fixed; inset: 0; background: rgba(20,22,31,.4); z-index: 99; }
  .mobile-only { display: grid; }
  .user-name { display: none; }
  .app-content { padding: 18px; }
  .grid-3 { grid-template-columns: 1fr; }
  .set-grid { grid-template-columns: 1fr; }
  .set-nav { position: static; flex-direction: row; overflow-x: auto; }
  .msg-layout { grid-template-columns: 1fr; }
  .msg-layout.show-thread .msg-list { display: none; }
  .msg-layout:not(.show-thread) .msg-thread { display: none; }
}
@media (max-width: 560px) {
  .grid-4 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 1.5rem; }
  .topsearch { display: none; }
}
