:root {
  --bg: #f3f7f4;
  --card: #ffffff;
  --text: #122620;
  --muted: #4f665e;
  --line: #d7e2dd;
  --accent: #0f766e;
  --accent-2: #134e4a;
  --danger: #b91c1c;
  --shadow: 0 10px 24px rgba(15, 37, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.08), transparent 35%),
    radial-gradient(circle at bottom left, rgba(20, 83, 45, 0.1), transparent 45%),
    var(--bg);
}

#app {
  width: min(1300px, 95vw);
  margin: 24px auto 40px;
}

body:not(.auth-mode) {
  overflow: hidden;
}

body:not(.auth-mode) #app {
  height: 100vh;
  margin: 0 auto;
  padding: 12px 0;
}

body.auth-mode #app {
  width: min(760px, 94vw);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-items: center;
  padding: 26px 0;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.auth-card {
  width: min(620px, 100%);
  margin: 0 auto;
  padding: 36px 34px;
  display: grid;
  gap: 18px;
  border-radius: 20px;
}

.auth-admin-link {
  position: fixed;
  top: 14px;
  right: 18px;
  z-index: 20;
  border: 0;
  background: transparent;
  color: #d9e2de;
  padding: 2px 4px;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.auth-admin-link:hover {
  color: #b7c6c0;
  filter: none;
}

.admin-main-link {
  color: #a9b8b2;
  border-color: #e3ece8;
  background: #fbfdfc;
}

.admin-main-link:hover {
  color: #8ca09a;
  border-color: #d5e2dc;
  background: #f7fbf9;
}

.auth-help-wrap {
  display: inline-flex;
  align-items: center;
}

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

#open-privacy-btn-auth {
  color: #6f837c;
  border-color: #dfe8e4;
  background: #fbfdfc;
}

#open-privacy-btn-auth:hover {
  color: #5f746d;
  border-color: #d3dfda;
  background: #f7fbf9;
}

.auth-help-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0;
  display: grid;
  place-items: center;
  font-weight: 800;
}

.auth-help-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 280px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #ffffff;
  color: #2d5650;
  box-shadow: 0 8px 20px rgba(17, 64, 59, 0.12);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-4px);
  transition: opacity 0.16s ease, transform 0.16s ease, visibility 0.16s ease;
  z-index: 5;
}

.auth-help-wrap:hover .auth-help-popover,
.auth-help-wrap.open .auth-help-popover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.auth-help-popover p {
  margin: 0;
  line-height: 1.4;
}

.auth-help-popover p+p {
  margin-top: 4px;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1,
h2,
h3 {
  letter-spacing: -0.02em;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 600;
  color: var(--muted);
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fcfffd;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  filter: brightness(0.95);
}

button.ghost {
  background: #fff;
  color: var(--accent-2);
  border-color: var(--line);
}

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

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

#auth-form {
  gap: 16px;
}

#auth-form input[type="password"] {
  border-radius: 12px;
  padding: 14px 15px;
  font-size: 1.02rem;
}

#auth-form input[type="password"]::placeholder {
  color: #7a8f87;
}

#auth-form input[type="password"]:focus {
  outline: 2px solid rgba(15, 118, 110, 0.22);
  outline-offset: 1px;
  border-color: var(--accent);
  background: #ffffff;
}

#login-btn {
  width: 100%;
  border-radius: 12px;
  padding: 13px 14px;
  font-size: 1rem;
}

#login-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

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

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

.tiny {
  font-size: 0.92rem;
}

.status {
  margin-top: 8px;
  min-height: 24px;
  font-size: 0.95rem;
  color: var(--muted);
}

#auth-status {
  margin-top: 0;
  min-height: 0;
}

#auth-status:empty {
  display: none;
}

.tiny-btn {
  min-height: 30px;
  padding: 5px 10px;
  font-size: 0.86rem;
}

.security-note {
  margin-top: 4px;
  font-size: 0.84rem;
  color: #55736a;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f4faf7;
  border: 1px solid #dce9e3;
  border-radius: 999px;
  width: fit-content;
  padding: 5px 10px;
}

.auth-card h1 {
  font-size: clamp(1.8rem, 2.6vw, 2.2rem);
  line-height: 1.1;
}

