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

:root {
  --sidebar-bg:  #6C5DD3;
  --sidebar-w:   180px;
  --purple:      #7B68EE;
  --purple-light:#EEE9FF;
  --blue:        #3B82F6;
  --green:       #22C55E;
  --orange:      #F97316;
  --red:         #EF4444;
  --pink:        #EC4899;
  --text:        #111827;
  --text-2:      #6B7280;
  --text-3:      #9CA3AF;
  --border:      #E5E7EB;
  --bg:          #FFFFFF;
  --bg-2:        #F9FAFB;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-2);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* ===== SIDEBAR ===== */
#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  height: 100vh;
  transition: width 0.25s ease;
}

.sidebar { display: contents; }

.sidebar-logo {
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.sidebar-logo-icon {
  display: flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.5);
}

.sidebar-logo-text {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #FFFFFF;
  display: block;
}

.sidebar-logo-sub {
  font-size: 15px;
  color: rgba(255,255,255,0.55);
  display: block;
  margin-top: 1px;
}

.sidebar-section {
  padding: 16px 0 6px;
}

.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 0 14px;
  margin-bottom: 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  cursor: pointer;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  text-decoration: none;
  border-radius: 0;
}

.sidebar-item:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  margin: 0 8px;
  padding: 8px 6px;
}

.sidebar-item.active {
  color: var(--sidebar-bg);
  background: #FFFFFF;
  border-radius: 8px;
  margin: 0 8px;
  padding: 8px 6px;
  font-weight: 600;
}

.sidebar-item-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.sidebar-item.active .sidebar-item-icon { opacity: 1; }

/* ===== MAIN CONTENT ===== */
#content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--bg);
}

.content { display: contents; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
}

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: #2563EB; }

.btn-outline {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg-2); }
.btn-active { background: var(--purple) !important; color: white !important; border-color: var(--purple) !important; }

/* ===== STATUS BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-purple { background: #EEE9FF; color: var(--purple); }
.badge-green  { background: #DCFCE7; color: #15803D; }
.badge-orange { background: #FFF7ED; color: #C2410C; }
.badge-red    { background: #FEF2F2; color: #B91C1C; }
.badge-gray   { background: #F3F4F6; color: var(--text-2); }

/* ===== STATUS SELECT (inline dropdown in table) ===== */
.status-select {
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 6px;
  outline: none;
  white-space: nowrap;
}
.status-select:hover { background: var(--bg-2); }
.status-select option { color: var(--text); background: white; }

