/* Visual Component Templates & Extended Cards Matching High-Fidelity ANMA ELECTRIC Screenshots */
.db-template-library { margin: 16px 0 20px; }
.db-template-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.db-template-heading h2 { font-size: 15px; margin: 0; }
#db-template-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.db-template-card { display: grid; grid-template-columns: 70px 1fr; gap: 14px; padding: 14px; text-align: left; min-width: 0; justify-content: stretch; position: relative; }
.db-template-card[aria-pressed=true] { border-color: var(--brand); background: var(--brand-soft); }
.db-template-card b { display: block; font-size: 13px; }
.db-template-card small { display: block; font-size: 11px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }
.db-template-mini { display: flex; align-items: center; justify-content: center; gap: 5px; height: 50px; border-radius: 8px; background: var(--bg); border: 1px solid var(--border); color: var(--brand); font-size: 20px; }
.db-template-mini i { display: block; width: 14px; height: 14px; border: 1px solid currentColor; border-radius: 50%; }
.db-template-mini[data-template=compact] { display: grid; grid-template-columns: repeat(2, 14px); gap: 4px; align-content: center; }
.db-template-mini[data-template=compact] i { border-radius: 3px; width: 14px; height: 12px; }
#db-template-demo { margin-top: 10px; color: var(--brand); font-size: 12px; }

