.history-page{
  width:100%;
  max-width:100%;
  min-width:0;
  padding:7px 0 25px;
  overflow-x:hidden;
}

.history-shell{
  width:100%;
  max-width:100%;
  min-width:0;
  display:grid;
  gap:20px;
}

.history-layout{
  display:grid;
  gap:20px;
  align-items:start;
}

.history-main-col,
.history-side-col{
  min-width:0;
  display:grid;
  gap:20px;
}

.history-card{
  min-width:0;
  max-width:100%;
  background: linear-gradient(180deg, var(--surface-strong) 0%, var(--surface) 100%);
  border:1px solid var(--border);
  border-radius:21px;
  padding:21px;
  box-shadow:
    0 20px 48px rgba(0,0,0,0.24),
    inset 0 1px 0 rgba(255,255,255,0.05);
  backdrop-filter:blur(16px) saturate(135%);
  -webkit-backdrop-filter:blur(16px) saturate(135%);
  overflow:hidden;
}

.section-kicker{
  display:inline-flex;
  align-items:center;
  padding:7px 11px;
  border-radius:999px;
  background:rgba(165, 189, 255, 0.18);
  border:1px solid rgba(124,92,255,0.22);
  color:var(--accent);
  font-size:11px;
  font-weight:800;
  margin-bottom:12px;
  max-width:100%;
}

.section-head{
  min-width:0;
  margin-bottom:16px;
}

.section-head-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  min-width:0;
}

.section-head-row > *{
  min-width:0;
}

.section-title{
  margin:0;
  font-size:21px;
  font-weight:900;
  line-height:1.5;
  color:var(--text);
  overflow-wrap:anywhere;
}

.section-desc{
  margin:7px 0 0;
  font-size:12px;
  line-height:1.9;
  color:var(--muted);
  overflow-wrap:anywhere;
}

/* hero */
.history-hero{
  min-width:0;
  display:grid;
  grid-template-columns:minmax(0, 1.4fr) minmax(196px, .9fr);
  gap:20px;
  align-items:stretch;
  /*background:
    linear-gradient(135deg, rgba(59, 130, 246,0.15), rgba(96, 165, 250,0.08)),
    var(--surface-soft);*/
}

.history-hero-main,
.history-hero-stats{
  min-width:0;
}

.history-hero-title{
  margin:0;
  font-size:30px;
  line-height:1.4;
  font-weight:900;
  color:var(--text);
  overflow-wrap:anywhere;
}

.history-hero-text{
  margin:12px 0 0;
  max-width:676px;
  font-size:13px;
  line-height:2.05;
  color:var(--muted);
  overflow-wrap:anywhere;
}

.history-hero-stats{
  display:grid;
  gap:12px;
}

.hero-stat-box{
  min-width:0;
  padding:16px;
  border-radius:16px;
  background:rgba(255,255,255,0.04);
  border:1px solid rgba(255,255,255,0.08);
  box-shadow:inset 0 1px 0 rgba(255,255,255,0.04);
}

.hero-stat-box span{
  display:block;
  margin-bottom:9px;
  font-size:12px;
  color:var(--muted);
}

.hero-stat-box strong{
  display:block;
  font-size:27px;
  font-weight:900;
  color:var(--text);
  overflow-wrap:anywhere;
}

/* controls */
.controls-grid{
  min-width:0;
  display:grid;
  grid-template-columns:minmax(0,1.5fr) minmax(142px,196px) minmax(142px,196px);
  gap:14px;
  align-items:end;
}

.field-group{
  min-width:0;
}

.field-group label{
  display:block;
  margin-bottom:9px;
  font-size:12px;
  color:var(--muted);
}

.search-input-wrap{
  min-width:0;
  display:flex;
  gap:9px;
}

.search-input-wrap input,
.field-group select{
  width:100%;
  min-width:0;
  height:44px;
  border-radius:12px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  color:var(--text);
  outline:none;
  padding:0 14px;
  font-family:inherit;
  transition:.2s ease;
}

.search-input-wrap input{
  overflow:hidden;
  text-overflow:ellipsis;
}

.search-input-wrap input:focus,
.field-group select:focus{
  border-color:rgba(59, 130, 246,0.55);
  box-shadow:0 0 0 3.56px rgba(59, 130, 246,0.12);
}