.auth-card .eyebrow {
  margin-bottom: 6px;
}

#auth-status {
  margin-top: 2px;
}

.error {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.topbar {
  padding: 18px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.top-edit-tools {
  gap: 6px;
  position: fixed;
  top: 82px;
  right: 16px;
  z-index: 30;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 8px 20px rgba(17, 64, 59, 0.12);
  max-width: min(92vw, 1100px);
  flex-wrap: wrap;
  align-items: center;
}

.top-edit-tools .zoom-btn {
  min-height: 32px;
  padding: 5px 10px;
}

.top-edit-tools .zoom-btn:disabled {
  background: #eef4f1;
  border-color: #d8e4de;
  color: #97aba4;
  opacity: 0.75;
  cursor: not-allowed;
  filter: none;
}

.view-switch {
  gap: 6px;
  margin-right: 4px;
}

.view-btn {
  min-height: 34px;
  padding: 6px 10px;
}

.view-btn.active {
  background: #dff1eb;
  border-color: #8abeb2;
  color: #11403b;
}

.split-rotate {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.split-rotate .split-btn {
  min-width: 34px;
  min-height: 32px;
  border: 0;
  border-radius: 0;
  padding: 0;
  font-weight: 800;
}

.split-rotate .split-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.split-rotate .split-label {
  font-size: 0.83rem;
  color: var(--accent-2);
  padding: 0 10px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  line-height: 1;
  height: 32px;
  display: inline-flex;
  align-items: center;
}

.settings-btn {
  width: 34px;
  min-width: 34px;
  height: 34px;
  min-height: 34px;
  padding: 0;
  display: grid;
  place-items: center;
  opacity: 0.76;
}

.chip {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f8fbf9;
}

.layout {
  margin-top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  min-height: 0;
  position: relative;
}

.layout.no-selection {
  grid-template-columns: minmax(0, 1fr);
}

.plan-panel,
.details-panel,
.data-panel,
.table-view {
  padding: 16px;
}

.plan-header {
  display: grid;
  grid-template-columns: minmax(220px, max-content) minmax(220px, 1fr) max-content;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.plan-header> :first-child {
  grid-column: 1;
}

.plan-header>.plan-hover-owner {
  grid-column: 2;
}

.plan-header>.plan-zoom-tools {
  grid-column: 3;
}

.plan-active-picker {
  display: block;
  margin-top: 6px;
}

.plan-active-picker select {
  min-width: 220px;
  min-height: 40px;
}

.plan-search-wrap {
  margin-top: 0;
  display: inline-flex;
  align-items: center;
}

.plan-search-input {
  min-width: 220px;
  max-width: 280px;
  min-height: 36px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: #16322f;
}

.plan-search-input::placeholder {
  color: #7a8f87;
}

.plan-search-input:focus {
  outline: none;
  border-color: #89bdb0;
  box-shadow: 0 0 0 3px rgba(137, 189, 176, 0.2);
}

.plan-tools-anchor {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.plan-zoom-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-self: end;
}

.plan-hover-owner {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f7fbf9;
  color: #2d5650;
  font-size: 0.85rem;
  font-weight: 600;
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  justify-self: start;
  margin-left: 20px;
}

.plan-hover-owner--invisible {
  visibility: hidden;
  pointer-events: none;
}

.zoom-btn {
  min-width: 38px;
  min-height: 36px;
  padding: 6px 10px;
}

.zoom-btn.active {
  background: #dff1eb;
  border-color: #8abeb2;
  color: #11403b;
}

.plan-grid {
  border: 1px dashed var(--line);
  border-radius: 12px;
  min-height: 0;
  height: 100%;
  background: #f9fcfa;
  padding: 10px;
  overflow: auto;
}

.plan-grid.edit-mode {
  cursor: crosshair;
}

.plan-canvas {
  position: relative;
  width: 100%;
  min-width: 0;
  aspect-ratio: 2014 / 984;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #fff;
}

.plan-canvas img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.spot-zone {
  position: absolute;
  border-radius: 2px;
  border: 1px solid rgba(15, 95, 89, 0.6);
  background: rgba(15, 118, 110, 0.34);
  color: #11403b;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.66rem;
  font-weight: 600;
  cursor: pointer;
  display: grid;
  place-items: center;
  line-height: 1;
  padding: 0;
}

.spot-zone.apartment-zone {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
}

.spot-zone.apartment-zone .spot-primary {
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1;
  background: rgba(245, 252, 249, 0.92);
  border: 1px solid rgba(15, 95, 89, 0.38);
  border-radius: 4px;
  padding: 1px 4px;
}

.spot-zone.apartment-zone .spot-owner {
  max-width: 100%;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1;
  background: rgba(245, 252, 249, 0.92);
  border: 1px solid rgba(15, 95, 89, 0.38);
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.spot-zone.apartment-zone .spot-tenant {
  max-width: 100%;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1;
  background: rgba(245, 252, 249, 0.92);
  border: 1px solid rgba(15, 95, 89, 0.38);
  border-radius: 4px;
  padding: 1px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.spot-zone.parking-zone {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
  padding: 2px 3px;
}

.spot-zone.parking-zone .spot-primary {
  font-size: 0.94rem;
  font-weight: 800;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
}

.spot-zone.parking-zone .spot-owner-mini {
  max-width: 100%;
  font-weight: 700;
  line-height: 1.05;
  background: rgba(245, 252, 249, 0.92);
  border: 1px solid rgba(15, 95, 89, 0.32);
  border-radius: 4px;
  padding: 1px 2px;
  white-space: normal;
  overflow: hidden;
  word-break: break-word;
  text-align: center;
  color: #133b36;
}

.spot-zone:hover {
  background: rgba(15, 118, 110, 0.45);
}

.spot-zone.edit-zone {
  cursor: move;
}

.spot-zone.edit-zone::after {
  content: "";
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(17, 64, 59, 0.8);
  border-bottom: 2px solid rgba(17, 64, 59, 0.8);
}

.spot-zone.edit-zone.editing {
  background: rgba(20, 78, 74, 0.35);
  border-color: rgba(20, 78, 74, 0.9);
}

.spot-zone.selected {
  outline: 2px solid #f59e0b;
  outline-offset: 0;
  background: rgba(245, 158, 11, 0.25);
}

.spot-zone.search-dim:not(.selected) {
  opacity: 0.2;
}

.spot-zone.search-match {
  opacity: 1;
  border-color: rgba(245, 158, 11, 0.95);
  background: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.25);
}

.spot-zone.edit-zone.selected {
  outline: none;
  border-color: rgba(245, 158, 11, 0.9);
  background: rgba(245, 158, 11, 0.24);
}

input[readonly],
select:disabled {
  background: #f3f5f4;
  color: #4f665e;
}

.details-panel dl {
  display: grid;
  gap: 12px;
  margin: 12px 0 0;
}

.details-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.details-edit-btn {
  background: #eef3f1;
  color: #35524a;
  border-color: #d5dfda;
  padding: 7px 10px;
  font-size: 0.88rem;
}

.details-edit-btn:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.details-panel dt {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.details-panel dd {
  margin: 2px 0 0;
  font-weight: 600;
}

.data-panel {
  margin-top: 16px;
}

.details-panel {
  position: absolute;
  top: 72px;
  right: 0;
  width: min(360px, 34vw);
  height: max-content;
  max-height: calc(100% - 88px);
  z-index: 6;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
}

.table-view {
  margin-top: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.table-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  min-width: 0;
}

.table-search-input {
  width: 420px;
  max-width: 100%;
  min-height: 36px;
  color: #16322f;
  background: #ffffff;
  caret-color: #16322f;
  -webkit-text-fill-color: #16322f;
}

.table-search-input::placeholder {
  color: #7a8f87;
}

.table-search-input:focus {
  outline: none;
  border-color: #89bdb0;
  box-shadow: 0 0 0 3px rgba(137, 189, 176, 0.2);
}

.export-presets {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.stats-view {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.library-view {
  margin-top: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 12px;
  padding: 16px;
}

.library-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.library-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
  gap: 12px;
}

.library-list-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fcfa;
  padding: 10px;
  overflow: auto;
}

.library-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.library-empty {
  color: #55736a;
  font-weight: 600;
  font-size: 0.92rem;
}

.library-item-btn {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 3px;
  padding: 9px 10px;
}

.library-item-btn.active {
  background: #dff1eb;
  border-color: #8abeb2;
  color: #11403b;
}

.library-item-name {
  font-weight: 700;
  font-size: 0.92rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-meta {
  font-size: 0.78rem;
  color: #57736d;
}

.library-preview-panel {
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fcfa;
  padding: 10px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
}

.library-preview-title {
  font-weight: 700;
  color: #264843;
  min-height: 22px;
}

.library-preview-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

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

.library-preview-actions button {
  min-height: 34px;
  padding: 6px 10px;
}

.library-preview-frame {
  width: 100%;
  height: 100%;
  min-height: 460px;
  border: 1px solid #d1e2dc;
  border-radius: 10px;
  background: #fff;
}

.stats-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.stats-cards-three {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
}

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

.energy-section {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fcfa;
  padding: 10px;
  display: grid;
  gap: 10px;
}

.energy-section-head h4 {
  margin: 0;
  font-size: 1rem;
  color: #1b433d;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
}

.stat-card h4 {
  margin-top: 3px;
  font-size: 1.35rem;
  line-height: 1.15;
}

.stat-card .stat-main,
.stat-card .stat-sub {
  display: block;
}

.stat-card .stat-sub {
  margin-top: 4px;
  font-size: 0.98rem;
  color: #365f57;
  font-weight: 600;
}

.stat-card h4.stat-good {
  color: #1b7f4b;
}

.stat-card h4.stat-bad {
  color: #b03045;
}

.stat-card h4.stat-neutral {
  color: #1b2c29;
}

.bar-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #ffffff;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}

.bar-card.compact {
  padding: 10px;
}

.gas-bars {
  display: flex;
  gap: 18px;
  align-items: end;
  justify-content: center;
  min-height: 190px;
  flex-wrap: wrap;
  width: 100%;
}

.gas-bar-item {
  display: grid;
  gap: 6px;
  justify-items: center;
  width: 86px;
}

.gas-bar-value,
.gas-bar-year {
  font-size: 0.86rem;
  color: #2f4d48;
}

.gas-bar {
  width: 56px;
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #67b3a7 0%, #1f7f74 100%);
  border: 1px solid rgba(17, 64, 59, 0.35);
}

.bar-empty {
  width: 100%;
  min-height: 150px;
  border: 1px dashed #b7ccc4;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: #5b766d;
  font-weight: 600;
  background: #f6fbf9;
}

.modal-sections {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

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

.modal-subsection h4 {
  margin: 0;
}

.modal-history-wrap {
  max-height: 182px;
  overflow: auto;
}

.modal-history-wrap .energy-table {
  min-width: 0;
}

.admin-audit-sections .modal-history-wrap {
  max-height: 260px;
}

.admin-audit-card {
  width: min(1400px, 96vw);
  max-width: none;
}

.admin-audit-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#admin-audit-search {
  min-width: 320px;
  flex: 1 1 360px;
}

.admin-audit-kpis {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-audit-kpi {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #cadad3;
  background: #f3f8f5;
  color: #2c5a52;
  font-weight: 700;
  font-size: 0.82rem;
}

.replicate-preview {
  border: 1px solid #d9e5df;
  border-radius: 12px;
  background: #f8fcfa;
  padding: 10px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.replicate-card {
  border: 1px solid #dce9e3;
  border-radius: 10px;
  background: #fff;
  padding: 8px;
}

.replicate-summary {
  display: grid;
  gap: 4px;
  font-size: 0.88rem;
  color: #2e4740;
}

.replicate-summary-row {
  display: flex;
  gap: 8px;
}

.replicate-summary-row strong {
  width: 86px;
  color: #385b52;
}

.replicate-arrow {
  text-align: center;
  font-size: 1.15rem;
  color: #3a6c62;
  font-weight: 700;
}

.replicate-confirm {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-self: start;
  width: 100%;
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed #d8e4de;
  color: #2f4e45;
}

.replicate-confirm input[type="checkbox"] {
  width: auto;
  min-width: 16px;
  padding: 0;
  margin: 0;
}

#replicate-submit-btn:disabled {
  background: #c8d8d2;
  border-color: #c8d8d2;
  color: #ffffff;
  cursor: not-allowed;
  filter: none;
}

.replicate-actions {
  justify-content: center !important;
  gap: 0 !important;
}

.modal-actions {
  justify-content: center !important;
  gap: 0 !important;
}

.replicate-actions > * + *,
.modal-actions > * + * {
  margin-left: 24px;
}

#create-unit-modal .create-unit-fields {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 42px;
  max-width: 560px;
  margin: 0 auto 4px;
}

#create-unit-modal .create-unit-fields > label {
  width: 230px;
  min-height: 74px;
  align-content: start;
}

#create-unit-modal .modal-card {
  width: min(760px, 94vw);
  padding: 20px 24px 18px;
}

#create-unit-form {
  gap: 14px;
  max-width: 620px;
  margin: 12px auto 0;
}

#create-unit-modal .modal-head {
  margin-bottom: 2px;
}

#create-unit-modal .modal-actions {
  margin-top: 6px;
}

#replicate-modal .modal-card {
  max-height: 88vh;
  overflow: auto;
}

.energy-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  gap: 10px;
}