/* ===== FILTER PANEL ===== */
.panel-filters {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.filter-field { display: flex; flex-direction: column; gap: 4px; }
.filter-field label { font-size: 11px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.03em; }
.filter-field input {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  outline: none;
  width: 160px;
  background: white;
}
.filter-field input:focus { border-color: var(--purple); }

/* ===== COLUMNS PANEL ===== */
.panel-cols {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.col-toggle-item {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-2);
  user-select: none;
}
.col-chk {
  width: 14px; height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border);
  background: white;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.col-chk-on { border-color: var(--blue); background: var(--blue); }
.col-toggle-item:has(.col-chk-on) { color: var(--blue); }

/* ===== COL RESIZE HANDLE ===== */
.col-resize-handle {
  position: absolute;
  right: -3px;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 2;
}
.col-resize-handle:hover { background: rgba(108,60,233,0.35); }
th.col-dragging { opacity: 0.5; }
th.col-drag-over { border-left: 3px solid #6C3CE9; }

/* нативный скроллбар таблицы */
#table-scroll-div::-webkit-scrollbar { height: 8px; width: 8px; }
#table-scroll-div::-webkit-scrollbar-track { background: var(--bg-2); }
#table-scroll-div::-webkit-scrollbar-thumb { background: #C4C4C4; border-radius: 4px; }
#table-scroll-div::-webkit-scrollbar-thumb:hover { background: var(--purple); }
#table-scroll-div::-webkit-scrollbar-corner { background: var(--bg-2); }

/* кнопка удаления строки */
.btn-del {
  background: none;
  border: none;
  cursor: pointer;
  color: #D1D5DB;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-del:hover { color: #EF4444; background: #FEE2E2; }

/* ===== CELL CLAMP (name, debtor) ===== */
.cell-clamp {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
  line-height: 1.4;
  font-size: 12px;
}

/* ===== CELL TOGGLE / EXPAND ===== */
.cell-dbl { cursor: pointer; }
.cell-dbl:hover { background: #F5F3FF; }
.cell-dbl.cell-open {
  white-space: normal !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  max-height: 160px;
  text-overflow: unset !important;
  background: #F0EDFF;
  position: relative;
  z-index: 5;
}
.cell-dbl.cell-open .cell-clamp {
  -webkit-line-clamp: unset !important;
  display: block !important;
  overflow: visible !important;
}

/* ===== CELL EDITING ===== */
td.cell-editing { padding: 2px !important; }
.cell-input {
  width: 100%;
  min-width: 80px;
  border: 1.5px solid var(--purple);
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  outline: none;
  background: white;
  box-sizing: border-box;
}
.cell-textarea {
  min-height: 72px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}
.cell-comment {
  cursor: pointer;
  font-size: 12px;
  max-width: 200px;
}
.cell-comment:hover { background: #F5F3FF; }
.cell-comment-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.4;
}
.cell-comment.cell-open .cell-comment-text {
  -webkit-line-clamp: unset;
  overflow: visible;
}
.cell-add-hint { color: var(--text-3); font-size: 11px; font-style: italic; }

/* ===== KPI CARDS ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.kpi-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 8px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
}
.kpi-value.accent { color: var(--purple); }
.kpi-value.kpi-green { color: var(--green); }
.kpi-sub { font-size: 11px; color: var(--text-3); margin-top: 4px; }
.status-bar-count { width: 80px !important; }

/* Donut chart animation */
@keyframes donutFill {
  from { stroke-dashoffset: var(--circ); }
  to   { stroke-dashoffset: var(--offset); }
}
.donut-seg {
  animation: donutFill 1s ease-out forwards;
  stroke-dashoffset: var(--circ);
}
.donut-wrap {
  display: flex; align-items: center; gap: 24px; padding: 8px 0;
}
.donut-legend { flex: 1; min-width: 0; }
.donut-legend-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 0; font-size: 12px; cursor: default;
}
.donut-legend-item:hover { background: var(--bg-2); border-radius: 6px; margin: 0 -6px; padding: 5px 6px; }
.donut-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.donut-legend-label { flex: 1; color: var(--text); }
.donut-legend-val { font-weight: 700; min-width: 28px; text-align: right; }
.donut-legend-pct { font-size: 10px; color: var(--text-3); min-width: 30px; text-align: right; }

/* Count-up animation for KPI numbers */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.kpi-card { animation: fadeSlideUp 0.5s ease-out both; }
.kpi-card:nth-child(2) { animation-delay: 0.08s; }
.kpi-card:nth-child(3) { animation-delay: 0.16s; }
.kpi-card:nth-child(4) { animation-delay: 0.24s; }

/* Collapsible dashboard sections */
.dash-accordion-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px;
}
.dash-acc {
  background: white; border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; transition: box-shadow 0.2s;
}
.dash-acc:hover { box-shadow: 0 2px 12px rgba(0,0,0,0.06); }
.dash-acc-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 16px; cursor: pointer; user-select: none;
}
.dash-acc-header:hover { background: var(--bg-2); }
.dash-acc-arrow {
  transition: transform 0.25s ease; flex-shrink: 0; color: var(--text-3);
}
.dash-acc-arrow.open { transform: rotate(90deg); }
.dash-acc-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-2); flex: 1;
}
.dash-acc-badge {
  font-size: 11px; font-weight: 600; color: var(--purple);
  background: var(--purple-light); border-radius: 10px; padding: 2px 8px;
}
.dash-acc-body {
  max-height: 0; overflow: hidden; transition: max-height 0.35s ease, padding 0.35s ease;
  padding: 0 16px;
}
.dash-acc-body.open {
  max-height: 600px; padding: 0 16px 14px;
}

/* ===== TABS (status filters) ===== */
.tab-group {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  padding: 12px 0;
  margin-top: -12px;
}

.tab {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-2);
  transition: all 0.15s;
}
.tab:hover { opacity: 0.85; }

/* всегда цветные пилюли */
.tab-neutral { border-color: #9CA3AF; color: #374151; background: #F9FAFB; }
.tab-green   { border-color: var(--green); color: var(--green); background: rgba(34,197,94,0.08); }
.tab-orange  { border-color: var(--orange); color: var(--orange); background: rgba(249,115,22,0.08); }
.tab-red     { border-color: var(--red); color: var(--red); background: rgba(239,68,68,0.08); }
.tab-blue    { border-color: var(--blue); color: var(--blue); background: rgba(59,130,246,0.08); }

/* активное состояние — залитый фон */
.tab-neutral-on { background: #374151; color: white; border-color: #374151; }
.tab-green-on   { background: var(--green); color: white; border-color: var(--green); }
.tab-orange-on  { background: var(--orange); color: white; border-color: var(--orange); }
.tab-red-on     { background: var(--red); color: white; border-color: var(--red); }
.tab-blue-on    { background: var(--blue); color: white; border-color: var(--blue); }

/* ===== TABLE ===== */
.table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.table-toolbar-left { display: flex; gap: 8px; align-items: center; }
.table-count { font-size: 13px; color: var(--text-2); }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  padding: 6px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAFA; }

.score-badge {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--orange);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.link-blue {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
  font-size: 13px;
}
.link-blue:hover { text-decoration: underline; }

.price { font-weight: 600; white-space: nowrap; }

/* ===== BOTTOM BAR ===== */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: var(--sidebar-w);
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  padding: 10px 28px;
  z-index: 100;
  align-items: center;
}

