@import url("https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;600;800&display=swap");

:root { 
  --primary: #4f46e5; 
  --accent: #818cf8;
  --bg: #0b1120; 
  --glass: rgba(30, 41, 59, 0.82); 
  --glass-2: rgba(15, 23, 42, 0.88);
  --border: rgba(255, 255, 255, 0.10);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --text: #ffffff;
  --muted: #94a3b8;
  --shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.60);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body { 
  font-family: 'Plus Jakarta Sans', sans-serif; 
  background: radial-gradient(circle at top left, #1e1b4b, #0b1120); 
  color: var(--text);
  min-height: 100vh; 
  width: 100%;
  overflow-x: hidden; 
}

/* ====== Purely visual WOW (overlay + decor) ====== */
.welcome-overlay{
  position: fixed;
  inset: 0;
  background: #0b1120;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
}
.welcome-overlay.show{
  opacity: 1;
  pointer-events: all;
}
.welcome-content h1{
  font-size: 1.9rem;
  font-weight: 800;
  background: linear-gradient(to right, #ffffff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin: 18px 14px 8px;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.welcome-content p{
  color: var(--muted);
  font-size: .9rem;
}
.spinner{
  width: 54px;
  height: 54px;
  border: 5px solid rgba(99, 102, 241, 0.18);
  border-top: 5px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.bg-decor{
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}
.bg-img{
  position: absolute;
  filter: brightness(0.55) contrast(1.15);
  border-radius: 20px;
  animation: float 8s ease-in-out infinite;
  opacity: 0.14;
}
.img-apartment{ top: 6%; left: -10%; width: 260px; --rot: -8deg; }
.img-water{ bottom: 12%; right: -6%; width: 190px; --rot: 14deg; animation-delay: 2.8s; }
@keyframes float{
  0%, 100% { transform: translateY(0) rotate(var(--rot)); }
  50% { transform: translateY(-18px) rotate(calc(var(--rot) + 5deg)); }
}

a { color: inherit; text-decoration: none; }

/* ====== App layout ====== */
.app { display: flex; min-height: 100vh; width: 100%; }
.content { flex: 1; padding: 18px; }
.main-content { flex: 1; padding: 22px; overflow-y: auto; }

/* ====== Glass panels/cards ====== */
.panel, .card, .auth-card, .modal-content, .box {
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}
.panel.pad, .card.pad { padding: 18px; }

/* ====== Brand / sidebar ====== */
.sidebar {
  width: 270px;
  padding: 18px;
  background: rgba(2, 6, 23, 0.72);
  border-right: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  display: flex;
  flex-direction: column;
}
.brand, .sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 16px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.logo, .brand .logo {
  width: 44px; height: 44px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(79, 70, 229, 0.18);
  border: 1px solid rgba(129, 140, 248, 0.25);
  color: #e0e7ff;
}
.brand .title { font-weight: 800; letter-spacing: -0.5px; }
.brand .subtitle { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.nav, .sidebar .nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 6px;
}
.nav a, .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px;
  border-radius: 14px;
  color: #cbd5e1;
  border: 1px solid transparent;
  transition: .2s;
}
.nav a:hover, .nav-item:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: rgba(129, 140, 248, 0.25);
  color: #ffffff;
}
.nav a.active, .nav-item.active {
  background: rgba(79, 70, 229, 0.22);
  border-color: rgba(129, 140, 248, 0.28);
  color: #ffffff;
}
.footer {
  margin-top: auto;
  padding: 14px 10px 6px 10px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .82rem;
}

/* ====== Top hero / background decor ====== */
.top-hero{
  border-radius: 26px;
  padding: 18px;
  background:
    radial-gradient(900px 400px at 20% 20%, rgba(79,70,229,.35), transparent 65%),
    radial-gradient(900px 400px at 80% 10%, rgba(16,185,129,.18), transparent 70%),
    var(--glass);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ====== Typography ====== */
.h1 { font-size: 1.35rem; font-weight: 800; letter-spacing: -0.5px; }
.h2 { font-size: 1.05rem; font-weight: 800; letter-spacing: -0.3px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* ====== Inputs ====== */
input, select, textarea {
  width: 100%;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.82);
  color: #ffffff;
  font-size: .95rem;
  transition: .2s;
  outline: none;
}
textarea { min-height: 120px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: rgba(79, 70, 229, 0.85);
  background: rgba(15, 23, 42, 0.95);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.20);
}
select option { background: #1e293b; color: white; }

/* ====== Buttons ====== */
.btn {
  padding: 12px 14px;
  border-radius: 14px;
  font-weight: 800;
  cursor: pointer;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.05);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: .2s;
  -webkit-user-select: none;
  user-select: none;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(79, 70, 229, 0.22); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary, .btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
}
.btn.ghost, .btn-ghost, .btn.secondary, .btn-secondary, .btn-soft {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border);
  color: #e2e8f0;
}
.btn.success { background: rgba(16, 185, 129, 0.20); border-color: rgba(16, 185, 129, 0.25); }
.btn.warning { background: rgba(245, 158, 11, 0.18); border-color: rgba(245, 158, 11, 0.25); }
.btn.danger, .btn-danger { background: rgba(239, 68, 68, 0.18); border-color: rgba(239, 68, 68, 0.25); }