.energy-form .full {
  grid-column: 1 / -1;
}

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

.energy-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  table-layout: fixed;
  background: #fff;
}

.energy-table th,
.energy-table td {
  border-bottom: 1px solid #e6eeea;
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.9rem;
  overflow: hidden;
}

.energy-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f8f5;
  font-weight: 700;
}

.energy-table th:nth-child(4),
.energy-table td:nth-child(4),
.energy-table th:nth-child(5),
.energy-table td:nth-child(5) {
  text-align: right;
}

.energy-table th:nth-child(7),
.energy-table td:nth-child(7) {
  width: 44px;
  max-width: 44px;
  text-align: right;
  padding-right: 6px;
  padding-left: 4px;
}

.units-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 980px;
  table-layout: fixed;
  background: #fff;
}

.units-table th,
.units-table td {
  border-bottom: 1px solid #e6eeea;
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 0.9rem;
  overflow: hidden;
}

.units-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f8f5;
  font-weight: 700;
  text-align: center;
}

.units-table th:nth-child(1),
.units-table td:nth-child(1) {
  width: 64px;
  max-width: 64px;
}

.units-table th:nth-child(2),
.units-table td:nth-child(2) {
  width: 110px;
  max-width: 110px;
}

.units-table th:nth-child(3),
.units-table td:nth-child(3) {
  width: 78px;
  max-width: 78px;
}

