/* ============================================================
   LB Marketing — Admin portal skin
   ------------------------------------------------------------
   The admin-only design layer. Loads AFTER styles.css and
   portal.css and refines them into a high-end corporate look.

   Design-token layering (single source of truth per layer):
     • styles.css   — base/brand tokens (--primary, --secondary,
                      --text-main, --bg-*, --border, …) shared by
                      the marketing site and every portal.
     • admin.css    — the --ent-* tokens below: the admin skin's
                      refined surfaces, hairlines, radii, shadows.
                      Only this file defines and uses them.

   Nothing here changes behaviour — it is presentation only.
   ============================================================ */

:root {
  --ent-bg:        hsl(210, 24%, 98%);   /* app canvas — cards pop against it */
  --ent-surface:   #ffffff;
  --ent-line:      hsl(214, 20%, 91%);   /* hairline borders */
  --ent-line-soft: hsl(214, 24%, 94%);
  --ent-ink:       hsl(220, 26%, 16%);
  --ent-muted:     hsl(220, 12%, 46%);
  --ent-faint:     hsl(220, 12%, 60%);
  --ent-radius:    12px;
  --ent-radius-sm: 9px;
  --ent-radius-xs: 7px;
  --ent-shadow-xs: 0 1px 2px rgba(16,24,40,.06);
  --ent-shadow-sm: 0 1px 3px rgba(16,24,40,.08), 0 1px 2px rgba(16,24,40,.04);
  --ent-shadow-md: 0 8px 20px -6px rgba(16,24,40,.12), 0 2px 6px -2px rgba(16,24,40,.06);
  --ent-shadow-lg: 0 24px 48px -12px rgba(16,24,40,.22);
  --ent-ring:      0 0 0 3px hsl(191, 60%, 88%);
}

body.lb-app { background: var(--ent-bg); color: var(--ent-ink); }

/* ---- Topbar ---- */
.lb-topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--ent-line);
  box-shadow: 0 1px 0 rgba(16,24,40,.02);
}
.lb-topbar-inner { max-width: none; padding: 12px 24px; gap: 14px; }
.lb-brand {
  font-family: 'DM Sans', sans-serif; font-weight: 800;
  font-size: 19px; letter-spacing: -.02em; color: var(--ent-ink);
}
.lb-brand span { color: var(--primary); }
.lb-topbar-user { font-size: 13px; color: var(--ent-muted); }
.lb-role-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .03em; text-transform: uppercase;
  color: var(--primary); background: var(--primary-tint);
  border-radius: 999px;
}
.lb-userbox { display: flex; align-items: center; gap: 10px; }
.lb-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 34px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  box-shadow: var(--ent-shadow-xs);
}
.lb-avatar-meta { line-height: 1.25; }
.lb-avatar-meta .nm { font-size: 13px; font-weight: 600; color: var(--ent-ink); }
.lb-avatar-meta .em { font-size: 11.5px; color: var(--ent-faint); }

/* ---- Locations map + address search (Locations tab) ---- */
#locMap { height: 460px; width: 100%; border: 1px solid var(--border); z-index: 1; }
.lb-loc-managed { font-size: 12px; color: var(--text-muted); }
.lb-loc-pin-hint { font-size: 13px; color: var(--text-muted); margin: 8px 0 0; }
.lb-loc-coords { font-family: monospace; font-size: 12px; color: var(--text-muted); }
.lb-loc-search-wrap { position: relative; margin-bottom: 12px; }
.lb-loc-search-row { display: flex; gap: 10px; align-items: stretch; }
.lb-loc-search-row .lb-input { flex: 1; }
.lb-loc-search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: 0 12px 26px rgba(15,23,42,.12); max-height: 280px; overflow-y: auto;
}
.lb-loc-search-item {
  padding: 11px 13px; border-top: 1px solid var(--border);
  cursor: pointer; font-size: 14px; line-height: 1.45;
}
.lb-loc-search-item:first-child { border-top: 0; }
.lb-loc-search-item:hover { background: var(--primary-tint); }
.lb-loc-search-empty { padding: 11px 13px; color: var(--text-muted); font-size: 14px; }

