:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #60706b;
  --line: #dbe4e0;
  --paper: #f6f8f5;
  --panel: #ffffff;
  --green: #136f52;
  --green-dark: #0f4f3d;
  --aqua: #dff3ee;
  --amber: #f3c969;
  --rose: #e87878;
  --blue: #4b83c4;
  --shadow: 0 12px 30px rgba(23, 33, 31, 0.08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Microsoft JhengHei", "Noto Sans TC", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(19,111,82,.08), transparent 34%),
    linear-gradient(315deg, rgba(75,131,196,.10), transparent 38%),
    var(--paper);
}

body[data-app="resident"] {
  background-color: #f6f8f5;
  background-image: linear-gradient(180deg, rgba(246, 248, 245, .86), rgba(223, 243, 238, .24)), url("assets/app-bg.svg");
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
}
body[data-app="admin"] {
  background:
    linear-gradient(135deg, rgba(19,111,82,.08), transparent 34%),
    linear-gradient(315deg, rgba(75,131,196,.10), transparent 38%),
    var(--paper);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
}
.side-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand-block, .resident-card {
  display: flex;
  align-items: center;
  gap: 12px;
}
.app-icon {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  box-shadow: 0 8px 18px rgba(127, 90, 58, 0.18);
}
.brand-mark, .avatar {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #fff;
  background: var(--green);
}
.brand-mark.admin { background: #365f86; }
.brand-title { font-size: 20px; font-weight: 800; }
.brand-subtitle, .muted { color: var(--muted); font-size: 13px; }
.resident-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.avatar { background: #365f86; }
.resident-name { font-weight: 700; }
.side-nav { display: grid; gap: 8px; }
.nav-btn {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  color: var(--muted);
  background: transparent;
}
.nav-btn:hover, .nav-btn.active {
  color: var(--ink);
  background: var(--aqua);
}
.admin-link {
  margin-top: auto;
  color: var(--green-dark);
  text-decoration: none;
  font-weight: 700;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.main-panel { padding: 28px; min-width: 0; }
body[data-app="resident"] .main-panel {
  background: rgba(246, 248, 245, 0.46);
  backdrop-filter: blur(2px);
}

body.login-locked .app-shell {
  display: block;
  min-height: 100vh;
}

body.login-locked .side-panel,
body.login-locked .view,
body.login-locked .modal-backdrop {
  display: none !important;
}

body.login-locked .main-panel {
  min-height: 100vh;
  padding: clamp(20px, 5vw, 56px);
  display: grid;
  align-content: start;
  gap: 18px;
  background:
    linear-gradient(135deg, rgba(255, 247, 232, 0.9), rgba(232, 246, 239, 0.92)),
    rgba(246, 248, 245, 0.92);
}

body.login-locked .login-strip,
body.login-locked .review-panel {
  width: min(100%, 980px);
  margin-inline: auto;
}

body.login-locked .login-strip {
  margin-top: clamp(18px, 7vh, 72px);
}

.login-strip, .review-panel, .work-panel, .summary-card, .feature-tile, .upload-zone {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.login-strip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px;
  margin-bottom: 22px;
}
h1, h2, h3, p { margin-top: 0; }
h1, h2 { margin-bottom: 4px; }
p { color: var(--muted); }
.login-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.line-btn, .primary-btn, .secondary-btn, .ghost-btn, .icon-btn {
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 10px 14px;
  font-weight: 700;
}
.line-btn { color: #fff; background: #06c755; }
.primary-btn, .secondary-btn, .ghost-btn, .admin-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.primary-btn { color: #fff; background: var(--green); }
.secondary-btn { color: var(--green-dark); background: var(--aqua); border-color: #b9ddd4; }
.ghost-btn, .icon-btn { background: #fff; border-color: var(--line); color: var(--ink); }
.icon-btn { width: 36px; height: 36px; padding: 0; font-size: 22px; }
.review-panel { padding: 18px; margin-bottom: 22px; }
.panel-head, .page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.inline-form {
  display: grid;
  grid-template-columns: 1fr 1fr auto auto;
  gap: 12px;
  align-items: end;
}

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

.login-verify-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.login-verify-actions .primary-btn,
.login-verify-actions .secondary-btn {
  min-height: 44px;
}

label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
}
.status-note { margin-top: 12px; color: var(--green-dark); font-weight: 700; }
.file-help {
  margin-top: -4px;
  color: var(--muted);
  font-size: 12px;
}
.attachment-preview,
.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 7px 10px;
  border: 1px solid rgba(30, 67, 55, 0.16);
  border-radius: 8px;
  background: rgba(229, 245, 238, 0.9);
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  word-break: break-word;
}
.file-chip small {
  color: var(--muted);
  font-weight: 700;
}
.file-chip.invalid,
.file-chip.pending {
  background: rgba(255, 243, 212, 0.92);
  color: #865d09;
}
.view { display: none; }
.view.active { display: block; }
.eyebrow {
  margin-bottom: 6px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}
.today-card {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}
.feature-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin: 20px 0;
}
.feature-tile {
  min-height: 150px;
  padding: 18px;
  text-align: left;
  display: grid;
  align-content: space-between;
  color: var(--ink);
}
.feature-tile span {
  width: 48px;
  height: 32px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}
.feature-tile:nth-child(2) span { background: var(--blue); }
.feature-tile:nth-child(3) span { background: #9a6b25; }
.feature-tile:nth-child(4) span { background: #7b617b; }
.feature-tile:nth-child(5) span { background: #b15d45; }
.feature-tile strong { font-size: 19px; }
.feature-tile small { color: var(--muted); }
.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  gap: 16px;
}
.finance-layout {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(420px, 1.1fr);
  gap: 16px;
}
.finance-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 860px) {
  .first-login-form {
    grid-template-columns: 1fr;
  }

  .login-verify-actions {
    justify-content: stretch;
  }

  .login-verify-actions .primary-btn,
  .login-verify-actions .secondary-btn {
    flex: 1 1 160px;
  }
}
.tab-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
.tab-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--green-dark);
  font-weight: 800;
}
.tab-btn.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}
.finance-tab-panel {
  display: none;
}
.finance-tab-panel.active {
  display: block;
}
.finance-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 14px;
  margin: 14px 0 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
}
.finance-filter-bar label {
  min-width: 240px;
}
.finance-filter-bar select {
  min-height: 44px;
  font-weight: 700;
}
.finance-filter-bar span {
  color: var(--green-dark);
  font-weight: 700;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(23, 33, 31, 0.42);
  backdrop-filter: blur(3px);
}
.modal-card {
  width: min(520px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(23, 33, 31, 0.22);
}
.payment-account {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}
.account-row,
.account-number,
.payment-note {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.account-row,
.account-number {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.account-row span,
.account-number span { color: var(--muted); font-size: 13px; }
.account-number {
  background: #fff8e8;
  border-color: #f0d6a0;
}
.account-number strong {
  font-size: 24px;
  color: #7a550d;
  letter-spacing: 1px;
}
.payment-note p { margin: 8px 0 0; }
.work-panel { padding: 18px; }
.report-layout {
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(0, 1.15fr);
  gap: 16px;
}
.report-form {
  display: grid;
  gap: 14px;
}
textarea {
  min-height: 118px;
  resize: vertical;
}
.text-counter,
.photo-help {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}
.photo-help { text-align: left; margin-top: -8px; }
.photo-preview {
  display: grid;
  gap: 8px;
}
.photo-chip,
.photo-empty {
  min-height: 38px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--muted);
  font-size: 13px;
}
.photo-chip span {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--green);
  font-weight: 800;
}
.incident-rules {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.list-stack { display: grid; gap: 10px; }
.privacy-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid #f0d6a0;
  border-radius: 8px;
  background: #fff8e8;
  color: #7a550d;
  margin-bottom: 12px;
}
.privacy-note span { color: #7a550d; font-size: 13px; }
.tenant-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.tenant-card-head,
.tenant-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.tenant-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin: 14px 0;
}
.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.item-title { font-weight: 800; }
.item-meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.badge {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
  background: var(--aqua);
  color: var(--green-dark);
}
.badge.warn { background: #fff3d4; color: #865d09; }
.badge.danger { background: #fde0df; color: #9f3030; }
.summary-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}
.summary-card { padding: 16px; }
.summary-card span, .metric-list span { color: var(--muted); font-size: 13px; }
.summary-card strong { display: block; margin-top: 8px; font-size: 28px; }
.metric-list { display: grid; gap: 10px; }
.metric-list div {
  display: flex;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.compact-table { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); }
th, td { padding: 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); background: #f1f5f2; font-size: 13px; }
.parking-map {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
}
.parking-slot {
  min-height: 160px;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  display: grid;
  align-content: space-between;
}
.parking-slot.available { border-color: #73b49d; background: #f0fbf7; }
.admin-access-layout {
  display: grid;
  grid-template-columns: minmax(280px, .8fr) minmax(0, 1.2fr);
  gap: 16px;
}
.admin-form {
  display: grid;
  gap: 14px;
}
.table-btn {
  padding: 6px 10px;
  white-space: nowrap;
}
.upload-zone {
  min-height: 220px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 28px;
  margin: 18px 0;
  border-style: dashed;
}
.upload-zone span { color: var(--muted); }
.import-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border-radius: 8px;
  background: #f6faf8;
  border: 1px solid var(--line);
}
.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.template-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}
.template-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.template-card div { display: grid; gap: 5px; }
.template-card span { color: var(--muted); font-size: 13px; }
.rule-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rule-card { padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fbfcfb; }
.hidden { display: none !important; }
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 1fr; }
  .side-panel { position: relative; height: auto; }
  .feature-grid, .summary-row, .two-column, .finance-layout, .report-layout, .admin-access-layout, .parking-map, .incident-rules, .tenant-grid, .template-grid { grid-template-columns: 1fr; }
  .finance-actions, .template-actions { justify-content: stretch; }
  .finance-actions > *, .template-actions > * { width: 100%; }
  .finance-filter-bar { align-items: stretch; flex-direction: column; }
  .finance-filter-bar label { min-width: 0; }
  .inline-form { grid-template-columns: 1fr; }
  .login-strip { align-items: stretch; flex-direction: column; }
}

