@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap');

:root {
  --navy:    #0C3547;
  --sea:     #1B6CA8;
  --accent:  #C17F3E;
  --cream:   #F8F3EC;
  --white:   #FFFFFF;
  --text:    #1A2632;
  --muted:   #607080;
  --border:  #E2D9CC;
  --success: #0D7A5F;
  --danger:  #C62828;
  --warning: #B45309;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,0.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'DM Sans', sans-serif; background: #F1EDE6; color: var(--text); }

/* ─── LOGIN PAGE ─────────────────────────────────── */
#login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--navy) 0%, #1B4A62 100%);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-box {
  background: var(--white); border-radius: 16px;
  padding: 40px 44px; width: 100%; max-width: 400px;
  box-shadow: 0 12px 48px rgba(0,0,0,0.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.5rem; font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.login-logo p { font-size: 0.82rem; color: var(--muted); }
.login-badge {
  display: inline-block; background: #FEF3C7; color: var(--warning);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em;
  padding: 3px 10px; border-radius: 20px; margin-bottom: 16px; text-transform: uppercase;
}
.login-label { font-size: 0.75rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; letter-spacing: 0.06em; text-transform: uppercase; }
.login-input {
  width: 100%; padding: 11px 14px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 0.9rem; font-family: 'DM Sans', sans-serif; color: var(--text);
  outline: none; transition: border-color 0.15s;
}
.login-input:focus { border-color: var(--sea); }
.login-btn {
  width: 100%; padding: 12px;
  background: var(--navy); color: #fff;
  border: none; border-radius: 8px; font-size: 0.9rem; font-weight: 500;
  font-family: 'DM Sans', sans-serif; cursor: pointer; margin-top: 18px;
  transition: background 0.15s;
}
.login-btn:hover { background: #0a2b3a; }
.login-err { color: var(--danger); font-size: 0.82rem; margin-top: 8px; display: none; text-align: center; }
.guest-link { text-align: center; margin-top: 16px; }
.guest-link a { font-size: 0.82rem; color: var(--sea); text-decoration: none; }

/* ─── ADMIN APP ──────────────────────────────────── */
#admin-app { display: flex; min-height: 100vh; }

.sb {
  width: 220px; min-height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sb-logo { padding: 22px 18px 18px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.sb-logo h1 { font-size: 1rem; font-weight: 600; color: #E8D49E; line-height: 1.3; }
.sb-logo .apt-name { font-size: 0.75rem; color: rgba(255,255,255,0.4); margin-top: 2px; }
.sb-logo .perspective {
  margin-top: 10px; display: inline-flex; align-items: center; gap: 5px;
  background: rgba(193,127,62,0.2); border: 1px solid rgba(193,127,62,0.3);
  color: #E8D49E; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.08em;
  padding: 3px 10px; border-radius: 20px; text-transform: uppercase;
}
.sb-nav { flex: 1; padding: 12px 8px; }
.nav-lbl { font-size: 0.65rem; color: rgba(255,255,255,0.28); padding: 8px 10px 4px; letter-spacing: 0.1em; text-transform: uppercase; }
.nb {
  display: flex; align-items: center; gap: 9px;
  width: 100%; padding: 8px 10px; border-radius: 8px;
  color: rgba(255,255,255,0.55); font-size: 0.85rem;
  border: none; background: none; cursor: pointer; text-align: left; margin-bottom: 1px;
  font-family: 'DM Sans', sans-serif; transition: all 0.12s;
}
.nb:hover { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); }
.nb.active { background: var(--sea); color: #fff; }
.nb svg { width: 15px; height: 15px; flex-shrink: 0; }
.sb-foot {
  padding: 14px 18px; border-top: 1px solid rgba(255,255,255,0.07);
  font-size: 0.75rem; color: rgba(255,255,255,0.3);
  display: flex; flex-direction: column; gap: 6px;
}
.sb-logout {
  background: rgba(255,255,255,0.08); border: none; border-radius: 6px;
  color: rgba(255,255,255,0.55); font-size: 0.8rem; padding: 6px 10px;
  cursor: pointer; font-family: 'DM Sans', sans-serif; text-align: left;
  transition: background 0.12s;
}
.sb-logout:hover { background: rgba(255,255,255,0.14); color: rgba(255,255,255,0.9); }
.guest-view-btn {
  display: flex; align-items: center; gap: 6px;
  color: rgba(255,255,255,0.4); font-size: 0.78rem; text-decoration: none;
  padding: 4px 0;
}
.guest-view-btn:hover { color: rgba(255,255,255,0.7); }

/* ─── MAIN ───────────────────────────────────────── */
.main { flex: 1; overflow-y: auto; background: #F1EDE6; display: flex; flex-direction: column; }
.tbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 10;
}
.tbar-title { font-size: 1rem; font-weight: 600; color: var(--text); }
.pg { padding: 24px 28px; display: none; }
.pg.active { display: block; }

/* ─── STATS ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 24px; }
.sc {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.sc-icon { width: 36px; height: 36px; border-radius: 8px; display: flex; align-items: center; justify-content: center; margin-bottom: 10px; }
.sc-icon svg { width: 18px; height: 18px; color: #fff; }
.sc-val { font-size: 1.7rem; font-weight: 600; color: var(--text); line-height: 1; }
.sc-lbl { font-size: 0.75rem; color: var(--muted); margin-top: 3px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.sec-title { font-size: 0.9rem; font-weight: 600; color: var(--text); margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }

/* ─── TABLES ─────────────────────────────────────── */
.tw { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.fbar { padding: 10px 16px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fbtn { padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; font-family: 'DM Sans', sans-serif; }
.fbtn:hover { background: var(--cream); }
.fbtn.active { background: var(--sea); border-color: var(--sea); color: #fff; }
.fsel { padding: 4px 10px; border-radius: 20px; font-size: 0.78rem; border: 1px solid var(--border); background: var(--white); color: var(--text); cursor: pointer; font-family: 'DM Sans', sans-serif; }
.sbox { margin-left: auto; padding: 5px 10px; border-radius: 20px; font-size: 0.78rem; border: 1px solid var(--border); background: var(--white); color: var(--text); width: 160px; font-family: 'DM Sans', sans-serif; }
.sbox:focus { outline: none; border-color: var(--sea); }

table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
th { padding: 9px 14px; text-align: left; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.06em; color: var(--muted); border-bottom: 1px solid var(--border); background: #FAFAF7; text-transform: uppercase; }
td { padding: 10px 14px; border-bottom: 1px solid #F2EDE5; color: var(--text); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #FAFAF7; }

.ab { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; color: #fff; }
.sb2 { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 0.72rem; font-weight: 600; }
.s-ok  { background: #D1FAE5; color: #065F46; }
.s-now { background: #DBEAFE; color: #1E40AF; }
.s-old { background: #F3F4F6; color: #6B7280; }
.s-can { background: #FEE2E2; color: #991B1B; }
.src-badge { background: var(--cream); color: var(--muted); font-size: 0.68rem; padding: 1px 6px; border-radius: 20px; }

.abt { padding: 3px 8px; border-radius: 5px; font-size: 0.78rem; border: 1px solid var(--border); background: transparent; cursor: pointer; color: var(--muted); font-family: 'DM Sans', sans-serif; }
.abt:hover { background: var(--cream); }

/* ─── BUTTONS ────────────────────────────────────── */
.btn { padding: 8px 16px; border-radius: 8px; font-size: 0.85rem; font-weight: 500; font-family: 'DM Sans', sans-serif; cursor: pointer; border: 1px solid var(--border); background: var(--white); color: var(--text); display: inline-flex; align-items: center; gap: 6px; transition: all 0.12s; }
.btn:hover { background: var(--cream); }
.btn-p { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-p:hover { background: #0a2b3a; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a12020; }

/* ─── MODAL ──────────────────────────────────────── */
.mo { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 20px; overflow-y: auto; }
.mo.open { display: flex; }
.md { background: var(--white); border-radius: var(--radius); width: 100%; max-width: 520px; border: 1px solid var(--border); flex-shrink: 0; margin: auto; }
.mh { padding: 18px 22px 14px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.mt { font-size: 0.95rem; font-weight: 600; color: var(--text); }
.mc { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: var(--cream); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.mb { padding: 18px 22px; }
.mf { padding: 12px 22px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }
.fg { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.fg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fl { font-size: 0.7rem; font-weight: 600; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }
.fi, .fs { padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 0.875rem; font-family: 'DM Sans', sans-serif; color: var(--text); background: var(--white); width: 100%; }
.fi:focus, .fs:focus { outline: none; border-color: var(--sea); }
.err-msg { font-size: 0.8rem; color: var(--danger); margin-top: 6px; display: none; }

/* ─── CALENDAR ───────────────────────────────────── */
.cal-wrap { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); }
.cal-hdr { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.mnbtn { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border); background: transparent; cursor: pointer; font-size: 14px; display: flex; align-items: center; justify-content: center; color: var(--text); }
.mnbtn:hover { background: var(--cream); }
.cal-scroll { overflow-x: auto; }
.cal-tbl { border-collapse: collapse; min-width: 700px; width: 100%; }
.cal-tbl th, .cal-tbl td { border: 1px solid #F0E8DE; padding: 0; font-size: 0.72rem; }
.caln { padding: 7px 10px; font-size: 0.8rem; font-weight: 500; color: var(--text); background: #FAFAF7; white-space: nowrap; min-width: 115px; border-left: 3px solid transparent; }
.cald { padding: 5px 3px; text-align: center; color: var(--muted); background: #FAFAF7; min-width: 28px; font-size: 0.7rem; }
.cald.tod { color: var(--sea); font-weight: 700; }
.cc { height: 36px; position: relative; }
.cc.tc { background: #EFF6FF; }
.rb { position: absolute; inset: 4px 0; display: flex; align-items: center; overflow: hidden; opacity: 0.88; cursor: pointer; font-size: 0.65rem; font-weight: 600; color: #fff; padding-left: 5px; white-space: nowrap; }
.rb:hover { opacity: 1; z-index: 2; }
.rb.rs { border-radius: 4px 0 0 4px; }
.rb.re { border-radius: 0 4px 4px 0; }
.rb.ro { border-radius: 4px; }

/* ─── APARTMENT CARDS ────────────────────────────── */
.apt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.ac { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ac-hdr { padding: 16px; color: #fff; }
.ac-name { font-size: 0.9rem; font-weight: 600; margin-bottom: 2px; }
.ac-desc { font-size: 0.75rem; opacity: 0.8; }
.ac-body { padding: 12px 14px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }

/* ─── TOAST ──────────────────────────────────────── */
.toast-c { position: fixed; top: 16px; right: 16px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 8px; font-size: 0.875rem; font-weight: 500; color: #fff; animation: tIn 0.25s ease; max-width: 320px; }
.t-ok  { background: var(--success); }
.t-err { background: var(--danger); }
@keyframes tIn { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.empty { text-align: center; padding: 40px; color: var(--muted); font-size: 0.85rem; }
