.tool-tabs {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.rent-view[hidden] {
  display: none;
}

.rent-view {
  min-width: 0;
}

.rent-page-heading .button-row {
  flex-wrap: wrap;
}

.rent-language-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, 34px);
  width: max-content;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel-soft);
  padding: 3px;
}

.rent-language-switch button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  padding: 4px;
  font-size: 0.76rem;
}

.rent-language-switch button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(26, 36, 31, 0.12);
}

.rent-share-band {
  display: grid;
  grid-template-columns: minmax(180px, 0.55fr) minmax(0, 1.45fr);
  gap: 18px;
  border-block: 1px solid var(--line);
  background: var(--panel-soft);
  margin: 12px 0 4px;
  padding: 14px;
  align-items: center;
}

.rent-share-band p {
  color: var(--muted);
  font-size: 0.78rem;
  margin: 4px 0 0;
}

.rent-share-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 8px;
}

.rent-page-heading h1,
.rent-history-section h2,
.rent-month-panel h2,
.rent-entry-panel h3 {
  margin: 0;
}

.rent-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  margin: 0 0 10px;
}

.rent-summary-item {
  min-width: 0;
  border-right: 1px solid var(--line);
  padding: 16px 18px;
}

.rent-summary-item:last-child {
  border-right: 0;
}

.rent-summary-item span,
.rent-due-preview span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.rent-summary-item strong {
  display: block;
  margin-top: 5px;
  font-size: 1.45rem;
  overflow-wrap: anywhere;
}

.rent-summary-item.balance-due strong {
  color: var(--danger);
}

.rent-summary-item.balance-credit strong {
  color: var(--success);
}

.rent-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(300px, 0.75fr);
  gap: 24px;
  border-bottom: 1px solid var(--line);
  margin-top: 8px;
  padding: 18px 0 24px;
}

.rent-month-panel,
.rent-entry-panel {
  min-width: 0;
}

.rent-entry-panel {
  border-left: 1px solid var(--line);
  padding-left: 24px;
}

.rent-period-field {
  width: 160px;
}

.rent-fixed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr)) minmax(150px, 0.7fr);
  gap: 10px;
  align-items: end;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.rent-due-preview {
  min-height: 42px;
  border-left: 3px solid var(--accent);
  padding: 4px 0 4px 12px;
}

.rent-due-preview strong {
  display: block;
  margin-top: 3px;
  font-size: 1.12rem;
}

.rent-utility-labels,
.rent-utility-row {
  display: grid;
  grid-template-columns: minmax(130px, 1.2fr) 105px 105px 85px 120px 105px 112px;
  gap: 8px;
  align-items: center;
}

.rent-utility-labels {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 17px 9px 7px;
}

.rent-utility-list {
  display: grid;
  border-top: 1px solid var(--line);
}

.rent-utility-row {
  --utility-color: var(--accent);
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
}

.rent-utility-row[data-utility-id="electricity"] {
  --utility-color: #b77900;
}

.rent-utility-row[data-utility-id="water"] {
  --utility-color: #1976a3;
}

.rent-utility-row[data-utility-id="gas"] {
  --utility-color: #b8462d;
}

.rent-utility-name {
  min-width: 0;
  border-left: 3px solid var(--utility-color);
  padding-left: 9px;
}

.rent-utility-name strong,
.rent-utility-name small {
  display: block;
  overflow-wrap: anywhere;
}

.rent-utility-name small,
.rent-utility-usage small,
.rent-utility-amount small {
  color: var(--muted);
  font-size: 0.72rem;
}

.rent-utility-row input {
  min-width: 0;
  padding-inline: 9px;
}

.rent-utility-field > span {
  display: none;
}

.rent-utility-rates {
  display: grid;
  gap: 5px;
}

.rent-utility-rates label {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
}

.rent-utility-rates label > span {
  display: block;
  margin: 0;
  font-size: 0.64rem;
}

.rent-utility-rates input {
  min-height: 34px;
  padding-block: 6px;
  font-size: 0.78rem;
}

.rent-utility-usage,
.rent-utility-amount {
  min-width: 0;
}

.rent-utility-usage strong,
.rent-utility-amount strong {
  display: block;
  overflow-wrap: anywhere;
}

.rent-photo-control {
  display: grid;
  gap: 5px;
}

.rent-reading-recorded {
  display: flex;
  gap: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  align-items: center;
  justify-content: center;
}

.rent-reading-recorded input {
  width: 15px;
  min-height: 15px;
  margin: 0;
}

.rent-photo-button {
  display: grid;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.75rem;
  font-weight: 800;
  place-items: center;
  text-align: center;
}

.rent-photo-button:hover {
  background: var(--panel-soft);
}

.rent-photo-link {
  color: var(--accent-dark);
  font-size: 0.7rem;
  font-weight: 750;
  text-align: center;
}

.rent-notes-field {
  margin-top: 16px;
}

