:root {
  --green: #0649a6;
  --green-dark: #08295a;
  --green-soft: #e6f0ff;
  --gold: #e0a12f;
  --ink: #122a4c;
  --muted: #63718a;
  --line: #d7e1f0;
  --paper: #f6f9fe;
  --white: #ffffff;
  --danger: #b33b32;
  --danger-soft: #fff0ed;
  --shadow: 0 24px 60px rgba(8, 41, 90, 0.11);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: "DM Sans", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(135deg, rgba(6, 73, 166, 0.06), transparent 44%),
    repeating-linear-gradient(90deg, transparent 0 79px, rgba(6, 73, 166, 0.025) 80px);
  content: "";
  pointer-events: none;
}

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

button { cursor: pointer; }

button:disabled { cursor: wait; opacity: 0.6; }

.tenant-shell { width: min(100%, 1240px); min-height: 100vh; margin: 0 auto; }

.tenant-header {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 30px;
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--green); text-decoration: none; }
.brand img { width: 48px; height: 38px; object-fit: contain; }
.brand span { display: grid; gap: 2px; }
.brand strong { font-size: 13px; letter-spacing: 0.08em; }
.brand small { color: var(--muted); font-size: 12px; }

.install-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--green);
  border-radius: 6px;
  padding: 9px 14px;
  background: transparent;
  color: var(--green);
  font-weight: 700;
}

.install-button > span:first-child { font-size: 20px; line-height: 1; }
.install-button.is-installed { border-color: var(--line); color: var(--muted); }

.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: 0.14em; }
h1, h2 { font-family: "Playfair Display", serif; font-weight: 600; letter-spacing: 0; }
h1 { margin: 0; font-size: clamp(34px, 5vw, 56px); line-height: 1.08; }
h2 { margin: 0; font-size: 26px; line-height: 1.2; }

