@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
  --bg: #f5f1e8;
  --bg-strong: #efe5d3;
  --surface: rgba(255, 255, 255, 0.84);
  --surface-strong: #fffdf8;
  --text: #1f2a2e;
  --muted: #59676b;
  --line: rgba(31, 42, 46, 0.12);
  --brand: #0f766e;
  --brand-soft: #d8f3ef;
  --accent: #d97706;
  --danger: #b91c1c;
  --warning: #b45309;
  --success: #047857;
  --shadow: 0 24px 80px rgba(31, 42, 46, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.12), transparent 30%),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.18), transparent 32%),
    linear-gradient(180deg, #fcf7ef 0%, var(--bg) 48%, #f7f2eb 100%);
}

body.nav-open {
  overflow: hidden;
}

.app-shell {
  width: 100%;
  min-height: 100vh;
}

.app-shell-authenticated {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 0;
}

.page-shell {
  width: 100%;
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.app-shell-authenticated .page-shell {
  max-width: none;
  margin: 0;
  padding: 28px 24px 48px 20px;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  max-height: 100vh;
  overflow-y: auto;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(250, 244, 233, 0.92)),
    radial-gradient(circle at top left, rgba(217, 119, 6, 0.10), transparent 34%);
  box-shadow: 24px 0 60px rgba(31, 42, 46, 0.06);
  z-index: 30;
}

.sidebar-topline {
  display: block;
}

.sidebar-brand {
  display: grid;
  gap: 8px;
  padding: 8px 8px 2px;
  min-width: 0;
}

.sidebar-title {
  margin: 0;
  font-size: clamp(1.55rem, 2vw, 2.2rem);
  line-height: 1.02;
  letter-spacing: -0.04em;
}

.sidebar-links,
.sidebar-actions {
  display: grid;
  gap: 12px;
  align-content: start;
}

.sidebar-actions {
  margin-top: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  text-decoration: none;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 12px 24px rgba(31, 42, 46, 0.07);
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

.sidebar-link-text {
  display: inline-flex;
  min-width: 0;
}

.sidebar-link:hover,
.sidebar-action-button:hover {
  transform: translateY(-1px);
}

.sidebar-user {
  width: 100%;
  justify-content: space-between;
}

.sidebar-action-button {
  width: 100%;
  justify-content: center;
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(31, 42, 46, 0.34);
  backdrop-filter: blur(6px);
  z-index: 20;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 28px;
  position: relative;
  z-index: 30;
}

.topbar-authenticated {
  justify-content: flex-end;
  margin-bottom: 12px;
}

.topbar-brand {
  flex: 1 1 auto;
  min-width: 0;
}

.topbar-title {
  margin: 6px 0 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.topbar-authenticated .topbar-brand {
  display: none;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.topnav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.topnav-links,
.topnav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.nav-user {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 24px rgba(31, 42, 46, 0.07);
}

.nav-toggle {
  display: none;
  min-width: 116px;
  min-height: 52px;
  padding: 0 16px;
  border: 0;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 28px rgba(31, 42, 46, 0.10);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.nav-toggle-icon {
  display: inline-flex;
  flex-direction: column;
  gap: 5px;
}

.nav-toggle-icon span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transition: transform 140ms ease, opacity 140ms ease;
}

.nav-toggle-text {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
}

.nav-toggle.is-active {
  background: rgba(15, 118, 110, 0.12);
}

.nav-toggle.is-active .nav-toggle-icon span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle.is-active .nav-toggle-icon span:nth-child(2) {
  opacity: 0;
}

.nav-toggle.is-active .nav-toggle-icon span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.role-pill {
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand);
}

.topnav a,
.ghost-button,
.primary-button,
.danger-button {
  border: 0;
  border-radius: 999px;
  text-decoration: none;
  font: inherit;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease, color 120ms ease;
}

.topnav a,
.ghost-button {
  background: rgba(255, 255, 255, 0.64);
  color: var(--text);
  padding: 10px 16px;
  box-shadow: 0 10px 24px rgba(31, 42, 46, 0.07);
}

.primary-button {
  background: linear-gradient(135deg, var(--brand), #115e59);
  color: white;
  padding: 12px 18px;
  box-shadow: 0 16px 32px rgba(15, 118, 110, 0.25);
}

.danger-button {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
  padding: 10px 14px;
}

.inline-button {
  display: inline-flex;
  align-items: center;
}

.topnav a:hover,
.ghost-button:hover,
.primary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.content {
  display: grid;
  gap: 22px;
}

.bridge-rail {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 14px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 12px 28px rgba(31, 42, 46, 0.08);
}

.bridge-rail-ok {
  border-color: rgba(4, 120, 87, 0.18);
}

.bridge-rail-danger {
  border-color: rgba(185, 28, 28, 0.18);
}

.bridge-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.bridge-pill-ok {
  background: rgba(4, 120, 87, 0.12);
  color: var(--success);
}

.bridge-pill-warn {
  background: rgba(180, 83, 9, 0.12);
  color: var(--warning);
}

.bridge-pill-danger {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
}

.panel,
.hero-card,
.status-card,
.metric-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.9), rgba(255, 250, 241, 0.78)),
    radial-gradient(circle at top right, rgba(217, 119, 6, 0.12), transparent 30%);
}

