* { margin:0; padding:0; box-sizing:border-box; font-family: 'Segoe UI', Arial, sans-serif; }
html, body { height:100%; }
body { display:flex; flex-direction:column; background:#0f172a; }

#login-screen {
  height:100%; width:100%;
  display:flex; align-items:center; justify-content:center;
  background: linear-gradient(135deg, #0f172a, #1e3a8a);
}
.login-card {
  background:#fff; width:340px; max-width:90vw;
  border-radius:16px; padding:32px 28px;
  box-shadow:0 10px 40px rgba(0,0,0,0.4);
}
.login-card h1 { font-size:22px; color:#1e3a8a; text-align:center; margin-bottom:4px; }
.login-card p.sub { text-align:center; color:#64748b; font-size:13px; margin-bottom:22px; }
.login-card label { display:block; font-size:13px; font-weight:600; color:#334155; margin-bottom:6px; margin-top:14px; }
.login-card input {
  width:100%; padding:11px 12px; border:1.5px solid #cbd5e1; border-radius:8px;
  font-size:14px; outline:none; transition:border 0.2s;
}
.login-card input:focus { border-color:#1e3a8a; }
.login-card button {
  width:100%; margin-top:22px; padding:12px; background:#1e3a8a; color:#fff;
  border:none; border-radius:8px; font-size:15px; font-weight:700; cursor:pointer; transition:background 0.2s;
}
.login-card button:hover { background:#1e40af; }
.login-card button:disabled { opacity:0.6; cursor:not-allowed; }
#login-error { color:#dc2626; font-size:13px; text-align:center; margin-top:12px; min-height:16px; font-weight:600; }
.home-link {
  display:block;
  text-align:center;
  margin-top:16px;
  font-size:13px;
  font-weight:600;
  color:#64748b;
  text-decoration:none;
}
.home-link:hover { color:#1e3a8a; text-decoration:underline; }

header {
  background: linear-gradient(135deg, #1e3a8a, #1e40af);
  padding: 14px 20px;
  display:flex; align-items:center; justify-content:space-between;
  flex-wrap:wrap; gap:10px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  z-index:10;
  position: relative; /* taaki #navCollapseBtn (position:absolute) header ke andar hi sahi jagah rahe */
}
.brand { color:#fff; font-size:20px; font-weight:700; display:flex; align-items:center; gap:8px; white-space:nowrap; }
.brand span.sub { font-size:12px; font-weight:400; color:#cbd5e1; display:block; }
.header-right { display:flex; align-items:center; gap:14px; flex-wrap:wrap; }
.tabs { display:flex; gap:10px; background: rgba(255,255,255,0.08); padding:6px; border-radius:12px; }
.tab-btn {
  padding:10px 20px; border:none; border-radius:8px; background:transparent; color:#e2e8f0;
  font-size:14px; font-weight:600; cursor:pointer; transition: all 0.2s ease; white-space:nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.12); }
.tab-btn.active { background: #fff; color:#1e3a8a; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.user-chip { display:flex; align-items:center; gap:10px; background:rgba(255,255,255,0.1); padding:8px 14px; border-radius:10px; color:#fff; font-size:13px; }
.user-chip .role-badge { background:#facc15; color:#7c2d12; font-size:10px; font-weight:800; padding:2px 8px; border-radius:20px; text-transform:uppercase; }
.logout-btn { background:#dc2626; color:#fff; border:none; padding:8px 16px; border-radius:8px; font-size:13px; font-weight:700; cursor:pointer; }
.logout-btn:hover { background:#b91c1c; }
.home-btn {
  background:rgba(255,255,255,0.12);
  color:#fff;
  border:1px solid rgba(255,255,255,0.3);
  padding:8px 16px;
  border-radius:8px;
  font-size:13px;
  font-weight:700;
  cursor:pointer;
  text-decoration:none;
  display:inline-block;
}
.home-btn:hover { background:rgba(255,255,255,0.22); }

.frame-wrap { flex:1; position:relative; background:#f1f5f9; overflow:auto; }
iframe { width:100%; height:100%; border:none; display:none; }
iframe.active { display:block; }
.loading, .no-access { display:flex; align-items:center; justify-content:center; height:100%; color:#64748b; font-size:16px; text-align:center; padding:20px; }

#admin-panel { display:none; padding:24px; overflow:auto; height:100%; }
#admin-panel.active { display:block; }
#leadgen-panel { display:none; padding:28px 40px; overflow:auto; height:100%; width:100%; box-sizing:border-box; }
#leadgen-panel.active { display:block; }
.lg-layout { display:flex; gap:20px; align-items:flex-start; }
.lg-sidebar {
  width:220px; flex-shrink:0;
  display:flex; flex-direction:column; gap:6px;
  background:#fff; border-radius:14px; padding:12px;
  box-shadow:0 2px 12px rgba(0,0,0,0.1);
  border:1px solid #f1f5f9;
  position:sticky; top:20px;
}
.lg-side-btn {
  display:flex; align-items:center; gap:12px;
  padding:12px 14px; border:none; border-radius:10px;
  background:transparent; color:#334155;
  font-size:14px; font-weight:700; text-align:left; cursor:pointer;
  transition: background 0.15s, color 0.15s;
  outline:none;
  width:100%;
  box-sizing:border-box;
  font-family: inherit;
}
.lg-side-btn .lg-icon {
  display:inline-flex; align-items:center; justify-content:center;
  width:30px; height:30px; border-radius:8px; flex-shrink:0;
  background:#f1f5f9; font-size:15px;
}
.lg-side-btn span:last-child { flex:1; }
.lg-side-btn:hover { background:#f8fafc; }
.lg-side-btn:hover .lg-icon { background:#e2e8f0; }
.lg-side-btn.active { background:#7c2d12; color:#fff; box-shadow:0 4px 10px rgba(124,45,18,0.25); }
.lg-side-btn.active .lg-icon { background:rgba(255,255,255,0.2); }
.lg-content { flex:1; min-width:0; }
@media (max-width:900px) {
  .lg-layout { flex-direction:column; }
  .lg-sidebar { width:100%; flex-direction:row; overflow-x:auto; position:static; -webkit-overflow-scrolling:touch; }
  .lg-side-btn { flex-shrink:0; white-space:nowrap; width:auto; }
}
.lg-form-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:16px; }
.lg-form-grid .field-group input, .lg-form-grid .field-group select { min-width:0; width:100%; padding:10px 12px; }
@media (max-width:700px){ .lg-form-grid { grid-template-columns:1fr; } }
#marketing-panel { display:none; padding:24px; overflow:auto; height:100%; }
#marketing-panel.active { display:block; }
.lead-status { padding:4px 10px; border-radius:20px; font-size:11px; font-weight:700; border:none; cursor:pointer; }
.lead-status.new { background:#fef3c7; color:#92400e; }
.lead-status.contacted { background:#dbeafe; color:#1e40af; }
.lead-status.closed { background:#dcfce7; color:#166534; }
.admin-box { background:#fff; border-radius:14px; padding:22px; width:100%; box-sizing:border-box; margin:0 0 20px 0; box-shadow:0 2px 10px rgba(0,0,0,0.08); }
.admin-box h2 { color:#1e3a8a; font-size:18px; margin-bottom:16px; }
.add-user-form { display:flex; gap:10px; flex-wrap:wrap; align-items:flex-end; margin-bottom:8px; }
.field-group { display:flex; flex-direction:column; gap:5px; }
.field-group label { font-size:12px; font-weight:700; color:#475569; }
.field-group input, .field-group select { padding:9px 11px; border:1.5px solid #cbd5e1; border-radius:7px; font-size:13px; min-width:150px; }
.perm-group { display:flex; flex-direction:column; gap:6px; background:#f8fafc; border:1.5px solid #e2e8f0; border-radius:7px; padding:8px 12px; }
.perm-group span.perm-title { font-size:12px; font-weight:700; color:#475569; }
.perm-checkbox { display:flex; align-items:center; gap:6px; font-size:12px; color:#334155; }
.btn-primary { background:#1e3a8a; color:#fff; border:none; padding:10px 20px; border-radius:7px; font-size:13px; font-weight:700; cursor:pointer; }
.btn-primary:hover { background:#1e40af; }
#add-user-msg { font-size:12px; margin-top:8px; font-weight:600; min-height:16px; }

table.user-table { width:100%; border-collapse:collapse; margin-top:14px; font-size:13px; }
table.user-table th { text-align:left; background:#eef2ff; color:#1e3a8a; padding:10px 12px; font-size:12px; text-transform:uppercase; letter-spacing:0.4px; }
table.user-table td { padding:10px 12px; border-bottom:1px solid #e2e8f0; color:#1f2937; vertical-align:middle; }
table.user-table tr:hover td { background:#f8fafc; }
.pw-mask { font-family:monospace; letter-spacing:2px; }
.pill { display:inline-block; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:700; }
.pill.admin { background:#fef3c7; color:#92400e; }
.pill.user { background:#dbeafe; color:#1e40af; }
.pill.active { background:#dcfce7; color:#166534; }
.pill.inactive { background:#fee2e2; color:#991b1b; }
.perm-cell { display:flex; flex-direction:column; gap:4px; }
.perm-cell label { display:flex; align-items:center; gap:6px; font-size:12px; }
.perm-full { font-size:11px; font-weight:700; color:#92400e; }
.row-actions button { border:none; padding:6px 10px; border-radius:6px; font-size:11px; font-weight:700; cursor:pointer; margin-right:6px; margin-bottom:6px; }
.btn-edit { background:#e0e7ff; color:#3730a3; }
.btn-toggle { background:#fef9c3; color:#854d0e; }
.btn-delete { background:#fee2e2; color:#991b1b; }

@media (max-width: 700px) {
  header { padding:10px 12px; }
  .brand { font-size:16px; }
  .tab-btn { padding:8px 12px; font-size:12px; }
  .add-user-form { flex-direction:column; align-items:stretch; }
  .field-group input, .field-group select { min-width:0; width:100%; }
}

/* ===== NOTIFICATION BELL ===== */
#notif-bell-btn:hover { background:rgba(255,255,255,.28) !important; }
#notif-panel { animation: notifFadeIn .18s ease; }
@keyframes notifFadeIn { from { opacity:0; transform:translateY(-6px); } to { opacity:1; transform:translateY(0); } }
.notif-item { display:flex; gap:10px; padding:12px 14px; border-bottom:1px solid #f1f5f9; align-items:flex-start; }
.notif-item:hover { background:#f8fafc; }
.notif-icon { font-size:18px; flex-shrink:0; margin-top:1px; }
.notif-body { flex:1; min-width:0; }
.notif-module { font-size:10px; font-weight:800; text-transform:uppercase; letter-spacing:.4px; color:#2563eb; margin-bottom:2px; }
.notif-msg { font-size:13px; color:#0f172a; line-height:1.4; word-break:break-word; }
.notif-time { font-size:11px; color:#94a3b8; margin-top:3px; }
.notif-hide-btn { background:#f1f5f9; border:none; color:#64748b; font-size:11px; font-weight:700; padding:4px 9px; border-radius:6px; cursor:pointer; flex-shrink:0; white-space:nowrap; }
.notif-hide-btn:hover { background:#e2e8f0; color:#334155; }
.notif-empty { padding:36px 14px; text-align:center; color:#94a3b8; font-size:13px; }

@media (max-width: 700px) {
  #notif-panel { position:fixed !important; right:8px !important; left:8px; width:auto !important; top:64px !important; max-height:70vh; }
}

/* ============================================================
   ADDITIONAL MOBILE-RESPONSIVE FIXES (added, nothing above changed)
   ============================================================ */

/* Safety net: kabhi bhi page horizontally scroll na ho.
   NOTE: overflow sirf <html> par lagaya hai, <body> par nahi -
   dono par ek saath lagane se kuch mobile browsers (khaaskar
   Safari) body ko ek alag scroll-container bana dete hain, jisse
   sticky/fixed elements aur nested scroll behavior gadbad ho
   sakta hai. */
html { overflow-x: hidden; }
body { max-width: 100%; }

/* Tab pill-bar: agar 4 tabs + notif + home + logout ek line me na aayen,
   to andar scroll ho (wrap se pill design toot jata, isliye scroll behtar hai)
   CRITICAL FIX: .tabs ek flex-child hai (.header-right ke andar), aur
   flex-children ka default "min-width: auto" hota hai — jiski wajah se
   browser ise kabhi shrink hi nahi hone deta tha, isliye overflow-x:auto
   kaam nahi kar raha tha aur "Admin" tab bas cut/clip ho raha tha, scroll
   nahi ho raha tha. min-width:0 dene se ab yeh sahi se shrink + scroll
   karta hai. */
.tabs {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none; /* Firefox */
}
.tabs::-webkit-scrollbar { display: none; } /* Chrome/Safari */

/* Har table.user-table (Users list, Meri Leads, etc.) ko horizontal
   scroll dena - table ke andar hi, page ko squish kiye bina.
   (display:block + overflow-x:auto ek well-known trick hai jo
   bina HTML badle kaam karti hai) */
table.user-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}
table.user-table thead, table.user-table tbody { display: table; width: max-content; min-width: 100%; }

@media (max-width: 700px) {
  /* Lead Generation panel - bada padding chhote screen par kam karein */
  #leadgen-panel { padding: 16px 14px; }
  #admin-panel { padding: 14px; }
  .admin-box { padding: 16px 14px; }

  /* Header ke andar user-chip/logout group - thoda compact */
  .user-chip { padding:6px 10px; font-size:12px; gap:6px; }
  .home-btn { padding:6px 12px; font-size:12px; }
  .logout-btn { padding:6px 12px; font-size:12px; }

  /* Tap targets kam se kam 40px height rahe - accessibility + easy tapping */
  .tab-btn, .btn-primary, .home-btn, .logout-btn { min-height: 38px; }
}

@media (max-width: 420px) {
  /* Bahut chhote phone (iPhone SE jaisa) ke liye extra tight fit */
  .brand { font-size: 14px; gap: 6px; }
  .brand img { height: 26px !important; width: 26px !important; }
  header { padding: 8px 10px; gap: 6px; }
  .tab-btn { padding: 8px 10px; font-size: 11px; }
  .user-chip .role-badge { display: none; } /* role badge chhupa dein, sirf name dikhe */
}

/* ============================================================
   HEADER COLLAPSE (user request: khali jagah kam ho, header ke
   side mein ek chota hide/show button ho jisse content dekhne ke
   liye zyada space mile). Sirf mobile par active — .tabs (asli
   navigation) hamesha dikhta rahega, sirf notif bell / Home /
   user-chip+logout chhup jaate hain jab collapse kiya jaaye.
   Button ab .header-right ke andar normal flex-item hai (position
   absolute nahi) — isse hamesha sahi line mein, sahi size mein
   dikhta hai, chahe header ki width kuch bhi ho. */
@media (max-width: 900px) {
  #navCollapseBtn { display: flex !important; order: -1; }
  body.nav-header-collapsed #notif-bell-wrap,
  body.nav-header-collapsed .home-btn,
  body.nav-header-collapsed .header-right > div:last-child {
    display: none !important;
  }
}
@media (min-width: 901px) {
  #navCollapseBtn { display: none !important; } /* desktop par zaroorat nahi, poori jagah already hai */
}

