:root {
  --primary: #1d9e75;
  --primary-dark: #085041;
  --primary-light: #e1f5ee;
  --secondary: #ef9f27;
  --success: #0e9f6e;
  --warning: #ef9f27;
  --error: #e02424;
  --ink: #2c2c2a;
  --muted: #888780;
  --line: #d3d1c7;
  --soft: #f1efe8;
  --bg: #f7f5ef;
  --white: #ffffff;
  font-family: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: radial-gradient(circle at top left, #e1f5ee 0, rgba(225,245,238,0) 300px), linear-gradient(180deg, #fbfaf6 0, var(--bg) 320px); color: var(--ink); }
button, input { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, strong { font-family: Georgia, "Times New Roman", serif; }
h1, h2, h3, p { margin-top: 0; }

.auth-screen { min-height: 100vh; display: grid; place-items: center; padding: 28px; }
.auth-brand { position: fixed; top: 22px; left: 28px; display: flex; align-items: center; gap: 12px; }
.brand-logo { width: 180px; height: auto; display: block; }
.auth-brand strong { display: block; }
.auth-brand span { color: var(--muted); font-size: 13px; }
.auth-panel { width: min(920px, 100%); background: rgba(255,255,255,.88); border: 1px solid rgba(211,209,199,.9); border-radius: 8px; box-shadow: 0 24px 60px rgba(44,44,42,.12); padding: 28px; backdrop-filter: blur(18px); }
.auth-panel h1 { font-size: 34px; margin-bottom: 8px; }
.auth-copy { color: var(--muted); margin-bottom: 22px; }
.auth-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.auth-card { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px; box-shadow: 0 10px 24px rgba(44,44,42,.06); }
.auth-card p { color: var(--muted); min-height: 48px; }
.auth-icon { width: 46px; height: 46px; border-radius: 8px; display: grid; place-items: center; background: var(--primary-light); color: var(--primary); margin-bottom: 14px; }
.auth-icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.google-button { width: 100%; min-height: 48px; border-radius: 8px; border: 1px solid var(--line); background: var(--white); color: var(--ink); font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 10px; }
.google-button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.google-g { width: 24px; height: 24px; border-radius: 99px; display: grid; place-items: center; color: #4285f4; background: #fff; border: 1px solid #e5e7eb; font-weight: 900; }
.app-shell { display: none; grid-template-columns: 1fr; min-height: 100vh; }
body.authenticated .auth-screen { display: none; }
body.authenticated .app-shell { display: grid; }
.sidebar { background: transparent; border-right: 0; padding: 18px 28px 0; display: block; }
.brand { display: flex; gap: 12px; align-items: center; }
.brand-mark { width: 44px; height: 44px; border-radius: 8px; background: var(--primary); color: var(--white); display: grid; place-items: center; font: 700 22px Georgia, serif; }
.brand span, .sidebar-card span, .eyebrow { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0; font-weight: 700; }
.brand strong { display: block; }
.nav { position: fixed; left: 50%; right: auto; bottom: 18px; transform: translateX(-50%); z-index: 10; width: min(760px, calc(100% - 28px)); display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px; background: rgba(255,255,255,.92); border: 1px solid rgba(211,209,199,.95); border-radius: 8px; box-shadow: 0 18px 44px rgba(44,44,42,.18); backdrop-filter: blur(18px); }
.nav::before { content: ""; position: absolute; inset: 1px; border-radius: 7px; pointer-events: none; box-shadow: inset 0 1px 0 rgba(255,255,255,.9); }
.nav-item { position: relative; border: 0; background: transparent; text-align: center; padding: 8px 6px; border-radius: 8px; color: var(--muted); font-weight: 800; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 5px; min-height: 62px; font-size: 12px; line-height: 1.15; transition: background .18s ease, color .18s ease, transform .18s ease; }
.nav-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: #fbfaf6; color: var(--muted); flex: 0 0 auto; border: 1px solid var(--line); transition: background .18s ease, color .18s ease, border-color .18s ease, transform .18s ease; }
.nav-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item.active, .nav-item:hover { background: linear-gradient(180deg, var(--primary-light), #fff); color: var(--primary); transform: translateY(-1px); }
.nav-item.active::after { content: ""; position: absolute; left: 26%; right: 26%; bottom: 4px; height: 3px; border-radius: 99px; background: var(--primary); }
.nav-item.active .nav-icon, .nav-item:hover .nav-icon { background: var(--primary); border-color: var(--primary); color: var(--white); transform: translateY(-1px); }
.sidebar-card { display: none; background: var(--soft); padding: 16px; border-radius: 8px; }
.sidebar-card:last-child { margin-top: auto; }
.sidebar-card p { color: var(--muted); margin-bottom: 0; font-size: 14px; }
.gemini-card { display: grid; gap: 10px; }

main { padding: 24px 28px 116px; overflow: auto; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-bottom: 24px; }
.topbar h1 { margin-bottom: 0; font-size: 28px; }
.top-actions { display: flex; gap: 10px; align-items: center; }
.role-chip { min-height: 34px; display: inline-flex; align-items: center; border-radius: 99px; padding: 0 12px; background: var(--primary-light); color: var(--primary); font-size: 12px; font-weight: 900; text-transform: uppercase; }
.icon-button { position: relative; border: 1px solid var(--line); background: var(--white); border-radius: 8px; min-width: 44px; height: 44px; }
.icon-button span { position: absolute; top: -6px; right: -6px; background: var(--error); color: white; border-radius: 99px; font-size: 11px; min-width: 20px; padding: 3px; }

.view { display: none; }
.view.active { display: block; }
.primary, .secondary, .text-button { border-radius: 8px; min-height: 44px; padding: 0 16px; font-weight: 800; }
.primary { background: var(--primary); border: 1px solid var(--primary); color: var(--white); }
.primary:hover { background: var(--primary-dark); }
.secondary { background: var(--white); border: 1.5px solid var(--primary); color: var(--primary); }
.text-button { border: 0; background: transparent; color: var(--primary); }
.small { min-height: 40px; }

.attention-band { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: var(--white); border-radius: 8px; padding: 22px; display: flex; justify-content: space-between; gap: 16px; align-items: center; margin-bottom: 20px; }
.attention-band h2 { margin-bottom: 0; font-size: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 26px; }
.metric, .property-card, .table-card, .tenant-panel, .sheet, .poster-preview { background: var(--white); border: 1px solid rgba(211,209,199,.85); border-radius: 8px; box-shadow: 0 10px 24px rgba(44,44,42,.06); }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-size: 14px; }
.metric strong { display: block; font-size: 28px; margin: 8px 0 2px; }
.metric p { color: var(--muted); margin-bottom: 0; }
.bar { height: 8px; background: var(--soft); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.bar i { display: block; height: 100%; background: var(--success); }

.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; }
.section-head h2 { margin-bottom: 2px; }
.section-head p { color: var(--muted); margin-bottom: 0; }
.property-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.property-card { overflow: hidden; }
.property-photo { height: 150px; background: linear-gradient(135deg, #e1f5ee, #f6d38f); position: relative; }
.property-photo::after { content: ""; position: absolute; inset: 18px; border: 1px solid rgba(255,255,255,.75); border-radius: 8px; }
.property-body { padding: 16px; }
.property-meta { color: var(--muted); font-size: 14px; }
.card-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.card-actions button { min-height: 38px; border: 1px solid var(--line); background: var(--white); border-radius: 8px; font-size: 13px; font-weight: 700; }

.pill { display: inline-flex; align-items: center; border-radius: 99px; padding: 5px 9px; font-size: 11px; text-transform: uppercase; font-weight: 800; }
.success { background: var(--primary-light); color: var(--primary-dark); }
.warning { background: #fef3c7; color: #92400e; }
.danger { background: #fee2e2; color: var(--error); }
.vacant { background: var(--primary-light); color: var(--primary); }

.table-card { overflow: hidden; }
.table-row { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr 140px; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid #edf0f3; }
.table-row.head { background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 800; }
.request-list { display: grid; gap: 12px; }
.split-section { margin-top: 28px; padding-top: 24px; border-top: 1px solid #e5e7eb; }
.ai-router-panel { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 14px; padding: 16px; border: 1px solid #9fe1cb; background: linear-gradient(135deg, var(--primary-light), #ffffff); border-radius: 8px; box-shadow: 0 10px 24px rgba(44,44,42,.05); }
.ai-router-panel h3 { margin: 8px 0 4px; }
.ai-router-panel p { margin-bottom: 0; color: var(--muted); }
.request-card { background: var(--white); border: 1px solid #e5e7eb; border-left: 5px solid var(--warning); border-radius: 8px; padding: 16px; display: flex; justify-content: space-between; gap: 16px; }
.request-card.emergency { border-left-color: var(--error); }

.poster-layout { display: grid; grid-template-columns: minmax(280px, 420px) minmax(280px, 460px); gap: 28px; align-items: start; }
.template-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.template { border: 1px solid var(--line); background: var(--white); border-radius: 8px; padding: 10px 12px; font-weight: 700; }
.template.active { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
label { display: grid; gap: 8px; margin-bottom: 14px; font-weight: 700; }
input, textarea, select { min-height: 48px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; font-family: inherit; font-size: inherit; color: inherit; background: var(--white); }
select { appearance: none; background: var(--white) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23888780'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") no-repeat right 12px center/16px; padding-right: 40px; }
textarea { min-height: 120px; padding: 12px; resize: vertical; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.poster-preview { aspect-ratio: 1 / 1; padding: 22px; display: flex; flex-direction: column; justify-content: space-between; background: linear-gradient(180deg, #ffffff, var(--primary-light)); }
.poster-photo { height: 155px; border-radius: 8px; background: linear-gradient(135deg, #9fe1cb, #ef9f27); }
.poster-preview h3 { font-size: 34px; margin: 6px 0 0; color: var(--primary); }
.poster-preview strong { font-size: 28px; }
.amenities { display: flex; gap: 8px; flex-wrap: wrap; }
.amenities span { background: var(--white); border: 1px solid var(--line); border-radius: 99px; padding: 8px 12px; font-weight: 800; }
.poster-footer { display: flex; justify-content: space-between; align-items: end; font-weight: 800; }
.qr { width: 62px; height: 62px; border: 2px dashed var(--ink); display: grid; place-items: center; border-radius: 8px; }

.tenant-home { max-width: 720px; display: grid; gap: 16px; }
.tenant-panel { padding: 18px; }
.tenant-panel strong { display: block; font-size: 28px; margin-bottom: 12px; }
.rent-tenant-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 18px; align-items: start; }
.ai-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 16px; }
.ai-card { background: var(--white); border: 1px solid rgba(211,209,199,.85); border-radius: 8px; padding: 18px; box-shadow: 0 2px 8px rgba(44,44,42,.05); }
.ai-card p { color: var(--muted); min-height: 66px; }
.ai-output { background: #fff8e9; border: 1px solid #f6d38f; border-radius: 8px; color: #633806; padding: 12px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; }
.ai-output.large { background: var(--white); border-color: var(--line); color: var(--ink); min-height: 220px; padding: 18px; }

.modal { display: none; position: fixed; inset: 0; background: rgba(17,25,40,.46); align-items: end; justify-content: center; padding: 20px; z-index: 100; }
.modal.active { display: flex; }

.sheet { width: min(560px, 100%); padding: 24px; position: relative; }
.close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border: 0; background: var(--soft); border-radius: 99px; font-size: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.form-grid label:first-child, .form-grid label:nth-child(3), .form-grid button { grid-column: 1 / -1; }

.welcome-banner { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--white); padding: 28px; border-radius: 12px; margin-bottom: 24px; box-shadow: 0 8px 24px rgba(8,80,65,.15); }
.welcome-banner h1 { margin-bottom: 8px; font-size: 28px; }
.welcome-banner p { margin-bottom: 0; opacity: 0.9; }
.tenant-balance-card { background: var(--white); border: 1px solid var(--line); padding: 24px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; box-shadow: 0 4px 12px rgba(44,44,42,.05); }
.tenant-balance-card h2 { font-size: 36px; margin: 8px 0; color: var(--error); }
.tenant-balance-card p { margin-bottom: 0; font-weight: 700; color: var(--muted); }
.tenant-quick-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 32px; }
.quick-link { background: var(--white); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: left; display: flex; align-items: center; gap: 14px; font-weight: 800; color: var(--ink); transition: all 0.2s; min-height: 72px; }
.quick-link:hover { border-color: var(--primary); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(29,158,117,.12); color: var(--primary); }
.quick-link .icon { font-size: 24px; }

.chat-container { border: 1px solid var(--line); border-radius: 12px; background: var(--white); display: flex; flex-direction: column; height: 500px; overflow: hidden; box-shadow: 0 8px 24px rgba(44,44,42,.06); }
.chat-window { flex: 1; padding: 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; background: var(--bg); }
.chat-message { max-width: 85%; padding: 14px 18px; border-radius: 18px; line-height: 1.5; font-size: 15px; }
.chat-message.ai { background: var(--white); border: 1px solid var(--line); color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-message.user { background: var(--primary); color: var(--white); align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-input-area { padding: 16px; background: var(--white); border-top: 1px solid var(--line); display: flex; gap: 12px; }
.chat-input-area input { flex: 1; border-radius: 99px; border: 1px solid var(--line); padding: 0 20px; font-size: 15px; background: var(--soft); transition: border-color 0.2s; }
.chat-input-area input:focus { outline: none; border-color: var(--primary); background: var(--white); }
.chat-input-area button { border-radius: 99px; padding: 0 24px; }

@media (max-width: 860px) {
  .auth-screen { align-items: start; padding: 96px 16px 24px; }
  .auth-brand { left: 16px; top: 16px; }
  .auth-panel { padding: 18px; }
  .auth-panel h1 { font-size: 28px; }
  .auth-options { grid-template-columns: 1fr; }
  .modal { padding-bottom: 110px; }
  .sidebar { padding: 14px 16px 0; }
  .brand { margin-bottom: 10px; }
  .nav { left: 0; right: 0; bottom: 0; width: auto; transform: none; gap: 3px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-right: 0; border-left: 0; border-bottom: 0; border-radius: 0; box-shadow: 0 -10px 26px rgba(17,25,40,.12); }
  .nav-item { justify-content: center; text-align: center; padding: 7px 3px; border-radius: 8px; font-size: 10px; line-height: 1.15; min-height: 58px; flex-direction: column; gap: 4px; }
  .nav-icon { width: 27px; height: 27px; }
  .nav-icon svg { width: 17px; height: 17px; }
  main { padding: 18px 14px 96px; }
  .topbar, .attention-band, .section-head { align-items: stretch; flex-direction: column; }
  .top-actions { flex-wrap: wrap; }
  .ai-router-panel { align-items: stretch; flex-direction: column; }
  .stats-grid, .poster-layout, .rent-tenant-layout { grid-template-columns: 1fr; }
  .table-row { grid-template-columns: 1fr 1fr; }
  .table-row span:nth-child(3), .table-row span:nth-child(4), .table-row span:nth-child(5) { justify-self: start; }
  .poster-preview h3 { font-size: 28px; }
}
