/* ===== Reset =====
   Theme tokens (CSS custom properties) live in theme.css and must be
   loaded BEFORE this stylesheet. */
*{margin:0;padding:0;box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--dark);
  background: var(--bg);
  line-height: 1.55;
  font-size: 14px;
  letter-spacing: -0.005em;
}
a{text-decoration:none;color:inherit}
ul{list-style:none}
img{max-width:100%}
button,input,select,textarea{font-family:inherit;font-size:inherit}

/* ===== Layout ===== */
.app{display:flex;min-height:100vh}

/* ===== Sidebar (light theme) ===== */
.sidebar{
  width:var(--sidebar-w);
  background:var(--sidebar-bg);
  color:var(--sidebar-fg);
  position:fixed;top:0;left:0;bottom:0;z-index:100;
  display:flex;flex-direction:column;
  border-right:1px solid var(--sidebar-border);
  transition:transform .3s, width .25s ease;
}
.sidebar-header{
  padding:18px 20px;
  border-bottom:1px solid var(--sidebar-border);
  display:flex;align-items:center;gap:12px;
  height:var(--topbar-h);
}
.sidebar-header .logo{font-size:1.15rem;font-weight:700;color:var(--dark);letter-spacing:-.01em}
.sidebar-header .logo span{color:var(--accent);font-weight:700}
.sidebar-header .logo-icon{
  width:32px;height:32px;
  background:linear-gradient(135deg,var(--accent),var(--accent-dark));
  border-radius:8px;
  display:flex;align-items:center;justify-content:center;
  font-size:.95rem;color:var(--white);font-weight:700;
  box-shadow:0 2px 6px rgba(217,119,87,.35);
}
.sidebar-nav{flex:1;padding:14px 12px;overflow-y:auto}
.sidebar-nav .nav-section{
  padding:14px 12px 6px;
  font-size:.68rem;font-weight:700;
  text-transform:uppercase;letter-spacing:.08em;
  color:var(--sidebar-fg-muted);
}
.sidebar-nav a{
  display:flex;align-items:center;gap:12px;
  padding:9px 12px;margin-bottom:2px;
  color:var(--sidebar-fg);
  border-radius:var(--radius);
  font-size:.9rem;font-weight:500;
  transition:background .15s, color .15s, transform .1s;
}
.sidebar-nav a:hover{background:var(--sidebar-hover-bg);color:var(--dark)}
.sidebar-nav a.active{
  background:var(--sidebar-active-bg);
  color:var(--sidebar-active-fg);
  font-weight:600;
}
.sidebar-nav a .icon{width:20px;text-align:center;font-size:1rem;flex-shrink:0}
.sidebar-nav a .badge{
  margin-left:auto;
  background:var(--accent);color:var(--white);
  font-size:.68rem;font-weight:700;
  padding:2px 8px;border-radius:999px;
}
.sidebar-nav .logout-btn{
  display:flex;align-items:center;gap:12px;width:100%;
  padding:9px 12px;margin-top:6px;
  background:none;border:0;border-radius:var(--radius);
  color:var(--sidebar-fg);
  font:inherit;font-size:.9rem;font-weight:500;text-align:left;
  cursor:pointer;transition:.15s;
}
.sidebar-nav .logout-btn:hover{background:#FAE8E2;color:var(--red)}
.sidebar-nav .logout-btn:focus-visible{outline:2px solid var(--accent);outline-offset:-2px}
.sidebar-nav .logout-btn .icon{width:20px;text-align:center;font-size:1rem}
.sidebar-user{
  padding:14px 16px;
  border-top:1px solid var(--sidebar-border);
  display:flex;align-items:center;gap:12px;
}
.sidebar-user .avatar{
  width:36px;height:36px;border-radius:50%;
  background:linear-gradient(135deg,var(--accent),var(--accent-dark));
  display:flex;align-items:center;justify-content:center;
  font-weight:700;color:var(--white);font-size:.8rem;
  box-shadow:0 1px 3px rgba(217,119,87,.30);
}
.sidebar-user .info{flex:1;min-width:0}
.sidebar-user .info h4{
  font-size:.85rem;font-weight:600;color:var(--dark);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.sidebar-user .info p{font-size:.72rem;color:var(--sidebar-fg-muted)}

/* ===== Confirm dialog & toasts ===== */
.confirm-dialog{position:fixed;inset:0;margin:auto;border:0;border-radius:14px;padding:0;width:min(560px,92vw);max-width:none;max-height:90vh;background:var(--white);color:var(--dark);box-shadow:var(--shadow-lg)}
/* Wider variant for forms with selects / multi-step inputs. Uses 60vw
   per spec, capped on narrow screens so the dialog never overflows. */
.assign-dialog{width:min(60vw,820px);max-width:92vw}
.confirm-dialog::backdrop{background:rgba(31,30,27,.45);backdrop-filter:blur(2px)}
.confirm-dialog[open]{animation:dialog-in .15s ease-out}
@keyframes dialog-in{from{opacity:0;transform:scale(.98)}to{opacity:1;transform:scale(1)}}
.confirm-dialog-form{padding:32px}
.confirm-dialog-form h3{font-size:1.2rem;font-weight:700;margin-bottom:8px;color:var(--dark)}
.confirm-dialog-form p{color:var(--gray);font-size:.95rem;margin-bottom:24px;line-height:1.5}
.confirm-dialog-actions{display:flex;gap:10px;justify-content:flex-end}
.confirm-dialog-actions .btn{padding:10px 22px}

.toasts{position:fixed;top:20px;right:20px;display:flex;flex-direction:column;gap:10px;z-index:10000;pointer-events:none;max-width:calc(100vw - 40px)}
.toast{pointer-events:auto;display:flex;align-items:flex-start;gap:12px;min-width:280px;max-width:380px;padding:12px 14px 12px 16px;background:var(--white);color:var(--dark);border-radius:12px;border-left:3px solid var(--gray-light);box-shadow:var(--shadow-md);animation:toast-in .25s cubic-bezier(.2,.9,.3,1.2)}
.toast.toast-leaving{animation:toast-out .2s ease-in forwards}
.toast.toast-success{border-left-color:var(--green)}
.toast.toast-success .toast-icon{color:var(--green)}
.toast.toast-danger{border-left-color:var(--red)}
.toast.toast-danger .toast-icon{color:var(--red)}
.toast.toast-warning{border-left-color:var(--orange)}
.toast.toast-warning .toast-icon{color:var(--orange)}
.toast.toast-info{border-left-color:var(--blue)}
.toast.toast-info .toast-icon{color:var(--blue)}
.toast .toast-icon{font-size:1.1rem;line-height:1.2;flex-shrink:0;margin-top:1px}
.toast .toast-body{flex:1;font-size:.9rem;line-height:1.4}
.toast .toast-close{background:none;border:0;color:var(--gray);font-size:1.2rem;line-height:1;cursor:pointer;padding:0 2px;flex-shrink:0;transition:.15s}
.toast .toast-close:hover{color:var(--dark)}
@keyframes toast-in{from{opacity:0;transform:translateX(20px)}to{opacity:1;transform:none}}
@keyframes toast-out{from{opacity:1}to{opacity:0;transform:translateX(20px)}}
@media (max-width:640px){.toasts{left:12px;right:12px;top:12px}.toast{min-width:0;max-width:none}}

/* ===== Main ===== */
.main{margin-left:var(--sidebar-w);flex:1;display:flex;flex-direction:column;transition:margin-left .25s ease}

/* ===== Collapsible sidebar =====
   Toggling the `sidebar-collapsed` class on <html> shrinks the sidebar
   to icon-only mode and reflows .main. Class lives on <html> so an
   inline <head> script can apply it before first paint (no flicker). */

html.no-init-transition .sidebar,
html.no-init-transition .main{transition:none !important}

.sidebar-toggle{
  margin-left:auto;
  background:transparent;border:0;color:var(--sidebar-fg-muted);
  width:32px;height:32px;border-radius:var(--radius);
  cursor:pointer;display:flex;align-items:center;justify-content:center;
  font-size:1rem;transition:.15s;
}
.sidebar-toggle:hover{background:var(--sidebar-hover-bg);color:var(--dark)}
.sidebar-toggle:focus-visible{outline:2px solid var(--accent);outline-offset:2px}

html.sidebar-collapsed .sidebar{width:var(--sidebar-w-collapsed, 68px) !important}
html.sidebar-collapsed .main{margin-left:var(--sidebar-w-collapsed, 68px) !important}

html.sidebar-collapsed .nav-text,
html.sidebar-collapsed .sidebar-nav .nav-section{display:none}

html.sidebar-collapsed .sidebar-header{padding:14px 0;justify-content:center;gap:0}
html.sidebar-collapsed .sidebar-header .logo-icon{display:none}
html.sidebar-collapsed .sidebar-nav{padding:14px 8px}
html.sidebar-collapsed .sidebar-nav a,
html.sidebar-collapsed .sidebar-nav .logout-btn{padding:11px 0;justify-content:center;gap:0;position:relative;margin-bottom:4px}
html.sidebar-collapsed .sidebar-nav a .icon,
html.sidebar-collapsed .sidebar-nav .logout-btn .icon{width:auto;font-size:1.15rem}

/* Badge → small bubble pinned to the top-right of the icon */
html.sidebar-collapsed .sidebar-nav a .badge{
  position:absolute;top:4px;right:8px;margin:0;
  min-width:16px;padding:1px 5px;font-size:.62rem;line-height:1.2;
  border:2px solid var(--sidebar-bg);border-radius:999px;text-align:center;
}

html.sidebar-collapsed .sidebar-user{padding:12px 0;justify-content:center;gap:0}
html.sidebar-collapsed .sidebar-user .info{display:none}

/* ===== Topbar ===== */
.topbar{
  height:var(--topbar-h);
  background:var(--white);
  border-bottom:1px solid var(--border);
  display:flex;align-items:center;justify-content:space-between;
  padding:0 28px;
  position:sticky;top:0;z-index:50;
}
.topbar .page-title{font-size:1.1rem;font-weight:700;color:var(--dark);letter-spacing:-.01em}
.topbar .page-title span{color:var(--gray);font-weight:400;font-size:.85rem;margin-left:8px}
.topbar-right{display:flex;align-items:center;gap:12px}
.topbar-right .search-bar{
  display:flex;align-items:center;gap:6px;
  background:var(--bg);border:1px solid transparent;
  border-radius:var(--radius);padding:0 12px;
  transition:.15s;
}
.topbar-right .search-bar:focus-within{background:var(--white);border-color:var(--accent);box-shadow:var(--shadow-ring-accent)}
.topbar-right .search-bar input{border:none;background:transparent;padding:8px 4px;width:220px;outline:none;font-size:.88rem;color:var(--dark)}
.topbar-right .icon-btn{
  width:36px;height:36px;border-radius:50%;border:none;
  background:var(--bg);cursor:pointer;
  display:flex;align-items:center;justify-content:center;
  font-size:1.05rem;position:relative;color:var(--gray);
  transition:.15s;
}
.topbar-right .icon-btn:hover{background:var(--bg-soft);color:var(--dark)}
.topbar-right .icon-btn .dot{position:absolute;top:6px;right:6px;width:8px;height:8px;background:var(--accent);border-radius:50%;border:2px solid var(--white)}
.hamburger-btn{display:none;background:none;border:none;font-size:1.4rem;cursor:pointer;color:var(--dark)}

/* ===== Content ===== */
.content{padding:28px;flex:1}

/* ===== Stat Cards ===== */
.stats-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:16px;margin-bottom:24px}
.stat-card{
  background:var(--white);border:1px solid var(--border);
  border-radius:var(--radius-lg);padding:20px;
  display:flex;align-items:center;gap:16px;
  transition:transform .15s, box-shadow .15s, border-color .15s;
  /* Cards are clickable anchors on the dashboard. Reset the default
     anchor styling (underline, blue) and adopt the body color. */
  color:inherit;text-decoration:none;
}
.stat-card:hover{
  box-shadow:var(--shadow-md);
  border-color:transparent;
  transform:translateY(-2px);
  cursor:pointer;
}
.stat-card:focus-visible{
  outline:none;
  box-shadow:var(--shadow-ring-accent);
  border-color:var(--accent);
}

/* Salesperson rows under the dashboard live-tracking map.
   Rows with `data-lo-map-focus` are clickable triggers that zoom the
   map onto the corresponding pin (toggle). Non-clickable rows (no
   recent ping) keep the default cursor and do nothing on click. */
.sp-row{transition:background .12s, transform .1s;border-radius:6px;padding-left:6px;padding-right:6px;margin-left:-6px;margin-right:-6px}
.sp-row-clickable{cursor:pointer}
.sp-row-clickable:hover{background:var(--bg)}
.sp-row-clickable:focus-visible{outline:none;background:var(--bg);box-shadow:var(--shadow-ring-accent)}

/* ===== Address autocomplete (Lead form) =====
   Dropdown of Nominatim suggestions hangs below the address input.
   Hidden by default; the JS toggles `.is-open` once it has results. */
.address-suggestions{
  position:absolute;left:0;right:0;top:100%;
  z-index:200;
  margin-top:4px;
  background:var(--white);border:1px solid var(--border);
  border-radius:var(--radius);box-shadow:var(--shadow-md);
  max-height:280px;overflow-y:auto;
  display:none;
}
.address-suggestions.is-open{display:block}
.address-suggestion{
  display:flex;align-items:flex-start;gap:8px;width:100%;
  padding:10px 12px;background:transparent;border:0;
  text-align:left;font-size:.85rem;color:var(--dark);cursor:pointer;
  border-bottom:1px solid var(--border);
}
.address-suggestion:last-child{border-bottom:none}
.address-suggestion:hover{background:var(--bg-soft)}
.address-suggestion-pin{flex-shrink:0;font-size:.95rem;color:var(--accent-dark)}
.address-suggestion-text{flex:1;line-height:1.45}

/* ===== Status filter cards on /leads/ =====
   Each card is an <a> drilling into a URL filter (`?status=<value>` or
   `?unassigned=1`). Clicking the currently-active card clears the
   filter. Tone classes drive every visual cue:
   - 3px top stripe in the tone color
   - subtle tinted background so cards read as a category strip even
     when the page is busy
   - colored count number (always tinted, brighter on hover/active)
   - active state: solid tinted background + accent border + lift   */
.stat-card-status{position:relative;overflow:hidden;border-color:var(--border)}
.stat-card-status::before{
  content:"";position:absolute;top:0;left:0;right:0;height:3px;
  background:var(--gray-light);
}
.stat-card-status .stat-info h3{
  color:var(--dark);font-weight:800;
  transition:color .12s, transform .12s;
}
.stat-card-status .stat-info p{
  color:var(--gray);font-weight:600;
}
.stat-card-status:hover .stat-info h3{transform:scale(1.04)}

/* Per-tone palette: top stripe + count color + soft tinted background. */
.stat-card-blue   {background:linear-gradient(180deg,var(--blue-light)  20%,var(--white) 80%)}
.stat-card-blue::before{background:var(--blue)}
.stat-card-blue   .stat-info h3{color:#42627E}
.stat-card-blue.is-active{background:var(--blue-light)}

.stat-card-orange {background:linear-gradient(180deg,var(--orange-light) 20%,var(--white) 80%)}
.stat-card-orange::before{background:var(--orange)}
.stat-card-orange .stat-info h3{color:var(--accent-dark)}
.stat-card-orange.is-active{background:var(--orange-light)}

.stat-card-purple {background:linear-gradient(180deg,var(--purple-light) 20%,var(--white) 80%)}
.stat-card-purple::before{background:var(--purple)}
.stat-card-purple .stat-info h3{color:var(--purple)}
.stat-card-purple.is-active{background:var(--purple-light)}

.stat-card-green  {background:linear-gradient(180deg,var(--green-light)  20%,var(--white) 80%)}
.stat-card-green::before{background:var(--green)}
.stat-card-green  .stat-info h3{color:#3F6029}
.stat-card-green.is-active{background:var(--green-light)}

.stat-card-red    {background:linear-gradient(180deg,var(--red-light)    20%,var(--white) 80%)}
.stat-card-red::before{background:var(--red)}
.stat-card-red    .stat-info h3{color:var(--red)}
.stat-card-red.is-active{background:var(--red-light)}

/* Amber = warm gold, used for the Unassigned attention card. Distinct
   from `orange` which is reserved for "Contacted" status. */
.stat-card-amber  {background:linear-gradient(180deg,#FFF6DC 20%,var(--white) 80%)}
.stat-card-amber::before{background:#D9A24A}
.stat-card-amber  .stat-info h3{color:#A87528}
.stat-card-amber.is-active{background:#FFF0C2}

/* Active card — accent border + lift + slightly stronger shadow. */
.stat-card-status.is-active{
  border-color:var(--accent);
  box-shadow:var(--shadow-md);
  transform:translateY(-1px);
}
.stat-card .stat-icon{
  width:48px;height:48px;border-radius:12px;
  display:flex;align-items:center;justify-content:center;
  font-size:1.3rem;flex-shrink:0;
}
.stat-card .stat-icon.blue{background:var(--blue-light);color:var(--blue)}
.stat-card .stat-icon.green{background:var(--green-light);color:var(--green)}
.stat-card .stat-icon.orange{background:var(--orange-light);color:var(--accent-dark)}
.stat-card .stat-icon.red{background:var(--red-light);color:var(--red)}
.stat-card .stat-icon.purple{background:var(--purple-light);color:var(--purple)}
.stat-card .stat-info h3{font-size:1.7rem;font-weight:700;color:var(--dark);line-height:1.15;letter-spacing:-.02em}
.stat-card .stat-info p{font-size:.82rem;color:var(--gray)}
.stat-card .stat-info .trend{font-size:.74rem;font-weight:600;margin-top:3px}
.stat-card .stat-info .trend.up{color:var(--green)}
.stat-card .stat-info .trend.down{color:var(--red)}

/* ===== Panel ===== */
.panel{
  background:var(--white);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  margin-bottom:20px;overflow:hidden;
  transition:border-color .15s;
}
.panel-header{padding:18px 22px;border-bottom:1px solid var(--border);display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;background:var(--white)}
.panel-header h2{font-size:1rem;font-weight:700;color:var(--dark);letter-spacing:-.01em}
.panel-header .actions{display:flex;gap:8px;flex-wrap:wrap}
.panel-body{padding:22px}
.panel-body.no-pad{padding:0}

/* ===== Buttons ===== */
.btn{
  display:inline-flex;align-items:center;gap:6px;
  padding:8px 16px;border-radius:var(--radius);
  font-size:.85rem;font-weight:600;
  cursor:pointer;transition:.15s;border:1px solid transparent;
  white-space:nowrap;letter-spacing:-.005em;
}
.btn:focus-visible{outline:none;box-shadow:var(--shadow-ring-accent)}
.btn-primary{background:var(--dark);color:var(--white)}
.btn-primary:hover{background:var(--primary-light)}
.btn-accent{background:var(--accent);color:var(--white);box-shadow:0 1px 2px rgba(217,119,87,.25)}
.btn-accent:hover{background:var(--accent-dark);box-shadow:0 2px 4px rgba(217,119,87,.30)}
.btn-success{background:var(--green);color:var(--white)}
.btn-success:hover{background:#4A7833}
.btn-danger{background:var(--red);color:var(--white)}
.btn-danger:hover{background:#A8392B}
.btn-outline{background:transparent;border-color:var(--border);color:var(--dark)}
.btn-outline:hover{background:var(--bg);border-color:var(--gray-light)}
.btn-ghost{background:transparent;color:var(--gray)}
.btn-ghost:hover{background:var(--bg);color:var(--dark)}
.btn-sm{padding:6px 12px;font-size:.78rem}
.btn-lg{padding:12px 24px;font-size:.95rem}
.btn-icon{width:32px;height:32px;padding:0;justify-content:center;border-radius:50%}

/* ===== Tables ===== */
.table-container{overflow-x:auto}
table{width:100%;border-collapse:collapse}
th,td{padding:12px 18px;text-align:left;font-size:.87rem;border-bottom:1px solid var(--border)}
thead th{background:var(--bg);color:var(--gray);font-weight:600;text-transform:uppercase;font-size:.72rem;letter-spacing:.05em}
tbody tr{transition:background .12s}
tbody tr:hover{background:var(--bg)}
tbody tr:last-child td{border-bottom:none}

/* ===== Badges ===== */
.badge{display:inline-flex;align-items:center;padding:2px 9px;border-radius:999px;font-size:.72rem;font-weight:600;gap:4px;letter-spacing:-.005em}
.badge-green{background:var(--green-light);color:#3F6029}
.badge-red{background:var(--red-light);color:var(--red)}
.badge-orange{background:var(--orange-light);color:var(--accent-dark)}
.badge-blue{background:var(--blue-light);color:#42627E}
.badge-purple{background:var(--purple-light);color:var(--purple)}
.badge-gray{background:var(--bg-soft);color:var(--gray)}

/* ===== Forms ===== */
.form-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(280px,1fr));gap:18px}
.form-group{display:flex;flex-direction:column;gap:6px}
.form-group label{font-size:.82rem;font-weight:600;color:var(--dark)}
.form-group label .req{color:var(--red)}
.form-group input,.form-group select,.form-group textarea{
  padding:10px 14px;border:1px solid var(--border);
  border-radius:var(--radius);font-size:.9rem;
  transition:.15s;background:var(--white);
  width:100%;box-sizing:border-box;color:var(--dark);
}
.form-group input:focus,.form-group select:focus,.form-group textarea:focus{
  outline:none;border-color:var(--accent);
  box-shadow:var(--shadow-ring-accent);
}
.form-group .hint{font-size:.74rem;color:var(--gray-light)}
.form-group input[type="file"]{padding:8px}

/* ===== Toggle switch ===== */
.toggle-field{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:10px 14px;border:1px solid var(--border);border-radius:var(--radius);background:var(--white);cursor:pointer;user-select:none;font-size:.9rem;transition:.15s}
.toggle-field:hover{border-color:var(--accent)}
.toggle-field .toggle-label{font-weight:500;color:var(--dark)}
.toggle-field input[type="checkbox"]{-webkit-appearance:none;appearance:none;width:42px;height:24px;flex:0 0 42px;padding:0;margin:0;border:0;border-radius:999px;background:var(--gray-light);position:relative;cursor:pointer;transition:background .2s}
.toggle-field input[type="checkbox"]:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.toggle-field input[type="checkbox"]::before{content:"";position:absolute;top:2px;left:2px;width:20px;height:20px;border-radius:50%;background:var(--white);box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .2s}
.toggle-field input[type="checkbox"]:checked{background:var(--green)}
.toggle-field input[type="checkbox"]:checked::before{transform:translateX(18px)}
.toggle-field input[type="checkbox"]:disabled{opacity:.55;cursor:not-allowed}
.toggle-field:has(input:disabled){cursor:not-allowed;background:var(--bg)}
.toggle-field .toggle-state{font-size:.74rem;font-weight:600;text-transform:uppercase;letter-spacing:.05em;color:var(--gray);margin-left:auto}
.toggle-field input[type="checkbox"]:checked ~ .toggle-state-on,
.toggle-field input[type="checkbox"]:not(:checked) ~ .toggle-state-off{display:inline-block;color:var(--dark)}
.toggle-field input[type="checkbox"]:not(:checked) ~ .toggle-state-on,
.toggle-field input[type="checkbox"]:checked ~ .toggle-state-off{display:none}

/* ===== Segmented control ===== */
.segmented-control{display:flex;width:100%;border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;background:var(--white)}
.segmented-control input[type="radio"]{position:absolute;opacity:0;pointer-events:none;width:0;height:0}
.segmented-control label{flex:1;text-align:center;padding:10px 12px;cursor:pointer;user-select:none;font-size:.86rem;font-weight:500;color:var(--gray);background:var(--white);transition:.12s;border-right:1px solid var(--border)}
.segmented-control label:last-of-type{border-right:none}
.segmented-control label:hover{background:var(--bg);color:var(--dark)}
.segmented-control input[type="radio"]:checked + label{color:var(--white);font-weight:600}
.segmented-control input[type="radio"]:checked + label[data-value="active"]{background:var(--green)}
.segmented-control input[type="radio"]:checked + label[data-value="on_leave"]{background:var(--orange)}
.segmented-control input[type="radio"]:checked + label[data-value="inactive"]{background:var(--gray-light);color:var(--dark)}
.segmented-control input[type="radio"]:focus-visible + label{outline:2px solid var(--accent);outline-offset:2px}

/* ===== Map pin (Leaflet div-icon) ===== */
.lo-map-pin{background:transparent;border:0}
.lo-map-pin svg{filter:drop-shadow(0 2px 4px rgba(31,30,27,.3))}

/* ===== Map controls (refresh + countdown overlay) =====
   Floats over the top-right corner of any source-driven map. Sits
   above Leaflet's default UI but inside the rounded map frame. */
.lo-map-wrap{position:relative}
.lo-map-controls{
  position:absolute;top:10px;right:10px;
  z-index:500;            /* above Leaflet tiles (z=200) and zoom controls (z=400) */
  display:flex;align-items:center;gap:6px;
  background:rgba(255,255,255,.92);backdrop-filter:blur(6px);
  border:1px solid var(--border);border-radius:999px;
  padding:4px 6px 4px 12px;
  box-shadow:var(--shadow);
}
.lo-map-countdown{
  font-size:.72rem;font-weight:600;
  color:var(--gray);letter-spacing:.02em;
  font-variant-numeric:tabular-nums;
  user-select:none;
}
.lo-map-refresh{
  background:var(--white);border:1px solid var(--border);
  width:28px;height:28px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  cursor:pointer;font-size:.95rem;color:var(--dark);
  transition:.15s;
}
.lo-map-refresh:hover{background:var(--bg);border-color:var(--accent);color:var(--accent-dark)}
.lo-map-refresh:focus-visible{outline:none;box-shadow:var(--shadow-ring-accent)}
.lo-map-refresh:disabled{cursor:wait;opacity:.7}
.lo-map-refresh.is-spinning{animation:lo-map-refresh-spin .6s linear}
@keyframes lo-map-refresh-spin{
  from{transform:rotate(0)}
  to{transform:rotate(360deg)}
}

/* ===== Form rows / sections ===== */
.form-row{display:flex;gap:16px;flex-wrap:wrap}
.form-row .form-group{flex:1;min-width:200px}
.form-actions{display:flex;gap:12px;margin-top:24px;padding-top:20px;border-top:1px solid var(--border)}
.form-section{margin-bottom:28px}
.form-section h3{font-size:.95rem;font-weight:700;color:var(--dark);margin-bottom:16px;padding-bottom:10px;border-bottom:1px solid var(--border);letter-spacing:-.005em}

/* ===== Pipeline ===== */
.pipeline{display:flex;gap:14px;overflow-x:auto;padding-bottom:16px;min-height:500px}
.pipeline-col{min-width:260px;max-width:280px;flex-shrink:0;background:var(--bg-soft);border-radius:var(--radius-lg);display:flex;flex-direction:column}
.pipeline-col-header{padding:14px 16px;font-weight:700;font-size:.85rem;display:flex;align-items:center;justify-content:space-between;border-bottom:1px solid var(--border)}
.pipeline-col-header .count{background:rgba(31,30,27,.08);padding:2px 8px;border-radius:999px;font-size:.72rem;color:var(--dark);font-weight:600}
.pipeline-col-body{padding:8px;flex:1;display:flex;flex-direction:column;gap:8px;overflow-y:auto}
.pipeline-card{background:var(--white);border:1px solid var(--border);border-radius:var(--radius);padding:14px;cursor:pointer;transition:.15s;border-left:3px solid transparent}
.pipeline-card:hover{box-shadow:var(--shadow-md);transform:translateY(-1px);border-color:var(--border) transparent}
.pipeline-card h4{font-size:.88rem;font-weight:600;color:var(--dark);margin-bottom:4px}
.pipeline-card p{font-size:.78rem;color:var(--gray);margin-bottom:6px}
.pipeline-card .meta{display:flex;justify-content:space-between;align-items:center;font-size:.72rem;color:var(--gray-light)}
.pipeline-card .meta .avatar-sm{width:22px;height:22px;border-radius:50%;background:linear-gradient(135deg,var(--accent),var(--accent-dark));color:var(--white);display:inline-flex;align-items:center;justify-content:center;font-size:.6rem;font-weight:700}

/* Stamp on closed/lost pipeline cards — full-card diagonal rubber-
   stamp. The stamp covers the whole card from corner to corner and
   sits ABOVE the card's text/avatars (z-index:5). The card content
   is desaturated underneath via a grayscale filter, so the stamp
   reads as a clear "this lead is closed" mark.
   `pointer-events:none` keeps the underlying link clickable; the
   card opts into container queries so the stamp scales naturally
   regardless of column width. */
.pipeline-card-stamped{position:relative;overflow:hidden;container-type:inline-size}
/* Grey-out every direct child except the stamp itself. We use the
   immediate-child selector so nested elements inherit the filter
   without needing extra wrappers. */
.pipeline-card-stamped > *:not(.card-stamp){
  filter:grayscale(0.85) opacity(0.55);
  transition:filter .15s ease;
}
.pipeline-card-stamped:hover > *:not(.card-stamp){
  filter:grayscale(0.5) opacity(0.85);
}
.card-stamp{
  position:absolute;
  inset:0;
  z-index:5;
  display:flex;
  align-items:center;
  justify-content:center;
  font-family:'Inter',system-ui,sans-serif;
  font-weight:800;
  /* Container query unit — scales with the card's inline size. The
     fallback (vw) handles browsers without `cqi` support. */
  font-size:clamp(1.1rem, 4.5vw, 2.1rem);
  font-size:clamp(1.1rem, 16cqi, 2.1rem);
  letter-spacing:.10em;
  text-transform:uppercase;
  line-height:1;
  text-align:center;
  transform:rotate(-22deg);
  opacity:.4;
  pointer-events:none;
  user-select:none;
  white-space:nowrap;
  text-shadow:0 0 1px currentColor;
}
/* Border drawn on a pseudo so it doesn't steal the layout box —
   the stamp keeps a slim "stamped on" frame around the text. */
.card-stamp::before{
  content:"";
  position:absolute;
  top:50%;left:50%;
  transform:translate(-50%,-50%);
  width:70%;
  padding:.1em 0;
  border:.1em solid currentColor;
  border-radius:.18em;
  box-shadow:inset 0 0 0 .03em currentColor;
  height:1.05em;
}
.card-stamp-closed_won{ color:var(--green) }
.card-stamp-lost{ color:var(--red) }

/* ===== Status colors ===== */
.status-new{color:var(--blue)}
.status-assigned{color:var(--purple)}
.status-contacted{color:var(--accent-dark)}
.status-visit{color:#42627E}
.status-negotiation{color:var(--purple)}
.status-won{color:var(--green)}
.status-lost{color:var(--red)}
.status-hold{color:var(--gray)}

/* ===== Map placeholder ===== */
.map-placeholder{background:linear-gradient(135deg,var(--bg-soft),#E8E5DD);border-radius:var(--radius-lg);height:350px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:var(--gray);font-size:1rem;position:relative;overflow:hidden}
.map-placeholder::before{content:'';position:absolute;inset:0;background:url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23A8A6A0' fill-opacity='0.10'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E")}
.map-placeholder .pin{width:40px;height:40px;background:var(--accent);border-radius:50% 50% 50% 0;transform:rotate(-45deg);margin-bottom:12px;display:flex;align-items:center;justify-content:center;box-shadow:0 4px 8px rgba(217,119,87,.30)}
.map-placeholder .pin::after{content:'';width:14px;height:14px;background:var(--white);border-radius:50%;transform:rotate(45deg)}

/* ===== Check-in card ===== */
.checkin-card{background:var(--white);border:1px solid var(--border);border-radius:var(--radius-lg);padding:28px;text-align:center;max-width:420px;margin:0 auto}
.checkin-card .gps-status{display:inline-flex;align-items:center;gap:8px;padding:6px 16px;border-radius:999px;font-size:.82rem;font-weight:600;margin-bottom:20px}
.checkin-card .gps-status.active{background:var(--green-light);color:#3F6029}
.checkin-card .gps-status.inactive{background:var(--red-light);color:var(--red)}
.checkin-card .time-display{font-size:2.6rem;font-weight:800;color:var(--dark);margin:14px 0 6px;letter-spacing:-.03em;font-variant-numeric:tabular-nums}
.checkin-card .date-display{color:var(--gray);margin-bottom:24px}
.checkin-btn{width:140px;height:140px;border-radius:50%;border:none;font-size:1.05rem;font-weight:700;cursor:pointer;transition:transform .15s, box-shadow .15s;box-shadow:var(--shadow-lg);color:var(--white)}
.checkin-btn.check-in{background:linear-gradient(135deg,var(--green),#4A7833)}
.checkin-btn.check-out{background:linear-gradient(135deg,var(--red),#A8392B)}
.checkin-btn:hover{transform:scale(1.04)}

/* ===== Visit timeline ===== */
.timeline{position:relative;padding-left:32px}
.timeline::before{content:'';position:absolute;left:11px;top:0;bottom:0;width:2px;background:var(--border)}
.timeline-item{position:relative;padding-bottom:22px}
.timeline-item:last-child{padding-bottom:0}
.timeline-item .dot{width:24px;height:24px;border-radius:50%;position:absolute;left:-32px;top:0;display:flex;align-items:center;justify-content:center;font-size:.7rem;color:var(--white);font-weight:700}
.timeline-item .dot.done{background:var(--green)}
.timeline-item .dot.current{background:var(--accent);box-shadow:0 0 0 4px rgba(217,119,87,.25)}
.timeline-item .dot.pending{background:var(--bg-soft);color:var(--gray);border:2px solid var(--border)}
.timeline-item .dot.info{background:var(--blue)}
.timeline-item .dot.warn{background:var(--orange)}
.timeline-item .dot.danger{background:var(--red);box-shadow:0 0 0 4px rgba(168,57,43,.18)}
/* Fake-visit timeline rows get a red-tinted card so the entry stands
   out at a glance, even before the manager reads the note. */
.timeline-item-visit_fake .content{
  background:var(--red-light);border-color:rgba(168,57,43,.25);
}
.timeline-item-visit_fake .content h4{color:var(--red)}
.timeline-item .content{background:var(--white);border:1px solid var(--border);border-radius:var(--radius);padding:14px 16px}
.timeline-item .content h4{font-size:.9rem;color:var(--dark);margin-bottom:4px;font-weight:600}
.timeline-item .content p{font-size:.82rem;color:var(--gray)}
.timeline-item .content .time-stamp{font-size:.72rem;color:var(--gray-light);margin-top:6px}

/* ===== Alert cards ===== */
.alert-card{display:flex;gap:14px;padding:14px 18px;border-radius:var(--radius);margin-bottom:10px;align-items:flex-start;border:1px solid transparent}
.alert-card.alert-danger{background:var(--red-light);border-left:3px solid var(--red)}
.alert-card.alert-warning{background:var(--orange-light);border-left:3px solid var(--orange)}
.alert-card.alert-success{background:var(--green-light);border-left:3px solid var(--green)}
.alert-card.alert-info{background:var(--blue-light);border-left:3px solid var(--blue)}
.alert-card .alert-icon{font-size:1.2rem;flex-shrink:0;margin-top:2px}
.alert-card .alert-content{flex:1}
.alert-card .alert-content h4{font-size:.9rem;color:var(--dark);margin-bottom:2px;font-weight:600}
.alert-card .alert-content p{font-size:.82rem;color:var(--gray)}
.alert-card .alert-time{font-size:.74rem;color:var(--gray-light);white-space:nowrap;margin-left:auto}

/* ===== Login ===== */
.login-page{min-height:100vh;display:flex;background:var(--bg)}
.login-left{
  flex:1;
  background:linear-gradient(135deg,var(--bg-soft) 0%,var(--accent-soft) 100%);
  display:flex;flex-direction:column;align-items:flex-start;justify-content:center;
  color:var(--dark);padding:64px;
  position:relative;overflow:hidden;
}
.login-left::before{
  content:'';position:absolute;
  width:480px;height:480px;border-radius:50%;
  background:radial-gradient(circle,rgba(217,119,87,.18) 0%,transparent 70%);
  top:-120px;right:-80px;
}
.login-left::after{
  content:'';position:absolute;
  width:300px;height:300px;border-radius:50%;
  background:radial-gradient(circle,rgba(217,119,87,.12) 0%,transparent 70%);
  bottom:-60px;left:-40px;
}
.login-left > *{position:relative;z-index:1}
.login-left h1{font-size:2.6rem;margin-bottom:14px;letter-spacing:-.02em;font-weight:800}
.login-left h1 span{color:var(--accent-dark)}
.login-left p{color:var(--gray);max-width:420px;font-size:1rem;line-height:1.6}
.login-right{flex:1;display:flex;align-items:center;justify-content:center;padding:48px;background:var(--white)}
.login-form{width:100%;max-width:400px}
.login-form h2{font-size:1.7rem;font-weight:700;color:var(--dark);margin-bottom:6px;letter-spacing:-.015em}
.login-form .subtitle{color:var(--gray);margin-bottom:28px;font-size:.95rem}
.login-form .form-group{margin-bottom:18px}
.login-form .form-submit{
  width:100%;padding:12px;
  background:var(--dark);color:var(--white);
  border:none;border-radius:var(--radius);
  font-size:.95rem;font-weight:600;cursor:pointer;
  transition:.15s;letter-spacing:-.005em;
}
.login-form .form-submit:hover{background:var(--primary-light)}
.login-form .role-tabs{display:flex;gap:0;margin-bottom:24px;background:var(--bg);border-radius:var(--radius);padding:4px}
.login-form .role-tabs button{flex:1;padding:9px;border:none;background:transparent;border-radius:8px;cursor:pointer;font-weight:600;color:var(--gray);transition:.15s;font-size:.86rem}
.login-form .role-tabs button.active{background:var(--white);color:var(--dark);box-shadow:var(--shadow)}

/* Password show/hide toggle. The wrapper is `position:relative` so we
   can absolutely position the button over the input's right edge.
   Right-padding on the input is reserved so typed text never collides
   with the eye glyph. */
.password-wrap{position:relative}
.password-wrap input{width:100%;padding-right:42px}
.password-toggle{
  position:absolute;top:50%;right:6px;transform:translateY(-50%);
  width:32px;height:32px;display:flex;align-items:center;justify-content:center;
  background:transparent;border:0;border-radius:50%;
  color:var(--gray);cursor:pointer;font-size:1rem;line-height:1;
  transition:background .15s,color .15s;
}
.password-toggle:hover{background:var(--bg);color:var(--dark)}
.password-toggle:focus-visible{outline:none;box-shadow:var(--shadow-ring-accent)}
/* `is-showing` flips the icon to a "hidden eye" via a strike-through. */
.password-toggle.is-showing{color:var(--accent-dark)}
.password-toggle.is-showing .password-toggle-icon{
  text-decoration:line-through;text-decoration-thickness:1.5px;
}

/* ===== Charts ===== */
.chart-placeholder{background:var(--bg-soft);border-radius:var(--radius-lg);height:250px;display:flex;align-items:center;justify-content:center;color:var(--gray)}
.chart-bar{display:flex;align-items:flex-end;gap:12px;height:200px;padding:0 20px}
.chart-bar .bar{flex:1;border-radius:6px 6px 0 0;position:relative;min-width:40px;transition:.4s}
.chart-bar .bar .val{position:absolute;top:-22px;left:50%;transform:translateX(-50%);font-size:.74rem;font-weight:700;color:var(--dark)}
.chart-bar .bar .lbl{position:absolute;bottom:-22px;left:50%;transform:translateX(-50%);font-size:.7rem;color:var(--gray);white-space:nowrap}

/* ===== Tabs ===== */
.tabs{display:flex;gap:0;border-bottom:1px solid var(--border);margin-bottom:22px}
.tabs .tab{padding:10px 20px;font-size:.88rem;font-weight:600;color:var(--gray);cursor:pointer;border-bottom:2px solid transparent;margin-bottom:-1px;transition:.15s}
.tabs .tab:hover{color:var(--dark)}
.tabs .tab.active{color:var(--dark);border-bottom-color:var(--accent)}

/* ===== Grid layouts ===== */
.grid-2{display:grid;grid-template-columns:1fr 1fr;gap:20px}
.grid-3{display:grid;grid-template-columns:1fr 1fr 1fr;gap:20px}

/* ===== Work order ===== */
.work-order{border:1px solid var(--border);border-radius:var(--radius-lg);padding:28px;background:var(--white)}
.work-order-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:24px;padding-bottom:16px;border-bottom:2px dashed var(--border)}
.work-order-header h2{color:var(--dark);font-size:1.15rem;font-weight:700}
.work-order-header .wo-number{font-size:1rem;font-weight:700;color:var(--accent-dark)}
.wo-grid{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin-bottom:20px}
.wo-grid .wo-item label{display:block;font-size:.74rem;color:var(--gray);text-transform:uppercase;letter-spacing:.05em;margin-bottom:2px;font-weight:600}
.wo-grid .wo-item span{font-size:.95rem;font-weight:600;color:var(--dark)}

/* ===== Full-page GPS loader — shown on /visits/checkin/ while we
   wait for the first geolocation fix. Sits above the page content
   (z-index:8000) but below the mandatory-permission dialog (top
   layer), so a denied-state dialog still pops over the loader. */
.gps-loader{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(255,255,255,.92);
  backdrop-filter:blur(2px);
  z-index:8000;
  transition:opacity .25s ease;
}
.gps-loader.is-hidden{ opacity:0; pointer-events:none }
.gps-loader-inner{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  text-align:center;
  padding:32px 28px;
}
.gps-loader-spinner{
  width:54px;
  height:54px;
  border-radius:50%;
  border:4px solid var(--border);
  border-top-color:var(--accent);
  animation:gps-spin .9s linear infinite;
}
@keyframes gps-spin{ to{ transform:rotate(360deg) } }
.gps-loader-title{
  font-size:1.05rem;font-weight:700;color:var(--dark);
  margin:0;
}
.gps-loader-sub{
  font-size:.85rem;color:var(--gray);
  margin:0;max-width:320px;line-height:1.45;
}

/* ===== Lead "closed" watermark — stamp-style overlay =================
   Sits ABOVE the page content (high z-index) but uses
   `pointer-events:none` so clicks/scroll still pass through to the
   underlying panels — the page stays interactive. The transform tilts
   the text -22deg so it reads diagonally; the double border + tracked
   letters give it the rubber-stamp feel. Native <dialog> elements
   open in the browser's "top layer" which is rendered above any
   z-index, so the action popups still appear over the watermark. */
.lead-watermark{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
  z-index:9000;
}
.lead-watermark > span{
  font-family:'Inter',system-ui,sans-serif;
  font-weight:800;
  font-size:clamp(2.4rem, 7vw, 6rem);
  letter-spacing:.08em;
  text-transform:uppercase;
  line-height:1;
  padding:0.18em 0.45em;
  border-style:solid;
  border-width:.1em;
  border-radius:.18em;
  transform:rotate(-22deg);
  opacity:.22;
  white-space:nowrap;
  user-select:none;
  /* Inner stroke for the classic "double border" stamp look. */
  box-shadow:inset 0 0 0 .04em currentColor;
  /* A faint glow gives the text a worn-ink texture without needing
     a background image. */
  text-shadow:0 0 1px currentColor;
}
.lead-watermark-closed_won > span{ color:var(--green) }
.lead-watermark-lost > span{ color:var(--red) }

@media(max-width:768px){
  .lead-watermark > span{ font-size:clamp(2rem, 12vw, 4.2rem) }
}

/* Grey-out the lead-detail panels when the lead is in a terminal
   state. We desaturate + dim — but keep `pointer-events` intact so
   the user can still scroll, copy text, click into the timeline,
   etc. The lockout for the action popups is enforced separately
   inside each dialog (see `_assign_warning.html`). */
.lead-detail-content.closed-lead{
  filter:grayscale(0.85) opacity(0.78);
  transition:filter .2s ease;
}
.lead-detail-content.closed-lead:hover{
  filter:grayscale(0.6) opacity(0.92);
}

/* ===== Lead-list row tints — mirror the stat-card palette so the
   row colour matches the card the user clicked to filter by.  We
   tint <td> instead of <tr> because table rows can't take a solid
   background reliably across browsers when borders / sticky cells
   are in play. */
tr.lead-row-unassigned > td{ background:#FFF6DC }
tr.lead-row-unassigned:hover > td{ background:#FFF0C2 }

tr.lead-row-lost > td{ background:var(--red-light); color:var(--gray) }
tr.lead-row-lost:hover > td{ background:#F4D6CD }

tr.lead-row-won > td{ background:var(--green-light) }
tr.lead-row-won:hover > td{ background:#D8E6C9 }

/* ===== Error pages (404 / 500) — friendly, on-brand =================
   Centred card on a soft cream wash. The big code reads as a
   watermark, the message owns the foreground. Stays inside the
   regular dashboard chrome (sidebar + topbar) so the user never
   feels like they got dropped onto a blank page. */
.error-page{
  display:flex;align-items:center;justify-content:center;
  min-height:60vh;padding:32px 16px;
}
.error-page-card{
  position:relative;
  max-width:560px;width:100%;
  text-align:center;
  background:var(--white);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  padding:48px 36px 40px;
  box-shadow:var(--shadow-md);
  overflow:hidden;
}
.error-page-code{
  position:absolute;top:-22px;right:-12px;
  font-size:9rem;font-weight:900;letter-spacing:-.05em;
  color:var(--bg-soft);line-height:1;pointer-events:none;
  user-select:none;font-family:'Inter',sans-serif;
}
.error-page-card h1{
  font-size:1.6rem;font-weight:700;color:var(--dark);
  margin:0 0 12px;letter-spacing:-.01em;
}
.error-page-card p{
  font-size:.95rem;color:var(--gray);line-height:1.6;
  margin:0 auto 28px;max-width:420px;
}
.error-page-actions{
  display:flex;gap:10px;justify-content:center;flex-wrap:wrap;
}
@media(max-width:560px){
  .error-page-code{ font-size:6rem;top:-10px;right:-4px }
  .error-page-card{ padding:36px 22px 30px }
}

/* ===== Reports page — analytics grid + horizontal bars =============
   Two-column responsive grid for the lead-source / funnel cards,
   with a full-width Top Products row underneath. Bars use named
   tone fills so any chart can borrow the same palette. */
.reports-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(360px,1fr));
  gap:18px;
  align-items:start;
}
.report-bars{
  list-style:none;margin:0;padding:0;
  display:flex;flex-direction:column;gap:14px;
}
.report-bar-head{
  display:flex;justify-content:space-between;align-items:baseline;
  font-size:.85rem;color:var(--dark);margin-bottom:6px;
  gap:12px;
}
.report-bar-head strong{
  color:var(--dark);font-weight:600;
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;min-width:0;
}
.report-bar-head span{
  font-size:.8rem;color:var(--gray);font-variant-numeric:tabular-nums;
}
.report-bar-pct{ color:var(--gray-light);font-size:.75rem }
.report-bar-track{
  position:relative;
  height:8px;
  background:var(--bg);
  border-radius:999px;
  overflow:hidden;
}
.report-bar-fill{
  display:block;
  height:100%;
  border-radius:999px;
  background:var(--accent);
  transition:width .4s ease;
  /* Subtle gradient adds polish without a second colour token. */
  background-image:linear-gradient(90deg, currentColor 0%, currentColor 80%, color-mix(in srgb, currentColor 78%, white 22%) 100%);
}
.report-bar-fill-blue{    color:var(--blue) }
.report-bar-fill-orange{  color:var(--orange) }
.report-bar-fill-purple{  color:var(--purple) }
.report-bar-fill-green{   color:var(--green) }
.report-bar-fill-red{     color:var(--red) }
.report-bar-fill-accent{  color:var(--accent) }

/* Top-products card list — ranked tile with a slim bar. */
.report-product-grid{
  display:grid;
  grid-template-columns:repeat(auto-fill,minmax(280px,1fr));
  gap:12px;
}
.report-product{
  display:flex;align-items:center;gap:12px;
  padding:12px 14px;background:var(--bg);
  border-radius:var(--radius);
}
.report-product-rank{
  width:28px;height:28px;border-radius:50%;
  background:var(--white);border:1px solid var(--border);
  color:var(--gray);font-weight:700;font-size:.78rem;
  display:flex;align-items:center;justify-content:center;flex-shrink:0;
}
.report-product:nth-child(-n+3) .report-product-rank{
  background:var(--accent);color:var(--white);border-color:var(--accent);
}
.report-product-body{ flex:1;min-width:0 }
.report-product-body strong{
  font-size:.88rem;color:var(--dark);
  display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;
}
.report-product-count{
  font-weight:700;color:var(--dark);font-size:1.05rem;
  font-variant-numeric:tabular-nums;flex-shrink:0;
}

@media(max-width:640px){
  .reports-grid{ grid-template-columns:1fr }
}

/* ===== Live Map page — map + today's salesperson sidebar ===========
   Map sits on the left, sidebar of "who's in the field today" rolls
   up the visit lifecycle (check-in / check-out / duration / fake) on
   the right. Sidebar collapses below the map under 1080px. */
.live-map-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(320px,420px);
  gap:20px;
  align-items:start;
}
.live-map-side .panel-body{ max-height:720px;overflow-y:auto }

.live-sp-list{ display:flex;flex-direction:column }
.live-sp-card{
  padding:14px 18px;border-bottom:1px solid var(--border);
  display:flex;flex-direction:column;gap:8px;
  cursor:pointer;transition:background .15s;
  --sp-color:var(--accent);
}
.live-sp-card:last-child{ border-bottom:0 }
.live-sp-card:hover{ background:var(--bg) }
.live-sp-head{ display:flex;align-items:flex-start;gap:10px }
.live-sp-dot{
  width:12px;height:12px;border-radius:50%;
  background:var(--sp-color);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--sp-color) 22%, transparent);
  flex-shrink:0;margin-top:5px;
}
.live-sp-name{ flex:1;min-width:0 }
.live-sp-name strong{ font-size:.92rem;color:var(--dark);display:block }
.live-sp-meta{ font-size:.74rem;color:var(--gray);margin-top:1px }
.live-sp-manager{ font-size:.72rem;color:var(--gray);margin-top:2px }

.live-sp-chips{
  display:flex;gap:6px;flex-wrap:wrap;
  font-size:.72rem;color:var(--gray);
}
.chip-count{
  padding:2px 8px;background:var(--bg);border-radius:999px;
  font-weight:600;
}
.chip-count-green{ background:rgba(95,140,72,.14);color:#3F6029 }
.chip-count-red{ background:var(--red-light);color:var(--red) }

.live-sp-action{
  font-size:.74rem;color:var(--gray);line-height:1.55;
  padding:8px 10px;background:var(--white);
  border:1px dashed var(--border);border-radius:var(--radius);
}
.live-sp-action-row{ }
.live-sp-address{ color:var(--gray-light);margin-top:2px }
.live-sp-distance{ color:var(--gray);margin-top:2px }

.live-sp-fake{
  font-size:.74rem;padding:8px 10px;
  background:var(--red-light);color:var(--red);
  border-radius:var(--radius);font-weight:500;
}

@media(max-width:1080px){
  .live-map-grid{ grid-template-columns:1fr }
  .live-map-side .panel-body{ max-height:none }
}

/* ===== Alerts page — toolbar, rows, empty state ====================
   Reuses the stat-card-status palette for the per-severity filter
   chips (handled inline in the template). This block styles the
   status-tab strip + search + the new card-style alert rows. */
.alerts-toolbar{
  padding:14px 18px;
  display:flex;align-items:center;gap:14px;flex-wrap:wrap;
}
.alerts-tabs{
  display:inline-flex;background:var(--bg);border-radius:999px;
  padding:4px;gap:2px;
}
.alerts-tab{
  padding:7px 14px;font-size:.82rem;font-weight:600;
  color:var(--gray);text-decoration:none;border-radius:999px;
  transition:background .15s,color .15s;
}
.alerts-tab:hover{ color:var(--dark);background:rgba(255,255,255,.6) }
.alerts-tab.is-active{
  background:var(--white);color:var(--dark);
  box-shadow:0 1px 2px rgba(28,29,28,.06);
}

.alerts-search{
  position:relative;flex:1;min-width:220px;max-width:380px;margin-left:auto;
  display:flex;align-items:center;
}
.alerts-search-icon{
  position:absolute;left:12px;font-size:.85rem;color:var(--gray-light);
  pointer-events:none;
}
.alerts-search input{
  width:100%;padding:8px 32px 8px 32px;font-size:.85rem;
  border:1px solid var(--border);border-radius:999px;
  background:var(--white);color:var(--dark);font-family:inherit;
  transition:border-color .15s,box-shadow .15s;
}
.alerts-search input:focus{
  outline:none;border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(217,119,87,.18);
}
.alerts-search-clear{
  position:absolute;right:10px;font-size:1.1rem;
  width:22px;height:22px;line-height:18px;text-align:center;
  border-radius:50%;color:var(--gray);background:transparent;
  text-decoration:none;
}
.alerts-search-clear:hover{ background:var(--bg);color:var(--dark) }

.alerts-list{ padding:0 }
.alerts-list .alert-row{
  display:grid;
  grid-template-columns:42px 1fr auto;
  gap:14px;
  padding:18px 22px;
  border-bottom:1px solid var(--border);
  align-items:flex-start;
  position:relative;
  transition:background .15s;
}
.alerts-list .alert-row:last-child{ border-bottom:0 }
.alerts-list .alert-row:hover{ background:var(--bg) }
/* Severity left-strip — read at a glance even when scrolling fast. */
.alerts-list .alert-row::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:3px;
  background:var(--border);
}
.alerts-list .alert-row-danger::before{  background:var(--red) }
.alerts-list .alert-row-warning::before{ background:var(--orange) }
.alerts-list .alert-row-info::before{    background:var(--blue) }
.alerts-list .alert-row-success::before{ background:var(--green) }
/* Resolved rows fade so they read as "handled". */
.alerts-list .alert-row-ack,
.alerts-list .alert-row-dismissed{ opacity:.7 }

.alert-row-icon{
  width:42px;height:42px;border-radius:50%;
  display:flex;align-items:center;justify-content:center;
  font-size:1.1rem;color:var(--white);font-weight:700;
  background:var(--gray-light);
}
.alert-row-danger  .alert-row-icon{ background:var(--red) }
.alert-row-warning .alert-row-icon{ background:var(--orange) }
.alert-row-info    .alert-row-icon{ background:var(--blue) }
.alert-row-success .alert-row-icon{ background:var(--green) }

.alert-row-body{ min-width:0 }
.alert-row-head{
  display:flex;justify-content:space-between;align-items:flex-start;
  gap:14px;margin-bottom:6px;flex-wrap:wrap;
}
.alert-row-head h4{
  font-size:.95rem;font-weight:700;color:var(--dark);
  margin:0;line-height:1.35;
}
.alert-row-meta{
  display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;
  font-size:.72rem;color:var(--gray);
}
.alert-row-meta time{ color:var(--gray-light) }
.alert-rule{
  font-family:'Inter',monospace;font-size:.7rem;
  padding:2px 8px;background:var(--bg-soft);border-radius:4px;
  color:var(--gray);letter-spacing:.02em;
}
.alert-row-detail{
  font-size:.85rem;color:var(--gray);line-height:1.55;
  margin:6px 0 8px;
}
.alert-row-context{
  display:flex;flex-direction:column;gap:4px;
  padding:8px 10px;margin-top:8px;
  background:var(--bg);border-radius:var(--radius);
  font-size:.78rem;color:var(--gray);
}
.alert-row-context-row{ display:flex;align-items:center;gap:6px;flex-wrap:wrap }
.alert-row-context-row a{
  color:var(--blue);font-weight:600;text-decoration:none;
}
.alert-row-context-row a:hover{ text-decoration:underline }
.alert-row-context-icon{ font-size:.85rem;flex-shrink:0 }
.alert-row-context-sub{ color:var(--gray-light) }

.alert-row-actions{
  display:flex;flex-direction:column;gap:6px;align-items:stretch;
  flex-shrink:0;min-width:140px;
}
.alert-row-actions form{ margin:0 }
.alert-row-actions .btn{ width:100%;justify-content:center }

/* Empty state — friendly, not just a hint line. */
.alerts-empty{
  text-align:center;padding:48px 24px;color:var(--gray);
}
.alerts-empty-icon{ font-size:3rem;margin-bottom:8px }
.alerts-empty h3{
  font-size:1.05rem;color:var(--dark);font-weight:700;margin-bottom:6px;
}
.alerts-empty p{
  font-size:.9rem;line-height:1.55;max-width:420px;
  margin:0 auto 14px;
}

@media(max-width:760px){
  .alerts-list .alert-row{ grid-template-columns:42px 1fr;gap:12px }
  .alert-row-actions{ grid-column:1 / -1;flex-direction:row;flex-wrap:wrap }
  .alert-row-actions .btn{ flex:1 }
  .alerts-toolbar{ gap:10px }
  .alerts-search{ margin-left:0;max-width:none }
}

/* ===== Visit-planning filter — date strip + salesperson chips ========
   The /visits/ filter used to be a flat dropdown row that felt utility-
   first. This block styles it as two stacked sections — a horizontal
   day-stepper on top and a row of clickable salesperson chips below —
   that read like a focused command surface instead of a form. */
.visit-filter{ margin-bottom:20px }
.visit-filter-body{ padding:18px 22px;display:flex;flex-direction:column;gap:14px }
.visit-filter-section{
  display:flex;align-items:center;gap:14px;flex-wrap:wrap;
}
.visit-filter-label{
  font-size:.78rem;font-weight:700;color:var(--gray);
  text-transform:uppercase;letter-spacing:.06em;flex-shrink:0;
  min-width:120px;
}
.date-strip{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
}
.date-strip .chip{
  display:inline-flex;align-items:center;gap:6px;
  padding:8px 14px;font-size:.85rem;font-weight:600;
  background:var(--white);border:1px solid var(--border);
  border-radius:999px;color:var(--dark);cursor:pointer;
  transition:background .15s,border-color .15s,box-shadow .15s;
  font-family:inherit;
}
.date-strip .chip:hover{
  background:var(--bg);border-color:var(--gray-light);
}
.date-strip .chip-active{
  background:var(--accent);color:var(--white);border-color:var(--accent);
  box-shadow:0 1px 2px rgba(217,119,87,.25);cursor:default;
}
.date-strip .chip-today{
  background:var(--bg-soft);color:var(--accent-dark);
  border-color:rgba(217,119,87,.3);
}
.date-strip .chip-today:hover{ background:var(--orange-light) }
.date-strip-picker{
  padding:7px 12px;font-size:.85rem;
  border:1px solid var(--border);border-radius:999px;
  background:var(--white);color:var(--dark);
  font-family:inherit;cursor:pointer;
}
.date-strip-picker:hover{ border-color:var(--gray-light);background:var(--bg) }

.sp-chips{
  display:flex;align-items:center;gap:8px;flex-wrap:wrap;
}
.sp-chip{
  display:inline-flex;align-items:center;gap:8px;
  padding:8px 14px;font-size:.85rem;font-weight:500;
  background:var(--white);border:1px solid var(--border);
  border-radius:999px;color:var(--dark);cursor:pointer;
  transition:background .15s,border-color .15s,transform .15s,box-shadow .15s;
  font-family:inherit;
  /* Per-chip color via CSS variable supplied inline. */
  --sp-color: var(--accent);
}
.sp-chip:hover{
  background:var(--bg);border-color:var(--sp-color);
  transform:translateY(-1px);
}
.sp-chip-dot{
  width:10px;height:10px;border-radius:50%;
  background:var(--sp-color);box-shadow:0 0 0 3px color-mix(in srgb, var(--sp-color) 20%, transparent);
  flex-shrink:0;
}
.sp-chip.is-active{
  background:var(--sp-color);border-color:var(--sp-color);
  color:var(--white);font-weight:600;
  box-shadow:0 2px 8px color-mix(in srgb, var(--sp-color) 35%, transparent);
}
.sp-chip.is-active .sp-chip-dot{
  background:var(--white);box-shadow:0 0 0 3px rgba(255,255,255,.35);
}

@media(max-width:640px){
  .visit-filter-section{ align-items:flex-start;flex-direction:column;gap:8px }
  .visit-filter-label{ min-width:0 }
}

/* ===== Salesperson Performance — two-column layout ====================
   LHS: chart bars (graph). RHS: quick-stats list. Stays side-by-side
   on tablet+ widths and stacks below 900px so the chart still gets
   enough horizontal room for taller bar groups. */
.perf-grid{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(280px,360px);
  gap:32px;
  align-items:start;
}
.perf-graph{ min-width:0 }
.perf-stats{ min-width:280px }
/* Slimmer bars now that the graph column is narrower. */
.perf-graph .chart-bar .bar{ width:34px !important }
@media(max-width:900px){
  .perf-grid{ grid-template-columns:1fr; gap:24px }
}

/* ===== Pagination (shared, right-aligned, lives below tables) ===== */
.pagination{
  display:flex;align-items:center;justify-content:space-between;
  gap:12px;flex-wrap:wrap;
  padding:14px 22px;border-top:1px solid var(--border);
  background:var(--white);
}
.pagination-info{font-size:.8rem;color:var(--gray)}
.pagination-controls{margin-left:auto;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.pagination-page{font-size:.82rem;color:var(--gray);padding:0 4px}
.pagination-page strong{color:var(--dark);font-weight:700}
.pagination-btn{
  display:inline-flex;align-items:center;gap:4px;
  padding:6px 12px;font-size:.78rem;font-weight:500;
  color:var(--dark);background:var(--white);
  border:1px solid var(--border);border-radius:var(--radius);
  text-decoration:none;transition:background .15s,border-color .15s;
}
.pagination-btn:hover{background:var(--bg);border-color:var(--gray-light)}
.pagination-btn.is-disabled{opacity:.45;cursor:not-allowed;pointer-events:none}

/* When the pagination sits inside a `panel > .panel-body.no-pad` the
   panel already provides the outer border/radius, so the pagination
   only needs the top divider. When used outside a panel, give it a
   subtle frame so it still reads as a contained widget. */
.panel-body.no-pad > .pagination{border-radius:0}

/* ===== Responsive ===== */
@media(max-width:1024px){
  .grid-2,.grid-3{grid-template-columns:1fr}
  .pipeline-col{min-width:240px}
}
@media(max-width:768px){
  .sidebar{transform:translateX(-100%)}
  .sidebar.open{transform:translateX(0)}
  .main{margin-left:0}
  .hamburger-btn{display:block}
  .topbar{padding:0 16px}
  .content{padding:16px}
  .stats-grid{grid-template-columns:1fr 1fr}
  .login-left{display:none}
  .form-grid{grid-template-columns:1fr}
  .wo-grid{grid-template-columns:1fr}
}
@media(max-width:480px){
  .stats-grid{grid-template-columns:1fr}
}