/* ---- Modals ---- */
.lb-modal-back {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(16,24,40,.42);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  animation: entFade .18s ease;
}
.lb-modal {
  width: 100%; max-width: 520px; background: var(--ent-surface);
  border: 1px solid var(--ent-line); padding: 28px;
  max-height: 92vh; overflow-y: auto;
  border-radius: var(--ent-radius);
  box-shadow: var(--ent-shadow-lg);
  animation: entPop .22s cubic-bezier(.16,1,.3,1);
}
.lb-modal h2 { margin-bottom: 4px; font-family: 'DM Sans', sans-serif; font-weight: 700; letter-spacing: -.01em; }
.lb-modal-actions { display: flex; gap: 10px; margin-top: 22px; }
.lb-modal-actions .lb-btn { flex: 1; }
@keyframes entFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes entPop { from { opacity: 0; transform: translateY(8px) scale(.985); } to { opacity: 1; transform: none; } }

/* ---- Settings tab misc ---- */
.lb-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.lb-color-row { display: flex; align-items: center; gap: 10px; }
.lb-color-row input[type="color"] { width: 46px; height: 38px; padding: 2px; border: 1px solid var(--border); background: var(--bg-main); }
.lb-live { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--secondary); margin-right: 6px; animation: pulse-soft 2s infinite; }
.lb-mono { font-family: monospace; letter-spacing: 1px; }

/* ---- Bulk-action bar ---- */
.lb-bulkbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: end;
  padding: 12px 14px; margin: 10px 0 0;
  border: 1px solid var(--ent-line); border-radius: var(--ent-radius);
  box-shadow: var(--ent-shadow-sm); background: var(--ent-surface);
}
.lb-bulkbar .lb-field { min-width: 180px; margin: 0; }
.lb-bulkmeta { font-size: 13px; font-weight: 700; color: var(--primary); margin-right: auto; }

/* ---- Custom sleek checkboxes ---- */
.lb-rowcheck, .lb-headcheck, .lb-perm-check {
  appearance: none; -webkit-appearance: none;
  width: 19px; height: 19px; flex: 0 0 19px;
  border: 1.5px solid var(--ent-line); border-radius: 6px;
  background: var(--ent-surface); cursor: pointer;
  position: relative; vertical-align: middle;
  transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease;
}
.lb-rowcheck:hover, .lb-headcheck:hover, .lb-perm-check:hover {
  border-color: var(--primary);
}
.lb-rowcheck:checked, .lb-headcheck:checked, .lb-perm-check:checked {
  background: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M13 4.5 6.4 11 3 7.6' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: 15px 15px; background-position: center; background-repeat: no-repeat;
}
.lb-rowcheck:indeterminate, .lb-headcheck:indeterminate {
  background: var(--primary); border-color: var(--primary);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Crect x='4' y='7' width='8' height='2' rx='1' fill='white'/%3E%3C/svg%3E");
  background-size: 15px 15px; background-position: center; background-repeat: no-repeat;
}
.lb-rowcheck:focus-visible, .lb-headcheck:focus-visible, .lb-perm-check:focus-visible {
  outline: none; box-shadow: var(--ent-ring);
}
.lb-checkcell { width: 52px; text-align: center; padding: 10px 0; }
tbody tr.selected { background: var(--primary-tint) !important; }
.lb-perm-cell { text-align: center; padding: 12px 8px; }
.lb-perm-check { width: 18px; height: 18px; flex: 0 0 18px; }