/* Inverter Status Rings Strip (Screenshot 1) */
.db-inverter-rings-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.db-inverter-ring-card {
  display: flex;
  justify-content: center;
}
.db-ring-circle {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle, #101923 0%, #0a0f16 100%);
  border: 2px solid #22303f;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px;
  transition: all .2s ease;
}
.db-inverter-ring-card[data-example=true] .db-ring-circle {
  border-color: #20bda0;
  box-shadow: 0 0 24px rgba(32,189,160,0.22);
}
.db-ring-icon-symbol {
  font-size: 14px;
  color: var(--text-faint);
  line-height: 1;
}
.db-ring-name {
  font-size: 12px;
  color: var(--text);
  margin-top: 4px;
}
.db-ring-power {
  font-size: 17px;
  font-weight: 750;
  color: #fff;
  margin: 3px 0;
}
.db-ring-brand {
  font-size: 9px;
  color: var(--text-faint);
}
.db-ring-status-dot {
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .05em;
  margin-top: 5px;
}
.db-ring-status-dot.green { color: #20bda0; }
.db-ring-status-dot.gray { color: #64748b; }

/* PV Fields & MPPT Arrays (Screenshot 1) */
.db-pv-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 10px;
}
.db-pv-group {
  border: 1px solid #1e293b;
  border-radius: 16px;
  background: #0f1722;
  overflow: hidden;
}
.db-pv-group-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid #1a2533;
  background: rgba(255,255,255,0.015);
}
.db-pv-group-head .db-pv-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  background: rgba(245,158,11,0.12);
  border: 1px solid rgba(245,158,11,0.35);
  border-radius: 8px;
  color: #f59e0b;
  font-size: 16px;
}
.db-pv-group-head h4 {
  font-size: 14px;
  font-weight: 750;
  margin: 0 0 3px;
  color: #fff;
}
.db-pv-group-head small {
  font-size: 10px;
  color: #64748b;
}
.db-pv-group-value {
  margin-left: auto;
  text-align: right;
}
.db-pv-group-value b {
  display: block;
  font-size: 16px;
  color: #fff;
}
.db-status-pill {
  display: inline-block;
  font-size: 8px;
  font-weight: 750;
  letter-spacing: .05em;
  margin-top: 3px;
}
.db-status-pill.green { color: #20bda0; }
.db-status-pill.gray { color: #64748b; }

.db-pv-field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  padding: 16px;
}
.db-pv-field {
  background: #131c28;
  border: 1px solid #223040;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
}
.db-pv-field-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.db-pv-subicon {
  font-size: 16px;
  color: #f59e0b;
}
.db-pv-tag {
  font-size: 7px;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 2px 5px;
  border-radius: 4px;
}
.db-pv-tag.green {
  background: rgba(32,189,160,0.14);
  color: #20bda0;
  border: 1px solid rgba(32,189,160,0.3);
}
.db-pv-tag.gray {
  background: rgba(100,116,139,0.14);
  color: #94a3b8;
  border: 1px solid rgba(100,116,139,0.25);
}
.db-pv-field h5 {
  font-size: 12px;
  font-weight: 750;
  margin: 0 0 3px;
  color: #fff;
}
.db-pv-field p {
  font-size: 9px;
  color: #64748b;
  margin: 0 0 12px;
  min-height: 22px;
}
.db-pv-watts {
  font-size: 17px;
  font-weight: 750;
  color: #fff;
  margin-top: auto;
  margin-bottom: 8px;
}
.db-pv-electrical {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #1a2533;
  padding-top: 8px;
  font-size: 10px;
  color: #94a3b8;
}

/* Server Health Grid (Screenshot 2) */
.db-card-server {
  grid-column: 1 / -1;
  background: #0f1722;
}
.db-server-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.db-server-card {
  background: #141c28;
  border: 1px solid #1f2b3a;
  border-radius: 12px;
  padding: 14px;
}
.db-server-card-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.db-server-badge {
  font-size: 8px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  background: #233142;
  color: #94a3b8;
}
.db-server-name {
  font-size: 11px;
  color: #94a3b8;
}
.db-server-val {
  font-size: 22px;
  font-weight: 750;
  color: #fff;
  margin-bottom: 4px;
}
.db-server-sub {
  font-size: 9px;
  color: #64748b;
}

/* Battery Rack Stack (Master / Slave Units) */
.db-card-battery-stack {
  grid-column: 1 / -1;
  background: #0f1722;
}
.db-battery-stack-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}
.db-can-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: rgba(241,135,61,0.08);
  border: 1px solid rgba(241,135,61,0.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin: 10px 0 14px;
}
.db-can-icon {
  font-size: 18px;
  line-height: 1.2;
}
.db-can-text b {
  display: block;
  font-size: 11px;
  color: #f1873d;
  margin-bottom: 2px;
}
.db-can-text p {
  margin: 0;
  font-size: 10px;
  color: #94a3b8;
  line-height: 1.5;
}
.db-battery-stack-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.db-battery-unit {
  background: #141c28;
  border: 1px solid #1f2b3a;
  border-radius: 12px;
  padding: 14px;
}
.db-battery-unit-top {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.db-role-pill {
  font-size: 8px;
  font-weight: 800;
  letter-spacing: .05em;
  padding: 2px 6px;
  border-radius: 4px;
}
.db-role-pill.master {
  background: rgba(241,135,61,0.18);
  border: 1px solid #f1873d;
  color: #ff9a52;
}
.db-role-pill.slave {
  background: rgba(55,201,139,0.14);
  border: 1px solid rgba(55,201,139,0.4);
  color: #37c98b;
}
.db-battery-unit-top h4 {
  font-size: 12px;
  font-weight: 700;
  margin: 0;
  color: #fff;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.db-battery-unit-status {
  font-size: 9px;
  color: #20bda0;
  font-weight: 700;
}
.db-battery-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.db-battery-bar-track {
  flex: 1;
  height: 8px;
  background: #1c2736;
  border-radius: 4px;
  overflow: hidden;
}
.db-battery-bar-track span {
  display: block;
  height: 100%;
  border-radius: 4px;
  transition: width .3s ease;
}
.db-battery-soc-num {
  font-size: 14px;
  font-weight: 750;
  color: #fff;
}
.db-battery-specs {
  display: flex;
  justify-content: space-between;
  border-top: 1px solid #1a2533;
  padding-top: 8px;
  font-size: 10px;
  color: #64748b;
}
.db-battery-specs b { color: #cbd5e1; }

/* Weather Card */
.db-card-weather {
  grid-column: 1 / -1;
  background: #0f1722;
}
.db-weather-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  align-items: center;
  margin-top: 10px;
}
.db-weather-sun-box {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}
.db-sun-arc {
  width: 120px;
  height: 64px;
  flex-shrink: 0;
}
.db-sun-metrics {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.db-sun-stat span {
  font-size: 10px;
  color: #64748b;
  display: block;
  white-space: nowrap;
}
.db-sun-stat b {
  font-size: 13px;
  color: #fff;
  font-weight: 750;
  white-space: nowrap;
}
.db-weather-rain-box {
  border-left: 1px solid #1e293b;
  padding-left: 16px;
  min-width: 0;
}
.db-rain-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  min-width: 0;
}
.db-rain-icon { font-size: 26px; flex-shrink: 0; }
.db-rain-header b { display: block; font-size: 13px; color: #fff; }
.db-rain-header small { display: block; font-size: 10px; color: #64748b; margin-top: 2px; }
.db-solar-estimate-bar .db-estimate-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  margin-bottom: 5px;
}
.db-solar-estimate-bar .db-estimate-label span { color: #64748b; }
.db-solar-estimate-bar .db-estimate-label b { color: var(--accent, var(--brand)); white-space: nowrap; }
.db-progress-track {
  height: 6px;
  background: #1c2736;
  border-radius: 4px;
  overflow: hidden;
}
.db-progress-track span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #e11d48);
  border-radius: 4px;
}

/* Container Queries for Weather Card Adaptation */
@container card (max-width: 540px) {
  .db-weather-body {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .db-weather-rain-box {
    border-left: none;
    border-top: 1px solid #1e293b;
    padding-left: 0;
    padding-top: 12px;
  }
  .db-weather-sun-box {
    gap: 10px;
  }
  .db-sun-arc {
    width: 100px;
    height: 54px;
  }
}

@container card (max-width: 380px) {
  .db-weather-sun-box {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .db-sun-arc {
    width: 90px;
    height: 48px;
    margin: 0 auto;
  }
  .db-sun-metrics {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 4px 10px;
  }
}

/* Energy Chart Card */
.db-card-chart {
  grid-column: 1 / -1;
  background: #0f1722;
}
.db-chart-tabs {
  display: flex;
  gap: 4px;
  background: #141d2a;
  border: 1px solid #1f2c3d;
  border-radius: 8px;
  padding: 3px;
  margin: 8px 0 10px;
  overflow-x: auto;
}
.db-chart-tab-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s ease;
}
.db-chart-tab-btn:hover {
  color: #fff;
  background: #1b2636;
}
.db-chart-tab-btn.active {
  background: var(--card-accent, #f1873d);
  color: #111;
  font-weight: 750;
}
.db-chart-wrap {
  position: relative;
  margin-top: 10px;
  touch-action: pan-y;
}
.db-chart-svg {
  width: 100%;
  height: 120px;
  overflow: visible;
  cursor: crosshair;
}
.db-chart-crosshair-line {
  stroke: rgba(255, 255, 255, 0.45);
  stroke-width: 1.2px;
  stroke-dasharray: 3 3;
  pointer-events: none;
}
.db-chart-dot {
  pointer-events: none;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
  transition: r 0.15s ease;
}
.db-chart-tooltip {
  position: absolute;
  top: 4px;
  background: rgba(13, 20, 31, 0.94);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  padding: 7px 11px;
  font-size: 10.5px;
  color: #fff;
  pointer-events: none;
  z-index: 25;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
  min-width: 135px;
  transition: opacity 0.1s ease;
}
.db-ctt-time {
  font-size: 11px;
  font-weight: 750;
  color: #e2e8f0;
  margin-bottom: 5px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.db-ctt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 3px;
  font-size: 10px;
}
.db-ctt-name {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #94a3b8;
}
.db-ctt-name i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.db-ctt-row b {
  color: #fff;
  font-weight: 750;
}
.db-chart-legend {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  font-size: 11px;
  color: #94a3b8;
  flex-wrap: wrap;
}
.db-chart-series-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  font-size: 10.5px;
  color: #cbd5e1;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}
.db-chart-series-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.db-chart-series-pill.is-active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.15);
}
.db-chart-series-pill.is-off {
  opacity: 0.35;
  text-decoration: line-through;
  border-style: dashed;
  background: transparent;
}
.db-chart-series-pill i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.db-chart-series-pill b {
  color: #fff;
  font-weight: 750;
}
.db-chart-legend span { display: flex; align-items: center; gap: 6px; }
.db-chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.db-chart-legend b { color: #fff; }

/* Light theme overrides for chart crosshair & tooltip */
.db-preview[data-theme-mode^="light_"] .db-chart-tooltip {
  background: rgba(255, 255, 255, 0.96);
  border-color: #cbd5e1;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  color: #0f172a;
}
.db-preview[data-theme-mode^="light_"] .db-ctt-time {
  color: #0f172a;
  border-bottom-color: #e2e8f0;
}
.db-preview[data-theme-mode^="light_"] .db-ctt-row b {
  color: #0f172a;
}
.db-preview[data-theme-mode^="light_"] .db-chart-crosshair-line {
  stroke: rgba(15, 23, 42, 0.45);
}
.db-preview[data-theme-mode^="light_"] .db-chart-series-pill {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #334155;
}
.db-preview[data-theme-mode^="light_"] .db-chart-series-pill.is-active {
  background: #e2e8f0;
}
.db-preview[data-theme-mode^="light_"] .db-chart-series-pill.is-active b {
  color: #0f172a;
}

/* Inverter Telemetry Card */
.db-card-telemetry {
  grid-column: span 2;
  background: #0f1722;
}
.db-telemetry-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-top: 12px;
}
.db-telemetry-item {
  background: #141c28;
  border: 1px solid #1f2b3a;
  border-radius: 10px;
  padding: 10px 8px;
  text-align: center;
}
.db-telemetry-item span { display: block; font-size: 10px; color: #64748b; margin-bottom: 4px; }
.db-telemetry-item b { font-size: 15px; font-weight: 750; color: #fff; }
.db-status-badge { font-size: 9px; font-weight: 750; padding: 3px 8px; border-radius: 20px; }
.db-status-badge.ok {
  background: rgba(55,201,139,.15);
  border: 1px solid rgba(55,201,139,.4);
  color: #37c98b;
}

/* Responsive adjustments */
@media (max-width: 1100px) {
  .db-server-grid { grid-template-columns: repeat(2, 1fr); }
  .db-pv-groups { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .db-weather-body { grid-template-columns: 1fr; gap: 14px; }
  .db-weather-rain-box { border-left: none; border-top: 1px solid #1e293b; padding-left: 0; padding-top: 12px; }
  .db-server-grid { grid-template-columns: 1fr; }
  .db-inverter-rings-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #db-template-cards { grid-template-columns: 1fr; }
  .db-battery-stack-list { grid-template-columns: 1fr; }
}

/* Viewport simulation overrides */
.db-viewport-container[data-viewport="mobile"] .db-server-grid { grid-template-columns: repeat(2, 1fr); }
.db-viewport-container[data-viewport="mobile"] .db-pv-groups { grid-template-columns: 1fr; }
.db-viewport-container[data-viewport="mobile"] .db-weather-body { grid-template-columns: 1fr; gap: 14px; }
.db-viewport-container[data-viewport="mobile"] .db-weather-rain-box { border-left: none; border-top: 1px solid #1e293b; padding-left: 0; padding-top: 12px; }
.db-viewport-container[data-viewport="mobile"] .db-inverter-rings-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.db-viewport-container[data-viewport="mobile"] .db-battery-stack-list { grid-template-columns: 1fr; }

/* Light Themes Overrides for Component Templates */
.db-preview[data-theme-mode="light_emerald"] .db-chart-legend b,
.db-preview[data-theme-mode="light_rose"] .db-chart-legend b,
.db-preview[data-theme-mode="light_clean"] .db-chart-legend b {
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-pv-group,
.db-preview[data-theme-mode="light_rose"] .db-pv-group,
.db-preview[data-theme-mode="light_clean"] .db-pv-group {
  background: #ffffff;
  border-color: #e2e8f0;
}
.db-preview[data-theme-mode="light_emerald"] .db-pv-field,
.db-preview[data-theme-mode="light_rose"] .db-pv-field,
.db-preview[data-theme-mode="light_clean"] .db-pv-field {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.db-preview[data-theme-mode="light_emerald"] .db-pv-group-head h4,
.db-preview[data-theme-mode="light_rose"] .db-pv-group-head h4,
.db-preview[data-theme-mode="light_clean"] .db-pv-group-head h4,
.db-preview[data-theme-mode="light_emerald"] .db-pv-field h5,
.db-preview[data-theme-mode="light_rose"] .db-pv-field h5,
.db-preview[data-theme-mode="light_clean"] .db-pv-field h5,
.db-preview[data-theme-mode="light_emerald"] .db-pv-watts,
.db-preview[data-theme-mode="light_rose"] .db-pv-watts,
.db-preview[data-theme-mode="light_clean"] .db-pv-watts {
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-battery-unit,
.db-preview[data-theme-mode="light_rose"] .db-battery-unit,
.db-preview[data-theme-mode="light_clean"] .db-battery-unit,
.db-preview[data-theme-mode="light_emerald"] .db-server-card,
.db-preview[data-theme-mode="light_rose"] .db-server-card,
.db-preview[data-theme-mode="light_clean"] .db-server-card,
.db-preview[data-theme-mode="light_emerald"] .db-telemetry-item,
.db-preview[data-theme-mode="light_rose"] .db-telemetry-item,
.db-preview[data-theme-mode="light_clean"] .db-telemetry-item {
  background: #ffffff;
  border-color: #e2e8f0;
}
.db-preview[data-theme-mode="light_emerald"] .db-battery-unit-top h4,
.db-preview[data-theme-mode="light_rose"] .db-battery-unit-top h4,
.db-preview[data-theme-mode="light_clean"] .db-battery-unit-top h4,
.db-preview[data-theme-mode="light_emerald"] .db-battery-soc-num,
.db-preview[data-theme-mode="light_rose"] .db-battery-soc-num,
.db-preview[data-theme-mode="light_clean"] .db-battery-soc-num,
.db-preview[data-theme-mode="light_emerald"] .db-server-val,
.db-preview[data-theme-mode="light_rose"] .db-server-val,
.db-preview[data-theme-mode="light_clean"] .db-server-val,
.db-preview[data-theme-mode="light_emerald"] .db-telemetry-item b,
.db-preview[data-theme-mode="light_rose"] .db-telemetry-item b,
.db-preview[data-theme-mode="light_clean"] .db-telemetry-item b {
  color: #0f172a;
}

/* Solar Generation Forecast (до 7 днів) */
.db-solar-forecast-section {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.db-forecast-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.db-forecast-title-box {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}
.db-forecast-title-box b {
  color: #fff;
  font-weight: 700;
}
.db-forecast-pills {
  display: flex;
  gap: 4px;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.db-forecast-pill {
  padding: 2px 7px;
  font-size: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #94a3b8;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 600;
}
.db-forecast-pill:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}
.db-forecast-pill.active {
  color: #fff !important;
  font-weight: 800;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}
.db-forecast-kpi-bar {
  display: flex;
  gap: 12px;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-radius: 8px;
  padding: 7px 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.db-forecast-kpi-item {
  font-size: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.db-forecast-kpi-item span {
  color: #94a3b8;
}
.db-forecast-kpi-item b {
  color: #fff;
  font-size: 11px;
}

.db-forecast-grid {
  display: grid;
  grid-template-columns: repeat(var(--forecast-cols, 7), minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

@container card (max-width: 620px) {
  .db-forecast-top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .db-forecast-grid {
    grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)) !important;
    gap: 6px;
  }
}

@container card (max-width: 440px) {
  .db-forecast-grid {
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)) !important;
    gap: 4px;
  }
  .db-forecast-day-card {
    padding: 6px 3px;
  }
  .db-fday-cond {
    display: none;
  }
  .db-fday-footer {
    display: none;
  }
  .db-fday-bar-track {
    height: 28px;
  }
}
.db-forecast-day-card {
  background: #111925;
  border: 1px solid #1e2a3a;
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.db-forecast-day-card:hover {
  border-color: rgba(245, 158, 11, 0.5);
  transform: translateY(-2px);
}
.db-forecast-day-card.is-today {
  border-color: rgba(245, 158, 11, 0.4);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.08) 0%, #111925 100%);
}
.db-fday-header {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}
.db-fday-title {
  font-size: 10px;
  font-weight: 750;
  color: #fff;
}
.db-fday-date {
  font-size: 8.5px;
  color: #64748b;
}
.db-fday-icon-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin: 4px 0;
}
.db-fday-icon {
  font-size: 20px;
  line-height: 1;
}
.db-fday-cond {
  font-size: 8px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 70px;
}
.db-fday-kwh {
  margin: 4px 0;
}
.db-fday-kwh b {
  font-size: 13px;
  color: #f59e0b;
  font-weight: 800;
}
.db-fday-kwh small {
  font-size: 8px;
  color: #94a3b8;
  margin-left: 2px;
}
.db-fday-bar-track {
  width: 100%;
  max-width: 32px;
  height: 40px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  display: flex;
  align-items: flex-end;
  padding: 2px;
  margin: 4px 0;
}
.db-fday-bar-fill {
  width: 100%;
  border-radius: 3px;
  min-height: 4px;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.3);
  transition: height 0.3s ease;
}
.db-fday-footer {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 8px;
  color: #64748b;
  margin-top: 4px;
}

/* Light themes overrides for forecast */
.db-preview[data-theme-mode="light_emerald"] .db-forecast-title-box b,
.db-preview[data-theme-mode="light_rose"] .db-forecast-title-box b,
.db-preview[data-theme-mode="light_clean"] .db-forecast-title-box b,
.db-preview[data-theme-mode="light_emerald"] .db-forecast-kpi-item b,
.db-preview[data-theme-mode="light_rose"] .db-forecast-kpi-item b,
.db-preview[data-theme-mode="light_clean"] .db-forecast-kpi-item b,
.db-preview[data-theme-mode="light_emerald"] .db-fday-title,
.db-preview[data-theme-mode="light_rose"] .db-fday-title,
.db-preview[data-theme-mode="light_clean"] .db-fday-title {
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-forecast-day-card,
.db-preview[data-theme-mode="light_rose"] .db-forecast-day-card,
.db-preview[data-theme-mode="light_clean"] .db-forecast-day-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
.db-preview[data-theme-mode="light_emerald"] .db-forecast-pills,
.db-preview[data-theme-mode="light_rose"] .db-forecast-pills,
.db-preview[data-theme-mode="light_clean"] .db-forecast-pills {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

/* Responsive forecast on mobile */
@media (max-width: 600px) {
  .db-forecast-grid {
    overflow-x: auto;
    padding-bottom: 4px;
    grid-auto-flow: column;
    grid-auto-columns: minmax(70px, 1fr);
  }
}
.db-viewport-container[data-viewport="mobile"] .db-forecast-grid {
  overflow-x: auto;
  padding-bottom: 4px;
  grid-auto-flow: column;
  grid-auto-columns: minmax(70px, 1fr);
}

/* -------------------------------------------------------------
   Microinverter MPPT Matrix Card Styles
------------------------------------------------------------- */
.db-card-microinverter {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.db-micro-devices-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.db-micro-device-card {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.db-micro-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.db-micro-title-box h4 {
  margin: 0;
  font-size: 14px;
  font-weight: 750;
  color: #fff;
}
.db-micro-meta {
  font-size: 11px;
  color: #94a3b8;
}
.db-micro-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.db-quick-inspect-btn {
  cursor: pointer;
  padding: 4px 10px;
  background: rgba(241, 135, 61, 0.15);
  border: 1px solid rgba(241, 135, 61, 0.4);
  color: #f1873d;
  font-weight: 700;
  font-size: 11px;
  border-radius: 6px;
  transition: all 0.15s ease;
}
.db-quick-inspect-btn:hover {
  background: rgba(241, 135, 61, 0.3);
  color: #fff;
}
.db-micro-kpi-summary {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.db-micro-kpi-metric {
  display: flex;
  flex-direction: column;
  min-width: 110px;
}
.db-micro-kpi-label {
  font-size: 10px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.db-micro-kpi-val {
  font-size: 20px;
  font-weight: 800;
  color: #f59e0b;
  font-family: 'JetBrains Mono', monospace;
}
.db-micro-kpi-bar-box {
  flex: 1;
  min-width: 140px;
}
.db-micro-kpi-bar-top {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 4px;
}
.db-micro-progress-track {
  height: 6px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.db-micro-progress-fill {
  height: 100%;
  display: block;
  border-radius: 3px;
  transition: width 0.3s ease;
}
.db-micro-kpi-stats {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 11px;
  color: #94a3b8;
}
.db-micro-rule-notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: rgba(56, 189, 248, 0.05);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: #94a3b8;
  line-height: 1.45;
}
.db-micro-rule-notice b {
  color: #38bdf8;
}
.db-mppt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.db-mppt-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.15s ease;
  cursor: pointer;
  position: relative;
}
.db-mppt-card:hover {
  border-color: rgba(241, 135, 61, 0.4);
  background: rgba(255, 255, 255, 0.055);
  transform: translateY(-1px);
}
.db-mppt-card.is-clipped {
  border-color: rgba(244, 63, 94, 0.35);
}
.db-mppt-card.is-limited {
  border-color: rgba(245, 158, 11, 0.3);
}
.db-mppt-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.db-mppt-badge {
  font-size: 11px;
  font-weight: 750;
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 7px;
  border-radius: 5px;
}
.db-mppt-tag {
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.db-mppt-tag.ok {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.db-mppt-tag.limited {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}
.db-mppt-tag.clipped {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.35);
}
.db-mppt-panel-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.db-mppt-model {
  font-size: 11.5px;
  font-weight: 650;
  color: #e2e8f0;
}
.db-mppt-limit {
  font-size: 10px;
  color: #94a3b8;
}
.db-mppt-power-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 2px;
}
.db-mppt-watts {
  font-size: 16px;
  font-weight: 800;
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
}
.db-mppt-panel-spec {
  font-size: 10px;
  color: #94a3b8;
}
.db-mppt-bar-track {
  height: 4px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2px;
}
.db-mppt-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.3s ease;
}
.db-mppt-electrical {
  display: flex;
  justify-content: space-between;
  font-size: 9.5px;
  color: #64748b;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 2px;
}

/* Light Theme Adaptations for Microinverters */
.db-preview[data-theme-mode="light_emerald"] .db-micro-device-card,
.db-preview[data-theme-mode="light_rose"] .db-micro-device-card,
.db-preview[data-theme-mode="light_clean"] .db-micro-device-card {
  background: #ffffff;
  border-color: #e2e8f0;
}
.db-preview[data-theme-mode="light_emerald"] .db-micro-title-box h4,
.db-preview[data-theme-mode="light_rose"] .db-micro-title-box h4,
.db-preview[data-theme-mode="light_clean"] .db-micro-title-box h4 {
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-micro-kpi-summary,
.db-preview[data-theme-mode="light_rose"] .db-micro-kpi-summary,
.db-preview[data-theme-mode="light_clean"] .db-micro-kpi-summary {
  background: #f8fafc;
  border-color: #e2e8f0;
}
.db-preview[data-theme-mode="light_emerald"] .db-mppt-card,
.db-preview[data-theme-mode="light_rose"] .db-mppt-card,
.db-preview[data-theme-mode="light_clean"] .db-mppt-card {
  background: #f8fafc;
  border-color: #cbd5e1;
}
.db-preview[data-theme-mode="light_emerald"] .db-mppt-badge,
.db-preview[data-theme-mode="light_rose"] .db-mppt-badge,
.db-preview[data-theme-mode="light_clean"] .db-mppt-badge {
  background: #e2e8f0;
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-mppt-model,
.db-preview[data-theme-mode="light_rose"] .db-mppt-model,
.db-preview[data-theme-mode="light_clean"] .db-mppt-model {
  color: #0f172a;
}
.db-preview[data-theme-mode="light_emerald"] .db-mppt-watts,
.db-preview[data-theme-mode="light_rose"] .db-mppt-watts,
.db-preview[data-theme-mode="light_clean"] .db-mppt-watts {
  color: #0f172a;
}