.hero-card h2,
.panel h2,
.status-card h3 {
  margin: 8px 0 12px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  letter-spacing: -0.03em;
}

.panel,
.status-card {
  padding: 24px;
}

.status-card {
  display: grid;
  align-content: start;
}

.detail-header-grid {
  align-items: stretch;
}

.hero-card-compact,
.status-card-compact {
  display: grid;
  gap: 16px;
  padding: 18px 20px;
}

.hero-topline,
.status-card-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.hero-card-compact h2 {
  margin-bottom: 0;
  font-size: clamp(1.32rem, 3vw, 1.95rem);
}

.status-card-compact {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(241, 249, 248, 0.84)),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.14), transparent 34%);
}

.overview-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.overview-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(31, 42, 46, 0.08);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.35;
}

.overview-chip strong {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.overview-chip-accent {
  background: rgba(15, 118, 110, 0.12);
  border-color: rgba(15, 118, 110, 0.14);
}

.status-inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-inline-list span,
.status-note {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
  color: var(--muted);
  font-size: 0.88rem;
}

.status-inline-list strong {
  color: var(--text);
  margin-right: 4px;
}

.header-grid,
.two-column-grid,
.config-grid,
.summary-strip,
.auth-layout {
  display: grid;
  gap: 20px;
}

.header-grid {
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
}

.header-grid.detail-header-grid {
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.95fr);
}

.two-column-grid,
.auth-layout {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-layout-single {
  grid-template-columns: minmax(0, 460px);
  justify-content: center;
}

.config-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.summary-strip {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.metric-card {
  padding: 20px;
  display: grid;
  gap: 8px;
}

.metric-card-period {
  background: linear-gradient(145deg, rgba(255, 248, 238, 0.96), rgba(255, 238, 214, 0.9));
}

.metric-card-usage {
  background: linear-gradient(145deg, rgba(239, 246, 255, 0.96), rgba(219, 234, 254, 0.9));
}

.metric-card-company {
  background: linear-gradient(145deg, rgba(240, 253, 250, 0.96), rgba(204, 251, 241, 0.9));
}

.metric-card-billing {
  background: linear-gradient(145deg, rgba(250, 245, 255, 0.96), rgba(237, 233, 254, 0.9));
}

.metric-card-warning {
  background: linear-gradient(145deg, rgba(255, 251, 235, 0.96), rgba(254, 240, 138, 0.82));
}

.metric-card-neutral {
  background: linear-gradient(145deg, rgba(248, 250, 252, 0.96), rgba(226, 232, 240, 0.9));
}

.metric-card-load {
  background: linear-gradient(145deg, rgba(239, 246, 255, 0.96), rgba(191, 219, 254, 0.86));
}

.metric-card-solar-generation {
  background: linear-gradient(145deg, rgba(254, 252, 232, 0.96), rgba(254, 249, 195, 0.88));
}

.metric-card-energy {
  background: linear-gradient(145deg, rgba(254, 242, 242, 0.96), rgba(254, 202, 202, 0.86));
}

.metric-card-service {
  background: linear-gradient(145deg, rgba(255, 247, 237, 0.96), rgba(254, 215, 170, 0.86));
}

.metric-card-invoice {
  background: linear-gradient(145deg, rgba(236, 253, 245, 0.96), rgba(187, 247, 208, 0.88));
}

.metric-card-source {
  position: relative;
  overflow: hidden;
}

.metric-card-source::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 18px;
  height: 4px;
  border-radius: 999px;
  opacity: 0.9;
}

.metric-card-source-utility::after {
  background: linear-gradient(90deg, #14b8a6, #0f766e);
}

.metric-card-source-inverter::after {
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
}

.metric-card-solar {
  position: relative;
  overflow: hidden;
}

.metric-card-solar::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 18px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #65a30d);
  opacity: 0.9;
}

.metric-card-inflation {
  position: relative;
  overflow: hidden;
  grid-column: span 2;
  background:
    linear-gradient(145deg, rgba(255, 250, 240, 0.95), rgba(255, 244, 214, 0.86)),
    radial-gradient(circle at top right, rgba(217, 119, 6, 0.16), transparent 38%);
}

.metric-card-inflation::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 18px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #d97706, #f59e0b);
}