.search-input-wrap button,
.primary-btn,
.secondary-btn{
  min-width:0;
  height:44px;
  border:none;
  border-radius:12px;
  font-family:inherit;
  cursor:pointer;
  transition:.2s ease;
  padding:0 16px;
  white-space:nowrap;
}

.search-input-wrap button,
.primary-btn{
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  color:#fff;
  font-weight:800;
  box-shadow:0 11px 21px rgba(96, 165, 250,0.24);
}

.search-input-wrap button:hover,
.primary-btn:hover{
  transform:translateY(-1px);
}

.secondary-btn{
  background:rgba(255,255,255,0.04);
  color:var(--text);
  border:1px solid var(--border);
}

.controls-foot{
  margin-top:16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:14px;
  flex-wrap:wrap;
  min-width:0;
}

.hint-box{
  min-width:0;
  display:flex;
  align-items:center;
  gap:9px;
  color:var(--muted);
  font-size:12px;
  line-height:1.8;
  overflow-wrap:anywhere;
}

.hint-dot{
  width:9px;
  height:9px;
  border-radius:50%;
  background:var(--accent);
  box-shadow:0 0 0 5px rgba(59, 130, 246,0.12);
  flex:0 0 auto;
}

.action-buttons{
  display:flex;
  gap:9px;
  flex-wrap:wrap;
  min-width:0;
}

.action-buttons button{
  min-width:0;
}

/* compare */
.compare-card{
  min-width:0;
}

.chart-wrap{
  position:relative;
  width:100%;
  min-width:0;
  height:347px;
  margin-bottom:18px;
}

.selected-box{
  min-width:0;
  padding-top:14px;
  border-top:1px solid var(--border-soft);
}

.selected-box-title{
  font-size:12px;
  color:var(--muted);
  margin-bottom:11px;
}

.selected-items{
  display:flex;
  flex-wrap:wrap;
  gap:9px;
  min-width:0;
}

.selected-item{
  max-width:100%;
  min-width:0;
  display:flex;
  align-items:center;
  gap:9px;
  padding:9px 11px;
  border-radius:11px;
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border-soft);
  font-size:12px;
}

