:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --primary: #2563eb;
  --primary-soft: rgba(37,99,235,0.08);
  --accent: #10b981;
  --danger: #ef4444;
  --border: #e2e8f0;
  --text-main: #111827;
  --text-muted: #6b7280;
  --radius-lg: 16px;
  --shadow-soft: 0 18px 40px rgba(15,23,42,0.08);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Inter", sans-serif;
  background: radial-gradient(circle at top, #e0f2fe, #f5f7fb);
  color: var(--text-main);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(16px);
  background: rgba(248,250,252,0.85);
  border-bottom: 1px solid rgba(148,163,184,0.25);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 32px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-dot {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: conic-gradient(from 180deg, #0ea5e9, #6366f1, #22c55e, #0ea5e9);
  box-shadow: 0 8px 20px rgba(59,130,246,0.5);
}

.logo-text {
  font-weight: 700;
  letter-spacing: 0.04em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.9rem;
}

.topbar-nav a {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.topbar-nav a:hover {
  border-color: rgba(148,163,184,0.6);
  background: rgba(255,255,255,0.9);
}

.btn-outline {
  border-color: rgba(148,163,184,0.7) !important;
}

.main-area {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.footer {
  text-align: center;
  padding: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* hero */
.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 32px;
  align-items: center;
  padding: 40px 0;
}

.hero-title {
  font-size: 2.4rem;
  margin-bottom: 12px;
}

.hero-subtitle {
  color: var(--text-muted);
  max-width: 460px;
}

.hero-actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
}

.hero-illustration {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card-soft {
  background: radial-gradient(circle at top left, #eff6ff, #ffffff);
  border-radius: 24px;
  padding: 16px 18px;
  border: 1px solid rgba(148,163,184,0.3);
  box-shadow: 0 18px 40px rgba(148,163,184,0.25);
}

/* buttons */
.btn-primary,
.btn-secondary,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0ea5e9);
  color: white;
  box-shadow: 0 10px 25px rgba(37,99,235,0.4);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 45px rgba(37,99,235,0.45);
}

.btn-secondary {
  background: rgba(255,255,255,0.95);
  color: var(--text-main);
  border: 1px solid rgba(148,163,184,0.6);
}

.btn-secondary:hover {
  background: #eff6ff;
}

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

.btn-danger {
  background: var(--danger);
  color: #fff;
}

/* room block in Add PG */
.room-row {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #f9fafb;
}

.room-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.room-row-header h4 {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.room-remove-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.1rem;
  color: #9ca3af;
  padding: 0 4px;
}

.room-remove-btn:hover {
  color: #ef4444;
}

/* checkbox alignment for Food / AC / Attach Bathroom */
.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  margin-top: 8px;
}

.toggle-row .toggle-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.85rem;
}

/* QR image box */
.qr-box {
  margin-top: 8px;
  padding: 8px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background: #f9fafb;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: 180px;
}

.qr-img {
  display: block;
  margin-top: 4px;
  width: 120px;          /* hard upper size */
  max-width: 35vw;       /* shrink on small screens */
  height: auto;
  object-fit: contain;
}

.w-100 { width: 100%; }

.page { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148,163,184,0.28);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.flex-row {
  display: flex;
  align-items: center;
}

.space-between { justify-content: space-between; gap: 16px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

label input,
label select,
label textarea {
  width: 100%;
  padding: 7px 10px;
  margin-top: 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  outline: none;
}

label textarea {
  min-height: 70px;
  resize: vertical;
}

label input:focus,
label select:focus,
label textarea:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37,99,235,0.2);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox input { width: auto; margin-top: 0; }

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* stats */
.stats-grid .stat-card {
  background: linear-gradient(135deg, rgba(37,99,235,0.08), rgba(16,185,129,0.06));
  border-radius: 18px;
  padding: 12px 14px;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 4px;
}

/* alerts */
.alert {
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 0.85rem;
}

.alert-success {
  background: rgba(16,185,129,0.08);
  border: 1px solid rgba(16,185,129,0.4);
}

.alert-error {
  background: rgba(239,68,68,0.06);
  border: 1px solid rgba(239,68,68,0.4);
}

/* auth */
.auth-wrapper {
  display: flex;
  justify-content: center;
  padding: 40px 0;
}

.auth-card {
  max-width: 380px;
  width: 100%;
  animation: floatIn 0.45s ease-out;
}

/* table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.table th,
.table td {
  border-bottom: 1px solid rgba(226,232,240,0.7);
  padding: 8px 6px;
  text-align: left;
}

.table thead th {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.32);
  display: flex;
  align-items: flex-start;   /* top align so tall content scrolls */
  justify-content: center;
  z-index: 40;
  padding: 24px 16px;
  overflow-y: auto;
}