/* ---- Permission cards (user modal) ---- */
.lb-perm-card {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  padding: 11px 13px; border: 1px solid var(--ent-line);
  border-radius: var(--ent-radius-xs); background: var(--ent-surface);
  transition: border-color .16s ease, background-color .16s ease, box-shadow .16s ease;
  user-select: none;
}
.lb-perm-card:hover { border-color: hsl(214, 20%, 82%); }
.lb-perm-card:has(.lb-perm-check:checked) {
  border-color: var(--primary); background: var(--primary-tint);
}
.lb-perm-card-label {
  text-transform: capitalize; font-size: 13px; font-weight: 600; color: var(--ent-ink);
}
.lb-taglist { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---- Sidebar ---- */
.lb-app-layout { display: flex; min-height: calc(100vh - 59px); }
.lb-sidebar {
  width: 244px; flex: 0 0 244px; background: var(--ent-surface);
  border-right: 1px solid var(--ent-line);
  padding: 18px 0; position: sticky; top: 59px;
  max-height: calc(100vh - 59px); overflow-y: auto;
}
.lb-sidebar-section { padding: 0 14px; margin-bottom: 22px; position: relative; }
.lb-sidebar-section:first-child { margin-top: 0; }
.lb-sidebar-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ent-faint);
  padding: 0 12px 8px; margin: 0;
}
.lb-sidebar-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  padding: 10px 12px; background: transparent; border: none; cursor: pointer;
  font-size: 13.5px; font-weight: 550; color: var(--ent-muted);
  border-radius: var(--ent-radius-xs); transition: background-color .16s ease, color .16s ease;
  margin-bottom: 2px; position: relative; font-family: 'DM Sans', sans-serif;
}
.lb-sidebar-item:hover { background: hsl(214, 30%, 96%); color: var(--ent-ink); }
.lb-sidebar-item.active { background: var(--primary-tint); color: var(--primary); font-weight: 700; }
.lb-sidebar-item.active::before {
  content: ''; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.lb-main-content { flex: 1; min-width: 0; overflow-y: auto; }
.lb-wrap { max-width: 1400px; margin: 0 auto; padding: 30px 30px 90px; }
.lb-tagpill {
  display: inline-flex; align-items: center; padding: 3px 8px;
  border-radius: 999px; background: var(--primary-tint); color: var(--primary);
  font-size: 12px; font-weight: 600;
}

/* =========================================================
   Component refinements — cards, tables, buttons, KPIs
   ========================================================= */

/* ---- Cards ---- */
.lb-card {
  border: 1px solid var(--ent-line); border-radius: var(--ent-radius);
  box-shadow: var(--ent-shadow-sm); padding: 22px;
  transition: box-shadow .2s ease, border-color .2s ease;
}
.lb-card:hover { box-shadow: var(--ent-shadow-md); }
.lb-card h2 {
  font-family: 'DM Sans', sans-serif; font-size: 15px; font-weight: 700;
  letter-spacing: -.01em; color: var(--ent-ink);
}
.lb-card-sub { color: var(--ent-muted); font-size: 12.5px; }

/* ---- Section title above panels ---- */
.lb-panel > .lb-filters:first-child { margin-top: 2px; }

/* ---- Buttons ---- */
.lb-btn {
  border-radius: var(--ent-radius-xs); font-weight: 600; font-size: 13px;
  padding: 9px 16px; letter-spacing: -.01em;
  box-shadow: var(--ent-shadow-xs);
  transition: background-color .16s ease, box-shadow .16s ease, transform .12s ease, border-color .16s ease, color .16s ease;
}
.lb-btn:hover { transform: translateY(-1px); box-shadow: var(--ent-shadow-sm); }
.lb-btn:active { transform: translateY(0); }
.lb-btn-ghost {
  background: var(--ent-surface); border: 1px solid var(--ent-line);
  color: var(--ent-ink); box-shadow: var(--ent-shadow-xs);
}
.lb-btn-ghost:hover {
  background: hsl(214, 30%, 97%); border-color: hsl(214, 20%, 84%);
  color: var(--ent-ink);
}
.lb-btn-sm { padding: 7px 12px; font-size: 12px; }

/* ---- Tables ---- */
.lb-table-wrap {
  border: 1px solid var(--ent-line); border-radius: var(--ent-radius);
  box-shadow: var(--ent-shadow-sm); overflow: hidden; overflow-x: auto;
}
.lb-table { font-size: 13px; }
.lb-table th {
  background: hsl(214, 30%, 98%); color: var(--ent-faint);
  font-size: 10.5px; letter-spacing: .07em; font-weight: 700;
  padding: 12px 14px; border-bottom: 1px solid var(--ent-line);
}
.lb-table td {
  padding: 13px 14px; border-top: 1px solid var(--ent-line-soft);
  color: var(--ent-ink);
}
.lb-table tbody tr { transition: background-color .12s ease; }
.lb-table tbody tr:hover td { background: hsl(214, 34%, 98%); }
.lb-table tbody tr.selected:hover td { background: var(--primary-tint) !important; }

/* ---- Badges (pill, refined) ---- */
.lb-badge {
  padding: 3px 10px; font-size: 11px; font-weight: 600;
  border-radius: 999px; letter-spacing: .01em;
  border: 1px solid transparent;
}
.lb-badge.on { background: var(--secondary-tint); color: var(--accent-dark); border-color: hsl(90,40%,84%); }
.lb-badge.off { background: hsl(220,14%,95%); color: var(--ent-muted); border-color: hsl(220,14%,88%); }
.lb-badge.new { background: var(--primary-tint); color: hsl(191,45%,32%); border-color: hsl(191,40%,84%); }

/* ---- KPI cards (premium) ---- */
.lb-kpis { gap: 14px; }
.lb-kpi {
  border: 1px solid var(--ent-line); border-radius: var(--ent-radius);
  box-shadow: var(--ent-shadow-sm); padding: 18px 20px;
  position: relative; overflow: hidden;
  transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease;
}
.lb-kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--primary), var(--secondary)); opacity: 0;
  transition: opacity .2s ease;
}
.lb-kpi:hover { transform: translateY(-2px); box-shadow: var(--ent-shadow-md); border-color: var(--ent-line); }
.lb-kpi:hover::before { opacity: 1; }
.lb-kpi .num {
  font-family: 'DM Sans', sans-serif; font-size: 30px; font-weight: 700;
  letter-spacing: -.02em; color: var(--ent-ink);
}
.lb-kpi .num.green { color: #16a34a; }
.lb-kpi .num.orange { color: #ea580c; }
.lb-kpi .num.red { color: #dc2626; }
.lb-kpi .lbl {
  font-size: 11px; letter-spacing: .05em; color: var(--ent-faint);
  font-weight: 600; margin-top: 6px;
}

/* ---- Inputs / selects ---- */
.lb-input, .lb-select, .lb-textarea {
  border: 1px solid var(--ent-line); border-radius: var(--ent-radius-xs);
  background: var(--ent-surface); font-size: 13.5px; padding: 9px 12px;
  color: var(--ent-ink);
}
.lb-input:focus, .lb-select:focus, .lb-textarea:focus {
  border-color: var(--primary); box-shadow: var(--ent-ring);
}
.lb-field label {
  font-size: 11px; letter-spacing: .04em; color: var(--ent-muted); font-weight: 600;
}

/* ---- Filters ---- */
.lb-filters { background: transparent; padding: 4px 0 16px; }

/* ---- Empty states ---- */
.lb-empty { color: var(--ent-faint); }

/* ---- Link report: platform badge + mini bar charts ---- */
.lb-plat {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background: hsl(214, 30%, 96%); color: var(--ent-ink); border: 1px solid var(--ent-line);
}
.lb-chart-bars {
  display: flex; align-items: flex-end; gap: 3px; height: 110px;
  padding: 8px 0; border-bottom: 1px solid var(--ent-line);
}
.lb-bar {
  flex: 1; min-width: 3px; background: var(--primary-tint);
  border-radius: 3px 3px 0 0; transition: background-color .15s ease;
}
.lb-bar:hover { background: var(--primary); }
.lb-bar.best { background: var(--secondary); }

/* ---- Ticket status + priority pills ---- */
.lb-tk-status, .lb-tk-prio {
  display: inline-flex; align-items: center; padding: 3px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid transparent; text-transform: capitalize; white-space: nowrap;
}
.lb-tk-status.open        { background: var(--primary-tint); color: hsl(191,45%,32%); border-color: hsl(191,40%,84%); }
.lb-tk-status.in_progress { background: hsl(38,90%,92%);     color: hsl(38,70%,32%);  border-color: hsl(38,80%,80%); }
.lb-tk-status.resolved    { background: var(--secondary-tint); color: var(--accent-dark); border-color: hsl(90,40%,84%); }
.lb-tk-status.closed      { background: hsl(220,14%,95%);    color: var(--ent-muted); border-color: hsl(220,14%,88%); }
.lb-tk-prio.low     { background: hsl(220,14%,95%); color: var(--ent-muted); }
.lb-tk-prio.normal  { background: var(--primary-tint); color: hsl(191,45%,32%); }
.lb-tk-prio.high    { background: hsl(28,90%,92%);  color: hsl(28,80%,34%); }
.lb-tk-prio.urgent  { background: hsl(0,75%,95%);   color: hsl(0,60%,42%); border-color: hsl(0,70%,88%); }

/* ---- On-site badge (worker within a saved work location's radius) ---- */
.lb-onsite {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
  background: var(--secondary-tint); color: var(--accent-dark);
  border: 1px solid hsl(90, 40%, 84%);
}

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .lb-sidebar { width: 200px; flex-basis: 200px; }
  .lb-wrap { padding: 22px 18px 80px; }
}
@media (max-width: 640px) {
  .lb-app-layout { flex-direction: column; }
  .lb-sidebar {
    width: 100%; flex-basis: auto; position: static; max-height: none;
    border-right: none; border-bottom: 1px solid var(--ent-line);
    display: flex; gap: 6px; overflow-x: auto; padding: 12px;
  }
  .lb-sidebar-section { display: flex; gap: 4px; margin: 0; padding: 0; }
  .lb-sidebar-label { display: none; }
  .lb-sidebar-item { white-space: nowrap; margin: 0; }
  .lb-sidebar-item.active::before { display: none; }
}
