/* =========================================
   Poytakht CRM — Custom Stylesheet
   Gold & Cream Theme
   ========================================= */

:root {
  --gold: #d4af37;
  --gold-light: #e8c95f;
  --gold-dark: #a77a1f;
  --gold-soft: rgba(212, 175, 55, 0.12);
  --cream: #f5f0e7;
  --cream-light: #fffaf2;
  --dark: #171411;
  --dark-2: #2b261f;
  --dark-3: #39342d;
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --border: rgba(166, 122, 33, 0.18);
  --shadow: 0 4px 20px rgba(24, 20, 16, 0.08);
  --radius: 14px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: 'Arial', sans-serif; background: #f0ebe0; color: #1a1611; }

/* ── App-launch splash ──────────────────────────────────────────────────────
   Plays once per browser session (gated in templates/pwa/splash.html), not
   on every internal navigation. transform/opacity only — no width/top/left,
   so it stays cheap even on low-end phones. Background is a soft warm
   charcoal (not flat black) with a blurred gold halo behind the logo, so
   the white logo card eases into the backdrop instead of a hard-edged
   black/white cut. */
.app-splash {
  position: fixed; inset: 0; z-index: 20000;
  flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #3c3427 0%, #241f18 55%, #171310 100%);
  cursor: pointer;
  animation: splashOut 0.55s ease 2.1s forwards;
}
.app-splash.app-splash-skip { animation: splashOut 0.35s ease forwards; }
.app-splash-glow {
  position: absolute;
  width: min(70vw, 340px); height: min(70vw, 340px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 175, 55, 0.35) 0%, rgba(212, 175, 55, 0.12) 45%, transparent 72%);
  filter: blur(18px);
  opacity: 0;
  animation: splashGlowIn 1.1s ease 0.1s forwards;
}
.app-splash-logo {
  position: relative;
  width: min(38vw, 176px);
  height: auto;
  border-radius: 22px;
  filter: drop-shadow(0 16px 34px rgba(0, 0, 0, 0.45)) drop-shadow(0 0 26px rgba(212, 175, 55, 0.14));
  opacity: 0;
  transform: scale(0.85);
  animation: splashLogoIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) 0.15s forwards;
}
.app-splash-sub {
  position: relative;
  margin-top: 22px;
  color: var(--gold-light);
  letter-spacing: 3px;
  text-transform: uppercase;
  font-size: 15px;
  font-weight: 700;
  opacity: 0;
  transform: translateY(8px);
  animation: splashTextIn 0.55s ease 0.65s forwards;
}
.app-splash-rule {
  position: relative;
  margin-top: 16px;
  width: 56px; height: 1.5px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  transform: scaleX(0);
  animation: splashRuleIn 0.6s ease 0.9s forwards;
}
.app-splash-tagline {
  position: relative;
  margin-top: 14px;
  color: var(--cream);
  opacity: 0;
  font-size: 13px;
  font-style: italic;
  letter-spacing: 0.5px;
  transform: translateY(6px);
  animation: splashTextIn 0.6s ease 1.15s forwards;
}
@keyframes splashGlowIn { to { opacity: 1; } }
@keyframes splashLogoIn { to { opacity: 1; transform: scale(1); } }
@keyframes splashTextIn { to { opacity: 1; transform: translateY(0); } }
@keyframes splashRuleIn { to { transform: scaleX(1); } }
@keyframes splashOut { to { opacity: 0; visibility: hidden; } }

