:root {
  --blue-dark: #123a8c;
  --blue: #1f6fe0;
  --orange: #f46a1f;
  --ink: #1a2233;
  --slate: #5a6376;
  --bg: #f4f6fb;
  --border: #e2e6f0;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
.muted { color: var(--slate); }

/* Login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--blue-dark), var(--blue)); }
.login-card { background: #fff; padding: 40px; border-radius: 12px; width: 340px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.login-card h1 { margin: 0 0 4px; font-size: 22px; color: var(--blue-dark); }
.login-card label { display: block; margin: 14px 0 4px; font-size: 13px; font-weight: 600; }
.login-card input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.login-card button { margin-top: 20px; width: 100%; padding: 12px; background: var(--orange); color: #fff; border: 0; border-radius: 6px; font-weight: 600; cursor: pointer; }
.error { color: #c0392b; font-size: 13px; min-height: 18px; margin-top: 8px; }

/* App shell */
.app { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: var(--blue-dark); color: #fff; display: flex; flex-direction: column; padding: 20px 0; flex-shrink: 0; }
.brand { font-weight: 700; font-size: 18px; padding: 0 20px 20px; border-bottom: 1px solid rgba(255,255,255,.15); }
.sidebar nav { display: flex; flex-direction: column; padding: 10px 0; flex: 1; }
.nav-link { padding: 12px 20px; text-decoration: none; color: rgba(255,255,255,.8); font-size: 14px; border-left: 3px solid transparent; }
.nav-link:hover { background: rgba(255,255,255,.08); }

/* Notification bell — fixed top-right of the viewport, reachable from
   every page regardless of which view is rendered inside #content. */
.notif-top-right { position: fixed; top: 16px; right: 56px; z-index: 1100; }
.notif-bell-btn-fixed {
  background: #fff; border: 1px solid var(--border); color: var(--ink); font-size: 18px;
  width: 42px; height: 42px; border-radius: 50%; cursor: pointer; position: relative;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(20,30,60,.15);
}
.notif-bell-btn-fixed:hover { background: #f5f8fc; }
.notif-bell-btn-fixed .bell-icon { line-height: 1; }
.notif-badge {
  position: absolute; top: -3px; right: -3px; background: #e74c3c; color: #fff;
  font-size: 10.5px; font-weight: 700; min-width: 17px; height: 17px; border-radius: 9px;
  display: none; align-items: center; justify-content: center; padding: 0 4px; line-height: 1;
}
.notif-badge.show { display: inline-flex; }
.notif-dropdown {
  position: absolute; top: 52px; right: 0; width: 300px; max-height: 420px; overflow-y: auto;
  background: #fff; border-radius: 10px; box-shadow: 0 10px 40px rgba(0,0,0,.3); z-index: 1200;
  color: var(--ink); display: none;
}
.notif-dropdown.show { display: block; }
.notif-dropdown-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.notif-dropdown-head b { font-size: 13.5px; }
.notif-dropdown-head a { font-size: 12px; color: var(--blue); cursor: pointer; text-decoration: none; }
.notif-item { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: #eef4ff; }
.notif-item:hover { background: #f5f8fc; }
.notif-item .notif-msg { font-size: 13px; }
.notif-item .notif-time { font-size: 11px; color: var(--slate); margin-top: 3px; }
.notif-empty { padding: 20px 14px; text-align: center; }

/* Toast for a newly-arrived notification, independent of the dropdown */
.notif-toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 1300; display: flex; flex-direction: column; gap: 10px; }
.notif-toast {
  background: #fff; border-radius: 10px; box-shadow: 0 8px 30px rgba(0,0,0,.25); padding: 14px 16px;
  width: 300px; border-left: 4px solid var(--orange); animation: notif-toast-in .25s ease-out;
}
.notif-toast .notif-msg { font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.notif-toast a { font-size: 12.5px; color: var(--blue); text-decoration: none; }
@keyframes notif-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.nav-link.active { background: rgba(255,255,255,.12); border-left-color: var(--orange); color: #fff; font-weight: 600; }
.logout-btn { margin: 0 20px; padding: 10px; background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; cursor: pointer; }

.content { flex: 1; padding: 30px 40px; overflow-x: hidden; min-width: 0; }
.content h2 { margin-top: 0; color: var(--blue-dark); }

/* Mobile topbar + drawer sidebar — hidden on desktop */
.mobile-topbar { display: none; align-items: center; justify-content: space-between; background: var(--blue-dark); color: #fff; padding: 12px 16px; position: sticky; top: 0; z-index: 500; }
.mobile-topbar .brand-sm { font-weight: 700; font-size: 15px; }
.hamburger-btn { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 900; }
.sidebar-overlay.show { display: block; }

@media (max-width: 860px) {
  .app { flex-direction: column; }
  .mobile-topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 250px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    z-index: 950;
    overflow-y: auto;
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 18px 16px 40px; }
  .notif-top-right { top: 58px !important; right: 14px !important; }
  .dash-banner { flex-direction: column; align-items: flex-start; padding: 18px 20px; }
  .dash-banner .figure { text-align: left; }
  .highlight-banner { padding: 16px 18px; }
  .two-col { gap: 14px; }
}

@media (max-width: 480px) {
  .status-breakdown { flex-direction: column; }
  .status-pill { min-width: 0; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar > div { width: 100%; }
  .login-card { width: 90%; max-width: 340px; padding: 28px 24px; }
}

/* Any table can outgrow a narrow screen — scroll just the table, not the page */
.card { overflow-x: auto; }
.card table { min-width: 560px; }

/* Generic components */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.btn { background: var(--blue); color: #fff; border: 0; padding: 9px 16px; border-radius: 6px; cursor: pointer; font-size: 14px; }
.btn.secondary { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn.danger { background: #fff; color: #c0392b; border: 1px solid #c0392b; }
.btn.orange { background: var(--orange); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: top; }
th { color: var(--slate); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
input, textarea, select { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; font-family: inherit; }
label { font-size: 13px; font-weight: 600; display: block; margin: 12px 0 4px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: #fff; border-radius: 10px; padding: 18px; border: 1px solid var(--border); }
.stat .num { font-size: 28px; font-weight: 700; color: var(--blue-dark); }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.new { background: #fde9e0; color: var(--orange); }
.badge.contacted { background: #e5edfc; color: var(--blue); }
.badge.converted { background: #e2f6ea; color: #1a7a3a; }
.badge.closed { background: #eee; color: var(--slate); }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.section-block { border: 1px solid var(--border); border-radius: 8px; padding: 16px; margin-bottom: 14px; }
.section-block .sb-head { display: flex; justify-content: space-between; align-items: center; }
.thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
.media-item img { width: 100%; height: 100px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }

/* ---------- LMS additions ---------- */
.nav-divider { height: 1px; background: rgba(255,255,255,.15); margin: 10px 20px; }
.tag-chip { font-weight: 600; }
.notes-log { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; background: var(--bg); }
.note-item { padding: 8px 0; border-bottom: 1px solid var(--border); }
.note-item:last-child { border-bottom: 0; }
select.assign-select { font-size: 13px; padding: 5px 6px; }
input[type="checkbox"] { width: auto !important; }

/* ---------- Analytical dashboard ---------- */
.dash-banner {
  background: linear-gradient(135deg, var(--blue-dark), #1a3f8c);
  color: #fff;
  border-radius: 12px;
  padding: 24px 28px;
  margin-bottom: 22px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 20px;
}
.dash-banner h2 { margin: 0 0 4px; color: #fff; font-size: 20px; }
.dash-banner .sub { color: rgba(255,255,255,.75); font-size: 13.5px; margin-bottom: 12px; }
.dash-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.dash-chip {
  background: rgba(255,255,255,.12);
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12.5px;
  color: #fff;
}
.dash-banner .figure { text-align: right; }
.dash-banner .figure .big { font-size: 30px; font-weight: 700; color: #fff; }
.dash-banner .figure .label { font-size: 12px; color: rgba(255,255,255,.7); }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  position: relative;
  border-radius: 10px;
  padding: 18px;
  background: #fff;
  border: 1px solid var(--border);
}
.stat-card .icon-badge {
  position: absolute; top: 16px; right: 16px;
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.stat-card .label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; color: var(--slate); padding-right: 38px; }
.stat-card .num { font-size: 27px; font-weight: 700; margin-bottom: 3px; color: var(--ink); }
.stat-card .note { font-size: 12px; color: var(--slate); }
.stat-card a.cta { display: inline-block; margin-top: 10px; font-size: 12.5px; font-weight: 700; text-decoration: none; }
.stat-card button.cta-btn {
  display: inline-block; margin-top: 12px; width: 100%;
  border: 0; border-radius: 7px; padding: 9px 12px;
  font-size: 12.5px; font-weight: 700; cursor: pointer;
}

.stat-card.urgent { border: 1.5px solid #f0c96b; background: #fffdf7; }
.stat-card.urgent .icon-badge { background: #fdf0d2; color: #b8860b; }
.stat-card.urgent .num { color: #9a7615; }
.stat-card.urgent a.cta { color: #9a7615; }

.stat-card.plain .icon-badge { background: #eef4ff; color: var(--blue); }
.stat-card.plain.money .icon-badge { background: #e9f8ee; color: #1a7a3a; }

.stat-card.attention { border: 1.5px solid #f3b3ab; background: #fffafa; }
.stat-card.attention .icon-badge { background: #fbdad6; color: #c0392b; }
.stat-card.attention .num { color: #c0392b; }
.stat-card.attention button.cta-btn { background: #e0472c; color: #fff; }
.stat-card.attention button.cta-btn:hover { background: #c53a22; }

.highlight-banner {
  background: var(--blue-dark);
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 20px;
  color: #fff;
}
.highlight-banner .hb-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.highlight-banner .hb-head .title { font-weight: 700; font-size: 14.5px; display: flex; align-items: center; gap: 8px; }
.highlight-banner .hb-head a { color: rgba(255,255,255,.85); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.hb-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.hb-tile { background: rgba(255,255,255,.08); border-radius: 8px; padding: 14px 16px; text-align: center; }
.hb-tile .n { font-size: 24px; font-weight: 700; color: #fff; }
.hb-tile .l { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 3px; }

.card-head-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.card-head-row h3 { margin: 0; }
.card-head-row a { font-size: 12.5px; font-weight: 600; color: var(--blue); text-decoration: none; }

/* Reminders page filter bar */
.filters-bar { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.filters-bar .filter-field { display: flex; flex-direction: column; gap: 5px; }
.filters-bar .filter-field label {
  margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--slate);
}
.filters-bar select, .filters-bar input[type="date"] { width: auto; min-width: 168px; height: 38px; }
.filters-bar .filter-field.clear-field label { visibility: hidden; }
.filters-bar .btn { height: 38px; padding: 0 16px; }
@media (max-width: 700px) {
  .filters-bar select, .filters-bar input[type="date"] { min-width: 0; width: 100%; }
  .filters-bar .filter-field { width: 100%; }
}

.status-breakdown { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.status-pill {
  flex: 1; min-width: 120px;
  border-radius: 10px; padding: 14px 16px;
  border: 1px solid var(--border); background: #fff;
}
.status-pill .n { font-size: 20px; font-weight: 700; }
.status-pill .l { font-size: 12px; color: var(--slate); text-transform: capitalize; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-top: 10px; }
.filter-grid label { margin: 0 0 4px; font-size: 12px; }
.filter-grid input, .filter-grid select { font-size: 13px; padding: 7px 9px; }

/* Inline Notes & Tags panel — expands directly under a lead's own row */
tr.notes-row td { background: var(--bg); border-bottom: 2px solid var(--border); padding: 16px 20px; }
.notes-inline-box { max-width: 640px; }
.notes-inline-box label:first-child { margin-top: 0; }

/* Lead Detail page */
.lead-name-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.lead-name-link:hover { color: var(--blue); text-decoration: underline; }
.lead-detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .lead-detail-grid { grid-template-columns: 1fr; } }
.detail-rows { display: flex; flex-direction: column; gap: 10px; }
.detail-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.detail-row:last-child { border-bottom: 0; }
.detail-row .muted { flex: 0 0 150px; }
.mini-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.mini-row:last-child { border-bottom: 0; }
.mini-row .count { background: var(--bg); padding: 2px 10px; border-radius: 12px; font-weight: 700; font-size: 12.5px; color: var(--blue-dark); }
.attend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.attend-dot.present { background: #1a7a3a; }
.attend-dot.late { background: var(--orange); }
.attend-dot.leave, .attend-dot.absent { background: #9aa6b6; }
.attend-dot.none { background: #d8dde5; }

.rule-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 13.5px; cursor: pointer; }
.rule-row input[type="checkbox"], .rule-row input[type="radio"] { width: auto !important; margin-right: 8px; }

/* ---------- Attendance: tabs, cards, calendar ---------- */
.att-tabs { display: flex; gap: 6px; }
.att-tab { background: #fff; border: 1px solid var(--border); color: var(--slate); padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.att-tab.active { background: var(--blue); color: #fff; border-color: var(--blue); }

.att-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.att-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.att-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.att-card-name { font-weight: 700; font-size: 14.5px; color: var(--ink); }
.att-card-shift { font-size: 11.5px; margin-top: 2px; }
.att-status { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.att-status.active, .att-status.present { background: #e2f6ea; color: #1a7a3a; }
.att-status.late { background: #fde9e0; color: var(--orange); }
.att-status.half_day { background: #f1e6fb; color: #6a3fb0; }
.att-status.leave { background: #e5edfc; color: var(--blue); }
.att-status.absent { background: #fbdad6; color: #c0392b; }
.att-worktime { background: #e2f6ea; border-radius: 8px; padding: 10px 12px; text-align: center; margin: 10px 0; }
.att-worktime .att-timer { display: block; font-size: 18px; font-weight: 700; color: #1a7a3a; }
.att-login-row { display: flex; gap: 12px; margin-top: 10px; font-size: 13px; }
.att-login-row > div { flex: 1; }

.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-weekdays > div { text-align: center; font-size: 11px; font-weight: 700; color: var(--slate); text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-cell { min-height: 64px; border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; cursor: pointer; background: #fff; }
.cal-cell:hover { border-color: var(--blue); }
.cal-cell.blank { border: 0; cursor: default; background: transparent; }
.cal-cell.today { border-color: var(--orange); border-width: 2px; }
.cal-daynum { font-size: 12.5px; font-weight: 700; display: flex; align-items: center; gap: 5px; }
.cal-summary { font-size: 11px; color: var(--slate); margin-top: 6px; }
.cal-shift-label { font-size: 10.5px; color: var(--slate); margin-top: 6px; }
@media (max-width: 700px) {
  .cal-cell { min-height: 48px; padding: 4px 5px; }
  .cal-weekdays > div { font-size: 9.5px; }
  .cal-daynum { font-size: 11px; }
  .cal-summary, .cal-shift-label { font-size: 9.5px; }
}

/* Import Leads modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(10, 20, 40, 0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px;
}
.modal-box {
  background: #fff; border-radius: 10px; padding: 24px; width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
.modal-box input[type="file"] {
  width: 100%; padding: 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px;
}
/* Leads pagination */
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0 24px; }
.pager-info { color: var(--slate); font-size: 13.5px; }
.pager-btns { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pager-btn { min-width: 36px; height: 36px; padding: 0 10px; border: 1px solid var(--border); background: #fff; color: var(--ink); border-radius: 6px; cursor: pointer; font-size: 13.5px; }
.pager-btn:hover:not(:disabled):not(.active) { border-color: var(--blue); color: var(--blue); }
.pager-btn.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; cursor: default; }
.pager-btn:disabled { opacity: .45; cursor: not-allowed; }
.pager-gap { padding: 0 4px; color: var(--slate); }
@media (max-width: 768px) { .pager { justify-content: center; } .pager-info { width: 100%; text-align: center; } }
