:root {
  color-scheme: light;
  --bg: #f3f6f9;
  --panel: #ffffff;
  --panel-soft: #f7fafc;
  --text: #18212f;
  --muted: #687385;
  --line: #dbe3ec;
  --line-strong: #c7d2de;
  --blue: #2563eb;
  --green: #16a34a;
  --teal: #0d9488;
  --red: #ef4444;
  --orange: #f97316;
  --yellow: #eab308;
  --violet: #7c3aed;
  --shadow: 0 12px 32px rgba(30, 41, 59, 0.08);
  --radius: 8px;
  font-family: "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: linear-gradient(135deg, #edf6f2 0%, #eef3f8 48%, #f8fafc 100%);
  overflow: hidden;
}

.auth-shell::before {
  content: "";
  position: absolute;
  inset: auto -8vw -14vh auto;
  width: min(760px, 82vw);
  aspect-ratio: 4 / 1;
  background: url("./assets/dongbu-logo-transparent.png") center / contain no-repeat;
  opacity: 0.06;
  pointer-events: none;
}

.auth-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  justify-items: center;
}

.auth-logo {
  display: block;
  width: 250px;
  max-width: 70vw;
  max-height: 68px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 18px;
}

.auth-copy {
  width: 100%;
  text-align: center;
}

.auth-copy h1 {
  margin: 0;
  font-size: 29px;
  line-height: 1.18;
  letter-spacing: 0;
}

.auth-copy p:not(.eyebrow) {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.auth-card {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.auth-form {
  display: grid;
  gap: 11px;
}

.auth-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.auth-form input {
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
}

.auth-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 24px;
}

.auth-text-link,
.auth-form-title button {
  border: 0;
  background: transparent;
  padding: 0;
  color: #dc2626;
  font-weight: 700;
  text-align: left;
}

.auth-text-link:hover,
.auth-form-title button:hover {
  text-decoration: underline;
  box-shadow: none;
  transform: none;
}

.check-row {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
  gap: 8px !important;
  color: var(--text) !important;
  font-size: 12px;
  white-space: nowrap;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  height: 16px;
  accent-color: #1f8a70;
}

.auth-secondary-button {
  width: 100%;
  justify-content: center;
  background: var(--panel-soft);
}

.auth-form-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.auth-form-title strong {
  font-size: 16px;
}

.auth-form-title button {
  color: var(--muted);
  font-size: 12px;
}

.auth-help {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 224px minmax(0, 1fr);
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 16px 12px;
  background: #142033;
  color: #e8eef7;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 4px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border-radius: 8px;
  background: #1f8a70;
  color: #fff;
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span:not(.brand-mark) {
  color: #aab7ca;
  font-size: 13px;
  margin-top: 3px;
}

.nav-list {
  display: grid;
  gap: 5px;
}

.nav-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: #c8d3e3;
  font-size: 13px;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  outline: none;
}

.nav-item.active {
  background: #fff;
  color: #142033;
  font-weight: 700;
}

.side-card {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  padding: 14px;
  background: rgba(255, 255, 255, 0.06);
}

.side-card strong,
.side-card small {
  display: block;
}

.side-card small {
  margin-top: 5px;
  color: #aab7ca;
}

.main-shell {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: rgba(243, 246, 249, 0.9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.top-bar h1 {
  margin: 4px 0 0;
  font-size: 19px;
  line-height: 1.25;
  letter-spacing: 0;
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.control-row,
.toolbar,
.site-selector,
.inline-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.status-pill,
.mini-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}

.status-pill.good {
  color: #11603a;
  background: #e9f8ef;
  border-color: #c5ebd4;
}

.status-pill.warn {
  color: #9a4b05;
  background: #fff5e6;
  border-color: #fed7aa;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  padding: 7px 11px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.primary-button {
  background: #1f8a70;
  border-color: #1f8a70;
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--text);
}

.danger-button {
  background: #fff4f4;
  color: #b42318;
  border-color: #fecaca;
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.inline-select {
  width: 100%;
  min-width: 116px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
}

.button-row.tight {
  gap: 5px;
}

.mini-action {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(30, 41, 59, 0.08);
}

.view-root {
  padding: 14px 22px 28px;
  display: grid;
  gap: 13px;
}

.view-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.view-head h2,
.panel h3,
.metric-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.view-head h2 {
  font-size: 21px;
}

.view-head p {
  margin: 5px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 0;
}

.panel-head h3 {
  font-size: 15px;
}

.panel-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-body {
  padding: 12px 14px 14px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.field {
  display: grid;
  gap: 6px;
}

.field label,
.field > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  min-height: 34px;
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  color: var(--text);
}

.field textarea {
  min-height: 92px;
  resize: vertical;
}

.field-note {
  width: 100%;
  min-height: 112px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  color: var(--text);
  line-height: 1.6;
  resize: vertical;
}

.site-selector {
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.site-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  user-select: none;
}

.site-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.site-chip .swatch {
  width: 10px;
  height: 10px;
  border-radius: 99px;
  background: var(--site-color);
}

.site-chip.checked {
  border-color: var(--site-color);
  box-shadow: inset 0 0 0 1px var(--site-color);
}

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

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

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.85fr);
  gap: 10px;
}

.metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.metric-card h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric-value {
  margin: 7px 0 3px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: 0;
}

.metric-card small {
  color: var(--muted);
}

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

.chart-wrap > canvas,
.billing-mini-chart > canvas {
  position: absolute;
  inset: 0;
}

.chart-wrap.short {
  min-height: 190px;
}

.chart-wrap.tall {
  min-height: 300px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--legend-color);
}