@media (prefers-reduced-motion: reduce) {
  .app-splash { animation: splashOut 0.3s ease 0.4s forwards; }
  .app-splash.app-splash-skip { animation: splashOut 0.2s ease forwards; }
  .app-splash-glow, .app-splash-logo, .app-splash-sub, .app-splash-rule, .app-splash-tagline {
    animation: none !important; opacity: 1; transform: none;
  }
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f5f0e7; }
::-webkit-scrollbar-thumb { background: #c8a84b; border-radius: 3px; }

/* ---- SIDEBAR ---- */
.crm-sidebar {
  position: fixed;
  left: 0; top: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--dark);
  border-right: 1px solid rgba(212,175,55,0.15);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.brand-logo {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900;
  color: var(--dark);
  flex-shrink: 0;
}
.brand-logo-img {
  width: 40px; height: 40px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  flex-shrink: 0;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { color: rgba(255,255,255,0.4); font-size: 11px; }

.sidebar-nav { flex: 1; padding: 12px 10px; }
.nav-label {
  padding: 14px 12px 4px;
  color: rgba(255,255,255,0.3);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-weight: 600;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item i { font-size: 16px; width: 20px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,0.07); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(212,175,55,0.2), rgba(212,175,55,0.05));
  color: var(--gold-light);
  border-left: 3px solid var(--gold);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.user-avatar {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px;
  color: var(--dark);
  flex-shrink: 0;
}
.user-avatar-lg {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 32px;
  color: var(--dark);
}
.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: rgba(255,255,255,0.4); font-size: 11px; }
.user-logout { color: rgba(255,255,255,0.35); font-size: 18px; transition: color 0.15s; }
.user-logout:hover { color: #ff6b6b; }

/* ---- TOPBAR ---- */
.crm-topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: rgba(255,252,245,0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  z-index: 90;
  transition: left 0.3s ease;
}
.topbar-toggle {
  background: none; border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px;
  cursor: pointer; font-size: 20px; color: var(--dark-3);
  display: none;
}
.topbar-search { flex: 1; max-width: 400px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  background: none; border: none;
  color: var(--dark-3); font-size: 20px;
  cursor: pointer; padding: 6px;
  position: relative; border-radius: 8px;
  transition: background 0.15s;
}
.topbar-btn:hover { background: var(--gold-soft); }
.notif-badge {
  position: absolute; top: 2px; right: 2px;
  background: #dc3545; color: #fff;
  font-size: 10px; font-weight: 700;
  width: 16px; height: 16px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.topbar-user-name { font-size: 14px; font-weight: 600; color: var(--dark-2); }

/* Notifications dropdown */
.notif-dropdown {
  width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,0.12);
  padding: 0;
  overflow: hidden;
}
.notif-header {
  padding: 12px 16px;
  background: var(--cream);
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px;
}
.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  cursor: pointer;
  transition: background 0.1s;
}
.notif-item:hover { background: var(--cream); }
.notif-item.unread { background: rgba(212,175,55,0.06); }
.notif-title { font-size: 13px; font-weight: 500; color: var(--dark); }
.notif-empty { padding: 20px 16px; text-align: center; color: #999; font-size: 13px; }

/* Search */
.search-input-wrap {
  position: relative; display: flex; align-items: center;
}
.search-input-wrap i {
  position: absolute; left: 10px;
  color: #999; font-size: 14px;
}
.search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255,255,255,0.9);
  font-size: 14px; color: var(--dark);
  outline: none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--gold); }
.search-form { display: flex; gap: 8px; align-items: center; }

/* ---- MAIN CONTENT ---- */
.crm-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--topbar-h);
  padding: 28px;
  min-height: calc(100vh - var(--topbar-h));
  padding-bottom: 40px;
  transition: margin-left 0.3s ease;
}

