/* =====================================================================
   EP Base UI · SHELL — app grid, ink sidebar, glass topbar, mobile tabs
   Component C1. Assumes tokens.css is loaded first.
   ===================================================================== */

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-slate-800);
  font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }

/* Fixed shell frame: page never scrolls, only .main scrolls -> sidebar &
   topbar stay locked to the viewport at any browser zoom level. */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--ink-grad);
  border-right: 1px solid rgba(255,255,255,.06);
  color: #fff;
  display: flex; flex-direction: column;
  padding: 22px 16px;
  height: 100%;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.18) transparent;
}
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.18); border-radius: 3px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px;
  border-bottom: 1px solid rgba(255,255,255,.08); margin-bottom: 18px;
  text-decoration: none; color: inherit; cursor: pointer; }
.brand:hover .brand-name { color: var(--color-amber-400); }
.brand-mark {
  width: 38px; height: 38px; border-radius: 13px;
  background: var(--gold-grad); color: #1a1206;
  display: grid; place-items: center;
  font-family: var(--font-serif); font-weight: 600; font-size: 18px;
  letter-spacing: -.5px; position: relative; overflow: hidden;
  box-shadow: 0 6px 18px -6px rgba(182,134,31,.7), inset 0 1px 0 rgba(255,255,255,.55);
}
.brand-name { font-family: var(--font-serif); font-weight: 600; font-size: 18px; letter-spacing: .2px; }
.brand-tag { font-size: 10px; color: var(--color-amber-400); letter-spacing: .12em; text-transform: uppercase; }

.nav-section { margin-bottom: 18px; }
.nav-label { font-size: 10px; color: rgba(255,255,255,.4); text-transform: uppercase;
  letter-spacing: .1em; padding: 0 12px 6px; }
.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px;
  color: rgba(255,255,255,.78); font-size: 13.5px; font-weight: 500; margin-bottom: 1px;
  transition: background .15s, color .15s; cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.is-active {
  background: linear-gradient(90deg, rgba(216,173,63,.20), rgba(216,173,63,.04));
  color: #fff;
}
.nav-item.is-active::before {
  content: ''; position: absolute; left: 0; top: 18%; bottom: 18%;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--gold-grad);
}
.nav-item.is-active .nav-icon { color: var(--color-amber-400); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: rgba(255,255,255,.5); text-align: center;
  display: inline-flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 18px; height: 18px; display: block; }
.nav-badge { margin-left: auto; background: rgba(216,173,63,.2); color: var(--color-amber-400);
  font-size: 10.5px; padding: 2px 7px; border-radius: 999px; font-weight: 600; }

/* Quick Actions group — gold-tinted action shortcuts, visually distinct from nav */
.nav-quick { margin-top: 4px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.nav-quick-item { color: rgba(255,255,255,.72); }
.nav-quick-item .nav-icon { color: var(--color-amber-400); font-weight: 700; }
.nav-quick-item:hover { background: rgba(216,173,63,.12); color: #fff; }

.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.08);
  position: sticky; bottom: -22px; background: #0a1222;
  margin: auto -16px -22px; padding: 16px 16px 22px; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); }

/* ---------- Main + topbar ---------- */
.main { display: flex; flex-direction: column; min-width: 0;
  height: 100%; overflow-y: auto; overflow-x: hidden; }
.topbar {
  background: rgba(255,255,255,.86); backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--color-border);
  padding: 14px 32px; display: flex; align-items: center; gap: 16px;
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-family: var(--font-serif); font-weight: 600; font-size: 20px;
  color: var(--color-slate-900); letter-spacing: .2px; }
.topbar-meta { color: var(--color-slate-500); font-size: 13px; }
.topbar-spacer { flex: 1; }
.topbar-search-wrap { position: relative; display: flex; align-items: center; }
.topbar-search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: inline-flex; color: var(--color-slate-400); pointer-events: none;
}
.topbar-search-icon svg { width: 16px; height: 16px; }
.topbar-search {
  background: #fff; border: 1px solid var(--color-border); border-radius: var(--radius);
  padding: 9px 16px 9px 40px; font-size: 13.5px; width: 340px; color: var(--color-slate-800);
  font-family: inherit; transition: border-color .15s, box-shadow .15s;
}
.topbar-search::placeholder { color: var(--color-slate-400); }
.topbar-search:focus { outline: none; border-color: var(--focus-border); box-shadow: 0 0 0 3px var(--focus-ring); }
.topbar-search:focus + .topbar-search-icon,
.topbar-search-wrap:focus-within .topbar-search-icon { color: var(--color-slate-500); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; background: #fff;
  border: 1px solid var(--color-border); display: grid; place-items: center;
  cursor: pointer; color: var(--color-slate-600); font-size: 15px;
  transition: background .15s, border-color .15s;
}
.icon-btn:hover { background: var(--color-slate-100); border-color: var(--color-slate-300); }
.icon-btn svg { width: 18px; height: 18px; }
/* Notification bell + unread dot */
.icon-btn-bell { position: relative; }
.icon-btn-bell.has-dot::after {
  content: ''; position: absolute; top: 8px; right: 9px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--color-red-500, #e5484d);
  box-shadow: 0 0 0 2px #fff;
}