.metric-card-inflation .metric-subvalue {
  color: #9a3412;
}

.metric-card-theoretical {
  position: relative;
  overflow: hidden;
  min-height: 100%;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(240, 248, 255, 0.88)),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.14), transparent 34%);
}

.metric-card-theoretical::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 18px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb, #38bdf8);
}

.metric-card-savings {
  position: relative;
  overflow: hidden;
  min-height: 100%;
  background:
    linear-gradient(145deg, rgba(244, 253, 240, 0.96), rgba(229, 255, 235, 0.88)),
    radial-gradient(circle at top right, rgba(34, 197, 94, 0.16), transparent 34%);
}

.metric-card-savings::after {
  content: "";
  position: absolute;
  inset: auto 18px 0 18px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #16a34a, #22c55e);
}

.metric-card-savings strong {
  color: #166534;
}

.metric-card strong {
  font-size: 1.8rem;
  letter-spacing: -0.04em;
}

.metric-subvalue {
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed rgba(31, 42, 46, 0.12);
  font-size: 0.9rem;
  font-weight: 700;
}

.metric-card-source-utility .metric-subvalue {
  color: #0f766e;
}

.metric-card-source-inverter .metric-subvalue {
  color: #1d4ed8;
}

.metric-label {
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
}

.stack-form,
.inline-form-grid {
  display: grid;
  gap: 14px;
}

.inline-form-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
}

.wide-field {
  grid-column: span 2;
}

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

.solar-insight-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 0.8fr) minmax(0, 1.2fr);
}

.wide-readonly {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid rgba(31, 42, 46, 0.16);
  border-radius: 16px;
  background: var(--surface-strong);
  color: var(--text);
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.16);
  border-color: rgba(15, 118, 110, 0.4);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-label input {
  width: 18px;
  height: 18px;
  padding: 0;
}

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

.table-shell {
  overflow-x: auto;
}

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

.responsive-detail-table td small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

th,
td {
  text-align: left;
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.04);
}

.list-stack {
  display: grid;
  gap: 12px;
}

.list-stack.compact {
  margin-top: 16px;
}

.list-card {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.7);
}

.collapse-stack {
  display: grid;
  gap: 18px;
}

.collapse-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.collapse-panel[open] {
  border-color: rgba(15, 118, 110, 0.24);
}

.collapse-summary {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 22px 24px;
  cursor: pointer;
}

.collapse-summary::-webkit-details-marker {
  display: none;
}

.collapse-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 1.1rem;
  letter-spacing: -0.02em;
}

.collapse-trigger {
  pointer-events: none;
}

.collapse-body {
  padding: 0 24px 24px;
}

.form-card {
  align-items: end;
}

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

.helper-card p,
.hero-card p,
.status-card p,
.panel p,
.list-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.helper-card p:last-child,
.hero-card p:last-child,
.status-card p:last-child,
.panel p:last-child,
.list-card p:last-child {
  margin-bottom: 0;
}