.modal {
  position: relative;
  background: #ffffff;
  border-radius: 20px;
  padding: 20px 22px;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;          /* scroll inside if too tall */
  box-shadow: var(--shadow-soft);
  animation: pop 0.22s ease-out;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  border: none;
  background: none;
  font-size: 1.2rem;
  cursor: pointer;
}

/* chat drawer */
.chat-drawer {
  position: fixed;
  right: -340px;
  top: 70px;
  width: 320px;
  height: calc(100% - 90px);
  background: #ffffff;
  border-left: 1px solid var(--border);
  box-shadow: -10px 0 30px rgba(15,23,42,0.2);
  border-radius: 16px 0 0 16px;
  display: flex;
  flex-direction: column;
  transition: right 0.25s ease-out;
  z-index: 40;
}

.chat-drawer.open {
  right: 10px;
}

.chat-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat-messages {
  flex: 1;
  padding: 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg {
  max-width: 80%;
  padding: 6px 8px;
  border-radius: 12px;
  font-size: 0.8rem;
}

.chat-msg.from-admin {
  margin-left: auto;
  background: var(--primary-soft);
}

.chat-msg.from-tenant {
  margin-right: auto;
  background: #e5e7eb;
}

.chat-form {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--border);
}

.chat-form input[type="text"] {
  flex: 1;
}

.chat-form input[type="file"] {
  font-size: 0.75rem;
}

/* misc */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.banner {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(251,191,36,0.1);
  border: 1px solid rgba(245,158,11,0.4);
  font-size: 0.85rem;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  margin-left: 4px;
}

.badge-urgent { background: rgba(239,68,68,0.1); color:#b91c1c; }
.badge-medium { background: rgba(251,191,36,0.15); color:#92400e; }
.badge-low { background: rgba(59,130,246,0.1); color:#1d4ed8; }

.ann-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  font-size: 0.85rem;
}

.ann-urgent { color: #b91c1c; }
.ann-medium { color: #92400e; }
.ann-low { color: #1d4ed8; }

.row-highlight {
  background: rgba(254,226,226,0.4);
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* auth animation */
@keyframes floatIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.slide-up { animation: slideUp 0.5s ease-out; }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.6s ease-out; }
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.float { animation: floatAnim 4s ease-in-out infinite; }
@keyframes floatAnim {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.pulse { animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 10px 25px rgba(37,99,235,0.5); }
  50% { box-shadow: 0 18px 45px rgba(37,99,235,0.3); }
  100% { box-shadow: 0 10px 25px rgba(37,99,235,0.5); }
}

/* responsive */
@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
  }
  .topbar {
    padding-inline: 16px;
  }
  .main-area {
    padding-inline: 16px;
  }

  .modal {
    max-width: 100%;
    border-radius: 16px;
  }

  .qr-box {
    max-width: 140px;
    margin-left: auto;
    margin-right: auto;
  }

  .chat-drawer {
    width: 100%;
    right: -100%;
  }
  .chat-drawer.open {
    right: 0;
  }
  
}