:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --text: #1e2329;
  --muted: #66707a;
  --line: #d9dee3;
  --primary: #1f7a5a;
  --primary-dark: #145c43;
  --accent: #d4862a;
  --danger: #b83b36;
  --paid: #edf7ed;
  --unpaid: #fff4df;
  --shadow: 0 10px 30px rgba(20, 32, 46, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  font-size: 16px;
}

.topbar p,
.section-title span,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast {
  transform: translateY(12px);
  opacity: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left-width: 5px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  font-size: 14px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

.toast-success {
  border-left-color: var(--primary);
}

.toast-warning {
  border-left-color: var(--accent);
}

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

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mode-tabs {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f3f5;
}

.mode-tabs[hidden],
.user-menu[hidden] {
  display: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.tab,
.ghost-button,
.primary-button,
.status-button,
.room-card {
  border: 0;
  cursor: pointer;
}

.tab {
  min-width: 84px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 8px rgba(20, 32, 46, 0.08);
}

main {
  padding: 24px 32px 40px;
}

.login-shell {
  min-height: calc(100vh - 140px);
  display: grid;
  place-items: center;
}

.login-shell[hidden] {
  display: none;
}

.login-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.login-form,
.demo-accounts {
  display: grid;
  gap: 12px;
}

.login-role-hint {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.password-reset-box {
  margin-top: 4px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.password-reset-box summary {
  cursor: pointer;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

.password-reset-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  margin-top: 10px;
}

.password-reset-grid input[name="changePhone"],
.password-reset-grid input[name="oldPassword"],
.password-reset-grid input[name="newPassword"],
.password-reset-grid input[name="confirmPassword"] {
  grid-column: 1 / -1;
}

.password-reset-grid input,
.password-reset-grid select {
  min-height: 38px;
}

.account-apply-content {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin-top: 12px;
}

.account-apply-content img {
  width: 150px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.account-apply-steps {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.account-apply-steps strong {
  color: var(--text);
  font-size: 14px;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

.demo-accounts {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.landlord-page-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.landlord-page {
  display: none;
}

.landlord-page.active.landlord-page-rooms {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
  height: calc(100dvh - 300px);
  min-height: 360px;
  overflow: hidden;
}

.landlord-page.active.landlord-page-rooms > .sidebar,
.landlord-page.active.landlord-page-rooms > .content-grid {
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 28px;
}

.landlord-page.active.landlord-page-rooms > .content-grid {
  align-content: start;
  padding-right: 4px;
  padding-bottom: 28px;
}

.landlord-page.active.landlord-page-rooms > .sidebar {
  padding-bottom: 14px;
}

.landlord-page.active.landlord-page-bills {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 20px;
}

.landlord-page.active.landlord-page-quick-reading {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.landlord-page.active.landlord-page-mobile-reading {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.room-search-field {
  margin-bottom: 10px;
}

.mobile-reading-picker,
.admin-key-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.admin-key-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

body.mobile-landlord-mode .metrics,
body.mobile-landlord-mode .landlord-page-tabs {
  display: none;
}

.mobile-card-form,
.admin-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
}

.landlord-page-mobile-reading .mobile-card-form {
  grid-template-columns: 1fr;
  gap: 14px;
}

.landlord-page-mobile-reading .mobile-card-form label {
  font-size: 15px;
  font-weight: 700;
}

.landlord-page-mobile-reading .mobile-card-form input,
.landlord-page-mobile-reading .mobile-card-form select {
  min-height: 54px;
  margin-top: 7px;
  padding: 0 14px;
  border-radius: 8px;
  font-size: 20px;
  font-weight: 700;
}

.landlord-page-mobile-reading .mobile-card-form label span {
  margin-top: 7px;
  font-size: 13px;
  font-weight: 500;
}

.mobile-card-form strong {
  grid-column: 1 / -1;
}

.mobile-card-form label span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.admin-form {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  margin-bottom: 12px;
}

.admin-form button {
  min-width: 96px;
}

.admin-toolbar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 180px;
  gap: 12px;
  margin-bottom: 12px;
}

.small-muted {
  color: #64748b;
  font-size: 12px;
  margin-left: 4px;
}

.tag-ok,
.tag-error {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.tag-ok {
  color: #166534;
  background: #dcfce7;
}

.tag-error {
  color: #b91c1c;
  background: #fee2e2;
}

.admin-portal-main,
.admin-portal-tenants {
  margin-top: 18px;
}

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

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

.metric strong {
  font-size: 24px;
}

.plan-metric {
  display: grid;
  gap: 6px;
  align-content: start;
}

.plan-metric strong {
  font-size: 18px;
  line-height: 1.35;
}

.quota-notice {
  margin: -6px 0 16px;
  padding: 10px 12px;
  border: 1px solid #f2c76b;
  border-radius: 8px;
  background: #fff8e8;
  color: #7a4a00;
  font-size: 14px;
  line-height: 1.6;
}

.quota-notice.danger {
  border-color: #f0a39a;
  background: #fff4f2;
  color: #8b1e12;
}

.metric-action {
  min-height: 34px;
  padding: 0 12px;
  justify-self: start;
}

.renew-plan-summary {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.renew-plan-summary strong {
  font-size: 18px;
}

.renew-plan-summary span,
.renew-plan-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.renew-payment-qr {
  width: min(340px, 100%);
  display: block;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 12px;
}

.mini-metric {
  min-height: 74px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.mini-metric strong {
  font-size: 20px;
}

.workspace,
.tenant-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

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

.sidebar {
  padding: 14px;
  position: sticky;
  top: 104px;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 20px;
}

.panel {
  padding: 18px;
}

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

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 32px;
  margin-bottom: 14px;
}

.bill-section-title {
  align-items: flex-start;
}

.period-pills {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 4px;
}

.room-bill-tools {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: auto minmax(240px, 1fr);
  align-items: start;
  gap: 8px;
}

.room-bill-tools .period-pills {
  width: 100%;
}

.period-select-field {
  min-width: 180px;
}

.period-select-field span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.period-filter-header {
  display: grid;
  gap: 6px;
}

.period-filter-header > span {
  color: var(--muted);
  font-size: 12px;
}

.period-filter-header > div,
.period-month-scroll {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.period-month-scroll {
  max-height: 92px;
  overflow-y: auto;
}

.period-filter-header button,
.period-month-scroll button {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
}

.period-filter-header button.active,
.period-month-scroll button.active {
  border-color: var(--primary);
  background: var(--surface-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

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

.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-size: 18px;
  line-height: 1;
}

.room-list {
  display: grid;
  gap: 10px;
  padding-bottom: 14px;
}

.room-group {
  display: grid;
  gap: 8px;
}

.room-group-heading-row {
  display: block;
}

.room-group-heading-row.has-add-button {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 52px;
  gap: 6px;
  align-items: center;
}

.room-group-heading {
  width: 100%;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: #eef1f4;
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.room-group-add-button {
  width: 52px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.room-group-add-button:hover {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.room-group-heading strong {
  min-width: 24px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.room-group.level-2 {
  margin-left: 10px;
}

.room-group.level-3 {
  margin-left: 18px;
}

.room-group.level-2 > .room-group-heading {
  background: #f5f7f8;
}

.room-group.level-3 > .room-group-heading {
  background: transparent;
  border: 1px dashed var(--line);
}

.room-card {
  width: 100%;
  min-height: 74px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.room-card.selectable {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.room-card.selected {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.room-card-select {
  display: grid;
  place-items: center;
}

.room-card-select input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.room-card-main {
  display: grid;
  gap: 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.room-card-main strong {
  font-size: 15px;
}

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

.room-card-share {
  min-width: 48px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.share-selected-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
}

.share-selected-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.room-card-share:hover {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.room-card.active {
  border-color: var(--primary);
  background: var(--surface-soft);
}

.sidebar-room-form {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.sidebar-room-form[hidden] {
  display: none;
}

.building-name-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(100px, 0.55fr);
  gap: 8px;
}

.sidebar-form-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input[type="number"] {
  appearance: textfield;
  -moz-appearance: textfield;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.14);
}

textarea {
  resize: vertical;
}

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

.listing-form {
  margin-bottom: 8px;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  align-items: end;
}

.listing-form .span-2 {
  grid-column: 1 / -1;
}

.listing-title-field {
  grid-column: span 2;
}

.listing-save-button {
  min-width: 140px;
  margin-top: 10px;
}

.share-link {
  color: var(--primary-dark);
  font-weight: 600;
  text-decoration: none;
}

.inline-copy-button {
  min-height: 28px;
  margin-left: 8px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.photo-upload-form {
  margin-top: 10px;
}

.photo-grid {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.photo-grid-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.photo-bulk-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.photo-bulk-toolbar span {
  margin-right: auto;
  color: var(--muted);
  font-size: 13px;
}

.photo-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.photo-select {
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 1;
  display: block;
  width: 20px;
  height: 20px;
}

.photo-select input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
  filter: drop-shadow(0 1px 4px rgba(20, 32, 46, 0.25));
}

.photo-card[draggable="true"] {
  cursor: grab;
}

.photo-card.cover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(31, 122, 90, 0.12);
}

.photo-card.selected {
  border-color: var(--accent);
  background: #fff8ed;
  box-shadow: 0 0 0 3px rgba(212, 134, 42, 0.2);
}

.photo-card.selected img {
  filter: saturate(1.04) contrast(1.02);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef1f4;
}

.photo-card-footer {
  min-height: 48px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.photo-caption-field {
  grid-column: 1 / -1;
  min-width: 0;
}

.photo-action-button,
.photo-delete-button {
  min-height: 30px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.photo-action-button {
  background: var(--surface-soft);
  color: var(--primary-dark);
}

.photo-action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.photo-delete-button {
  background: #fff0ef;
  color: var(--danger);
}

.primary-button {
  min-height: 42px;
  align-self: end;
  padding: 0 16px;
  color: #fff;
  background: var(--primary);
  border-radius: 6px;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.period-select-button {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfd;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.period-picker {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.previous-reading-hint {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.room-info-actions {
  display: grid;
  grid-template-columns: minmax(132px, 1.35fr) minmax(74px, 0.8fr) minmax(96px, 1fr);
  gap: 12px;
  align-self: end;
}

.room-info-actions button {
  width: 100%;
  white-space: nowrap;
}

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

.landlord-page-mobile-reading .mobile-reading-actions button {
  min-height: 56px;
  border-radius: 8px;
  font-size: 17px;
  font-weight: 800;
}

.reading-import-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.room-import-tools {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin: 12px 0;
}

.reading-import-tools .ghost-button,
.room-import-tools .ghost-button,
.file-import-button {
  width: auto;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--primary-dark);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.file-import-button {
  position: relative;
  overflow: hidden;
}

.file-import-button input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

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

.quick-reading-toolbar {
  display: grid;
  grid-template-columns: minmax(130px, 160px) minmax(150px, 190px) minmax(130px, 170px) minmax(220px, 1fr) repeat(3, max-content);
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.quick-reading-toolbar label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.quick-reading-table table {
  table-layout: fixed;
  min-width: 1080px;
}

.quick-reading-table th:first-child,
.quick-reading-table td:first-child {
  width: 140px;
}

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

.quick-reading-table th:nth-child(3),
.quick-reading-table td:nth-child(3),
.quick-reading-table th:nth-child(4),
.quick-reading-table td:nth-child(4),
.quick-reading-table th:nth-child(5),
.quick-reading-table td:nth-child(5) {
  width: 160px;
}

.quick-reading-table th:nth-child(6),
.quick-reading-table td:nth-child(6) {
  width: 250px;
}

.quick-reading-table th:nth-child(7),
.quick-reading-table td:nth-child(7) {
  width: 90px;
  text-align: center;
}

.quick-reading-table td:first-child strong,
.quick-reading-table td:first-child span {
  display: block;
}

.quick-reading-table td:first-child span,
.quick-reading-table small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: nowrap;
}

.quick-reading-input-cell {
  display: grid;
  grid-template-rows: 36px 18px;
  gap: 8px;
  align-items: start;
}

.quick-reading-table input {
  width: 136px;
  min-width: 0;
  height: 36px;
  padding: 0 8px;
}

.quick-reading-table [data-quick-field="otherAmountNote"] {
  width: 230px;
}

.quick-reading-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

.quick-reading-actions .primary-button,
.quick-reading-actions .ghost-button {
  min-width: 160px;
}

.manual-utility-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(160px, 1fr));
  gap: 14px;
}

.manual-utility-fields[hidden] {
  display: none;
}

.danger-button {
  min-height: 42px;
  height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: #fff0ef;
  color: var(--danger);
  cursor: pointer;
  font: inherit;
}

.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.ghost-button {
  min-height: 32px;
  padding: 0 10px;
  background: #f1f3f5;
  color: var(--muted);
  border-radius: 6px;
}

.ghost-button.active {
  background: #1f7a5a;
  color: #fff;
}

.unpaid-button {
  min-height: 32px;
  margin-right: 6px;
  padding: 0 10px;
  border: 1px solid #d7a84f;
  border-radius: 6px;
  background: #fff8e8;
  color: #8a560c;
  cursor: pointer;
  font: inherit;
}

.hint {
  min-height: 20px;
  margin-top: 12px;
}

.table {
  overflow-x: auto;
}

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

th,
td {
  position: relative;
  height: 48px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  background: #fbfcfd;
}

.amount {
  font-weight: 700;
}

.other-amount-cell {
  position: relative;
}

.instant-note-tooltip {
  position: absolute;
  left: 10px;
  bottom: calc(100% - 2px);
  z-index: 20;
  display: none;
  max-width: 260px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #1e2329;
  color: #fff;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  white-space: normal;
}

.other-amount-cell:hover .instant-note-tooltip,
.other-amount-cell:focus-within .instant-note-tooltip {
  display: block;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 58px;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 13px;
}

.badge.paid {
  color: var(--primary-dark);
  background: var(--paid);
}

.badge.issued {
  color: #8a560c;
  background: var(--unpaid);
}

.status-button {
  min-height: 32px;
  margin-right: 6px;
  padding: 0 10px;
  color: var(--primary-dark);
  background: var(--surface-soft);
  border-radius: 6px;
}

.danger-small-button {
  min-height: 32px;
  margin-right: 6px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  box-shadow: none;
  background: #fff0ef;
  color: var(--danger);
  font: inherit;
}

.danger-small-button:hover,
.danger-small-button:focus {
  box-shadow: none;
}

.bill-table-toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

.bill-table-filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.table-filter {
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.table-filter legend,
.bill-batch-actions span {
  color: var(--muted);
  font-size: 12px;
}

.table-filter legend {
  padding: 0 4px;
}

.table-filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.filter-check {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}

.filter-check span {
  font-size: 13px;
  color: var(--text);
}

.filter-check input,
.bill-select-checkbox {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.bill-batch-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.bill-batch-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(20, 32, 46, 0.38);
}

.modal-panel {
  width: min(560px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.compact-modal-panel {
  width: min(460px, 100%);
}

.modal-panel textarea {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.compact-modal-panel textarea {
  min-height: 150px;
}

.import-result-panel {
  width: min(1180px, calc(100vw - 32px));
}

.import-result-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.import-result-summary span {
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  font-size: 13px;
}

.import-result-table {
  max-height: min(62vh, 620px);
  overflow: auto;
}

.import-row-error td {
  background: #fff7f6;
}

.bill-share-canvas,
.bill-share-image {
  width: 100%;
  height: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.bill-share-image {
  display: block;
  user-select: auto;
  -webkit-user-select: auto;
  -webkit-touch-callout: default;
}

.modal-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  margin-top: 12px;
}

.modal-actions-top {
  margin-top: 0;
  margin-bottom: 12px;
}

.ghost-link-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}

.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.link-button:hover {
  text-decoration: underline;
}

.full-select {
  margin-bottom: 14px;
}

.tenant-profile {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 8px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.tenant-profile strong {
  color: var(--text);
  font-size: 18px;
}

.tenant-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.tenant-summary-grid div,
.tenant-room-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.tenant-summary-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.tenant-summary-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
}

.tenant-room-list {
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.tenant-room-card {
  display: grid;
  gap: 7px;
}

.tenant-room-card > strong {
  font-size: 15px;
}

.tenant-room-card > span {
  color: var(--muted);
}

.tenant-room-facts {
  display: grid;
  gap: 8px;
  margin: 6px 0 0;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.tenant-room-facts div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
}

.tenant-room-facts dt {
  color: var(--muted);
  font-size: 12px;
}

.tenant-room-facts dd {
  margin: 0;
  color: var(--text);
  font-weight: 600;
}

.tenant-area-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tenant-area-chips span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
}

.bill-cards {
  display: grid;
  gap: 12px;
}

.bill-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.bill-card dl {
  display: grid;
  grid-template-columns: repeat(4, minmax(86px, 1fr));
  gap: 8px;
  margin: 0;
}

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

.bill-card dd {
  margin: 2px 0 0;
  font-weight: 600;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.share-view {
  display: block;
}

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

.share-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
}

.share-state {
  width: min(520px, 100%);
  margin: 120px auto 0;
  display: grid;
  gap: 8px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.share-state strong {
  font-size: 18px;
}

.share-state span {
  color: var(--muted);
  font-size: 14px;
}

.public-listing {
  display: grid;
  gap: 18px;
}

.public-hero {
  display: grid;
  grid-template-columns: minmax(360px, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: stretch;
}

.public-cover,
.public-main,
.public-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.public-cover {
  overflow: hidden;
  min-height: 460px;
}

.public-cover img,
.photo-placeholder {
  width: 100%;
  height: 100%;
  min-height: 460px;
}

.public-cover img {
  display: block;
  object-fit: cover;
}

.photo-placeholder {
  display: grid;
  place-items: center;
  color: var(--muted);
  background: #eef1f4;
}

.public-main {
  display: grid;
  align-content: start;
  gap: 18px;
  padding: 28px;
}

.public-eyebrow {
  color: var(--muted);
  font-size: 14px;
}

.public-main h2 {
  font-size: 30px;
  line-height: 1.25;
}

.public-price {
  color: var(--primary-dark);
  font-size: 34px;
  font-weight: 800;
}

.public-price span {
  margin-left: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
}

.public-facts {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}

.public-facts div {
  min-height: 68px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

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

.public-facts dd {
  margin: 6px 0 0;
  font-size: 17px;
  font-weight: 700;
}

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

.public-section {
  padding: 22px;
}

.public-section h3 {
  margin: 0 0 12px;
  font-size: 17px;
}

.public-description {
  color: #3c444c;
  line-height: 1.8;
}

.area-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.area-chips span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 6px;
  background: #fbfcfd;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.public-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.public-thumbs button {
  overflow: hidden;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: #eef1f4;
  cursor: pointer;
}

.public-thumbs button.active {
  border-color: var(--primary);
}

.public-thumbs img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.public-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.public-photo-grid figure {
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.public-photo-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #eef1f4;
}

.public-photo-grid figcaption {
  min-height: 38px;
  padding: 9px 10px;
  color: var(--muted);
  font-size: 13px;
}

.share-empty {
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 980px) {
  .metrics,
  .workspace,
  .tenant-layout,
  .public-hero,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .landlord-page.active.landlord-page-rooms {
    height: auto;
    min-height: 0;
    overflow: visible;
  }

  .landlord-page.active.landlord-page-rooms > .sidebar,
  .landlord-page.active.landlord-page-rooms > .content-grid {
    max-height: none;
    overflow-y: visible;
  }

  .bill-table-filters {
    grid-template-columns: repeat(2, minmax(150px, 1fr));
  }

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

  .mobile-reading-picker,
  .mobile-card-form,
  .admin-key-row,
  .admin-form,
  .admin-toolbar {
    grid-template-columns: 1fr;
  }

  .quick-reading-toolbar button,
  .quick-reading-toolbar label {
    min-width: 0;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

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

  .bill-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .period-pills {
    justify-content: flex-start;
  }

  main {
    padding: 16px;
  }

  .metrics,
  .form-grid,
  .bill-table-filters,
  .room-bill-tools {
    grid-template-columns: 1fr;
  }

  .bill-card,
  .bill-card dl {
    grid-template-columns: 1fr;
  }

  .span-2,
  .public-section {
    grid-column: auto;
  }

  .public-cover,
  .public-cover img,
  .photo-placeholder {
    min-height: 280px;
  }

  .public-main {
    padding: 20px;
  }

  .public-main h2 {
    font-size: 24px;
  }

  .public-price {
    font-size: 28px;
  }

  .public-facts {
    grid-template-columns: 1fr;
  }

  .public-actions .primary-button {
    width: 100%;
  }
}