.units-table th:nth-child(5),
.units-table td:nth-child(5),
.units-table th:nth-child(7),
.units-table td:nth-child(7) {
  width: 110px;
  max-width: 110px;
}

.units-table th:nth-child(10),
.units-table td:nth-child(10) {
  width: 44px;
  max-width: 44px;
  text-align: right;
  padding-right: 6px;
  padding-left: 4px;
}

.units-table th:nth-child(1),
.units-table th:nth-child(2),
.units-table th:nth-child(3),
.units-table th:nth-child(4),
.units-table th:nth-child(5),
.units-table th:nth-child(7),
.units-table td:nth-child(1),
.units-table td:nth-child(2),
.units-table td:nth-child(3),
.units-table td:nth-child(4),
.units-table td:nth-child(5),
.units-table td:nth-child(7) {
  text-align: center;
}


.table-edit-btn {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
  border-radius: 999px;
  font-size: 0.98rem;
  line-height: 1;
  display: inline-grid;
  place-items: center;
  margin-left: auto;
  margin-right: 6px;
}

.cell-box {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: calc(1.25em * 2);
  text-align: center;
}

.cell-box .cell-text {
  display: block;
  width: 100%;
}

.cell-ellipsis .cell-text {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  line-height: 1.25;
  max-height: calc(1.25em * 2);
}

