:root {
  --ink: #172033;
  --muted: #687386;
  --line: #dbe3ec;
  --soft: #f4f7fb;
  --panel: #ffffff;
  --nav: #12263a;
  --nav-2: #173b52;
  --brand: #176b87;
  --brand-2: #2f8f9d;
  --accent: #d98937;
  --ok: #13795b;
  --warn: #b7791f;
  --bad: #b42318;
}

* { letter-spacing: 0; }

body {
  min-height: 100vh;
  background: #eef3f7;
  color: var(--ink);
  font-size: 15px;
}

.shell-body {
  display: flex;
}

.app-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  background: linear-gradient(180deg, var(--nav), var(--nav-2));
  color: #fff;
  padding: 18px 14px;
  overflow-y: auto;
  box-shadow: 12px 0 32px rgba(16, 24, 40, .18);
  z-index: 20;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  padding: 8px 8px 18px;
  border-bottom: 1px solid rgba(255,255,255,.14);
  margin-bottom: 12px;
}

.brand-block small {
  display: block;
  color: rgba(255,255,255,.68);
  font-size: .78rem;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  font-weight: 800;
  color: #102a3c;
  background: #f6d37f;
  flex: 0 0 auto;
}

.side-nav {
  display: grid;
  gap: 4px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: rgba(255,255,255,.86);
  text-decoration: none;
  padding: 10px 11px;
  border-radius: 8px;
}

.side-nav a:hover {
  color: #fff;
  background: rgba(255,255,255,.12);
}

.side-nav .side-sub-link {
  padding-left: 2.2rem;
  font-size: 0.9rem;
  color: #b9c8d8;
}

.side-section {
  color: #f6d37f;
  font-size: .73rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 15px 11px 5px;
}

.app-main {
  margin-left: 260px;
  min-height: 100vh;
  width: calc(100% - 260px);
}

.login-main {
  width: 100%;
}

.topbar {
  height: 76px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 0 26px;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title {
  font-weight: 800;
  font-size: 1.05rem;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: .86rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #344054;
  background: #f7fafc;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-weight: 700;
}

.app-shell {
  padding: 24px 26px 36px;
}

.message-stack {
  max-width: 980px;
}

.page-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 18px;
}

.page-title {
  font-weight: 850;
  margin: 0;
  font-size: 1.72rem;
}

.page-subtitle {
  color: var(--muted);
  margin: .24rem 0 0;
}

.hero-dashboard {
  overflow: hidden;
  background:
    linear-gradient(125deg, rgba(18, 38, 58, .95), rgba(23, 107, 135, .84)),
    url("https://images.unsplash.com/photo-1509391366360-2e959784a276?auto=format&fit=crop&w=1600&q=70");
  background-size: cover;
  background-position: center;
  border-radius: 8px;
  color: #fff;
  padding: 28px;
  min-height: 230px;
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 20px;
  align-items: end;
  margin-bottom: 18px;
}

.hero-dashboard h1 {
  font-size: 2rem;
  font-weight: 850;
  margin: 0 0 8px;
}

.hero-dashboard p {
  color: rgba(255,255,255,.82);
  max-width: 720px;
  margin: 0;
}

.hero-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(120px, 1fr));
  gap: 10px;
}

.hero-stat {
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 8px;
  padding: 13px;
}

.hero-stat span {
  display: block;
  color: rgba(255,255,255,.74);
  font-size: .78rem;
  text-transform: uppercase;
  font-weight: 800;
}

.hero-stat strong {
  font-size: 1.4rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .06);
}

