:root {
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef5f1;
  --ink: #16352e;
  --muted: #63736d;
  --line: #d7e2dc;
  --green: #098c67;
  --green-dark: #087052;
  --amber: #ba7a00;
  --red: #b43232;
  --blue: #2d6f9f;
  --shadow: 0 14px 34px rgba(22, 53, 46, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
}

.access-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
}

.access-screen.hidden {
  display: none;
}

.access-box {
  width: min(520px, 100%);
}

.access-brand {
  margin-bottom: 28px;
}

.access-box h1 {
  margin: 0 0 10px;
  font-size: 34px;
  line-height: 1.15;
}

.access-copy {
  margin: 0 0 22px;
  color: var(--muted);
}

.local-file-warning {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid #e7c56a;
  border-radius: 8px;
  background: #fff8e5;
}

.local-file-warning[hidden] {
  display: none;
}

.local-file-warning strong,
.local-file-warning span {
  display: block;
}

.local-file-warning span {
  color: #6f5b18;
  line-height: 1.4;
}

.login-form {
  display: grid;
  gap: 14px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.access-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.access-hints strong {
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

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

.access-card {
  min-height: 150px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 18px;
  text-align: left;
  box-shadow: var(--shadow);
}

.access-card:hover {
  border-color: var(--green);
}

.access-card strong,
.access-card span {
  display: block;
}

.access-card strong {
  font-size: 22px;
  margin-bottom: 10px;
}

.access-card span {
  color: var(--muted);
  line-height: 1.35;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfdfc;
  padding: 24px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--green);
  font-weight: 800;
  letter-spacing: 0;
}

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

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.active-profile {
  display: grid;
  gap: 8px;
  margin-bottom: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.active-profile span {
  color: var(--muted);
  font-size: 12px;
}

.active-profile strong {
  font-size: 18px;
}

.filters {
  display: grid;
  gap: 16px;
}

label,
.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

.workspace {
  padding: 24px;
}

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

.topbar p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

.topbar h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.15;
}

.status-pill {
  min-width: 168px;
  border-radius: 999px;
  padding: 10px 14px;
  text-align: center;
  font-weight: 700;
  background: var(--surface-soft);
}

.status-paid {
  color: var(--green-dark);
}

.status-pending {
  color: var(--amber);
}

.status-dispute {
  color: var(--red);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.sindico-home,
.operation-detail {
  margin-bottom: 16px;
}

.home-heading,
.detail-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.home-heading h2,
.detail-heading h2 {
  margin: 0;
  font-size: 24px;
}

.compact-metrics .metric {
  min-height: 86px;
}

.operation-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.operation-card {
  display: grid;
  gap: 12px;
  min-height: 172px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 16px;
  text-align: left;
  box-shadow: var(--shadow);
}

.operation-card.active,
.operation-card:hover {
  border-color: var(--green);
}

.operation-card > span {
  color: var(--muted);
  font-size: 13px;
}

.operation-card strong {
  font-size: 19px;
}

.operation-card dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.operation-card dt {
  color: var(--muted);
  font-size: 12px;
}

.operation-card dd {
  margin: 3px 0 0;
  font-weight: 700;
}

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

.detail-tab {
  appearance: none;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  font-weight: 700;
}

.detail-tab.active {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.s-tab {
  display: none !important;
}

.s-tab.active {
  display: block !important;
}

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

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.metric {
  min-height: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 12px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.15;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(300px, 0.6fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  box-shadow: var(--shadow);
}

.panel-wide {
  min-width: 0;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 18px;
}

.panel-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.panel-actions label {
  display: grid;
  gap: 5px;
  min-width: 150px;
  color: var(--muted);
  font-size: 12px;
}

.panel-actions select {
  min-height: 40px;
}

.primary-button,
.ghost-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  color: #fff;
  background: var(--green);
}

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

.danger-button {
  color: #fff;
  background: var(--red);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled {
  border-color: var(--line);
  color: #819089;
  background: #eef3f0;
  cursor: not-allowed;
  opacity: 1;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tr[data-condo-id] {
  cursor: pointer;
}

tr[data-condo-id]:hover td,
tr.selected-row td {
  background: var(--surface-soft);
}

.empty-state {
  color: var(--muted);
  text-align: center;
}

.sales-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  height: 132px;
  border-bottom: 1px solid var(--line);
  margin: 8px 0 16px;
  padding-top: 10px;
}

.bar {
  display: grid;
  align-items: end;
  gap: 6px;
  height: 100%;
}

.bar-fill {
  border-radius: 8px 8px 0 0;
  background: linear-gradient(180deg, #30a982, var(--green));
  min-height: 12px;
}

.bar span {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 14px;
}

.detail-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 13px;
}

.detail-list dd {
  margin: 5px 0 0;
  font-weight: 700;
}

.muted-detail {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.energy-upload {
  display: grid;
  grid-template-columns: minmax(160px, 0.35fr) 1fr;
  gap: 12px;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 10px;
  font-weight: 700;
  font-size: 12px;
  background: var(--surface-soft);
}

.badge.red {
  color: var(--red);
}

.badge.amber {
  color: var(--amber);
}

.badge.green {
  color: var(--green-dark);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(11, 30, 26, 0.55);
}

.modal.open {
  display: flex;
}

.modal-dialog {
  display: grid;
  grid-template-rows: auto 1fr;
  width: min(980px, 100%);
  height: min(760px, 92vh);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.24);
  overflow: hidden;
}

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

.modal-header p,
.modal-header h2 {
  margin: 0;
}

.modal-header p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.modal-header h2 {
  font-size: 18px;
}

#receiptFrame {
  width: 100%;
  height: 100%;
  border: 0;
  background: #f8faf9;
}

.receipt-fallback {
  align-self: start;
  margin: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 18px;
  color: var(--ink);
  line-height: 1.45;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .access-grid,
  .filters,
  .metrics-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .panel-header,
  .panel-actions,
  .energy-upload,
  .home-heading,
  .detail-heading,
  .operation-grid,
  .summary-list {
    display: grid;
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .panel-actions label {
    min-width: 0;
  }

  .panel {
    overflow-x: hidden;
  }

  th,
  td {
    padding: 9px 6px;
    font-size: 12px;
  }

  th {
    font-size: 10px;
  }

  .sales-chart {
    gap: 8px;
  }

  .modal {
    padding: 10px;
  }

  .modal-dialog {
    height: 94vh;
  }

  .modal-header {
    align-items: flex-start;
  }
}