.d-day {
  display: grid;
  gap: 14px;
}

.d-day-main {
  display: grid;
  place-items: center;
  min-height: 152px;
  border-radius: 8px;
  background: linear-gradient(180deg, #f8fbff 0%, #eef6f3 100%);
  border: 1px solid var(--line);
  text-align: center;
}

.d-day-main strong {
  display: block;
  font-size: 32px;
  letter-spacing: 0;
}

.d-day-main span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 700;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: #e6edf5;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: var(--progress);
  background: linear-gradient(90deg, #2563eb, #1f8a70);
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.progress-row strong {
  font-size: 24px;
}

.progress-row input[type="number"] {
  width: 86px;
  min-height: 34px;
}

.mini-bars {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 82px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.mini-bars span {
  flex: 1;
  min-width: 0;
  height: var(--h);
  border-radius: 4px 4px 0 0;
  background: #dfe8f2;
}

.mini-bars span.active {
  background: #93c5fd;
}

.mini-bars span.current {
  background: #34d399;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
}

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  background: var(--panel-soft);
}

tbody tr:hover {
  background: #f9fbfd;
}

.risk {
  display: inline-flex;
  min-width: 58px;
  justify-content: center;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.risk.high {
  color: #b42318;
  background: #fee2e2;
}

.risk.mid {
  color: #9a4b05;
  background: #ffedd5;
}

.risk.low {
  color: #11603a;
  background: #dcfce7;
}

.detail-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 14px;
}

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

.site-list button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  text-align: left;
}

.site-list button.active {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 1px var(--blue);
}

.site-list strong,
.site-list span {
  display: block;
}

.site-list span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.info-list {
  display: grid;
  gap: 10px;
}

.info-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.info-line span:first-child {
  color: var(--muted);
}

.info-line span:last-child {
  font-weight: 700;
  text-align: right;
}

.equipment-grid,
.approval-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.equipment-item,
.approval-item,
.check-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.equipment-item strong,
.approval-item strong {
  display: block;
  margin-bottom: 4px;
}

.equipment-item span,
.approval-item span {
  color: var(--muted);
  font-size: 13px;
}

.range-row {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 86px;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.range-row input[type="range"] {
  width: 100%;
  accent-color: #1f8a70;
}

.range-row output {
  font-weight: 800;
  text-align: right;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.smart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 10px;
  align-items: stretch;
}

.portfolio-summary {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
  padding: 12px 14px;
  align-items: center;
}

.portfolio-total {
  min-width: 0;
}

.portfolio-total strong,
.portfolio-total small {
  display: block;
}

.portfolio-total strong {
  margin-top: 5px;
  font-size: 21px;
  line-height: 1.15;
  letter-spacing: 0;
}

.portfolio-total small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.portfolio-sites {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.portfolio-site {
  min-width: 0;
  min-height: 58px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  column-gap: 7px;
  row-gap: 2px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.portfolio-site strong,
.portfolio-site small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portfolio-site strong {
  font-size: 12px;
}

.portfolio-site small {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.portfolio-site.active {
  border-color: var(--site-color);
  box-shadow: inset 0 0 0 1px var(--site-color);
  background: #f8fbff;
}

.site-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--site-color);
}

.smart-main .panel-body {
  min-height: 252px;
  display: grid;
}

.smart-meter {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: auto minmax(54px, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.speech {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
}

.speech span,
.speech strong {
  display: block;
}

.speech span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.speech strong {
  margin-top: 6px;
  color: var(--text);
  font-size: 21px;
  line-height: 1.1;
  letter-spacing: 0;
}

.speech.blue {
  background: #eef6ff;
  border-color: #bfdbfe;
}

.speech.gray {
  background: #f5f7fa;
  border-color: #dbe3ec;
}

.speech.bottom {
  border-top-width: 4px;
}

.speech.blue.bottom {
  border-top-color: var(--blue);
}

.speech.gray.bottom {
  border-top-color: #94a3b8;
}

.meter-line {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.meter-track {
  height: 10px;
  border-radius: 999px;
  background: #e3eaf3;
  overflow: hidden;
}

.meter-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #1f8a70);
}

.smart-lower {
  align-items: start;
}

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

.compact-select {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 7px 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.compact-select select {
  min-height: 28px;
  min-width: 180px;
  border: 0;
  color: var(--text);
  background: transparent;
  outline: none;
  font-weight: 700;
}

.usage-filters {
  grid-template-columns: repeat(6, minmax(128px, 1fr));
}

.readings-filters {
  grid-template-columns: 160px minmax(280px, 1fr) 200px;
}

.mode-field {
  grid-column: span 4;
}

.mode-tabs,
.metric-tabs,
.radio-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mode-tabs button,
.metric-tabs button,
.radio-tabs button {
  min-height: 31px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 6px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.mode-tabs button.active,
.metric-tabs button.active,
.radio-tabs button.active {
  border-color: #1f8a70;
  background: #e9f8ef;
  color: #11603a;
}

.readonly-field {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.billing-hero .panel-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.9fr);
  gap: 12px;
  align-items: center;
}

.billing-hero h3 {
  margin: 12px 0 0;
  max-width: 720px;
  font-size: 20px;
  line-height: 1.35;
  letter-spacing: 0;
}

.billing-hero h3 strong {
  color: #1f8a70;
}

.billing-mini-chart {
  position: relative;
  min-height: 190px;
}

.capacity-hero {
  display: grid;
  gap: 6px;
  padding: 14px;
  border-radius: 8px;
  background: #eefaf6;
  border: 1px solid #c5ebd4;
}

.capacity-hero span,
.capacity-hero small {
  color: var(--muted);
  font-size: 12px;
}

.capacity-hero strong {
  color: #11603a;
  font-size: 28px;
  line-height: 1.1;
}

.info-stack {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.inspection-wrap {
  display: grid;
  gap: 10px;
}

.inspection-meta {
  max-width: 620px;
}

.inspection-meta th {
  width: 130px;
  background: #eff6ff;
}

.inspection-table td:nth-child(n + 3),
.inspection-table th:nth-child(n + 3) {
  text-align: center;
}

.compact-chart-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 12px;
  align-items: start;
}

.total-row th,
.total-row td {
  color: #11603a;
  background: #e9f8ef;
  font-size: 16px;
  font-weight: 800;
}

tr[data-row-site] {
  cursor: pointer;
}

.selected-row {
  background: #eff6ff;
  box-shadow: inset 4px 0 0 var(--blue);
}

.form-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

.integration-card .panel-body {
  min-height: 126px;
  position: relative;
  padding-left: 60px;
}

.integration-card h3 {
  margin: 4px 0 8px;
  font-size: 16px;
}

.integration-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.step-number {
  position: absolute;
  left: 14px;
  top: 14px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1f8a70;
  color: #fff;
  font-weight: 800;
}

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

.flow-node {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-weight: 700;
}

.flow-arrow {
  color: var(--muted);
  font-weight: 800;
}

.api-test-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  align-items: end;
  gap: 12px;
}

.api-status {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
}

.api-status strong {
  min-width: 54px;
  color: var(--text);
}

.api-status span {
  flex: 1;
}

.api-status em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.api-status.ok {
  border-color: #b7e3c3;
  background: #effaf2;
}

.api-status.error {
  border-color: #fecaca;
  background: #fff1f2;
}

.api-status.loading {
  border-color: #bfdbfe;
  background: #eff6ff;
}

.empty-state {
  padding: 22px 14px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--muted);
  text-align: center;
}

.legend-line {
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: #94a3b8;
}

.legend-line.orange {
  background: #f97316;
}

.legend-line.gray {
  background: #64748b;
}

table small {
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  max-width: min(360px, calc(100vw - 40px));
  padding: 13px 15px;
  border-radius: 8px;
  background: #142033;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.42);
}

.modal-card {
  width: min(440px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
  padding: 18px;
}

.modal-card h3 {
  margin: 0;
  font-size: 18px;
}

.modal-card p {
  margin: 7px 0 14px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-card form {
  display: grid;
  gap: 10px;
}

.modal-card label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.modal-card input {
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 7px 9px;
}

@media (max-width: 1180px) {
  .filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

  .grid-2,
  .detail-layout,
  .portfolio-summary,
  .smart-grid,
  .compact-chart-grid {
    grid-template-columns: 1fr;
  }

  .portfolio-sites {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mode-field {
    grid-column: span 3;
  }

  .readings-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 840px) {
  body {
    font-size: 13px;
  }

  .auth-shell {
    padding: 16px;
  }

  .auth-panel {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .auth-copy h1 {
    font-size: 24px;
  }

  .auth-logo {
    width: 220px;
    max-height: 60px;
    margin-bottom: 14px;
  }

  .auth-card {
    padding: 14px;
  }

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

  .side-nav {
    position: static;
    height: auto;
    padding: 10px;
    gap: 10px;
  }

  .brand {
    border-bottom: 0;
    padding-bottom: 0;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .nav-item {
    text-align: center;
    padding: 8px 6px;
    font-size: 12px;
  }

  .side-card {
    display: none;
  }

  .top-bar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    padding: 10px 12px;
  }

  .top-bar h1 {
    font-size: 17px;
  }

  .user-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .view-root {
    padding: 10px;
    gap: 10px;
  }

  .view-head {
    flex-direction: column;
    gap: 8px;
  }

  .view-head h2 {
    font-size: 19px;
  }

  .view-head p,
  .panel-head p {
    font-size: 11px;
  }

  .panel-head {
    padding: 9px 10px 0;
    gap: 8px;
  }

  .panel-head h3 {
    font-size: 14px;
  }

  .panel-body {
    padding: 9px 10px 10px;
  }

  .filters {
    gap: 6px;
    padding: 8px;
  }

  .field {
    gap: 4px;
  }

  .field label,
  .field > span {
    font-size: 11px;
  }

  .field input,
  .field select,
  .field textarea,
  .readonly-field {
    min-height: 31px;
    padding: 5px 7px;
    font-size: 12px;
  }

  .filters,
  .readings-filters,
  .grid-3,
  .form-grid,
  .equipment-grid,
  .approval-grid,
  .api-test-panel {
    grid-template-columns: 1fr;
  }

  .api-status {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .billing-hero .panel-body,
  .smart-meter {
    grid-template-columns: 1fr;
  }

  .billing-hero h3 {
    font-size: 17px;
  }

  .billing-mini-chart {
    min-height: 170px;
  }

  .meter-line,
  .mode-field {
    grid-column: auto;
  }

  .metric-tabs {
    width: 100%;
  }

  .metric-card {
    padding: 9px;
  }

  .metric-value,
  .portfolio-total strong,
  .speech strong {
    font-size: 18px;
  }

  .speech {
    min-height: 64px;
    padding: 9px;
  }

  .portfolio-summary {
    padding: 9px;
    gap: 8px;
  }

  .portfolio-sites {
    gap: 6px;
  }

  .portfolio-site {
    min-height: 48px;
    padding: 6px;
  }

  .mode-tabs,
  .metric-tabs,
  .radio-tabs,
  .inline-actions {
    gap: 5px;
  }

  .mode-tabs button,
  .metric-tabs button,
  .radio-tabs button {
    min-height: 29px;
    padding: 5px 7px;
    font-size: 11px;
  }

  .chart-wrap {
    min-height: 210px;
  }

  .chart-wrap.tall {
    min-height: 240px;
  }

  .chart-wrap.short {
    min-height: 165px;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
  }

  table {
    min-width: 100%;
    table-layout: fixed;
  }

  th,
  td {
    padding: 6px 5px;
    font-size: 11px;
    line-height: 1.25;
    overflow-wrap: anywhere;
    word-break: keep-all;
  }

  th {
    font-size: 10.5px;
  }

  .form-grid .wide {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .auth-copy h1 {
    font-size: 21px;
  }

  .auth-logo {
    width: 190px;
    max-height: 52px;
    margin-bottom: 10px;
  }

  .auth-form input {
    min-height: 32px;
  }

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

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

  .compact-select,
  .compact-select select,
  .inline-actions {
    width: 100%;
  }

  .compact-select {
    min-height: 31px;
    padding: 4px 6px;
  }

  .compact-select select {
    min-width: 0;
    font-size: 12px;
  }

  .portfolio-sites {
    grid-template-columns: 1fr;
  }

  .primary-button,
  .ghost-button,
  .danger-button {
    flex: 1 1 auto;
    min-height: 31px;
    padding: 5px 8px;
    font-size: 12px;
  }

  .mini-action {
    flex: 1 1 44%;
  }

  .range-row {
    grid-template-columns: 1fr;
  }

  .chart-wrap {
    min-height: 190px;
  }

  .chart-wrap.tall {
    min-height: 220px;
  }

  table {
    min-width: 100%;
  }

  th,
  td {
    padding: 5px 4px;
    font-size: 10.5px;
  }
}

@media (max-width: 420px) {
  html {
    min-width: 300px;
  }

  .side-nav,
  .top-bar,
  .view-root {
    padding-left: 8px;
    padding-right: 8px;
  }

  .nav-item {
    font-size: 11px;
    padding: 7px 5px;
  }

  .panel-head {
    flex-direction: column;
  }

  .metric-card h3,
  .speech span,
  .portfolio-site strong,
  .portfolio-site small {
    font-size: 11px;
  }

  .metric-value,
  .portfolio-total strong,
  .speech strong {
    font-size: 16px;
  }

  th,
  td {
    padding: 4px 3px;
    font-size: 10px;
  }

  .chart-wrap {
    min-height: 180px;
  }

  .chart-wrap.tall {
    min-height: 205px;
  }
}