.panel-header {
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.panel-body {
  padding: 16px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.metric {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 14px;
}

.operator-wrap {
  display: grid;
  gap: 18px;
}

.operator-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(120deg, #12324a, #176b87);
  color: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 16px 36px rgba(18, 38, 58, .18);
}

.operator-hero.compact {
  padding: 20px 24px;
}

.operator-hero h1 {
  margin: 0;
  font-size: 1.9rem;
  font-weight: 850;
}

.operator-hero p {
  margin: 5px 0 0;
  color: rgba(255,255,255,.82);
}

.operator-date,
.operator-filter {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

.operator-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.operator-date .btn,
.operator-actions .btn {
  min-height: 38px;
}

.operator-date .form-select {
  width: auto;
}

.operator-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 0 10px;
  border-radius: 8px;
  background: rgba(255,255,255,.16);
  color: inherit;
  font-weight: 750;
}

.operator-check.light {
  background: #f8fbfd;
  color: var(--ink);
  border: 1px solid var(--line);
}

.operator-filter {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.operator-filter label {
  min-width: 220px;
  flex: 1 1 220px;
}

.operator-filter .operator-check {
  flex: 0 1 auto;
}

.operator-filter .operator-check span {
  display: inline;
  margin: 0;
  color: inherit;
  font-size: .92rem;
  text-transform: none;
}

.operator-filter label span {
  display: block;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 750;
  margin-bottom: 4px;
}

.operator-report-builder {
  overflow: hidden;
}

.operator-report-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  align-items: end;
}

.operator-report-grid label {
  min-width: 0;
}

.operator-report-grid .form-label {
  display: block;
  margin-bottom: 6px;
}

.operator-inline-check {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid #cfd8e3;
  border-radius: 7px;
  background: #f8fbff;
  font-weight: 700;
}

.operator-inline-check .form-check-input {
  margin: 0;
}

.operator-period-summary {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid #2f66ff;
  background: #f5f8ff;
  color: var(--muted);
}

.operator-report-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.operator-access-details {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.operator-access-details summary {
  cursor: pointer;
  font-weight: 750;
  color: var(--muted);
}

.report-download-command {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #2456d6;
  font-weight: 750;
}

@media (max-width: 1100px) {
  .operator-report-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .operator-report-grid {
    grid-template-columns: 1fr;
  }

  .operator-report-actions > * {
    flex: 1 1 150px;
  }
}

.operator-inline-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  align-items: end;
}

.operator-inline-form label {
  display: grid;
  gap: 6px;
  margin: 0;
}

.operator-inline-form label span {
  color: var(--muted);
  font-size: .9rem;
  font-weight: 800;
}

.operator-inline-form .btn {
  min-height: 42px;
}

.operator-inline-form .operator-manual-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfd;
}

.operator-inline-form .operator-manual-confirm span {
  color: var(--ink);
}

.operator-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

.operator-summary div,
.operator-section,
.operator-location-card,
.operator-plant-card,
.operator-empty {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.operator-summary div {
  padding: 16px;
}

.operator-summary.compact div {
  padding: 12px;
}

.operator-summary span {
  display: block;
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.operator-summary strong {
  font-size: 1.42rem;
  color: #102033;
}

.operator-section,
.operator-location-card {
  padding: 16px;
}

.operator-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.operator-section-head h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 850;
}

.operator-period-label {
  color: var(--muted);
  font-weight: 750;
}

.operator-timeline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.operator-period {
  display: grid;
  gap: 3px;
  border-left: 5px solid var(--brand);
  background: #f8fbfd;
  border-radius: 8px;
  padding: 12px;
}

.operator-period.descarcare {
  border-left-color: #ad2b27;
}

.operator-period span {
  color: var(--muted);
  font-size: .78rem;
  font-weight: 800;
}

.operator-period strong {
  font-size: 1.05rem;
}

.operator-period em {
  font-style: normal;
  color: #334155;
  font-weight: 750;
}

.operator-period small {
  color: var(--muted);
  font-weight: 750;
}

.operator-cycle-list,
.price-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.operator-cycle-card,
.price-stat-grid div {
  border: 1px solid var(--line);
  background: #f8fbfd;
  border-radius: 8px;
  padding: 12px;
}

.operator-cycle-card {
  display: grid;
  gap: 3px;
}

.operator-cycle-card strong,
.price-stat-grid strong {
  color: #102033;
  font-size: 1.08rem;
}

.operator-cycle-card span,
.price-stat-grid span {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 750;
}

.price-stat-grid strong,
.price-stat-grid small {
  display: block;
  margin-top: 3px;
}

.price-stat-grid small {
  color: var(--muted);
}

.operator-cycle-card em {
  font-style: normal;
  color: #087f5b;
  font-weight: 850;
}

.operator-note {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #edf7ff;
  color: #17496a;
  font-weight: 700;
}

.price-mini {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: .86rem;
  font-weight: 750;
}

.operator-chart-wrap {
  position: relative;
  height: 340px;
  min-height: 260px;
  touch-action: none;
}

.operator-chart-fallback,
.operator-chart-fallback svg {
  width: 100%;
  height: 100%;
  display: block;
}

.operator-chart-fallback {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  cursor: grab;
}

.operator-chart-fallback:active {
  cursor: grabbing;
}

.operator-chart-grid {
  stroke: #d7e0ea;
  stroke-width: 1;
}

.operator-chart-axis,
.operator-chart-axis-title {
  fill: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.operator-chart-axis-title {
  font-size: 13px;
}

.operator-chart-tooltip {
  position: absolute;
  z-index: 3;
  min-width: 170px;
  max-width: 240px;
  padding: 9px 10px;
  border: 1px solid #d2dce8;
  border-radius: 8px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 12px 30px rgba(15, 23, 42, .15);
  pointer-events: none;
}

.operator-chart-tooltip strong,
.operator-chart-tooltip span,
.operator-chart-tooltip small {
  display: block;
}

.operator-chart-tooltip strong {
  color: #102033;
}

.operator-chart-tooltip span,
.operator-chart-tooltip small {
  color: #475569;
  font-size: .84rem;
}

.operator-chart-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.operator-chart-actions .btn {
  width: 36px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.operator-card-grid,
.operator-plant-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.operator-plant-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  color: var(--ink);
  text-decoration: none;
}

.operator-plant-card:hover {
  border-color: #9fb6ca;
  box-shadow: 0 12px 28px rgba(16, 24, 40, .08);
}

.operator-plant-card small,
.report-simple-row small {
  display: block;
  color: var(--muted);
}

.battery-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--brand);
}

.operator-empty {
  padding: 16px;
  color: var(--muted);
}

.operator-empty.with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.report-simple-list {
  display: grid;
  gap: 8px;
}

.report-simple-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
}