.expression-list,
.simple-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.expression-list li,
.simple-list li {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.simple-list li small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.subpanel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  margin-top: 16px;
}

.flash-stack {
  display: grid;
  gap: 10px;
}

.flash {
  padding: 14px 16px;
  border-radius: 18px;
  font-weight: 700;
}

.flash-success {
  background: rgba(4, 120, 87, 0.12);
  color: var(--success);
}

.flash-error {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
}

.badge,
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 800;
}

.badge-success,
.pill {
  background: rgba(4, 120, 87, 0.12);
  color: var(--success);
}

.badge-warning {
  background: rgba(180, 83, 9, 0.12);
  color: var(--warning);
}

.badge-danger {
  background: rgba(185, 28, 28, 0.12);
  color: var(--danger);
}

.muted {
  color: var(--muted);
}

.comparison-stack {
  display: grid;
  gap: 18px;
}

.comparison-row {
  display: grid;
  grid-template-columns: minmax(180px, 0.95fr) minmax(320px, 1.7fr) minmax(220px, 1fr);
  gap: 18px;
  align-items: center;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.comparison-row:first-child,
.comparison-row.no-border {
  border-top: 0;
  padding-top: 0;
}

.comparison-meta {
  display: grid;
  gap: 8px;
}

.comparison-meta a {
  color: var(--text);
  text-decoration: none;
}

.comparison-meta a:hover {
  color: var(--brand);
}

.comparison-bars {
  display: grid;
  gap: 12px;
}

.bar-line {
  display: grid;
  gap: 8px;
}

.bar-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bar-label span {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.bar-track {
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(31, 42, 46, 0.08);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.inverter-bar {
  background: linear-gradient(135deg, var(--brand), #0ea5a0);
}

.utility-bar {
  background: linear-gradient(135deg, var(--accent), #f59e0b);
}

.missing-bar {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(89, 103, 107, 0.18),
      rgba(89, 103, 107, 0.18) 8px,
      rgba(89, 103, 107, 0.08) 8px,
      rgba(89, 103, 107, 0.08) 16px
    );
}

.delta-positive,
.delta-negative,
.delta-neutral {
  font-weight: 700;
}

.delta-positive {
  color: var(--warning);
}

.delta-negative {
  color: var(--brand);
}

.delta-neutral {
  color: var(--text);
}

.chart-collection {
  display: grid;
  gap: 20px;
}

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.68);
  display: grid;
  gap: 16px;
  overflow: hidden;
}

.chart-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.chart-card h3 {
  margin: 0;
  font-size: 1.2rem;
  letter-spacing: -0.03em;
}

.chart-card-header p {
  margin: 8px 0 0;
}

.echart-root {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 460px;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(31, 42, 46, 0.05);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.legend-swatch {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  display: inline-block;
}

.toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.source-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.source-toggle form {
  margin: 0;
}

.source-toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 108px;
  padding: 9px 14px;
  border-radius: 999px;
  border: 1px solid rgba(31, 42, 46, 0.12);
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.source-toggle-button:hover {
  transform: translateY(-1px);
}

.source-toggle-button.is-active {
  background: linear-gradient(135deg, var(--brand), #115e59);
  color: white;
  box-shadow: 0 14px 28px rgba(15, 118, 110, 0.18);
}

.source-toggle-button.is-disabled {
  cursor: default;
  opacity: 0.55;
}

.toggle-button {
  border: 1px solid rgba(31, 42, 46, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--text);
  padding: 10px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, color 120ms ease, box-shadow 120ms ease;
}

.toggle-button:hover {
  transform: translateY(-1px);
}

.toggle-button.is-active {
  background: linear-gradient(135deg, var(--brand), #115e59);
  color: white;
  box-shadow: 0 16px 32px rgba(15, 118, 110, 0.20);
}

[data-chart-view][hidden] {
  display: none !important;
}

.empty-state {
  text-align: center;
  padding: 42px 24px;
}

code {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: #134e4a;
  font-family: "SFMono-Regular", "Menlo", monospace;
}

@media (max-width: 1080px) {
  .header-grid.detail-header-grid {
    grid-template-columns: 1fr;
  }

  .app-shell-authenticated {
    grid-template-columns: 1fr;
  }

  .app-shell-authenticated .page-shell {
    padding: 22px 16px 38px;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(82vw, 320px);
    min-height: 100vh;
    transform: translateX(-110%);
    transition: transform 180ms ease;
    z-index: 40;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar-authenticated {
    justify-content: space-between;
    margin-bottom: 24px;
  }

  .topbar-authenticated .topbar-brand {
    display: block;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .header-grid,
  .two-column-grid,
  .config-grid,
  .summary-strip,
  .auth-layout,
  .solar-insight-grid {
    grid-template-columns: 1fr;
  }

  .metric-card-inflation {
    grid-column: span 1;
  }

  .inline-form-grid {
    grid-template-columns: 1fr 1fr;
  }

  .wide-field {
    grid-column: span 2;
  }

  .chart-grid,
  .comparison-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 12px 10px 26px;
  }

  .app-shell-authenticated .page-shell {
    padding: 12px 10px 26px;
  }

  .topbar {
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
  }

  .topbar-title {
    font-size: clamp(1.35rem, 8vw, 2rem);
  }

  .nav-toggle {
    min-width: 96px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 14px;
  }

  .nav-toggle-text {
    font-size: 0.72rem;
  }

  .inline-form-grid {
    grid-template-columns: 1fr;
  }

  .wide-field {
    grid-column: span 1;
  }

  .list-card,
  .section-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .bridge-rail,
  .chart-card-header,
  .bar-label,
  .hero-topline,
  .status-card-topline {
    flex-direction: column;
    align-items: flex-start;
  }

  .sidebar {
    width: min(88vw, 320px);
    padding: 18px 14px;
  }

  .sidebar-title {
    font-size: 1.65rem;
  }

  .sidebar-link,
  .sidebar-action-button {
    min-height: 48px;
    padding-inline: 14px;
  }

  .nav-user {
    width: 100%;
    max-width: 100%;
  }

  .overview-chip-row,
  .status-inline-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .overview-chip,
  .status-inline-list span,
  .status-note {
    width: 100%;
    border-radius: 14px;
  }

  .chart-card {
    padding: 16px 14px;
  }

  .responsive-detail-table,
  .responsive-detail-table tbody,
  .responsive-detail-table tfoot {
    display: block;
    width: 100%;
  }

  .responsive-detail-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .responsive-detail-table tbody,
  .responsive-detail-table tfoot {
    display: grid;
    gap: 12px;
  }

  .responsive-detail-table tbody tr,
  .responsive-detail-table tfoot tr {
    display: block;
    padding: 14px 16px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 12px 24px rgba(31, 42, 46, 0.06);
  }

  .responsive-detail-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.9);
  }

  .responsive-detail-table tfoot tr {
    background: rgba(15, 118, 110, 0.08);
    border-color: rgba(15, 118, 110, 0.16);
  }

  .responsive-detail-table td {
    display: grid;
    grid-template-columns: minmax(112px, 42%) minmax(0, 1fr);
    gap: 10px 14px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    word-break: break-word;
  }

  .responsive-detail-table td:last-child {
    border-bottom: 0;
  }

  .responsive-detail-table td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  .responsive-detail-table td[data-full-row="true"] {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .responsive-detail-table td[data-full-row="true"]::before {
    display: block;
  }

  .responsive-daily-cost-table td {
    grid-template-columns: minmax(126px, 44%) minmax(0, 1fr);
  }

  .hero-card,
  .status-card,
  .metric-card {
    padding: 16px;
  }

  .hero-card-compact h2,
  .status-card h3 {
    font-size: 1.2rem;
  }

  .chart-collection {
    gap: 16px;
  }

  .metric-card strong {
    font-size: 1.45rem;
  }

  .chart-card {
    padding: 12px;
    gap: 14px;
  }

  .echart-root {
    min-height: 360px;
  }

  .chart-card h3 {
    font-size: 1.08rem;
  }

  .chart-card-header p {
    font-size: 0.9rem;
  }

  .chart-legend {
    gap: 8px;
  }

  .legend-chip {
    padding: 7px 9px;
    font-size: 0.78rem;
  }
}