/* ---- ALERTS ---- */
.messages-wrap { margin-bottom: 16px; }
.crm-alert { border-radius: var(--radius); border: none; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-title { font-family: Georgia, serif; font-size: 28px; font-weight: 700; margin: 0; color: var(--dark); }
.page-sub { margin: 4px 0 0; font-size: 14px; }

/* ---- CARDS ---- */
.crm-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header-crm {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(166,122,33,0.1);
  background: rgba(245,240,231,0.4);
  gap: 12px;
  flex-wrap: wrap;
}
.card-title-crm { font-weight: 700; font-size: 15px; color: var(--dark); }

/* ---- KPI GRID ---- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.kpi-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
  text-decoration: none;
  color: inherit;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.1); }
.kpi-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}
.kpi-value { font-size: 28px; font-weight: 800; line-height: 1; margin-bottom: 4px; font-family: Georgia, serif; }
.kpi-label { font-size: 12px; color: #6b5f50; line-height: 1.3; }

.bg-gold-soft { background: rgba(212,175,55,0.12); }
.bg-success-soft { background: rgba(25,135,84,0.1); }
.bg-warning-soft { background: rgba(255,193,7,0.12); }
.bg-danger-soft { background: rgba(220,53,69,0.1); }
.bg-primary-soft { background: rgba(13,110,253,0.1); }
.text-gold { color: var(--gold-dark) !important; }

/* ---- TABLES ---- */
.crm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.crm-table th {
  background: rgba(245,240,231,0.6);
  padding: 12px 16px;
  font-weight: 600; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: #6b5f50;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.crm-table td {
  padding: 13px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  vertical-align: middle;
}
.crm-table tbody tr:hover { background: rgba(212,175,55,0.04); }
.crm-table tbody tr:last-child td { border-bottom: none; }

/* ---- FORMS ---- */
.form-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  max-width: 900px;
}
.form-control, .form-select {
  border: 1px solid rgba(166,122,33,0.22);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--dark);
  background: #fffaf2;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.15);
  background: #fff;
}