/* ---------- Notifications dropdown ---------- */
.notif-panel {
  width: 380px; max-width: calc(100vw - 24px); max-height: min(560px, 80vh);
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--color-border); border-radius: 14px;
  box-shadow: var(--shadow-lg, 0 18px 48px -12px rgba(16,24,40,.28)); z-index: 1200;
  animation: notif-in .14s cubic-bezier(.4,0,.2,1);
}
@keyframes notif-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--color-border);
}
.notif-title { font-family: var(--font-serif); font-weight: 600; font-size: 15px; color: var(--color-slate-900); }
.notif-markall {
  background: none; border: none; cursor: pointer; padding: 4px 6px; font: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--color-amber-700); border-radius: 6px;
}
.notif-markall:hover { background: var(--color-amber-100); }
.notif-body { overflow-y: auto; flex: 1; }
.notif-empty { padding: 32px 16px; text-align: center; color: var(--color-slate-500); font-size: 13px; }
.notif-item {
  display: flex; align-items: flex-start; gap: 12px; padding: 12px 16px; text-decoration: none;
  border-bottom: 1px solid var(--color-slate-100); transition: background .12s; position: relative;
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-slate-100); }
.notif-item.is-unread { background: rgba(205,162,58,.06); }
.notif-item.is-unread:hover { background: rgba(205,162,58,.1); }
.notif-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.notif-ico svg { width: 17px; height: 17px; }
.notif-main { min-width: 0; flex: 1; }
.notif-item-title { font-size: 13.5px; font-weight: 600; color: var(--color-slate-900); line-height: 1.3; }
.notif-item-text { font-size: 12.5px; color: var(--color-slate-500); line-height: 1.4; margin-top: 2px; }
.notif-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.notif-time { font-size: 11px; color: var(--color-slate-400); white-space: nowrap; }
.notif-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-amber-500); }
.notif-foot { padding: 10px 16px; border-top: 1px solid var(--color-border); text-align: center; }
.notif-viewall { font-size: 12.5px; font-weight: 600; color: var(--color-navy-700); text-decoration: none; }
.notif-viewall:hover { color: var(--color-navy-800); text-decoration: underline; }

.content { padding: 28px 32px 64px; flex: 1; }
.page-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head-spacer { flex: 1; }

/* "← Back to Dashboard" affordance injected when a page is opened from a KPI card */
.ep-back { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600;
  color: var(--color-slate-500); text-decoration: none; margin-bottom: 8px; padding: 4px 10px;
  border: 1px solid var(--color-border); border-radius: 8px; background: var(--color-card); }
.ep-back:hover { color: var(--color-navy-800); border-color: var(--color-navy-500); }

/* ---------- Mobile shell (off-canvas drawer + bottom tab bar) ---------- */
.hamburger { display: none; }
.mobile-nav { display: none; }
.sidebar-backdrop { display: none; }

@media (max-width: 1024px) {
  .app { display: block; }
  .main { width: 100%; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 280px; height: auto; z-index: 1000;
    transform: translateX(-100%); transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,18,34,.5);
    backdrop-filter: blur(2px); z-index: 900; opacity: 0; visibility: hidden; transition: opacity .25s; }
  .sidebar-backdrop.show { opacity: 1; visibility: visible; }
  .hamburger { display: inline-flex; align-items: center; justify-content: center; }
  .topbar { gap: 8px; }
  .topbar-title { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 55vw; }
  .topbar-meta { display: none; }
  .content { padding-bottom: 92px; overflow-x: hidden; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 850;
    background: rgba(255,255,255,.9); backdrop-filter: saturate(1.5) blur(14px);
    border-top: 1px solid var(--color-border);
    padding: 8px 6px calc(8px + env(safe-area-inset-bottom,0px)) 6px;
    justify-content: space-around; align-items: flex-end; box-shadow: 0 -6px 24px rgba(16,24,40,.08);
  }
  .mnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    background: none; border: none; cursor: pointer; text-decoration: none;
    color: var(--color-slate-500); font-size: 10.5px; font-weight: 600; padding: 4px 2px; min-width: 0; }
  .mnav-icon { font-size: 18px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
  .mnav-icon svg { width: 20px; height: 20px; }
  .mnav-item.is-active { color: var(--color-amber-700); }
  .mnav-add .mnav-icon { width: 46px; height: 46px; border-radius: 50%; display: flex;
    align-items: center; justify-content: center; background: var(--gold-grad); color: #1a1206;
    font-size: 26px; font-weight: 400; margin-top: -22px;
    box-shadow: 0 8px 18px -4px rgba(182,134,31,.65), inset 0 1px 0 rgba(255,255,255,.5); }
  .mnav-add .mnav-label { color: var(--color-amber-700); }
}
@media (max-width: 768px) {
  .topbar-search { display: none; }
  .content { padding-left: 16px; padding-right: 16px; }
  .topbar [data-action="add-lead"] { display: none; }
}
@media (prefers-reduced-motion: reduce) { .sidebar, .kpi-clickable, .btn { transition: none !important; } }
