* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: #f6f7fb;
  color: #1f2d3d;
}

.app-header {
  padding: 24px 32px 12px;
  background: linear-gradient(120deg, #1f2d3d, #283e51);
  color: #fff;
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.app-logo {
  width: 220px;
  height: auto;
  max-height: 82px;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  padding: 8px;
}

.app-titles {
  min-width: 0;
}

.app-link {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-weight: 600;
  white-space: nowrap;
}

.app-link:hover {
  text-decoration: underline;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 28px;
}

.app-header .sub {
  opacity: 0.8;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 12px 24px 0;
}

.tab-button {
  border: none;
  padding: 10px 16px;
  background: #e1e8f0;
  border-radius: 10px 10px 0 0;
  cursor: pointer;
  font-weight: 600;
  color: #1f2d3d;
}

.tab-button.active {
  background: #ffffff;
  box-shadow: 0 -2px 8px rgba(31, 45, 61, 0.1);
}

.tab-content {
  padding: 0 24px 24px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.content-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: start;
}

.stack {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.panel {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(31, 45, 61, 0.08);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #3c4b64;
}

.metric-toggle input {
  accent-color: #1f78ff;
}

.legend-bar {
  display: flex;
  gap: 16px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  background: #f4f6fb;
  color: #3c4b64;
  font-size: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.status-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
  justify-content: space-between;
}

.status-filter-btn::after {
  content: "▾";
  font-size: 12px;
  opacity: 0.8;
}

.status-filter-label {
  font-size: 12px;
}

.status-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(31, 45, 61, 0.12);
  border: 1px solid #d5ddea;
}

.status-filter-menu.open {
  display: flex;
}

.status-option {
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #1f2d3d;
  padding: 4px 6px;
  border-radius: 8px;
  text-align: left;
  opacity: 0.45;
}

.status-option:hover {
  background: #f4f6fb;
}

.status-option.selected {
  opacity: 1;
}

.status-option.disabled {
  opacity: 0.25;
  cursor: not-allowed;
}

.status-neutral {
  background: #9aa5b1;
}

.multi-filter {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 80px;
  justify-content: space-between;
}

.filter-btn::after {
  content: "▾";
  font-size: 12px;
  opacity: 0.8;
}

.filter-label {
  font-size: 12px;
}

.multi-filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 10;
  display: none;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
  padding: 10px;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(31, 45, 61, 0.12);
  border: 1px solid #d5ddea;
}

.multi-filter-menu.open {
  display: flex;
}

.multi-option {
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: #1f2d3d;
  padding: 4px 6px;
  border-radius: 8px;
  text-align: left;
}

.multi-option:hover {
  background: #f4f6fb;
}

.multi-option.selected {
  background: #e8f0ff;
}

.panel-header-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-header h2 {
  margin: 0;
  font-size: 18px;
}

.panel-header input[type="search"] {
  border: 1px solid #d5ddea;
  border-radius: 8px;
  padding: 8px 12px;
  min-width: 180px;
}

.table-wrapper {
  overflow: auto;
  max-height: 70vh;
  min-height: 600px;
  padding-top: 90px;
}

#batteryTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

#compareTable {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  table-layout: fixed;
  min-width:  1800px;
  max-width: 2500px;
}

#batteryTable thead {
  position: sticky;
  top: 0;
  background: #f2f5fa;
  z-index: 1;
}

#compareTable thead {
  position: sticky;
  top: 0;
  background: #f2f5fa;
  z-index: 1;
}

#compareTable thead .group-header {
  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: #2f3b52;
  background: #e9eef7;
}

#batteryTable th,
#batteryTable td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  white-space: nowrap;
}

#compareTable th,
#compareTable td {
  padding: 8px 10px;
  border-bottom: 1px solid #edf0f5;
  text-align: left;
  white-space: nowrap;
  border-right: 1px solid #c7d2e2;
  overflow: hidden;
  text-overflow: ellipsis;
}


#compareTable th:last-child,
#compareTable td:last-child {
  border-right: none;
}

#compareTable thead tr:first-child th {
  border-right: 1px solid #c7d2e2;
}

#compareTable thead tr:first-child th:last-child {
  border-right: none;
}

#batteryTable th {
  cursor: pointer;
  user-select: none;
  font-weight: 600;
  color: #3c4b64;
}

#compareTable th {
  user-select: none;
  font-weight: 600;
  color: #3c4b64;
}

#compareTable .filter-row th {
  background: #f7f9fc;
}

.compare-filter {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d5ddea;
  border-radius: 6px;
  font-size: 12px;
}

#compareTable th[data-key] {
  cursor: pointer;
  position: relative;
  padding-right: 22px;
}

#compareTable th[data-key]::after {
  content: "↕";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: #9aa5b1;
}

#compareTable th.sort-asc::after {
  content: "↑";
  color: #0346ab;
}

#compareTable th.sort-desc::after {
  content: "↓";
  color: #0346ab;
}

#batteryTable tbody tr:hover {
  background: #f9fbff;
}

#compareTable tbody tr:hover {
  background: #f9fbff;
}

.status-cell {
  display: flex;
  gap: 6px;
  align-items: center;
}

.status-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.status-new {
  background: #2ecc71;
}

.status-alkaline {
  background: #f1c40f;
  color: #3b2f00;
}

.status-energy {
  background: #27ae60;
}

.graph-btn {
  border: none;
  padding: 6px 10px;
  border-radius: 8px;
  background: #1f78ff;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
}

.ghost-btn {
  border: 1px solid #d5ddea;
  padding: 6px 10px;
  border-radius: 8px;
  background: #ffffff;
  color: #1f2d3d;
  cursor: pointer;
  font-size: 12px;
}

.icon-btn {
  width: 36px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-btn .icon {
  font-size: 16px;
  line-height: 1;
}

.plot {
  width: 100%;
  min-height: 460px;
}

.plot-meta {
  font-size: 13px;
  color: #5c6b80;
}

.plot-meta-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

.plot-progress {
  width: 220px;
  height: 8px;
  accent-color: #1f78ff;
  visibility: hidden;
}

.env-hint {
  margin-top: 16px;
  padding: 12px;
  background: #f4f6fb;
  border-radius: 12px;
  color: #4a5a75;
}

@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .app-header-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .app-link {
    margin-top: 6px;
  }

  .app-logo {
    width: 200px;
    max-height: 76px;
  }
}

#compareTable col.col-select {
  width: 48px;
}

#compareTable col.col-status {
  width: 90px;
}

#compareTable col.col-manufacturer {
  width: 140px;
}

#compareTable col.col-details {
  width: 220px;
}

#compareTable col.col-size {
  width: 90px;
}

#compareTable col.col-type {
  width: 120px;
}

#compareTable col.col-photo {
  width: 80px;
}

#compareTable col.col-weight {
  width: 90px;
}

#compareTable col.col-exp {
  width: 140px;
}

#compareTable col.col-load {
  width: 120px;
}

#compareTable col.col-resistance {
  width: 110px;
}

#compareTable col.col-cap,
#compareTable col.col-energy {
  width: 100px;
}

.photo-cell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.photo-thumb {
  width: 48px;
  height: auto;
  max-height: 32px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid #d5ddea;
  background: #ffffff;
}

.photo-preview-floating {
  position: fixed;
  padding: 6px;
  background: #ffffff;
  border: 1px solid #d5ddea;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(31, 45, 61, 0.12);
  display: none;
  z-index: 2000;
}

.photo-preview-floating img {
  max-width: 260px;
  max-height: 260px;
  display: block;
}