/* ---- BUTTONS ---- */
.btn-gold {
  background: linear-gradient(100deg, #ffe47a, #e8c95f, #d4af37);
  color: var(--dark) !important;
  border: none;
  font-weight: 700;
  border-radius: 10px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(212,175,55,0.35); }
.btn-outline-gold {
  border: 1.5px solid var(--gold);
  color: var(--gold-dark);
  font-weight: 600;
  border-radius: 10px;
  background: transparent;
  transition: all 0.15s;
}
.btn-outline-gold:hover { background: var(--gold-soft); color: var(--gold-dark); }
.btn-xs { padding: 3px 8px; font-size: 12px; }

/* ---- DETAIL VIEW ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.detail-rows { padding: 4px 0; }
.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span:first-child { color: #7a6d5e; font-size: 13px; flex-shrink: 0; }
.detail-row strong, .detail-row a { font-size: 14px; text-align: right; }

/* ---- APARTMENT MAP ---- */
.apt-map { padding: 20px; }
.apt-floor {
  display: flex;
  align-items: center;
  margin-bottom: 8px;
  gap: 12px;
}
.floor-label {
  width: 70px; flex-shrink: 0;
  font-size: 12px; font-weight: 600;
  color: #7a6d5e; text-align: right;
}
.floor-apartments { display: flex; flex-wrap: wrap; gap: 6px; }
.apt-cell {
  position: relative;
  width: 48px; height: 38px;
  border-radius: 8px;
  font-size: 11px; font-weight: 700;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  text-decoration: none;
}
.apt-cell:hover { transform: scale(1.1); z-index: 1; }
.apt-free { background: rgba(25,135,84,0.15); border-color: #198754; color: #155237; }
.apt-free:hover { background: rgba(25,135,84,0.25); }
.apt-booked { background: rgba(255,193,7,0.2); border-color: #ffc107; color: #856404; }
.apt-booked:hover { background: rgba(255,193,7,0.35); }
.apt-sold { background: rgba(220,53,69,0.15); border-color: #dc3545; color: #842029; }
.apt-sold:hover { background: rgba(220,53,69,0.25); }
.apt-unavailable { background: rgba(108,117,125,0.12); border-color: #6c757d; color: #495057; }
.apt-add { background: var(--gold-soft); border-color: var(--gold); color: var(--gold-dark); text-decoration: none; font-size: 18px; }
/* Additive marker — apartment sold on installment/mortgage, not fully paid off yet. Doesn't replace the status color, just flags it. */
.apt-credit-flag::after {
  content: '';
  position: absolute;
  top: -3px; right: -3px;
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #fd7e14;
  border: 1.5px solid #fff;
}
.apt-add:hover { background: rgba(212,175,55,0.25); color: var(--gold-dark); }

.apt-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #6b5f50; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* Apt modal */
.crm-modal { border-radius: var(--radius); border: 1px solid var(--border); }
.apt-modal-info { display: flex; flex-direction: column; gap: 0; }
.apt-modal-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 14px;
}
.apt-modal-row:last-child { border-bottom: none; }
.apt-modal-row span:first-child { color: #7a6d5e; }

/* ---- BLOCKS GRID ---- */
.blocks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; padding: 20px; }
.block-card {
  background: rgba(245,240,231,0.5);
  border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
  text-decoration: none; color: inherit;
  transition: all 0.15s;
  display: block;
}
.block-card:hover { background: #fff; border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.08); }
.block-card.over-budget { border-color: #dc3545; }
.block-name { font-weight: 700; font-size: 16px; margin-bottom: 14px; color: var(--dark); }
.block-stats { display: flex; gap: 12px; }
.block-stat { text-align: center; }
.block-stat-value { font-size: 22px; font-weight: 800; font-family: Georgia, serif; }
.block-stat-label { font-size: 10px; color: #8b7355; margin-top: 2px; }
.block-budget-warn { margin-top: 10px; font-size: 12px; color: #dc3545; font-weight: 600; }

/* ---- DASHBOARD GRID ---- */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  margin-top: 20px;
}
.dashboard-chart-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chart-wrap { padding: 20px; height: 280px; position: relative; }
.dashboard-side {}
.dash-info-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}
.dash-info-title { font-weight: 700; font-size: 14px; margin-bottom: 14px; color: var(--dark); }
.dash-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(0,0,0,0.05); font-size: 13px;
}
.dash-info-row:last-child { border-bottom: none; }

/* Audit list */
.audit-list { padding: 4px 0; }
.audit-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; font-size: 13px;
  border-bottom: 1px solid rgba(0,0,0,0.04);
}
.audit-item:last-child { border-bottom: none; }

/* ---- STAGES ---- */
.stages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; padding: 16px; }
.stage-card {
  background: rgba(245,240,231,0.5);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 14px;
}
.stage-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.stage-name { font-weight: 600; font-size: 13px; }

/* ---- PHOTOS GRID ---- */
.photos-grid { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px; }
.photo-thumb {
  width: 120px; height: 100px;
  border-radius: 8px; overflow: hidden;
  display: block; position: relative; cursor: pointer;
  transition: transform 0.15s;
}
.photo-thumb:hover { transform: scale(1.03); }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-cap {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.55); color: #fff;
  font-size: 10px; padding: 3px 6px;
}

/* ---- PROGRESS BAR ---- */
.bg-gold { background: linear-gradient(90deg, var(--gold-dark), var(--gold-light)) !important; }

/* ---- LOGIN PAGE ---- */
.login-page { background: radial-gradient(circle at 20% 20%, rgba(212,175,55,0.15), transparent 30%), linear-gradient(135deg, #f5f0e7, #e9ddcb); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-wrap { width: 100%; max-width: 440px; padding: 20px; }
.login-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 24px 60px rgba(24,20,16,0.12);
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo-img {
  width: 160px;
  height: auto;
  object-fit: contain;
  margin: 0 auto 10px;
  display: block;
}
.login-sub { color: #8b7355; font-size: 13px; margin-top: 4px; }
.login-demo { border-top: 1px solid var(--border); padding-top: 16px; }
.demo-title { color: #8b7355; }
.demo-item { font-size: 12px; color: #6b5f50; padding: 2px 0; }
.demo-item code { background: rgba(212,175,55,0.15); padding: 1px 5px; border-radius: 4px; color: var(--dark); }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 80px 20px;
  color: #8b7355;
}
.empty-state i { font-size: 64px; display: block; margin-bottom: 16px; opacity: 0.4; }
.empty-state h3 { font-family: Georgia, serif; color: var(--dark); }
.empty-state p { font-size: 15px; margin-bottom: 24px; }

/* ---- MOBILE BOTTOM NAV ---- */
.mobile-bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--dark);
  border-top: 1px solid rgba(212,175,55,0.2);
  display: flex; justify-content: space-around;
  /* env() gives correct padding in PWA/standalone mode on iPhone */
  padding: 8px 0 max(12px, calc(8px + env(safe-area-inset-bottom)));
  z-index: 200;
}
.mob-nav-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; color: rgba(255,255,255,0.5);
  text-decoration: none; font-size: 10px; flex: 1;
  padding: 4px;
  transition: color 0.15s;
  /* Ensure tap targets meet 44px minimum (Apple HIG) */
  min-height: 44px; justify-content: center;
}
.mob-nav-item i { font-size: 22px; }
.mob-nav-item:hover, .mob-nav-item.active { color: var(--gold-light); }

/* ---- RESPONSIVE ---- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .crm-sidebar { transform: translateX(-100%); }
  .crm-sidebar.open { transform: translateX(0); }
  /* Sidebar needs bottom padding so the logout button clears the mobile bottom nav */
  .crm-sidebar { padding-bottom: max(72px, calc(60px + env(safe-area-inset-bottom))); }
  .crm-topbar { left: 0; }
  /* Bottom padding accounts for mobile nav bar + iPhone home indicator */
  .crm-main { margin-left: 0; padding: 16px 14px max(80px, calc(70px + env(safe-area-inset-bottom))); }
  .topbar-toggle { display: flex; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 22px; }
  .kpi-card { padding: 14px; gap: 10px; }
  .kpi-icon { width: 40px; height: 40px; font-size: 18px; }
  .page-title { font-size: 22px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-card { padding: 18px; }
  .crm-table th, .crm-table td { padding: 10px 12px; }
  .blocks-grid { grid-template-columns: 1fr 1fr; padding: 12px; }
  .apt-floor { flex-wrap: wrap; }
  .floor-label { width: 100%; text-align: left; padding-left: 4px; }
  .dashboard-side { display: none; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; }
  .page-header .d-flex { flex-wrap: wrap; }
  .blocks-grid { grid-template-columns: 1fr; }
}

/* ---- SIDEBAR OVERLAY (mobile) ---- */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}
.sidebar-overlay.active { display: block; }

/* ---- MISC ---- */
.fw-mono { font-family: monospace; }
.text-gold { color: var(--gold-dark) !important; }
a.text-gold:hover { color: var(--gold) !important; }
.breadcrumb-item a { color: var(--gold-dark); }
.table-danger { background: rgba(220,53,69,0.07) !important; }
.table-warning { background: rgba(255,193,7,0.1) !important; }

/* ---- EMPTY STATE (h5 variant) ---- */
.empty-state h5 { font-family: Georgia, serif; color: var(--dark); margin-bottom: 16px; }

/* ---- KPI VALUE ---- */
.kpi-value { font-size: 26px; font-weight: 800; font-family: Georgia, serif; line-height: 1.1; }
.kpi-label { font-size: 11px; color: #8b7355; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }

/* ---- PAGE HEADER ---- */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-title { font-size: 26px; font-weight: 800; font-family: Georgia, serif; color: var(--dark); margin: 0; }
.page-sub { color: #8b7355; font-size: 14px; margin: 4px 0 0; }

/* ---- WORKER STATUS BADGE sizes ---- */
.btn-group-sm .btn { min-width: 38px; }

/* ---- ATTENDANCE TABLE mobile ---- */
@media (max-width: 767px) {
  .btn-group .btn { padding: 4px 6px; font-size: 13px; }
  .table-responsive table td, .table-responsive table th { padding: 8px 10px; }
}

/* ---- MOBILE: show workers/materials in bottom nav ---- */
@media (max-width: 767px) {
  .mobile-bottom-nav .mob-nav-item { font-size: 9px; }
  .mobile-bottom-nav .mob-nav-item i { font-size: 20px; }
}

/* ---- CARD improvements ---- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }
.card-header { background: rgba(245,240,231,0.6); border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; padding: 12px 16px; }
.card-footer { border-top: 1px solid var(--border); padding: 10px 16px; }

/* ---- PRINT styles for receipts ---- */
@media print {
  .crm-sidebar, .crm-topbar, .mobile-bottom-nav, .no-print { display: none !important; }
  .crm-main { margin: 0 !important; padding: 0 !important; }
  body { background: #fff; }
}

/* =====================================================
   ANIMATIONS & MODERN ENHANCEMENTS — Poytakht CRM
   Pure CSS + JS, zero dependencies
   ===================================================== */

/* ── Keyframes ───────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0);    }
}
@keyframes fadeIn {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0);     }
}
@keyframes pulseRing {
  0%,100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.8; }
}
@keyframes rippleOut {
  to { transform: scale(90); opacity: 0; }
}
@keyframes shimmerSlide {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}
@keyframes goldGlow {
  0%,100% { box-shadow: 0 0 6px rgba(212,175,55,0.25); }
  50%      { box-shadow: 0 0 18px rgba(212,175,55,0.55); }
}
@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-14px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes borderGrow {
  from { width: 0; } to { width: 100%; }
}

/* ── Page entry ──────────────────────────────────────── */
.crm-main   { animation: fadeIn 0.28s ease; }
.login-card { animation: fadeInUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both; }
.page-header { animation: fadeInUp 0.38s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ── KPI cards — stagger + spring hover ─────────────── */
.kpi-card {
  animation: fadeInUp 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
  transition:
    transform   0.28s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow  0.25s ease,
    border-color 0.2s ease;
}
.kpi-card:nth-child(1) { animation-delay: 0.04s; }
.kpi-card:nth-child(2) { animation-delay: 0.09s; }
.kpi-card:nth-child(3) { animation-delay: 0.14s; }
.kpi-card:nth-child(4) { animation-delay: 0.19s; }
.kpi-card:nth-child(5) { animation-delay: 0.24s; }
.kpi-card:nth-child(6) { animation-delay: 0.29s; }
.kpi-card:hover {
  transform:   translateY(-6px) scale(1.018);
  box-shadow:  0 18px 40px rgba(0,0,0,0.12), 0 4px 12px rgba(212,175,55,0.14);
  border-color: rgba(212,175,55,0.4);
  color: inherit;
  text-decoration: none;
}

/* ── KPI value counter animation trigger ────────────── */
.kpi-value.counting {
  animation: fadeInUp 0.3s ease;
  display: inline-block;
}

/* ── Alerts slide from top ───────────────────────────── */
.crm-alert { animation: slideDown 0.32s cubic-bezier(0.22, 1, 0.36, 1); }

/* ── Table rows stagger ──────────────────────────────── */
.crm-table tbody tr {
  animation: fadeInUp 0.3s ease both;
  transition: background 0.14s ease;
}
.crm-table tbody tr:nth-child(1)  { animation-delay: 0.04s; }
.crm-table tbody tr:nth-child(2)  { animation-delay: 0.08s; }
.crm-table tbody tr:nth-child(3)  { animation-delay: 0.12s; }
.crm-table tbody tr:nth-child(4)  { animation-delay: 0.16s; }
.crm-table tbody tr:nth-child(5)  { animation-delay: 0.20s; }
.crm-table tbody tr:nth-child(6)  { animation-delay: 0.24s; }
.crm-table tbody tr:nth-child(7)  { animation-delay: 0.28s; }
.crm-table tbody tr:nth-child(8)  { animation-delay: 0.32s; }
.crm-table tbody tr:nth-child(9)  { animation-delay: 0.36s; }
.crm-table tbody tr:nth-child(10) { animation-delay: 0.38s; }

/* ── Block cards spring hover ────────────────────────── */
.block-card {
  transition: all 0.26s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.block-card:hover {
  transform:    translateY(-6px) scale(1.022);
  box-shadow:   0 16px 32px rgba(0,0,0,0.1), 0 0 0 1.5px rgba(212,175,55,0.45);
  border-color: rgba(212,175,55,0.5);
}

/* ── Nav items: slide-in indent on hover ─────────────── */
.nav-item { transition: all 0.18s ease; }
.nav-item:not(.active):hover {
  background: rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.92);
  padding-left: 20px;
}

/* ── Sidebar brand logo hover glow ──────────────────── */
.brand-logo-img {
  transition: transform 0.28s ease, box-shadow 0.28s ease;
}
.sidebar-brand:hover .brand-logo-img {
  transform:  scale(1.07);
  box-shadow: 0 0 0 2.5px rgba(212,175,55,0.55);
}

/* ── Sidebar user logout spring ──────────────────────── */
.user-logout {
  transition: color 0.2s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.user-logout:hover { color: #ff6b6b; transform: scale(1.22); }

/* ── Topbar button spring ────────────────────────────── */
.topbar-btn {
  transition: background 0.18s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.topbar-btn:hover { transform: scale(1.12); background: var(--gold-soft); }

/* ── Topbar shadow on scroll ─────────────────────────── */
.crm-topbar { transition: box-shadow 0.3s ease; }
.crm-topbar.scrolled {
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 0 rgba(212,175,55,0.12);
}

/* ── Scroll progress bar ─────────────────────────────── */
.scroll-progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold-dark), var(--gold-light), var(--gold-dark));
  background-size: 200% 100%;
  animation: shimmerSlide 2.5s linear infinite;
  z-index: 9999;
  pointer-events: none;
  border-radius: 0 2px 2px 0;
  transition: width 0.08s linear;
}

/* ── Notification badge pulse ────────────────────────── */
.notif-badge { animation: pulseRing 2.2s ease infinite; }

/* ── Ripple element (added by JS) ────────────────────── */
.btn-ripple {
  position: absolute;
  width: 8px; height: 8px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%;
  transform: scale(0);
  animation: rippleOut 0.55s ease-out forwards;
  pointer-events: none;
  z-index: 0;
}

/* ── Buttons: ensure relative+overflow for ripple ───── */
.btn-gold, .btn-outline-gold { position: relative; overflow: hidden; }

/* ── Enhanced card top accent ────────────────────────── */
.crm-card { border-top: 2px solid rgba(212,175,55,0.28); }
.dash-info-card { border-top: 2px solid rgba(212,175,55,0.22); }
.dashboard-chart-card { border-top: 2px solid rgba(212,175,55,0.22); }

/* ── Cards general appear ────────────────────────────── */
.crm-card, .form-card { animation: fadeInUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }
.dash-info-card       { animation: fadeInUp 0.48s cubic-bezier(0.22, 1, 0.36, 1) both; animation-delay: 0.08s; }
.dashboard-chart-card { animation: fadeInUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ── Mobile nav active spring + glow ─────────────────── */
.mob-nav-item {
  transition: color 0.2s ease, transform 0.24s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
}
.mob-nav-item.active { transform: translateY(-3px); }
.mob-nav-item.active i { text-shadow: 0 0 12px rgba(212,175,55,0.5); }
.mob-nav-item.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 50%;
  width: 22px; height: 3px;
  background: var(--gold);
  border-radius: 3px 3px 0 0;
  transform: translateX(-50%);
  animation: fadeIn 0.25s ease;
}

/* ── Apartment cells spring ──────────────────────────── */
.apt-cell { transition: all 0.22s cubic-bezier(0.34, 1.56, 0.64, 1); }
.apt-cell:hover { transform: scale(1.16); z-index: 3; }

/* ── Form inputs enhanced focus ──────────────────────── */
.form-control, .form-select {
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.form-control:focus, .form-select:focus {
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px rgba(212,175,55,0.18), 0 4px 10px rgba(212,175,55,0.1);
}

/* ── Progress bars: fill animation ──────────────────── */
.progress-bar { transition: width 1.1s cubic-bezier(0.4, 0, 0.2, 1); }

/* ── Focus ring for accessibility ────────────────────── */
.btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px rgba(212,175,55,0.2);
}

/* ── Skeleton loading utility class ─────────────────── */
.skeleton {
  background: linear-gradient(90deg, #ede8df 25%, #e2dbd2 50%, #ede8df 75%);
  background-size: 200% 100%;
  animation: shimmerSlide 1.5s infinite;
  border-radius: 6px;
  color: transparent !important;
  user-select: none;
}

/* ── Stage cards appear ──────────────────────────────── */
.stage-card { animation: fadeInUp 0.35s ease both; }

/* ── Photo thumbs hover ──────────────────────────────── */
.photo-thumb { transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease; }
.photo-thumb:hover { transform: scale(1.06); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }

/* ── Badge success glow (active/available status) ────── */
.badge.bg-success { box-shadow: 0 0 8px rgba(25,135,84,0.35); }
.badge.bg-danger  { box-shadow: 0 0 8px rgba(220,53,69,0.3); }
.badge.bg-warning { box-shadow: 0 0 8px rgba(255,193,7,0.3); }

/* ── Respect prefers-reduced-motion ─────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration:   0.01ms !important;
    animation-delay:      0ms    !important;
    transition-duration:  0.01ms !important;
  }
  .scroll-progress { animation: none; }
}

/* =====================================================
   SIMPLIFIED NAVIGATION — Collapsible sidebar groups
   ===================================================== */
.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.06);
  margin: 10px 14px;
}
.nav-collapse { margin-bottom: 1px; }
.nav-collapse-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,0.62);
  cursor: pointer;
  font-size: 14px;
  user-select: none;
  transition: background 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
}
.nav-collapse-header:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.92);
  padding-left: 18px;
}
.nav-collapse.open .nav-collapse-header { color: rgba(255,255,255,0.9); }
.nav-collapse-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.nav-collapse-label i { font-size: 16px; width: 20px; text-align: center; }
.nav-chevron {
  font-size: 11px;
  color: rgba(255,255,255,0.28);
  flex-shrink: 0;
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1), color 0.2s ease;
}
.nav-collapse.open .nav-chevron { transform: rotate(90deg); color: var(--gold); }
.nav-collapse-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
  padding-left: 8px;
}
.nav-collapse.open .nav-collapse-body { max-height: 400px; }
.nav-sub {
  display: flex;
  align-items: center;
  padding: 8px 12px 8px 30px;
  border-radius: 8px;
  color: rgba(255,255,255,0.46);
  text-decoration: none;
  font-size: 13px;
  margin-bottom: 1px;
  position: relative;
  transition: background 0.15s ease, color 0.15s ease, padding-left 0.15s ease;
}
.nav-sub::before {
  content: '';
  position: absolute;
  left: 13px; top: 50%;
  transform: translateY(-50%);
  width: 4px; height: 4px;
  border-radius: 50%;
  background: rgba(255,255,255,0.16);
  transition: all 0.15s ease;
}
.nav-sub:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); padding-left: 34px; }
.nav-sub:hover::before { background: rgba(255,255,255,0.4); }
.nav-sub.active {
  color: var(--gold-light);
  background: linear-gradient(90deg, rgba(212,175,55,0.14), rgba(212,175,55,0.03));
  font-weight: 500;
}
.nav-sub.active::before { background: var(--gold); width: 6px; height: 6px; }