.report-simple-row:hover {
  border-color: #9fb6ca;
  background: #f8fbfd;
}

.metric-label {
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  font-weight: 800;
}

.metric-value {
  font-size: 1.28rem;
  font-weight: 850;
  margin-top: 3px;
}

.power-calculator-table th {
  white-space: nowrap;
  font-size: .84rem;
}

.power-calculator-table td {
  min-width: 140px;
}

.power-calculator-table td:first-child {
  min-width: 220px;
}

.site-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 14px;
}

.site-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(16, 24, 40, .05);
}

.site-photo {
  height: 130px;
  background: linear-gradient(135deg, #ced9e4, #f5e4c4);
  overflow: hidden;
  position: relative;
}

.site-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.site-photo-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #edf3f8, #f7edd5);
}

.photo-empty-content {
  color: #667085;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 100%;
  text-align: center;
  font-weight: 700;
}

.photo-empty-content svg {
  width: 26px;
  height: 26px;
}

.photo-empty-content span {
  font-weight: 600;
}

.photo-action {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 5px 9px;
  background: rgba(255, 255, 255, .92);
  border: 1px solid rgba(148, 163, 184, .55);
  color: #0d6efd;
  font-size: .8rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(16, 24, 40, .12);
}

.photo-action:hover {
  background: #fff;
  color: #0a58ca;
}

.site-card-body {
  padding: 14px;
}

.battery-mini {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-top: 1px solid #edf1f5;
}

.battery-thumb {
  width: 52px;
  height: 42px;
  border-radius: 7px;
  object-fit: cover;
  background: #e8eef4;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  text-decoration: none;
}

.battery-thumb-link {
  display: inline-flex;
  width: 52px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 7px;
  overflow: hidden;
  text-decoration: none;
}

.battery-thumb-empty {
  border: 1px dashed #b6c3d1;
}

.battery-thumb-empty:hover {
  background: #f8fbff;
  color: #0d6efd;
  border-color: #0d6efd;
}

img.battery-thumb {
  display: block;
}

.photo-editor-panel {
  max-width: 980px;
}

.photo-editor-grid {
  display: grid;
  grid-template-columns: minmax(280px, 1.15fr) minmax(260px, .85fr);
  gap: 22px;
  align-items: start;
}

.photo-preview-large {
  position: relative;
  min-height: 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #eef3f7;
}

.photo-preview-large img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  display: block;
}

.photo-preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-photo-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--muted);
  margin-right: 6px;
}