.cell-phone-full {
  min-height: auto;
}

.cell-phone-full .cell-text {
  white-space: nowrap;
  overflow: visible;
  text-overflow: clip;
}

.cell-word-lines {
  min-height: calc(1.25em * 2);
}

.cell-word-lines .cell-text {
  white-space: normal;
  line-height: 1.25;
}

.cell-contact {
  min-height: calc(1.2em * 2 + 2px);
}

.cell-contact .cell-text {
  display: grid;
  gap: 2px;
  line-height: 1.2;
  min-height: calc(1.2em * 2 + 2px);
}

.cell-contact .line {
  display: block;
}

.cell-contact .line.phone-line {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.cell-contact .line:last-child {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cell-contact.single-line {
  min-height: calc(1.2em * 2 + 2px);
}

.details-panel.left {
  left: 0;
  right: auto;
}

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

.grid-form .full {
  grid-column: 1 / -1;
}

.mini-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
}

.mini-fields.owner-fields {
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) minmax(104px, 0.78fr) minmax(196px, 1.62fr);
}

.mini-fields.lease-fields {
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr);
}

.toggle-field {
  display: grid;
  gap: 6px;
  align-items: end;
}

.toggle-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #375852;
}

.toggle-switch {
  min-height: 36px;
  min-width: 74px;
  padding: 7px 12px;
}