.btn-icon { width: 44px; height: 44px; padding: 0; }

/* ====== Badges / statuses ====== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 800;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: #e2e8f0;
}
.badge.success, .badge-paid { background: rgba(16,185,129,.18); border-color: rgba(16,185,129,.28); color:#d1fae5; }
.badge.warning, .badge-pending { background: rgba(245,158,11,.18); border-color: rgba(245,158,11,.28); color:#ffedd5; }
.badge.review, .badge-billed { background: rgba(129,140,248,.16); border-color: rgba(129,140,248,.28); color:#e0e7ff; }
.badge.neutral, .badge-vacant { background: rgba(148,163,184,.10); border-color: rgba(148,163,184,.18); color:#e2e8f0; }
.badge-overdue { background: rgba(239,68,68,.18); border-color: rgba(239,68,68,.28); color:#fee2e2; }
.badge-review { background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.28); color:#ffedd5; }

/* ====== Dashboard stats/grid ====== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.stat {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}
.stat .val { font-size: 1.35rem; font-weight: 800; margin-top: 6px; }

.grid, .unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.unit, .unit-card {
  padding: 14px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  transition: .2s;
}
.unit:hover, .unit-card:hover { border-color: rgba(129, 140, 248, 0.35); transform: translateY(-1px); }
.unit-card.overdue { border-color: rgba(239,68,68,.45); box-shadow: 0 18px 35px rgba(239,68,68,.12); }
.unit-id { font-weight: 800; color: #e0e7ff; }
.unit-name { font-weight: 800; margin-top: 6px; }
.unit-sub { color: var(--muted); font-size: .85rem; margin-top: 4px; }

/* ====== Modal ====== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.70);
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal.show { display: flex; }
.box { width: min(560px, 100%); overflow: hidden; }
.head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}
.body { padding: 16px; }
.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 10px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 16px;
}
.kv .k { color: var(--muted); font-size: .86rem; }
.kv .v { font-weight: 800; color: #fff; text-align: right; }
.break {
  margin-top: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(129, 140, 248, 0.22);
  background: rgba(79, 70, 229, 0.12);
}
.break .line { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; }
.hr { height: 1px; background: var(--border); margin: 10px 0; }

/* ====== Legacy helpers used in index.html ====== */
.search-box { position: relative; width: 100%; max-width: 420px; }
.search-box i { position: absolute; left: 14px; top: 15px; color: var(--muted); }
.search-box input { padding-left: 40px; }
.stats-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-value { font-size: 1.6rem; font-weight: 800; margin-top: 6px; }
.calc-breakdown, .tenant-info {
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
}
.calc-row { display:flex; justify-content:space-between; margin-bottom: 6px; color:#e2e8f0; }

/* ====== Responsive ====== */
@media (max-width: 920px){
  .sidebar{ display:none; }
  .content, .main-content{ padding: 14px; }
  .stats{ grid-template-columns: repeat(2, minmax(0,1fr)); }
  .top-bar { display: grid; gap: 10px; }
  .search-box { max-width: 100%; }
  .modal-content { width: 100%; max-width: 560px; }
  .row { flex-wrap: wrap; }
  .btn { min-height: 44px; }
}
@media (max-width: 520px){
  .stats{ grid-template-columns: 1fr; }
  .grid, .unit-grid{ grid-template-columns: repeat(auto-fill, minmax(165px,1fr)); }
  .panel.pad, .card.pad { padding: 14px; }
  input, select, textarea { font-size: 16px; }
}