.status-ok { background: var(--ok); }
.status-warn { background: var(--warn); }
.status-bad { background: var(--bad); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn {
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}

.table {
  vertical-align: middle;
}

.table thead th {
  color: #344054;
  background: #eef4f7;
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
}

.tou-table td,
.tou-table th {
  text-align: center;
  white-space: nowrap;
}

.tou-check {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  background: var(--brand-2);
  font-weight: 800;
}

.json-box {
  background: #111827;
  color: #e5e7eb;
  border-radius: 8px;
  padding: 12px;
  max-height: 420px;
  overflow: auto;
  font-size: .82rem;
}

.form-section {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.grid-span { grid-column: 1 / -1; }

.operator-report-permission-band {
  padding: 16px;
  border: 1px solid #b8d7c5;
  border-radius: 8px;
  background: #f2f8f4;
}

.operator-report-permission-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.operator-report-permission-band .form-check-label {
  font-weight: 800;
  color: #153c2a;
}

.operator-report-permission-band .form-check-input {
  width: 1.25rem;
  height: 1.25rem;
}

@media (max-width: 768px) {
  .operator-report-permission-head {
    flex-direction: column;
  }
}

.checkbox-list {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  padding: 10px 12px;
  display: block;
}

.checkbox-list > div {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 14px;
  align-items: start;
}

.checkbox-list ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: contents;
}

.checkbox-list li,
.checkbox-list > div > div {
  min-width: 0;
}

.checkbox-list label {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid #d6e0ea;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  min-width: 0;
  line-height: 1.25;
  font-size: .95rem;
  font-weight: 700;
}

.checkbox-list input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand);
}

.report-publish-check {
  padding: 0.7rem 0.8rem 0.7rem 2.25rem;
  border: 1px solid var(--line);
  background: #f7f9fc;
}

.report-publish-check .form-check-input {
  margin-top: 0.2rem;
}

.report-visibility-cell {
  min-width: 15rem;
  vertical-align: top;
}

.report-visibility-details > summary {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--brand);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
  list-style: none;
}

.report-visibility-details > summary::-webkit-details-marker {
  display: none;
}

.report-visibility-form {
  width: min(20rem, 70vw);
  margin-top: 0.55rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  background: #fff;
}

.report-operator-list {
  max-height: 11rem;
  overflow-y: auto;
  padding-right: 0.25rem;
}

.report-operator-list .form-check {
  min-height: 1.75rem;
  margin: 0;
}

.operator-plant-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
}

.operator-report-location-picker {
  grid-column: 1 / -1;
  min-width: 0;
}

.operator-report-location-picker .operator-plant-picker {
  width: min(100%, 620px);
  max-height: 184px;
  overflow-y: auto;
  overscroll-behavior: contain;
  grid-template-columns: 1fr;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.operator-plant-access-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.operator-plant-access-list {
  max-height: 330px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  scrollbar-gutter: stable;
}

.operator-plant-access-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(150px, .4fr));
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}

.operator-plant-access-row:last-child {
  border-bottom: 0;
}

.operator-plant-access-row.is-active {
  background: #f5f9ff;
}

.operator-plant-access-columns {
  position: sticky;
  top: 0;
  z-index: 1;
  min-height: 40px;
  background: #edf3f8;
  color: var(--muted);
  font-size: .78rem;
  text-transform: uppercase;
}

.operator-plant-access-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 700;
}

@media (max-width: 720px) {
  .operator-plant-access-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .operator-plant-access-row {
    grid-template-columns: minmax(170px, 1fr) repeat(3, 145px);
    min-width: 640px;
  }

  .operator-plant-access-list {
    overflow-x: auto;
  }
}

.operator-plant-picker .checkbox-card {
  min-height: 44px;
  border-color: #c8d7e6;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .04);
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.operator-plant-picker .checkbox-card input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--brand);
}

.operator-plant-picker .operator-plant-name {
  font-weight: 800;
  line-height: 1.25;
}

.operator-plant-picker .checkbox-card.is-selected,
.operator-plant-picker .checkbox-card:has(input:checked) {
  border-color: var(--brand);
  background: #eef6ff;
  color: #0f2f57;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .10);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="url"],
select,
textarea {
  max-width: 100%;
}

.form-check-input {
  border-color: #9aa8b5;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 700;
}

details > summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 700;
}

.admin-tile {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  text-decoration: none;
  color: var(--ink);
}

.admin-tile:hover {
  color: var(--brand);
  background: #f7fafc;
}

.admin-tile .icon-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #e7f4f6;
  display: inline-grid;
  place-items: center;
  color: var(--brand);
}

#tou-editor-table .form-control,
#tou-editor-table .form-select {
  min-width: 88px;
}

#tou-editor-table .tou-label {
  min-width: 180px;
}

#id_chart_editors {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 10px;
}

#id_chart_editors li label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  min-height: 30px;
  white-space: nowrap;
}

#id_chart_editors input {
  flex: 0 0 auto;
}