.community-visual { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #e8f3ef; }
















.data-source-banner {
  margin-bottom: 14px;
  padding: 10px 14px;
  border: 1px solid rgba(19, 111, 82, 0.18);
  border-radius: 8px;
  background: rgba(255, 248, 238, 0.82);
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 700;
}
.data-source-banner.online { background: rgba(229, 245, 238, 0.9); }
.data-source-banner.warn { background: rgba(255, 239, 220, 0.9); color: #8a4a14; }
.admin-form textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(30, 67, 55, 0.18);
  border-radius: 8px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}
.check-line input { width: auto; }

.admin-auth-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(30, 67, 55, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}
.admin-auth-panel div:first-child { display: grid; gap: 4px; }
.admin-auth-panel span { color: var(--muted); font-size: 14px; }
.auth-actions { display: flex; gap: 10px; align-items: center; }
.hidden { display: none !important; }

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.danger-btn {
  border: 1px solid #f2b8b5;
  border-radius: 8px;
  padding: 6px 10px;
  background: #fde0df;
  color: #9f3030;
  font-weight: 800;
  cursor: pointer;
}
.danger-btn:hover { background: #facbc8; }

.resident-panel-head {
  align-items: flex-start;
  gap: 16px;
}

.resident-excel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.resident-excel-actions .primary-btn,
.resident-excel-actions .secondary-btn {
  min-height: 44px;
  white-space: nowrap;
}

@media (max-width: 760px) {
  .resident-panel-head {
    flex-direction: column;
  }

  .resident-excel-actions {
    width: 100%;
    justify-content: stretch;
  }

  .resident-excel-actions .primary-btn,
  .resident-excel-actions .secondary-btn {
    flex: 1 1 140px;
  }
}
.resident-form-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.resident-table th,
.resident-table td {
  vertical-align: middle;
}

.resident-floor-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 14px;
  background: #fff;
}

.resident-floor-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: #eef5f1;
  color: var(--green-dark);
}