.tenant-login {
  width: calc(100% - 60px);
  min-height: 570px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  margin: 34px auto 70px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.login-intro {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(42px, 7vw, 86px);
  background:
    linear-gradient(rgba(8, 41, 90, 0.9), rgba(8, 41, 90, 0.94)),
    url("assets/Logo%20BPG.jpg") center / 240px auto no-repeat;
  color: var(--white);
}

.login-intro .eyebrow { color: #f4c66e; }
.login-intro h1 { max-width: 590px; }
.login-intro > p:not(.eyebrow) { max-width: 540px; margin: 24px 0 30px; color: #dfeaff; font-size: 16px; line-height: 1.7; }
.login-intro ul { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.login-intro li { position: relative; padding-left: 26px; font-size: 14px; }
.login-intro li::before { position: absolute; left: 0; color: #f4c66e; content: "✓"; font-weight: 800; }

.login-form { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 64px); }
.login-form h2 { margin-bottom: 24px; }

label { display: grid; gap: 8px; margin: 10px 0; color: #344c70; font-size: 13px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid #c8d9f0;
  border-radius: 5px;
  padding: 12px 13px;
  outline: none;
  background: var(--white);
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input, select { min-height: 46px; }
textarea { min-height: 126px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(6, 73, 166, 0.1); }

.login-form > button, [data-feedback-form] > button, .install-dialog [data-install-confirm] {
  min-height: 46px;
  border: 0;
  border-radius: 5px;
  margin-top: 14px;
  padding: 12px 18px;
  background: var(--green);
  color: var(--white);
  font-weight: 800;
}

.login-help { margin: 16px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
[data-login-error], [data-feedback-error] { margin: 8px 0 0; color: var(--danger); font-size: 13px; }

.tenant-dashboard { padding: 48px 30px 80px; }
.welcome { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 30px; }
.welcome h1 { font-size: clamp(32px, 4vw, 48px); }
.welcome > div:first-child > p:last-child { margin: 9px 0 0; color: var(--muted); font-size: 13px; }
.dashboard-actions { display: flex; align-items: center; gap: 8px; }
.dashboard-actions button { min-height: 42px; border: 1px solid var(--line); border-radius: 5px; padding: 9px 13px; background: var(--white); color: var(--ink); font-weight: 700; }
.dashboard-actions .notification-button { border-color: var(--green); background: var(--green); color: var(--white); }
.dashboard-actions .icon-button { width: 42px; padding: 0; font-size: 20px; }
.dashboard-actions .text-button { color: var(--muted); }

.tenant-summary { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 7px; margin-bottom: 22px; background: var(--white); }
.tenant-summary article { min-width: 0; display: grid; gap: 7px; padding: 22px 24px; }
.tenant-summary article + article { border-left: 1px solid var(--line); }
.tenant-summary span { overflow-wrap: anywhere; color: var(--muted); font-size: 12px; font-weight: 700; }
.tenant-summary strong { color: var(--green-dark); font-family: "Playfair Display", serif; font-size: 34px; font-weight: 600; }
.tenant-summary small { color: var(--muted); font-size: 12px; }

.tenant-grid { display: grid; grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr); gap: 22px; }
.tenant-grid > section, .feedback-section { border: 1px solid var(--line); border-radius: 7px; background: var(--white); }
.tenant-grid > section { min-width: 0; padding: 24px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.section-heading > span { flex: 0 0 auto; border-radius: 20px; padding: 5px 9px; background: var(--green-soft); color: var(--green); font-size: 11px; font-weight: 800; }
.item-list { display: grid; }

.tenant-item { min-width: 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-top: 1px solid #e5ecf7; padding: 18px 0; }
.tenant-item strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
.tenant-item p { margin: 7px 0 0; overflow-wrap: anywhere; color: var(--muted); font-size: 13px; line-height: 1.55; }
.tenant-item small { display: block; margin-top: 8px; color: #71809a; font-size: 11px; }
.tenant-item a { display: inline-block; margin-top: 9px; color: var(--green); font-size: 12px; font-weight: 700; }
.item-value { flex: 0 0 auto; display: grid; justify-items: end; gap: 8px; }
.item-value b { font-size: 15px; white-space: nowrap; }

.status { width: fit-content; border-radius: 20px; padding: 5px 9px; background: var(--green-soft); color: var(--green); font-size: 10px; font-weight: 800; white-space: nowrap; }
.status.unpaid { background: #fff5df; color: #876016; }
.status.overdue { background: var(--danger-soft); color: var(--danger); }
.status.paid { background: var(--green-soft); color: var(--green); }
.invoice-item.is-overdue { border-left: 3px solid var(--danger); margin-left: -24px; padding-left: 21px; }

.notification-item { justify-content: flex-start; }
.notification-mark { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; margin-top: 5px; background: var(--gold); }
.empty { display: grid; gap: 5px; border-top: 1px solid #e5ecf7; padding: 24px 0 8px; color: var(--muted); font-size: 13px; }
.empty strong { color: var(--ink); font-size: 14px; }

.feedback-section { margin-top: 22px; padding: 28px; }
.feedback-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; border-bottom: 1px solid var(--line); padding-bottom: 22px; }
.feedback-heading > p { max-width: 430px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.feedback-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 0.82fr); gap: 40px; padding-top: 20px; }
.feedback-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.file-field small { color: var(--muted); font-weight: 400; }
.feedback-history { min-width: 0; border-left: 1px solid var(--line); padding-left: 30px; }
.feedback-history h3 { margin: 10px 0 14px; font-size: 15px; }
.feedback-item { align-items: flex-start; }

.install-dialog { width: min(90vw, 430px); border: 1px solid var(--line); border-radius: 7px; padding: 30px; color: var(--ink); box-shadow: var(--shadow); }
.install-dialog::backdrop { background: rgba(8, 41, 90, 0.54); }
.install-dialog h2 { margin-bottom: 14px; }
.install-dialog > p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.dialog-close { position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); font-size: 25px; }
.install-dialog [data-install-confirm] { width: 100%; }

.tenant-toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; max-width: min(360px, calc(100vw - 40px)); transform: translateY(20px); border-radius: 5px; padding: 13px 16px; background: var(--ink); color: var(--white); font-size: 13px; opacity: 0; pointer-events: none; transition: opacity 180ms ease, transform 180ms ease; }
.tenant-toast.is-visible { transform: translateY(0); opacity: 1; }

@media (max-width: 820px) {
  .tenant-header { padding: 14px 20px; }
  .tenant-login { width: calc(100% - 40px); grid-template-columns: 1fr; margin-top: 18px; }
  .login-intro { min-height: 330px; padding: 42px; }
  .login-intro h1 { font-size: 40px; }
  .tenant-dashboard { padding: 34px 20px 60px; }
  .welcome { align-items: stretch; flex-direction: column; }
  .dashboard-actions { flex-wrap: wrap; }
  .tenant-grid { grid-template-columns: 1fr; }
  .feedback-layout { grid-template-columns: 1fr; gap: 22px; }
  .feedback-history { border-top: 1px solid var(--line); border-left: 0; padding-top: 18px; padding-left: 0; }
}

@media (max-width: 560px) {
  .tenant-header { min-height: 72px; padding: 12px 16px; }
  .brand img { width: 42px; height: 34px; }
  .brand strong { font-size: 12px; }
  .install-button { min-width: 42px; justify-content: center; padding: 8px 10px; }
  .install-button [data-install-label] { display: none; }
  .tenant-login { width: 100%; min-height: 0; margin: 0; border-right: 0; border-left: 0; border-radius: 0; box-shadow: none; }
  .login-intro { min-height: 270px; padding: 32px 24px; }
  .login-intro h1 { font-size: 34px; }
  .login-intro > p:not(.eyebrow) { margin: 17px 0 20px; font-size: 14px; }
  .login-intro li { font-size: 13px; }
  .login-form { padding: 32px 24px 42px; }
  .tenant-dashboard { padding: 28px 14px 50px; }
  .welcome { margin-bottom: 22px; }
  .welcome h1 { font-size: 34px; }
  .dashboard-actions { display: grid; grid-template-columns: 1fr 42px auto; }
  .dashboard-actions button { min-width: 0; padding: 8px 10px; font-size: 12px; }
  .tenant-summary { grid-template-columns: 1fr; }
  .tenant-summary article { grid-template-columns: 1fr auto; align-items: center; padding: 16px 18px; }
  .tenant-summary article + article { border-top: 1px solid var(--line); border-left: 0; }
  .tenant-summary strong { grid-row: 1 / 3; grid-column: 2; font-size: 29px; }
  .tenant-summary small { grid-column: 1; }
  .tenant-grid > section, .feedback-section { padding: 20px 18px; }
  .tenant-item { gap: 12px; }
  .invoice-item { display: grid; }
  .item-value { grid-template-columns: 1fr auto; justify-items: start; align-items: center; }
  .invoice-item.is-overdue { margin-left: -18px; padding-left: 15px; }
  .feedback-heading { align-items: flex-start; flex-direction: column; gap: 12px; }
  .feedback-form-grid { grid-template-columns: 1fr; gap: 0; }
  .feedback-item { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}