.opcom-chart-wrap {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 280px;
  height: clamp(280px, 34vh, 340px);
  max-height: 340px;
  border: 1px solid #cfdae7;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, .92), rgba(255, 255, 255, .98)),
    #fff;
  overflow: hidden;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85), 0 10px 24px rgba(15, 23, 42, .06);
}

.opcom-chart-wrap canvas,
#opcom-pt60-chart,
#opcom-pt15-chart {
  position: absolute !important;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  display: block;
}

.chart-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 1fr));
  gap: 10px;
}

.price-stat-card {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff, #f4f8fc);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}

.price-stat-card span {
  display: block;
  font-size: .74rem;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
}

.price-stat-card strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 1rem;
  font-weight: 800;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.auto-context-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.2fr) minmax(180px, .7fr) minmax(240px, 1fr);
  gap: 12px;
  align-items: end;
}

.auto-status {
  min-height: 38px;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  padding: 8px 10px;
  color: #334155;
  background: #f8fbff;
}

.auto-status[data-mode="ok"] {
  border-color: #bbf7d0;
  color: #14532d;
  background: #f0fdf4;
}

.auto-status[data-mode="error"] {
  border-color: #fecaca;
  color: #7f1d1d;
  background: #fef2f2;
}

.planner-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
}

.stat-card,
.cycle-pill,
.decision-step {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, #f7fbff);
  padding: 10px 12px;
}

.stat-card span,
.decision-step span {
  display: block;
  color: #64748b;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
  font-weight: 800;
}

.auto-cycle-profit {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
}

.cycle-pill {
  display: grid;
  gap: 2px;
}

.cycle-pill b {
  font-size: 1.05rem;
}

.cycle-pill small {
  color: #64748b;
}

.chart-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.auto-tou-table input,
.auto-tou-table select {
  min-width: 92px;
}

.auto-tou-table td {
  vertical-align: middle;
}

.decision-flow {
  display: grid;
  gap: 8px;
}

.decision-step {
  display: grid;
  gap: 3px;
}

.decision-step small {
  color: #475569;
  overflow-wrap: anywhere;
}

.cycle-profit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 10px;
}

.cycle-profit-card {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  padding: 12px 14px;
  background: linear-gradient(180deg, #ffffff, #f7fbff);
  box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}

.cycle-profit-card span,
.cycle-profit-card small {
  display: block;
}

.cycle-profit-card span {
  font-size: .74rem;
  color: #64748b;
  font-weight: 800;
  text-transform: uppercase;
}

.cycle-profit-card strong {
  display: block;
  margin-top: 3px;
  color: #0f172a;
  font-size: 1.05rem;
  font-weight: 850;
}

.cycle-profit-card small {
  margin-top: 4px;
  color: #64748b;
  line-height: 1.35;
}

.chart-action-toolbar .btn {
  min-width: 36px;
  justify-content: center;
}

.chart-legend-badge {
  border-radius: 999px;
  font-weight: 700;
  padding: 6px 10px;
  border: 1px solid transparent;
  color: #fff;
  box-shadow: 0 6px 14px rgba(15, 23, 42, .1);
}

.chart-legend-charge-grid {
  background: #065f46;
  border-color: #065f46;
}

.chart-legend-charge-pv {
  background: #3f8f5f;
  border-color: #3f8f5f;
}

.chart-legend-discharge-grid {
  background: #991b1b;
  border-color: #991b1b;
}

.chart-legend-discharge-pv {
  background: #dc2626;
  border-color: #dc2626;
}

.chart-manual-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 12px;
  align-items: end;
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff, #f3f7fb);
  padding: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.75);
}

.chart-manual-row {
  min-width: 0;
}

.chart-manual-range input[type="range"] {
  width: 100%;
}

.chart-manual-row-action .btn {
  width: 100%;
}