/* Mobile "More" button */
.mob-nav-more { background: none; border: none; cursor: pointer; outline: none; -webkit-tap-highlight-color: transparent; }

/* =====================================================
   DASHBOARD GREETING
   ===================================================== */
.dash-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(212,175,55,0.15);
  animation: fadeInUp 0.38s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.dash-hello {
  font-family: Georgia, serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
  line-height: 1.2;
}
.dash-date { margin: 4px 0 0; font-size: 14px; color: #8b7355; text-transform: capitalize; }

@media (max-width: 767px) {
  .dash-greeting { flex-direction: column; align-items: flex-start; }
  .dash-hello { font-size: 20px; }
  .dash-greeting .btn { width: 100%; justify-content: center; }
}

/* =====================================================
   ACCESSIBILITY — Larger targets, cleaner labels
   ===================================================== */
.crm-table .btn-sm { min-height: 34px; padding: 5px 12px; font-size: 13px; }
.crm-table td { padding: 14px 16px; }
.crm-table th { padding: 13px 16px; }
.form-control, .form-select { padding: 11px 14px; font-size: 15px; }
label { font-size: 14px; font-weight: 500; color: var(--dark-2); margin-bottom: 5px; }
@media (max-width: 767px) {
  .crm-table td, .crm-table th { padding: 12px 12px; }
  .form-control, .form-select { font-size: 16px; }
}