.resident-floor-head strong {
  font-size: 1rem;
}

.resident-floor-head span {
  color: var(--muted);
  font-size: .86rem;
}

.resident-floor-group .resident-table {
  margin: 0;
  border: 0;
}

.stacked-cell {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.stacked-cell strong {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.25;
}

.stacked-cell span {
  color: var(--muted);
  font-size: .88rem;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.resident-table .table-actions {
  justify-content: flex-start;
  gap: 8px;
}

@media (max-width: 760px) {
  .resident-form-actions {
    grid-template-columns: 1fr;
  }

  .stacked-cell {
    min-width: 130px;
  }
}
.resident-admin-layout {
  grid-template-columns: 1fr;
  align-items: start;
}

.resident-admin-layout.editing {
  grid-template-columns: minmax(220px, 320px) minmax(0, 1fr);
}

.resident-admin-form {
  padding: 14px;
  gap: 10px;
  font-size: 12px;
}

.resident-admin-form h3 {
  font-size: 16px;
  margin-bottom: 2px;
}

.resident-admin-form label,
.resident-admin-form input,
.resident-admin-form select,
.resident-admin-form .status-note,
.resident-admin-form .primary-btn,
.resident-admin-form .secondary-btn {
  font-size: 12px;
}

.resident-admin-form input,
.resident-admin-form select {
  min-height: 38px;
  padding: 8px 10px;
}

.resident-admin-form .resident-form-actions {
  gap: 8px;
}

#residentsAdminView .work-panel:not(.resident-admin-form) {
  padding: 16px;
}

#residentsAdminView .resident-panel-head p {
  display: none;
}

#residentExcelStatus.hidden {
  display: none;
}

#residentExcelStatus.warn {
  color: #9b2c2c;
}

@media (max-width: 980px) {
  .resident-admin-layout {
    grid-template-columns: 1fr;
  }
}
.summary-link {
  width: 100%;
  text-align: left;
  color: inherit;
}

.summary-link:hover,
.summary-link:focus-visible {
  border-color: #9acfc2;
  background: #f4fbf8;
  box-shadow: 0 12px 24px rgba(30, 80, 65, .10);
  transform: translateY(-1px);
}

.summary-link:focus-visible {
  outline: 3px solid rgba(19, 111, 82, .22);
  outline-offset: 2px;
}
body.admin-locked .admin-shell {
  display: none;
}

.admin-identity-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.identity-card {
  width: min(560px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.identity-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.identity-brand div {
  display: grid;
  gap: 4px;
}

.identity-brand span {
  color: var(--muted);
  font-size: 13px;
}

.identity-card h1 {
  font-size: 32px;
  margin-bottom: 10px;
}

.identity-actions {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.line-identity-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.status-note.warn {
  color: #8a4a14;
}

.status-note.online {
  color: var(--green-dark);
}

@media (max-width: 640px) {
  .line-identity-form {
    grid-template-columns: 1fr;
  }
}