.rent-month-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.rent-entry-form {
  display: grid;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.rent-entry-form + .rent-entry-form {
  margin-top: 18px;
}

.rent-entry-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.rent-entry-fields .wide-field {
  grid-column: 1 / -1;
}

.rent-entry-manager {
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}

.rent-entry-manager summary {
  display: flex;
  min-height: 42px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  align-items: center;
  justify-content: space-between;
}

.rent-entry-manager summary small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.rent-entry-manager[open] summary {
  border-bottom: 1px solid var(--line);
}

#rentEntryList {
  display: grid;
}

.rent-entry-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 36px;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
  align-items: center;
}

.rent-entry-copy {
  min-width: 0;
}

.rent-entry-copy strong,
.rent-entry-copy small {
  display: block;
  overflow-wrap: anywhere;
}

.rent-entry-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 2px;
}

.rent-entry-amount {
  font-weight: 850;
  white-space: nowrap;
}

.rent-entry-row[data-kind="payment"] .rent-entry-amount,
.rent-entry-row[data-kind="credit"] .rent-entry-amount {
  color: var(--success);
}

.rent-entry-row[data-kind="charge"] .rent-entry-amount {
  color: var(--danger);
}

.rent-history-section {
  padding-top: 22px;
}

.rent-usage-section {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 22px;
}

.rent-usage-heading h2 {
  margin: 0;
}

.rent-chart-range {
  width: 150px;
}

.rent-usage-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.rent-usage-tabs button {
  min-width: 120px;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
}

.rent-usage-tabs button:hover,
.rent-usage-tabs button.active {
  border-bottom-color: var(--accent);
  background: var(--panel-soft);
  color: var(--ink);
}

.rent-chart-wrap {
  position: relative;
  width: 100%;
  height: 350px;
  padding: 18px 4px 4px;
}

.rent-usage-section > .small-note {
  min-height: 18px;
  margin: 8px 0 0;
}

.rent-shared-shell {
  width: min(1260px, calc(100% - 28px));
  margin: 18px auto 40px;
}

.rent-shared-heading {
  display: flex;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  padding: 8px 0 18px;
  align-items: center;
  justify-content: space-between;
}

.rent-shared-heading h1 {
  margin-top: 3px;
}

.rent-shared-detail td {
  background: var(--panel-soft);
  padding: 0 14px 14px;
}

.rent-shared-detail p {
  color: var(--muted);
  margin: 8px 0 0;
}

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

.rent-shared-utility {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  border-left: 3px solid var(--utility-color, var(--accent));
  padding: 10px 12px;
}