.selected-item strong,
.selected-item span{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

/* table */
.panel-count{
  min-width:41px;
  height:41px;
  border-radius:12px;
  display:grid;
  place-items:center;
  background:rgba(59, 130, 246,0.12);
  border:1px solid rgba(59, 130, 246,0.22);
  color:#dccfff;
  font-weight:800;
  flex:0 0 auto;
}

.table-card{
  min-width:0;
}

.table-wrap{
  width:100%;
  max-width:100%;
  min-width:0;
  overflow-x:auto;
  overflow-y:hidden;
  border:1px solid var(--border-soft);
  border-radius:16px;
  -webkit-overflow-scrolling:touch;
}

.history-table{
  width:100%;
  min-width:872px;
  border-collapse:collapse;
}

.history-table thead th{
  position:sticky;
  top:0;
  z-index:2;
  white-space:nowrap;
  text-align:right;
  padding:12px;
  font-size:12px;
  font-weight:800;
  color:#cbd7ef;
  background:#111a2c;
  border-bottom:1px solid var(--border);
}

.history-table tbody td{
  padding:12px;
  border-bottom:1px solid var(--border-soft);
  vertical-align:middle;
}

.history-table tbody tr{
  transition:.18s ease;
}

.history-table tbody tr:hover{
  background:rgba(255,255,255,0.025);
}

.domain-cell{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:5px;
}

.domain-cell strong{
  font-size:12px;
  color:var(--text);
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.domain-cell small{
  color:var(--muted);
  direction:ltr;
  text-align:left;
  unicode-bidi:embed;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.checkbox-wrap{
  position:relative;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.checkbox-wrap input{
  position:absolute;
  opacity:0;
  pointer-events:none;
}

.checkbox-wrap span{
  width:18px;
  height:18px;
  border-radius:6px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  display:inline-block;
  position:relative;
  transition:.2s ease;
}

.checkbox-wrap input:checked + span{
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  border-color:transparent;
}

.checkbox-wrap input:checked + span::after{
  content:"";
  position:absolute;
  width:4px;
  height:9px;
  border:solid #fff;
  border-width:0 2px 2px 0;
  transform:rotate(45deg);
  top:1.78px;
  right:5px;
}

.device-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:68px;
  padding:7px 11px;
  border-radius:999px;
  font-size:11px;
  font-weight:800;
  border:1px solid var(--border);
  text-transform:capitalize;
}

.device-badge.mobile{
  background:rgba(6,182,212,0.10);
  color:#9feeff;
}

.device-badge.desktop{
  background:rgba(34,197,94,0.10);
  color:#b7f7cb;
}

.score-chip{
  min-width:48px;
  height:28px;
  border-radius:9px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:800;
  font-size:12px;
  white-space:nowrap;
}

.score-chip.performance{
  background:rgba(59, 130, 246,0.14);
  color:#eadfff;
}

.score-chip.seo{
  background:rgba(34,197,94,0.14);
  color:#bdf5cd;
}

.score-chip.accessibility{
  background:rgba(245,158,11,0.14);
  color:#ffe0a0;
}

.score-chip.best{
  background:rgba(6,182,212,0.14);
  color:#b8f6ff;
}


/* =========================
   Light Mode Badges & Chips
========================= */

:root[data-theme="light"] .device-badge.mobile{
  background: rgba(6,182,212,0.12);
  color: #0e7490;
  border-color: rgba(6,182,212,0.25);
}

:root[data-theme="light"] .device-badge.desktop{
  background: rgba(34,197,94,0.12);
  color: #166534;
  border-color: rgba(34,197,94,0.25);
}

/* =========================
   Score Chips (Light)
========================= */

:root[data-theme="light"] .score-chip.performance{
  background: rgba(59, 130, 246,0.12);
  color: #5b21b6;
}

:root[data-theme="light"] .score-chip.seo{
  background: rgba(34,197,94,0.12);
  color: #166534;
}

:root[data-theme="light"] .score-chip.accessibility{
  background: rgba(245,158,11,0.14);
  color: #92400e;
}

:root[data-theme="light"] .score-chip.best{
  background: rgba(6,182,212,0.12);
  color: #0e7490;
}

:root[data-theme="light"] .panel-count{
  background: rgba(59, 130, 246,0.12);
  border-color: rgba(59, 130, 246,0.22);
  color: #5b21b6;
}


.details-link{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:80px;
  height:34px;
  border-radius:10px;
  border:1px solid var(--border);
  background:rgba(255,255,255,0.04);
  color:var(--text);
  text-decoration:none;
  transition:.2s ease;
  white-space:nowrap;
}

.details-link:hover{
  border-color:rgba(59, 130, 246,0.45);
  background:rgba(59, 130, 246,0.09);
}

.empty-state{
  padding:32px 18px;
  text-align:center;
}

.empty-state h3{
  margin:0 0 9px;
  color:var(--text);
}

.empty-state p,
.empty-mini{
  color:var(--muted);
}

/* timeline */
.timeline-list{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:11px;
}

.timeline-item{
  min-width:0;
  display:flex;
  gap:12px;
  padding:12px;
  border-radius:14px;
  border:1px solid var(--border-soft);
  background:rgba(255,255,255,0.025);
  text-decoration:none;
  transition:.2s ease;
}

.timeline-item:hover{
  background:rgba(255,255,255,0.04);
  border-color:rgba(59, 130, 246,0.28);
}

.timeline-marker{
  width:11px;
  min-width:11px;
  height:11px;
  border-radius:50%;
  background:linear-gradient(135deg,var(--accent),var(--accent-2));
  margin-top:7px;
  box-shadow:0 0 0 6px rgba(59, 130, 246,0.10);
}

.timeline-content{
  flex:1;
  min-width:0;
}

.timeline-top,
.timeline-bottom{
  display:flex;
  justify-content:space-between;
  gap:11px;
  flex-wrap:wrap;
}

.timeline-top{
  margin-bottom:7px;
}

.timeline-top strong{
  display:block;
  max-width:100%;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:var(--text);
}

.timeline-top span,
.timeline-bottom span{
  color:var(--muted);
  font-size:12px;
  overflow-wrap:anywhere;
}

/* side stats */
.mini-stats-grid{
  min-width:0;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:14px;
}

.mini-stat-card{
  min-width:0;
}

.mini-stat-card span{
  display:block;
  color:var(--muted);
  font-size:12px;
  margin-bottom:7px;
  overflow-wrap:anywhere;
}

.mini-stat-card strong{
  font-size:25px;
  font-weight:900;
  color:var(--text);
  overflow-wrap:anywhere;
}

/* pagination */
.history-pagination{
  margin-top:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  gap:12px;
  flex-wrap:wrap;
}

.page-link{
  padding:9px 12px;
  border-radius:11px;
  background:rgba(255,255,255,0.04);
  border:1px solid var(--border);
  color:var(--text);
  text-decoration:none;
  white-space:nowrap;
}

.page-status{
  color:var(--muted);
  text-align:center;
}

/* light theme */
:root[data-theme="light"] .history-card{
  background:#fff;
  border-color:rgba(15,23,42,0.08);
  box-shadow:
    0 11px 28px rgba(15,23,42,0.06),
    inset 0 1px 0 rgba(255,255,255,0.92);
  backdrop-filter:none;
  -webkit-backdrop-filter:none;
}

:root[data-theme="light"] .hero-stat-box,
:root[data-theme="light"] .timeline-item,
:root[data-theme="light"] .selected-item,
:root[data-theme="light"] .mini-stat-card{
  background:#fff;
  border-color:rgba(15,23,42,0.08);
  box-shadow:
    0 9px 21px rgba(15,23,42,0.04),
    inset 0 1px 0 rgba(255,255,255,0.9);
}

:root[data-theme="light"] .history-hero-title,
:root[data-theme="light"] .section-title,
:root[data-theme="light"] .domain-cell strong,
:root[data-theme="light"] .timeline-top strong,
:root[data-theme="light"] .mini-stat-card strong,
:root[data-theme="light"] .hero-stat-box strong,
:root[data-theme="light"] .selected-item strong{
  color:#0f172a;
}

:root[data-theme="light"] .history-hero-text,
:root[data-theme="light"] .section-desc,
:root[data-theme="light"] .hint-box,
:root[data-theme="light"] .domain-cell small,
:root[data-theme="light"] .timeline-top span,
:root[data-theme="light"] .timeline-bottom span,
:root[data-theme="light"] .selected-box-title,
:root[data-theme="light"] .mini-stat-card span,
:root[data-theme="light"] .hero-stat-box span,
:root[data-theme="light"] .field-group label,
:root[data-theme="light"] .page-status,
:root[data-theme="light"] .empty-mini,
:root[data-theme="light"] .empty-state p{
  color:#64748b;
}

:root[data-theme="light"] .history-table thead th{
  background:#eef4fb;
  color:#1e293b;
}

:root[data-theme="light"] .history-table tbody td{
  color:#1e293b;
}

:root[data-theme="light"] .search-input-wrap input,
:root[data-theme="light"] .field-group select{
  background:#fff;
  border-color:rgba(15,23,42,0.12);
  color:#0f172a;
}

:root[data-theme="light"] .details-link,
:root[data-theme="light"] .secondary-btn,
:root[data-theme="light"] .page-link{
  color:#0f172a;
  background:rgba(248,250,252,0.95);
  border-color:rgba(15,23,42,0.12);
}

:root[data-theme="light"] .details-link:hover{
  background:rgba(29, 78, 216,0.08);
  border-color:rgba(29, 78, 216,0.22);
}

#searchBtn{
  display: inline-flex;
  align-items: center;
  justify-content: center;

  height: 44px;
  padding: 0 16px;

  font-family: inherit;
  font-weight: 700;

  line-height: 1; /* 👈 خیلی مهم */
}

/* responsive */
@media (max-width:1400px){

  .controls-grid{
    grid-template-columns:minmax(0,1fr) minmax(134px,178px) minmax(134px,178px);
  }
}

@media (max-width:1250px){
  .history-hero{
    grid-template-columns:1fr;
  }

  .history-layout{
    grid-template-columns:1fr;
  }
}

@media (max-width:980px){
  .history-card{
    padding:18px 14px;
    border-radius:18px;
  }

  .history-hero-title{
    font-size:25px;
  }

  .section-title{
    font-size:20px;
  }

  .controls-grid{
    grid-template-columns:1fr;
  }

  .controls-foot{
    flex-direction:column;
    align-items:stretch;
  }

  .action-buttons{
    width:100%;
  }

  .action-buttons button{
    flex:1;
  }

  .mini-stats-grid{
    grid-template-columns:1fr 1fr;
  }

  .chart-wrap{
    height:285px;
  }
}

@media (max-width:720px){
  .history-page{
    padding-top:1.78px;
  }

  .history-hero-title{
    font-size:21px;
    line-height:1.6;
  }

  .history-hero-text{
    font-size:12px;
    line-height:2;
  }

  .search-input-wrap{
    flex-direction:column;
  }

  .search-input-wrap button{
    width:100%;
  }

  .section-head-row{
    flex-direction:column;
    align-items:flex-start;
  }

  .mini-stats-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:560px){
  .history-card{
    padding:16px 12px;
  }

  .history-hero-title{
    font-size:20px;
  }

  .section-title{
    font-size:18px;
  }

  .hero-stat-box strong,
  .mini-stat-card strong{
    font-size:21px;
  }

  .chart-wrap{
    height:249px;
  }

  .history-table{
    min-width:801px;
  }
}

/* fix when sidebar is expanded on desktop */
/* fix when sidebar is expanded on desktop - compact mode */
@media (min-width:1101px){
  body:not(.sidebar-collapsed) .history-layout,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-layout{
    gap:16px;
  }

  body:not(.sidebar-collapsed) .history-main-col,
  body:not(.sidebar-collapsed) .history-side-col,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-main-col,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-side-col{
    gap:16px;
  }

  body:not(.sidebar-collapsed) .history-card,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-card{
    padding:18px 16px;
    border-radius:18px;
  }

  body:not(.sidebar-collapsed) .history-hero,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-hero{
    grid-template-columns:minmax(0, 1.2fr) minmax(178px, 0.8fr);
    gap:14px;
  }

  body:not(.sidebar-collapsed) .history-hero-title,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-hero-title{
    font-size:25px;
  }

  body:not(.sidebar-collapsed) .history-hero-text,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .history-hero-text{
    font-size:12px;
    line-height:1.95;
  }

  body:not(.sidebar-collapsed) .hero-stat-box,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .hero-stat-box{
    padding:12px;
  }

  body:not(.sidebar-collapsed) .hero-stat-box strong,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .hero-stat-box strong{
    font-size:21px;
  }

  body:not(.sidebar-collapsed) .section-title,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .section-title{
    font-size:19px;
  }

  body:not(.sidebar-collapsed) .controls-grid,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .controls-grid{
    grid-template-columns:minmax(0,1fr) minmax(120px,151px) minmax(120px,151px);
    gap:11px;
  }

  body:not(.sidebar-collapsed) .search-input-wrap,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .search-input-wrap{
    gap:7px;
  }

  body:not(.sidebar-collapsed) .search-input-wrap input,
  body:not(.sidebar-collapsed) .field-group select,
  body:not(.sidebar-collapsed) .search-input-wrap button,
  body:not(.sidebar-collapsed) .primary-btn,
  body:not(.sidebar-collapsed) .secondary-btn,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .search-input-wrap input,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .field-group select,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .search-input-wrap button,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .primary-btn,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .secondary-btn{
    height:41px;
  }

  body:not(.sidebar-collapsed) .controls-foot,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .controls-foot{
    gap:11px;
  }

  body:not(.sidebar-collapsed) .hint-box,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .hint-box{
    font-size:12px;
  }

  body:not(.sidebar-collapsed) .action-buttons,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .action-buttons{
    flex-wrap:nowrap;
  }

  body:not(.sidebar-collapsed) .chart-wrap,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .chart-wrap{
    height:267px;
  }

  body:not(.sidebar-collapsed) .timeline-item,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .timeline-item{
    padding:11px;
    gap:11px;
  }

  body:not(.sidebar-collapsed) .mini-stats-grid,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .mini-stats-grid{
    gap:11px;
  }

  body:not(.sidebar-collapsed) .mini-stat-card strong,
  html:not(.sidebar-collapsed-preload) body:not(.sidebar-collapsed) .mini-stat-card strong{
    font-size:21px;
  }
}


.chart-wrap{
  position:relative;
  min-height:249px;
}

.chart-empty{
  position:absolute;
  inset:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  text-align:center;
  gap:9px;
  background: rgba(16, 24, 44, 0.7);
  backdrop-filter: blur(3.56px);
  border-radius:11px;
}

:root[data-theme="light"] .chart-empty {
  background:rgba(255,255,255,0.3);  
}

.chart-empty.hidden{
  display:none;
}

.empty-icon{
  width:57px;
  height:57px;
  border-radius:50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:25px;
  background:#f1f5f9;
}

.under-chart-stats{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(134px,1fr));
  gap:11px;
}