.compiled-deye-card {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.compiled-deye-table {
  font-size: .88rem;
}

.compiled-deye-table th {
  white-space: nowrap;
}

.compiled-command-summary {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
}

.compiled-row-muted {
  color: #64748b;
  background: rgba(226, 232, 240, .36);
}

.chart-panel-fullscreen {
  width: 100vw !important;
  height: 100vh !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 0 !important;
}

.chart-panel-fullscreen .panel-body {
  height: calc(100vh - 88px);
  overflow: auto;
}

.chart-panel-fullscreen .opcom-chart-wrap {
  min-height: 280px;
  height: min(43vh, 460px);
  max-height: 460px;
}

.login-hero {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  background:
    linear-gradient(125deg, rgba(8, 16, 28, 0.88), rgba(14, 45, 72, 0.8)),
    url("https://images.unsplash.com/photo-1497435334941-8c899ee9e8e9?auto=format&fit=crop&w=1800&q=70");
  background-size: cover;
  background-position: center;
}

.login-hero-copy {
  color: #f8fafc;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-hero-copy h1 {
  font-size: 2.2rem;
  line-height: 1.15;
  margin: 0 0 12px;
  font-weight: 850;
}

.login-hero-copy p {
  max-width: 520px;
  margin: 0;
  color: rgba(248, 250, 252, 0.86);
}

.login-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.login-card {
  width: min(420px, 100%);
}

.login-card input[type="text"],
.login-card input[type="email"],
.login-card input[type="password"] {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid #cfd8e3;
  border-radius: 7px;
  outline: none;
}

.login-card input[type="text"]:focus,
.login-card input[type="email"]:focus,
.login-card input[type="password"]:focus {
  border-color: #2f66ff;
  box-shadow: 0 0 0 .2rem rgba(47, 102, 255, .14);
}

.login-meta {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.login-meta-item {
  border: 1px solid #dbe3ec;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
}

@media (max-width: 960px) {
  .login-hero {
    grid-template-columns: 1fr;
  }
  .login-hero-copy {
    padding: 24px 18px 14px;
  }
  .login-shell {
    padding: 14px;
  }
}

@media (max-width: 1020px) {
  .shell-body { display: block; }
  .app-sidebar {
    position: static;
    width: 100%;
    min-height: auto;
    padding: 10px 12px;
    overflow: visible;
    box-shadow: 0 10px 22px rgba(16, 24, 40, .16);
  }
  .brand-block {
    padding: 6px 4px 10px;
    margin-bottom: 8px;
  }
  .side-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 4px;
    scrollbar-width: thin;
  }
  .side-nav a {
    flex: 0 0 auto;
    padding: 8px 10px;
    white-space: nowrap;
  }
  .side-section {
    flex: 0 0 auto;
    align-self: center;
    padding: 0 8px;
    white-space: nowrap;
  }
  .app-main {
    margin-left: 0;
    width: 100%;
  }
  .hero-dashboard {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .side-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
    padding-bottom: 0;
  }
  .side-nav a,
  .side-nav .side-sub-link {
    min-width: 0;
    padding: 8px 10px;
    white-space: normal;
  }
  .side-section {
    grid-column: 1 / -1;
    padding: 8px 10px 2px;
  }
  .app-shell { padding: 14px; }
  .operator-hero {
    align-items: stretch;
    flex-direction: column;
  }
  .operator-hero > div,
  .operator-date {
    min-width: 0;
    width: 100%;
  }
  .operator-date > .form-control {
    flex: 1 1 180px;
    min-width: 0;
  }
  .operator-date .form-select {
    flex: 0 1 110px;
    min-width: 0;
  }
  .operator-date .operator-check {
    flex: 1 1 180px;
    max-width: 100%;
    white-space: normal;
  }
  .topbar {
    height: auto;
    min-height: 68px;
    padding: 10px 14px;
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .topbar > div:first-child {
    min-width: 0;
    flex: 1 1 220px;
  }
  .topbar-title {
    font-size: 1rem;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  .topbar-subtitle {
    font-size: .78rem;
    overflow-wrap: anywhere;
  }
  .topbar-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
  .user-pill {
    max-width: 100%;
  }
  .side-nav a {
    font-size: .9rem;
  }
  .page-head { display: block; }
  .page-title {
    font-size: 1.35rem;
  }
  .toolbar { margin-top: 12px; }
  .hero-dashboard { padding: 20px; }
  .chart-stats-grid {
    grid-template-columns: 1fr;
  }
  .auto-context-controls,
  .planner-stats {
    grid-template-columns: 1fr;
  }
  .auto-visual-panel .panel-header {
    align-items: stretch;
  }
  .auto-visual-panel .btn-row > * {
    flex: 1 1 150px;
  }
  .cycle-profit-grid {
    grid-template-columns: 1fr;
  }
  .photo-editor-grid {
    grid-template-columns: 1fr;
  }
  .photo-preview-large,
  .photo-preview-large img {
    min-height: 220px;
  }
  .chart-manual-controls {
    grid-template-columns: 1fr;
  }
  .opcom-chart-wrap {
    min-height: 240px;
    height: 280px;
    max-height: 320px;
  }
}