.bottom-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  color: white;
}

.bb-purple { background: var(--purple); }
.bb-purple:hover { background: #6655DD; }
.bb-green  { background: #16A34A; }
.bb-green:hover  { background: #15803D; }
.bb-orange { background: var(--orange); }
.bb-orange:hover { background: #EA6C00; }
.bb-blue   { background: #1D3461; }
.bb-blue:hover   { background: #162848; }

/* ===== DASHBOARD ===== */
.dash-mid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.dash-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 20px;
}

.dash-card-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 12px;
}

.dash-mid-stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.dash-mid-stat .big { font-size: 30px; font-weight: 700; color: var(--purple); }
.dash-mid-stat .sub { font-size: 12px; color: var(--text-2); }
.dash-mid-stat .rtk { color: var(--purple); font-weight: 600; }

.dash-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  opacity: 0;
  animation: barRowIn 0.5s ease-out forwards;
}
.bar-row:nth-child(1) { animation-delay: 0s; }
.bar-row:nth-child(2) { animation-delay: 0.06s; }
.bar-row:nth-child(3) { animation-delay: 0.12s; }
.bar-row:nth-child(4) { animation-delay: 0.18s; }
.bar-row:nth-child(5) { animation-delay: 0.24s; }
.bar-row:nth-child(6) { animation-delay: 0.30s; }
.bar-row:nth-child(7) { animation-delay: 0.36s; }
.bar-row:nth-child(8) { animation-delay: 0.42s; }
@keyframes barRowIn {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes barGrow {
  from { width: 0; }
}
.bar-label { width: 180px; font-size: 13px; font-weight: 500; color: var(--text); flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--bg-2); border-radius: 6px; overflow: hidden; }
.bar-fill  {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #6C5DD3, #3B82F6);
  animation: barGrow 0.8s ease-out forwards;
}
.bar-count { width: 36px; font-size: 13px; font-weight: 700; color: var(--text); text-align: right; flex-shrink: 0; }

.status-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.status-bar-label { width: 110px; font-size: 12px; flex-shrink: 0; }
.status-bar-track { flex: 1; height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.status-bar-count { width: 24px; text-align: right; font-size: 12px; font-weight: 600; flex-shrink: 0; }

.lot-rank-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.lot-rank-item:last-child { border-bottom: none; }

.lot-rank-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--purple);
  color: white;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.lot-rank-info { flex: 1; min-width: 0; overflow: hidden; }
.lot-rank-name { font-size: 12px; font-weight: 600; text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lot-rank-region { font-size: 11px; color: var(--text-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lot-rank-price { font-size: 13px; font-weight: 700; color: var(--orange); white-space: nowrap; }

/* ===== PROJECTS ===== */
.projects-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 9px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  background: white;
}
.search-input:focus { border-color: var(--purple); }

.projects-stats {
  display: flex;
  gap: 20px;
  align-items: center;
  flex-shrink: 0;
}

.pstat { text-align: right; }
.pstat-val { font-size: 18px; font-weight: 700; color: var(--purple); }
.pstat-label { font-size: 10px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.05em; }

.stage-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.stage-tab {
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-2);
  transition: all 0.15s;
}
.stage-tab:hover { border-color: var(--purple); color: var(--purple); }
.stage-tab.active { background: var(--text); color: white; border-color: var(--text); }

.projects-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
}

.project-card {
  border-radius: 10px;
  padding: 12px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  min-height: 72px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.project-card:hover { transform: translateY(-2px); opacity: 0.9; }

.project-card-name {
  font-size: 12px;
  font-weight: 600;
  color: white;
  line-height: 1.3;
}

.project-card-stage {
  font-size: 10px;
  color: rgba(255,255,255,0.75);
  margin-top: 6px;
}

.pc-bc { background: var(--purple); }
.pc-b1 { background: var(--green); }
.pc-b2 { background: var(--red); }
.pc-none { background: #9CA3AF; }

/* ===== PORTFOLIO ===== */
.portfolio-section { margin-bottom: 16px; }

.portfolio-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  cursor: pointer;
}

.portfolio-section-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.portfolio-section-title { font-size: 15px; font-weight: 700; }

.portfolio-table-wrap {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.creditors-table {
  margin: 0 16px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.creditors-table th { background: #F3F4F6; }
.creditors-table td { font-size: 12px; }

.source-badge {
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: var(--purple-light);
  color: var(--purple);
}

/* ===== EFRSB PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px;
  border-top: 1px solid var(--border);
}

.pag-info { font-size: 13px; color: var(--text-2); margin-right: 8px; }

.pag-btn {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}
.pag-btn:hover { border-color: var(--purple); color: var(--purple); }
.pag-btn.active { background: var(--purple); color: white; border-color: var(--purple); }
.pag-btn:disabled { opacity: 0.4; cursor: default; }

/* ===== AI ANALYST ===== */
.ai-layout {
  display: flex;
  height: calc(100vh - 48px);
  margin: -24px -28px;
  background: white;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* ---- Sidebar ---- */
.ai-sidebar {
  width: 200px;
  border-right: 1px solid var(--border);
  padding: 14px 12px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg-2);
}

.ai-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 4px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.01em;
}

.ai-new-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 7px 12px;
  justify-content: center;
}

.ai-history-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  padding: 4px 4px 0;
}

.ai-no-dialogs { font-size: 12px; color: var(--text-3); padding: 2px 4px; }

.ai-history-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-2);
  padding: 7px 8px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.12s;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.ai-history-item:hover { background: var(--border); }
.ai-history-active { background: var(--purple-light); color: var(--purple); font-weight: 600; }
.ai-history-active:hover { background: var(--purple-light); }

.ai-sidebar-footer { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--border); }
.ai-model-badge {
  font-size: 10px;
  color: var(--text-3);
  background: var(--border);
  border-radius: 4px;
  padding: 3px 7px;
  display: inline-block;
}

/* ---- Main ---- */
.ai-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- Welcome screen ---- */
.ai-chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  gap: 20px;
}

.ai-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--purple-light);
  border: 2px solid rgba(123,104,238,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--purple);
}