.rent-shared-utility[data-utility-id="electricity"] { --utility-color: #b77900; }
.rent-shared-utility[data-utility-id="water"] { --utility-color: #1976a3; }
.rent-shared-utility[data-utility-id="gas"] { --utility-color: #b8462d; }

.rent-shared-utility strong,
.rent-shared-utility span:first-of-type {
  grid-column: 1 / -1;
}

.rent-shared-utility span,
.rent-shared-utility a {
  color: var(--muted);
  font-size: 0.74rem;
}

.rent-shared-utility a {
  color: var(--accent-dark);
  font-weight: 750;
  text-align: right;
}

.rent-history-wrap {
  max-height: 560px;
  border-block: 1px solid var(--line);
  overflow: auto;
}

.rent-mobile-history {
  display: none;
}

.rent-history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.rent-history-table th,
.rent-history-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 9px;
  text-align: right;
  white-space: nowrap;
}

.rent-history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 0.72rem;
}

.rent-history-table th:first-child,
.rent-history-table td:first-child {
  text-align: left;
}

.rent-history-row {
  cursor: pointer;
}

.rent-history-row:hover,
.rent-history-row.active {
  background: var(--accent-soft);
}

.rent-balance-positive {
  color: var(--danger);
  font-weight: 850;
}

.rent-balance-negative {
  color: var(--success);
  font-weight: 850;
}

.rent-settings-dialog {
  width: min(760px, calc(100% - 28px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
}

.rent-settings-dialog::backdrop {
  background: rgba(24, 31, 27, 0.5);
}

.rent-settings-dialog form {
  display: grid;
  gap: 18px;
  padding: 22px;
}

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

.rent-settings-grid .wide-field {
  grid-column: 1 / -1;
}

.rent-utility-settings {
  display: grid;
  border-top: 1px solid var(--line);
}

.rent-utility-setting-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 110px 140px 140px;
  gap: 9px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  align-items: end;
}

@media (max-width: 1040px) {
  .rent-workspace {
    grid-template-columns: 1fr;
  }

  .rent-entry-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    border-top: 1px solid var(--line);
    border-left: 0;
    padding-top: 20px;
    padding-left: 0;
  }

  .rent-entry-form + .rent-entry-form {
    margin-top: 0;
  }

  .rent-entry-manager {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .rent-share-band {
    grid-template-columns: 1fr;
  }

  .rent-share-actions {
    grid-template-columns: minmax(0, 1fr) repeat(3, auto);
  }

  .rent-utility-labels {
    display: none;
  }

  .rent-utility-list {
    gap: 10px;
    border-top: 0;
    margin-top: 15px;
  }

  .rent-utility-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    border: 1px solid var(--line);
    border-radius: 7px;
    padding: 12px;
  }

  .rent-utility-name,
  .rent-photo-control {
    grid-column: 1 / -1;
  }

  .rent-utility-field > span {
    display: block;
    margin-bottom: 4px;
    font-size: 0.7rem;
  }

  .rent-photo-control {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }
}

@media (max-width: 760px) {
  #rentSharedView .rent-history-wrap {
    display: none;
  }

  .rent-mobile-history {
    display: grid;
    max-height: min(72vh, 680px);
    gap: 8px;
    border-block: 1px solid var(--line);
    padding: 8px 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .rent-mobile-month {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
  }

  .rent-mobile-month-heading {
    display: grid;
    width: 100%;
    min-height: 58px;
    grid-template-columns: minmax(0, 1fr) auto 26px;
    gap: 10px;
    border-radius: 0;
    background: #fff;
    color: var(--ink);
    padding: 10px 12px;
    text-align: left;
    align-items: center;
  }

  .rent-mobile-month-heading:hover {
    background: var(--panel-soft);
  }

  .rent-mobile-month-title {
    min-width: 0;
    font-weight: 850;
    overflow-wrap: anywhere;
  }

  .rent-mobile-balance {
    display: grid;
    min-width: 0;
    text-align: right;
  }

  .rent-mobile-balance small {
    color: var(--muted);
    font-size: 0.67rem;
  }

  .rent-mobile-balance strong {
    font-size: 0.86rem;
    white-space: nowrap;
  }

  .rent-mobile-chevron {
    font-size: 1.2rem;
    text-align: center;
    transition: transform 180ms ease;
  }

  .rent-mobile-month.expanded .rent-mobile-chevron {
    transform: rotate(180deg);
  }

  .rent-mobile-month-summary,
  .rent-mobile-costs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    border-top: 1px solid var(--line);
  }

  .rent-mobile-month-summary > span,
  .rent-mobile-costs > span {
    min-width: 0;
    border-right: 1px solid var(--line);
    padding: 9px 8px;
  }

  .rent-mobile-month-summary > span:last-child,
  .rent-mobile-costs > span:last-child {
    border-right: 0;
  }

  .rent-mobile-month-summary small,
  .rent-mobile-costs small {
    display: block;
    color: var(--muted);
    font-size: 0.65rem;
    font-weight: 750;
  }

  .rent-mobile-month-summary strong,
  .rent-mobile-costs strong {
    display: block;
    margin-top: 3px;
    font-size: 0.74rem;
    overflow-wrap: anywhere;
  }

  .rent-mobile-month-details {
    border-top: 1px solid var(--line);
    background: var(--panel-soft);
    padding: 12px;
  }

  .rent-mobile-month-details > .eyebrow {
    margin-bottom: 8px;
  }

  .rent-mobile-month-details .rent-mobile-costs {
    border: 1px solid var(--line);
    margin-bottom: 10px;
    background: #fff;
  }

  .rent-mobile-month-details .rent-shared-utilities {
    grid-template-columns: 1fr;
  }

  .rent-mobile-month-details .rent-shared-utility {
    background: #fff;
  }

  .rent-shared-note {
    color: var(--muted);
    margin: 8px 0 0;
    font-size: 0.76rem;
  }
}

@media (max-width: 640px) {
  .admin-app-nav {
    overflow-x: auto;
  }

  .tool-tabs {
    grid-template-columns: repeat(5, minmax(60px, 1fr));
  }

  .rent-page-heading,
  .rent-month-panel .section-head,
  .rent-usage-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .rent-page-heading .button-row {
    width: 100%;
  }

  .rent-page-heading .button-row > button {
    flex: 1 1 120px;
  }

  .rent-period-field {
    width: 100%;
  }

  .rent-shared-shell {
    width: calc(100% - 16px);
    margin-top: 8px;
  }

  .rent-share-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .rent-share-actions input {
    grid-column: 1 / -1;
  }

  .rent-shared-utilities {
    grid-template-columns: 1fr;
  }

  .rent-chart-range {
    width: 100%;
  }

  .rent-chart-wrap {
    height: 300px;
  }

  .rent-summary {
    grid-template-columns: 1fr;
  }

  .rent-summary-item,
  .rent-summary-item:last-child {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .rent-summary-item:last-child {
    border-bottom: 0;
  }

  .rent-fixed-grid,
  .rent-entry-panel,
  .rent-settings-grid,
  .rent-entry-fields {
    grid-template-columns: 1fr;
  }

  .rent-due-preview,
  .rent-entry-fields .wide-field,
  .rent-settings-grid .wide-field,
  .rent-entry-manager {
    grid-column: auto;
  }

  .rent-utility-setting-row {
    grid-template-columns: 1fr 1fr;
  }

  .rent-utility-setting-row label:first-child {
    grid-column: 1 / -1;
  }

  .rent-month-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