.toggle-switch.active {
  background: #dff1eb;
  border-color: #8abeb2;
  color: #11403b;
}

.lease-toggle-field {
  justify-items: start;
}

.toggle-switch-group {
  display: inline-flex;
  gap: 6px;
}

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

.tenant-row-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tenant-row-btn {
  min-height: 36px;
  min-width: 36px;
  width: 36px;
  padding: 0;
  font-weight: 800;
}

.tenant-row-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.tenant-rows {
  display: grid;
  gap: 10px;
}

.mini-fields.tenant-fields,
.tenant-row {
  grid-template-columns: minmax(110px, 1fr) minmax(110px, 1fr) minmax(104px, 0.78fr) minmax(196px, 1.62fr);
}

.mini-fields label {
  gap: 4px;
  font-size: 0.84rem;
}

.mini-fields input,
.mini-fields select {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 0.94rem;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 27, 21, 0.5);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 20;
}

.modal-card {
  width: min(920px, 96vw);
  max-height: 92vh;
  overflow: auto;
  padding: 16px;
}

#admin-auth-modal .modal-card {
  width: min(420px, 92vw);
}

.privacy-card {
  width: min(760px, 96vw);
}

.privacy-content {
  margin-top: 10px;
  display: grid;
  gap: 10px;
  color: #24453f;
  line-height: 1.45;
}

.privacy-content ul {
  margin: 0;
  padding-left: 18px;
}

.privacy-content li {
  margin: 3px 0;
}

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

#main-view {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
  min-height: 0;
}

.plan-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 0;
}

@media (max-width: 1100px) {
  .plan-header {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .plan-header> :first-child,
  .plan-header>.plan-hover-owner,
  .plan-header>.plan-zoom-tools {
    grid-column: 1;
  }

  .plan-hover-owner {
    justify-self: start;
    max-width: 100%;
  }

  .plan-zoom-tools {
    justify-self: start;
  }

  body:not(.auth-mode) {
    overflow: auto;
  }

  body:not(.auth-mode) #app {
    height: auto;
    padding: 16px 0 20px;
  }

  #main-view {
    height: auto;
    display: block;
  }

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

  .details-panel {
    position: static;
    width: auto;
    height: auto;
  }

  .plan-grid {
    min-height: 340px;
  }

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

  .mini-fields {
    grid-template-columns: 1fr 1fr;
  }

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

  .stats-cards {
    grid-template-columns: 1fr;
  }

  .stats-cards-three {
    grid-template-columns: 1fr;
  }

  .energy-sections {
    grid-template-columns: 1fr;
  }

  .library-layout {
    grid-template-columns: 1fr;
  }

  .library-list-panel {
    max-height: 260px;
  }

  .library-preview-head {
    align-items: flex-start;
    flex-direction: column;
  }

}

@media (max-width: 700px) {
  body.auth-mode #app {
    align-items: start;
    padding: 18px 0;
  }

  .auth-card {
    padding: 26px 20px;
    border-radius: 16px;
    gap: 14px;
  }

  .auth-help-popover {
    right: 0;
    left: auto;
    min-width: min(320px, calc(100vw - 48px));
  }

  .plan-active-picker select {
    min-width: 100%;
  }

  .top-edit-tools {
    top: 70px;
    right: 8px;
    left: 8px;
    max-width: none;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .plan-grid {
    min-height: 300px;
  }

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

  .mini-fields {
    grid-template-columns: 1fr;
  }

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

  .modal {
    padding: 10px;
  }
}