.ai-welcome-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.ai-welcome-sub {
  font-size: 13px;
  color: var(--text-2);
  text-align: center;
  margin-top: -10px;
}

.ai-quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 520px;
}

.ai-action-btn {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: white;
  cursor: pointer;
  font-size: 12px;
  color: var(--text);
  text-align: left;
  transition: all 0.15s;
  line-height: 1.4;
}
.ai-action-btn svg { flex-shrink: 0; margin-top: 1px; color: var(--text-3); }
.ai-action-btn:hover { border-color: var(--purple); color: var(--purple); background: var(--purple-light); }
.ai-action-btn:hover svg { color: var(--purple); }

/* ---- Messages ---- */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  max-width: 78%;
  font-size: 13px;
  line-height: 1.55;
}

.msg-user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  word-break: break-word;
}

.msg-user .msg-bubble {
  background: var(--purple);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg-ai .msg-bubble {
  background: var(--bg-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple);
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  border: 1px solid rgba(123,104,238,0.2);
}

.msg-loading { display: flex; align-items: center; gap: 5px; padding: 14px 18px; }
.msg-loading span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-3);
  animation: bounce 1.2s infinite;
}
.msg-loading span:nth-child(2) { animation-delay: 0.2s; }
.msg-loading span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ---- Input area ---- */
.ai-input-area {
  border-top: 1px solid var(--border);
  background: white;
}

.ai-input-bar {
  padding: 12px 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.ai-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: 24px;
  font-size: 13px;
  outline: none;
  background: var(--bg-2);
  transition: border-color 0.15s, background 0.15s;
}
.ai-input:focus { border-color: var(--purple); background: white; box-shadow: 0 0 0 3px rgba(123,104,238,0.1); }

.ai-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--purple);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.ai-send-btn:hover:not(:disabled) { background: #6655DD; transform: scale(1.05); }
.ai-send-btn:disabled { opacity: 0.6; cursor: default; }

.ai-input-hint {
  font-size: 11px;
  color: var(--text-3);
  text-align: center;
  padding: 0 0 10px;
}

@keyframes spin { from { stroke-dashoffset: 20; } to { stroke-dashoffset: 83; } }

/* ===== Scrollbar ===== */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D1D5DB; border-radius: 4px; }

/* ===== Responsive ===== */
@media (max-width: 1200px) {
  .projects-grid { grid-template-columns: repeat(5, 1fr); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

.has-bottom-bar { padding-bottom: 58px; }
