:root {
    --bg:#f5f7fb;
    --panel:#ffffff;
    --muted:#6b7280;
    --text:#111827;
    --accent:#2563eb;
    --accent2:#10b981;
    --border:#e5e7eb;
  }

  * { box-sizing:border-box; }

  body {
    margin:0;
    font:16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    background:var(--bg);
    color:var(--text);
  }

  .app {
    max-width:1100px;
    margin:32px auto;
    padding:0 16px;
  }

  .app-header {
    margin-bottom:18px;
  }

  .logo-row {
    display:flex;
    align-items:center;
    gap:12px;
  }

  .header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .app-logo {
    width:140px;
    height:auto;
  }

  .app-header h1 {
    margin:0;
    font-size:26px;
    font-weight:700;
  }

  .subtitle {
    color:var(--muted);
    margin:4px 0 0;
    font-size:14px;
  }

  .tabs {
    display:flex;
    gap:8px;
    justify-content:center;
    margin:18px 0 22px;
    flex-wrap:wrap;
  }

  .tab {
    background:#ffffff;
    border:1px solid var(--border);
    color:var(--text);
    padding:8px 14px;
    border-radius:999px;
    cursor:pointer;
    font-size:14px;
  }

  .tab.active {
    background:var(--accent);
    color:#ffffff;
    border-color:var(--accent);
  }

  .panel {
    display:none;
    background:var(--panel);
    border:1px solid var(--border);
    border-radius:16px;
    padding:20px;
    box-shadow:0 12px 30px rgba(15,23,42,.06);
  }

  .panel.show { display:block; }

  .section-title {
    margin:0 0 8px;
    font-size:18px;
    font-weight:600;
  }

  .form label {
    display:block;
    font-weight:600;
    margin-bottom:6px;
    font-size:14px;
  }

  .form input,
  .form select,
  .form textarea {
    width:100%;
    padding:9px 11px;
    border-radius:10px;
    border:1px solid var(--border);
    background:#f9fafb;
    color:var(--text);
    outline:none;
    font-size:14px;
  }

  .form input:focus,
  .form select:focus,
  .form textarea:focus {
    border-color:var(--accent);
    box-shadow:0 0 0 3px rgba(37,99,235,.15);
    background:#ffffff;
  }

  .grid.two {
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:16px;
  }

  @media (max-width:900px){
    .grid.two { grid-template-columns: 1fr; }
  }

  .actions {
    margin-top:12px;
    display:flex;
    gap:12px;
    align-items:center;
    flex-wrap:wrap;
  }

  #visitResult {
  order: 99 !important;
}

#conversionResult {
  order: 99 !important;
}

  .btn {
    border:1px solid var(--border);
    background:#ffffff;
    color:var(--text);
    padding:9px 16px;
    border-radius:999px;
    cursor:pointer;
    font-weight:600;
    font-size:14px;
    box-shadow:0 1px 2px rgba(15,23,42,.05);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition:
      background-color 0.15s ease,
      box-shadow 0.15s ease,
      transform 0.08s ease;
  }

  .btn.primary {
    background:linear-gradient(90deg, var(--accent), var(--accent2));
    color:#ffffff;
    border:none;
    box-shadow:0 6px 16px rgba(37,99,235,.25);
  }

  .btn:disabled {
    opacity:.6;
    cursor:not-allowed;
  }

  .btn-icon {
    padding: 6px 8px;
    min-width: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .btn:hover:not(:disabled):not(.primary) {
    transform: translateY(-1px);
    box-shadow:0 4px 10px rgba(15,23,42,.18);
    background: var(--accent);
    color: #ffffff;
    border-color: var(--accent);
  }

  .btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow:0 8px 20px rgba(37,99,235,.35);
    filter: brightness(1.03);
    background: linear-gradient(90deg, var(--accent), var(--accent2));
  }

  .actions-cell .btn + .btn {
    margin-left: 6px;
  }

  #leadClearBtn:hover:not(:disabled),
  #leadDiscardBtn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  #visitClearFilters:hover:not(:disabled),
#conversionClearFilters:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}


#visitDiscardBtn:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

#conversionDiscardBtn:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}


  #logoutBtn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  .hint { color:var(--muted); font-size:13px; }

  .records { margin-top:18px; }

  .records-controls {
    display:flex;
    gap:8px;
    align-items:center;
  }

  .records-controls input {
    flex:1;
  }

  .records-controls select {
    width:auto;
  }

  .table table {
    width:100%;
    border-collapse:collapse;
    margin-top:10px;
    font-size:14px;
  }

  .table th,
  .table td {
    border:1px solid var(--border);
    padding:8px;
    vertical-align:top;
  }

  .table th {
    background:#f9fafb;
    text-align:left;
    font-weight:600;
  }

  .pager {
    display:flex;
    gap:8px;
    align-items:center;
    margin-top:10px;
    font-size:13px;
  }

  .leadpicker { position:relative; }

  .picker-list {
    position:absolute;
    z-index:1000;
    top:72px;
    left:0;
    right:0;
    background:#ffffff;
    border:1px solid var(--border);
    border-radius:12px;
    max-height:220px;
    overflow:auto;
    display:none;
    box-shadow:0 12px 30px rgba(15,23,42,.12);
  }

  .picker-list.show { display:block; }

  .picker-item {
    padding:10px 12px;
    border-bottom:1px solid #f3f4f6;
    cursor:pointer;
    display:flex;
    gap:8px;
    align-items:center;
    font-size:14px;
  }

  .picker-item:hover {
    background:#eff6ff;
  }

  .pill {
    font-size:12px;
    padding:2px 8px;
    border:1px solid var(--border);
    border-radius:999px;
    color:var(--muted);
    background:#f9fafb;
  }

  .overlay {
    position:fixed;
    inset:0;
    background:rgba(15,23,42,.25);
    opacity:0;
    pointer-events:none;
    transition:.18s;
  }

  .overlay.show {
    opacity:1;
    pointer-events:auto;
  }

  .drawer {
    position:fixed;
    top:0;
    right:0;
    height:100%;
    width:420px;
    max-width:96vw;
    background:#ffffff;
    border-left:1px solid var(--border);
    transform:translateX(100%);
    transition:transform .2s ease;
    display:flex;
    flex-direction:column;
    box-shadow:-12px 0 30px rgba(15,23,42,.12);
  }

  .drawer.show { transform:translateX(0); }

  .drawer-header,
  .drawer-footer {
    padding:12px;
    border-bottom:1px solid var(--border);
    display:flex;
    align-items:center;
    gap:8px;
  }

  .drawer-footer {
    border-top:1px solid var(--border);
    border-bottom:none;
    margin-top:auto;
  }

  .drawer-body {
    padding:12px;
    overflow:auto;
  }

  .drawer .form .grid.two {
    grid-template-columns: 1fr;
  }

  .toast {
    position:absolute;
    left:12px;
    bottom:12px;
    padding:8px 12px;
    background:#111827;
    color:#f9fafb;
    border-radius:10px;
    display:none;
    font-size:13px;
  }

  .toast.show { display:block; }

  .card {
    background:#ffffff;
    border-radius:16px;
    border:1px solid var(--border);
    box-shadow:0 16px 40px rgba(15,23,42,.10);
  }

  .global-toast {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 9999;
  }

  #loginPanel .actions {
    flex-wrap:wrap;
    align-items:center;
  }

  #loginPanel .actions .btn {
    flex:0 0 auto;
  }

  #authMsg {
    flex-basis:100%;
    word-break:break-word;
    overflow-wrap:break-word;
    line-height:1.4;
    margin-top:4px;
  }

  .map-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 99999;
  }

  .map-content {
    width: 90%;
    max-width: 600px;
    height: 450px;
    background: #fff;
    border-radius: 12px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .map-canvas {
    flex: 1;
    border-radius: 8px;
  }

  .location-row {
    margin-top: 12px;
    margin-bottom: 4px;
  }

  .location-field {
    display: flex;
    flex-direction: column;
  }

  .form input[readonly] {
    background: #e1e5f0;
    color: #555;
    cursor: not-allowed;
  }

  .location-btn {
    width: 100%;
    margin-top: 6px;
    justify-content: center;
  }

  .table th.actions-cell,
  .table td.actions-cell {
    text-align: right;
  }

  .confirm-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15,23,42,.35);
    z-index: 9998;
  }

  .confirm-modal.show {
    display: flex;
  }

  .confirm-content {
    padding: 16px 20px;
    max-width: 420px;
    width: 90%;
  }

  .records-controls-bottom {
    margin-top: 8px;
  }

  .icon-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .icon-logout svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

  .logout-text {
    margin-left: 6px;
  }

  .icon-trash {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .icon-trash svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

  .delete-text { }

  .icon-pencil {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .icon-pencil svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

  .icon-print {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .icon-print svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
  }

.icon-print svg {
  width: 14px !important;
  height: 14px !important;
  stroke-width: 2;
}

  .print-text {
    margin-left: 6px;
  }

  #mapCancelBtn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  .actions-cell .btn-icon.danger:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  #leadDiscardBtn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  #leadCancelEdit:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  #visitCancelEdit:hover:not(:disabled),
#conversionCancelEdit:hover:not(:disabled) {
  background: #fee2e2;
  border-color: #ef4444;
  color: #b91c1c;
}

  #confirmCancelBtn:hover:not(:disabled) {
    background: #fee2e2;
    border-color: #ef4444;
    color: #b91c1c;
  }

  .confirm-content .actions {
    justify-content: flex-end;
  }


/* Extra spacing in Lead form */
#pickLocationBtn {
  margin-bottom: 18px;
}

#productInterestsContainer {
  margin-bottom: 18px;
}

#productAvailabilityContainer {
  margin-bottom: 18px;
}

#marketingMaterialContainer {
  margin-bottom: 18px;
}

/* Make visit filters align like lead filters */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 10px;
  margin-bottom: 6px;
}



.filters input,
.filters select {
  flex: 1;
  min-width: 140px;
}

/* === FIX VISIT FILTER ROWS TO MATCH LEAD FILTER LAYOUT === */

.visit-filters-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0;
}

.visit-filters-row label {
  font-size: 14px;
  font-weight: 600;
}

.visit-filters-row input[type="date"] {
  flex: 1;
  min-width: 180px;
}

.visit-filters-row select {
  min-width: 80px;
}

.visit-filters-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto; /* push Apply & Clear to the right */
}

/* Make Visit page-size dropdown exactly match the Lead page-size dropdown */
.visit-filters-actions select#visitPageSize {
  width: auto;                 /* SAME as Lead */
  min-width: unset;            /* Prevent forced stretching */
  flex: 0 0 auto;              /* Prevent expansion inside flex row */
  padding: 6px 8px;            /* Button-like padding */
  height: 32px;                /* Match Lead’s visual height */
  font-size: 14px;
  border-radius: 8px;          /* Match Lead curvature */
  line-height: normal;         /* Force correct internal height */
}

/* Ensure Visit dropdown does NOT stretch horizontally */
#visitPageSize {
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
}
/* Make Visit filter labels match form labels */
.records-controls label {
  font-size: 14px;
  font-weight: 600;
  margin-right: 4px;
}


#panel-conversion .records-controls-bottom label {
  font-size: 14px !important;
  font-weight: 600 !important;
  margin-bottom: 4px;
}







/* Legacy mobile enlargement rules removed.
   The premium mobile system below is now the single source of truth for <=1024px. */

  /* === Product Interests & Marketing Material multi-select grid === */
  .multi-select-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
  }

  .multi-select-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #f9fafb;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition:
      background-color 0.15s ease,
      border-color 0.15s ease,
      box-shadow 0.15s ease,
      transform 0.08s ease;
  }

  .multi-select-pill:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15,23,42,.12);
  }

  .multi-select-pill.selected {
    background: rgba(37,99,235,0.12);
    border-color: var(--accent);
    color: var(--accent);
  }

  .multi-select-pill .pill-label {
    white-space: nowrap;
  }

  .multi-select-pill .pill-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
  }

/* ========================================================================== 
   Premium mobile experience — desktop rules above remain unchanged
   ========================================================================== */
.tab-icon,
.mobile-records-header {
  display: none;
}

@media (max-width: 1024px) {
  :root {
    --mobile-ink: #0b1220;
    --mobile-ink-soft: #182235;
    --mobile-muted: #718096;
    --mobile-line: #e8edf4;
    --mobile-surface: rgba(255,255,255,.94);
    --mobile-accent: #2563eb;
    --mobile-accent-soft: #eef4ff;
    --mobile-success: #0f9f6e;
    --mobile-danger: #dc2626;
    --mobile-radius-xl: 24px;
    --mobile-radius-lg: 18px;
    --mobile-shadow: 0 18px 48px rgba(15, 23, 42, .09);
  }

  html {
    background: #f3f6fa;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
  }

  html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  body {
    margin: 0;
    padding: 0;
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
    background:
      radial-gradient(circle at 100% -10%, rgba(37,99,235,.12), transparent 28rem),
      linear-gradient(180deg, #f8faff 0, #f3f6fa 22rem, #f3f6fa 100%);
    color: var(--mobile-ink);
    font-size: 16px !important;
    line-height: 1.45;
    -webkit-tap-highlight-color: transparent;
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
  }

  button,
  .btn,
  .tab,
  .multi-select-pill,
  .picker-item {
    touch-action: manipulation;
  }

  .app {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 0 14px 28px;
  }

  /* App chrome */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    margin: 0 -14px 18px;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
    background: rgba(248,250,255,.84);
    border-bottom: 1px solid rgba(226,232,240,.72);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
  }

  .header-row {
    min-height: 52px;
    gap: 10px;
  }

  .logo-row {
    min-width: 0;
    gap: 10px;
  }

  .app-logo {
    width: 54px;
    max-height: 38px;
    object-fit: contain;
    flex: 0 0 auto;
  }

  .app-header h1 {
    margin: 0;
    font-size: 18px !important;
    line-height: 1.15;
    letter-spacing: -.02em;
    font-weight: 760;
    color: var(--mobile-ink);
  }

  .subtitle {
    margin: 3px 0 0;
    color: var(--mobile-muted);
    font-size: 11px !important;
    line-height: 1.2;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-weight: 700;
  }

  #logoutBtn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.84);
    border: 1px solid var(--mobile-line);
    color: #64748b;
    box-shadow: 0 4px 14px rgba(15,23,42,.05);
  }

  #logoutBtn .logout-text {
    display: none;
  }

  #logoutBtn .icon-logout {
    margin: 0;
  }

  #logoutBtn .icon-logout svg {
    width: 19px;
    height: 19px;
  }

  /* Native-feeling bottom navigation */
  .tabs {
    position: fixed;
    z-index: 2000;
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(9px, env(safe-area-inset-bottom));
    width: auto;
    max-width: 620px;
    margin: 0 auto;
    padding: 6px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    border: 1px solid rgba(226,232,240,.92);
    border-radius: 24px;
    background: rgba(255,255,255,.92);
    box-shadow: 0 18px 50px rgba(15,23,42,.17);
    -webkit-backdrop-filter: blur(22px) saturate(170%);
    backdrop-filter: blur(22px) saturate(170%);
  }

  .tabs .tab {
    min-width: 0;
    min-height: 56px;
    padding: 6px 5px 5px;
    border: 0;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: transparent;
    color: #7b8799;
    font-size: 11px !important;
    line-height: 1;
    font-weight: 700;
    box-shadow: none;
    transition: color .18s ease, background .18s ease, transform .18s ease;
  }

  .tabs .tab.active {
    background: linear-gradient(180deg, #f1f6ff, #eaf2ff);
    color: var(--mobile-accent);
    border: 0;
    box-shadow: inset 0 0 0 1px rgba(37,99,235,.08);
  }

  .tabs .tab:active {
    transform: scale(.97);
  }

  .tab-icon {
    width: 21px;
    height: 21px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .tab-icon svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .tab-label {
    display: block;
  }

  /* Main workspace surface */
  .panel {
    padding: 18px 15px 20px;
    border: 1px solid rgba(229,235,243,.9);
    border-radius: var(--mobile-radius-xl);
    background: var(--mobile-surface);
    box-shadow: var(--mobile-shadow);
  }

  .panel.show {
    animation: mobilePanelIn .22s ease-out both;
  }

  @keyframes mobilePanelIn {
    from { opacity: .55; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .section-header {
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 18px;
  }

  .section-title {
    margin: 0 0 18px;
    font-size: 22px !important;
    line-height: 1.18;
    letter-spacing: -.035em;
    font-weight: 780;
    color: var(--mobile-ink);
  }

  .section-header .section-title {
    margin-bottom: 0;
  }

  #leadPrintBtn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    padding: 0;
    border-radius: 14px;
  }

  #leadPrintBtn .print-text {
    display: none;
  }

  #leadPrintBtn .icon-print {
    margin: 0;
  }

  /* Form system */
  .form {
    display: flex;
    flex-direction: column;
    gap: 17px;
  }

  .form .grid.two {
    display: grid;
    grid-template-columns: 1fr !important;
    gap: 17px;
  }

  .form .grid.two > * {
    min-width: 0;
  }

  .form .grid.two > [style*="grid-column"] {
    grid-column: 1 / -1 !important;
  }

  #form-visit .grid.two > [style*="grid-template-columns"] {
    grid-column: 1 / -1 !important;
    grid-template-columns: 1fr !important;
    gap: 17px !important;
  }

  .form label {
    display: block;
    margin: 0 0 7px;
    color: #344155;
    font-size: 12px !important;
    line-height: 1.2;
    font-weight: 750;
    letter-spacing: .025em;
  }

  .form input,
  .form select,
  .form textarea,
  .records-controls input,
  .records-controls select,
  .filters input,
  .filters select,
  .pager input {
    width: 100%;
    min-height: 50px;
    padding: 12px 14px;
    border: 1px solid #dce3ed;
    border-radius: 14px;
    background: #f8fafc;
    color: var(--mobile-ink);
    font-size: 16px !important;
    line-height: 1.25;
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.86);
    transition: background .16s ease, border-color .16s ease, box-shadow .16s ease;
  }

  .form textarea {
    min-height: 104px;
    resize: vertical;
  }

  .form input::placeholder,
  .records input::placeholder,
  .filters input::placeholder {
    color: #a0aaba;
  }

  .form input:focus,
  .form select:focus,
  .form textarea:focus,
  .records-controls input:focus,
  .records-controls select:focus,
  .filters input:focus,
  .filters select:focus,
  .pager input:focus {
    border-color: #8eb4ff;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37,99,235,.10), 0 5px 16px rgba(37,99,235,.05);
  }

  .form input[readonly] {
    color: #667085;
    background: #eef2f6;
    border-color: #e1e6ee;
  }

  .location-row {
    margin: 0;
    padding: 13px;
    gap: 10px !important;
    border: 1px solid var(--mobile-line);
    border-radius: 16px;
    background: #f8fafc;
  }

  #pickLocationBtn {
    margin: -4px 0 1px;
  }

  .btn {
    min-height: 46px;
    padding: 11px 15px;
    border-radius: 14px;
    border: 1px solid #dfe5ed;
    background: #fff;
    color: #344155;
    font-size: 14px !important;
    line-height: 1.15;
    font-weight: 750;
    box-shadow: 0 4px 12px rgba(15,23,42,.045);
  }

  .btn.primary {
    border: 1px solid transparent;
    background: linear-gradient(135deg, #2463eb 0%, #2878ef 54%, #159a85 118%);
    color: #fff;
    box-shadow: 0 10px 24px rgba(37,99,235,.24);
  }

  .btn:active:not(:disabled) {
    transform: scale(.985);
  }

  .btn:hover:not(:disabled),
  .btn.primary:hover:not(:disabled) {
    transform: none;
  }

  .location-btn {
    min-height: 50px;
    border-color: #dbe7ff;
    background: var(--mobile-accent-soft);
    color: #1e5fce;
    box-shadow: none;
  }

  .form > .actions {
    position: sticky;
    z-index: 850;
    bottom: 75px;
    margin: 2px -7px 0;
    padding: 9px 7px;
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 8px;
    align-items: center;
    border-radius: 18px;
    background: rgba(255,255,255,.88);
    -webkit-backdrop-filter: blur(18px) saturate(150%);
    backdrop-filter: blur(18px) saturate(150%);
    box-shadow: 0 12px 30px rgba(15,23,42,.10);
  }

  .form > .actions .btn {
    width: 100%;
    min-width: 0;
  }

  .form > .actions .hint {
    grid-column: 1 / -1;
    width: 100%;
  }

  #form-conversion > .actions {
    display: flex !important;
    flex-wrap: wrap;
    gap: 8px !important;
  }

  #form-conversion > .actions > div {
    flex: 1 1 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
    gap: 8px !important;
  }

  #form-conversion > .actions > div .btn {
    min-width: 0;
    width: 100%;
  }

  .hint {
    color: var(--mobile-muted);
    font-size: 12px !important;
    line-height: 1.45;
  }

  /* Multi-select */
  .multi-select-grid {
    gap: 8px;
    margin-top: 8px;
  }

  .multi-select-pill {
    min-height: 38px;
    padding: 8px 11px;
    gap: 7px;
    border-radius: 12px;
    border-color: #e0e6ef;
    background: #f8fafc;
    color: #48566a;
    font-size: 12px;
    font-weight: 700;
    box-shadow: none;
  }

  .multi-select-pill.selected {
    border-color: #b9d1ff;
    background: #edf4ff;
    color: #1f62d5;
    box-shadow: inset 0 0 0 1px rgba(37,99,235,.05);
  }

  .multi-select-pill .pill-remove {
    width: 19px;
    height: 19px;
  }

  #productInterestsContainer,
  #productAvailabilityContainer,
  #marketingMaterialContainer {
    margin-bottom: 2px;
  }

  /* Search pickers */
  .leadpicker {
    position: relative;
  }

  .picker-list {
    top: calc(100% + 6px);
    max-height: min(320px, 45vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid #e1e7ef;
    border-radius: 16px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 20px 44px rgba(15,23,42,.15);
  }

  .picker-item {
    min-height: 48px;
    padding: 11px 13px;
    gap: 8px;
    border-color: #edf1f5;
    font-size: 13px;
  }

  .pill {
    flex: 0 0 auto;
    padding: 4px 8px;
    border-color: #dce5f2;
    background: #f4f7fb;
    font-size: 10px;
    font-weight: 800;
  }

  /* Records area */
  .records {
    margin: 26px -4px 0;
    padding-top: 20px;
    border-top: 1px solid var(--mobile-line);
  }

  .mobile-records-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 4px 13px;
  }

  .mobile-records-title {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .mobile-records-title strong {
    overflow: hidden;
    color: var(--mobile-ink);
    font-size: 17px;
    line-height: 1.2;
    letter-spacing: -.02em;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-records-eyebrow {
    color: #8b96a8;
    font-size: 9px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: .11em;
    text-transform: uppercase;
  }

  .mobile-filter-toggle {
    flex: 0 0 auto;
    min-height: 40px;
    padding: 9px 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #dfe6ef;
    border-radius: 13px;
    background: #fff;
    color: #536176;
    font-size: 12px;
    font-weight: 800;
    box-shadow: 0 4px 12px rgba(15,23,42,.04);
  }

  .mobile-filter-toggle svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
  }

  .mobile-filter-toggle.active {
    border-color: #bdd3ff;
    background: #edf4ff;
    color: #1f62d5;
  }

  .records > .records-controls,
  .records > .filters,
  .records > .records-controls-bottom {
    display: none;
  }

  .records.mobile-filters-open > .records-controls,
  .records.mobile-filters-open > .filters,
  .records.mobile-filters-open > .records-controls-bottom {
    display: flex;
  }

  .records .records-controls,
  .records .filters {
    margin: 0 4px 9px;
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 9px;
    border: 1px solid #e5eaf1;
    border-radius: 17px;
    background: #f8fafc;
    font-size: 14px !important;
  }

  .records .records-controls-bottom {
    margin-top: 8px;
  }

  .records .records-controls > *,
  .records .filters > * {
    width: 100% !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
  }

  .records .records-controls > div[style*="flex:1"] {
    display: none;
  }

  .records .records-controls label {
    margin: 2px 0 -3px;
    color: #536176;
    font-size: 11px !important;
    font-weight: 780;
  }

  .records .records-controls .btn,
  .records .filters .btn {
    min-height: 46px;
  }

  #leadPageSize,
  #visitPageSize,
  #conversionPageSize {
    width: 100% !important;
    height: auto !important;
    min-height: 46px !important;
    padding: 11px 13px !important;
    border-radius: 13px !important;
    font-size: 14px !important;
  }

  /* Tables become compact record cards */
  .table {
    width: 100%;
    overflow: visible;
  }

  .table table,
  .table tbody {
    display: block;
    width: 100%;
    min-width: 0 !important;
    margin: 0;
  }

  .table thead {
    display: none;
  }

  .table tr {
    position: relative;
    width: 100%;
    margin: 0 0 11px;
    padding: 13px 13px 11px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
    overflow: hidden;
    border: 1px solid #e5eaf1;
    border-radius: 18px;
    background: #fff;
    box-shadow: 0 7px 20px rgba(15,23,42,.055);
  }

  .table tr:last-child {
    margin-bottom: 0;
  }

  .table td {
    min-width: 0;
    padding: 7px 0;
    display: grid;
    grid-template-columns: minmax(92px, .72fr) minmax(0, 1.28fr);
    gap: 12px;
    align-items: start;
    border: 0;
    border-bottom: 1px solid #f0f3f7;
    color: #253247;
    font-size: 13px !important;
    line-height: 1.35;
    word-break: break-word;
  }

  .table td::before {
    content: attr(data-label);
    color: #8a95a6;
    font-size: 9px;
    line-height: 1.4;
    font-weight: 820;
    letter-spacing: .065em;
    text-transform: uppercase;
  }

  .table td:first-child {
    margin: -13px -13px 7px;
    padding: 12px 13px 11px;
    display: flex;
    align-items: center;
    gap: 7px;
    border-bottom: 1px solid #e9eef5;
    background: linear-gradient(135deg, #f8fbff, #f4f8ff);
    color: #124eb2;
    font-size: 14px !important;
    font-weight: 800;
  }

  .table td:first-child::before {
    display: inline-flex;
    padding: 4px 7px;
    border-radius: 7px;
    background: #e8f1ff;
    color: #3971c9;
    font-size: 8px;
  }

  .table td.actions-cell {
    min-height: 48px;
    padding: 9px 0 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 7px;
    border-bottom: 0;
    white-space: nowrap;
  }

  .table td.actions-cell::before {
    display: none;
  }

  .actions-cell .btn + .btn {
    margin-left: 0;
  }

  .table .btn-icon {
    width: 42px;
    min-width: 42px;
    height: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 13px;
    box-shadow: none;
  }

  .table .btn-icon svg {
    width: 17px !important;
    height: 17px !important;
  }

  .table .btn-icon.danger {
    border-color: #fde2e2;
    background: #fffafa;
    color: #c93636;
  }

  /* Pagination */
  .pager {
    margin: 13px 2px 0;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    align-items: center;
    font-size: 12px;
  }

  .pager > span:first-child {
    grid-column: 1 / -1;
    min-height: 18px;
    color: #7c889a;
    text-align: center;
    font-size: 11px;
  }

  .pager .btn {
    width: 100%;
    min-height: 42px;
    padding: 9px 10px;
    font-size: 12px !important;
  }

  .pager > .hint {
    display: none;
  }

  .pager input[type="number"] {
    width: 100% !important;
    min-height: 42px;
    padding: 8px 10px;
    text-align: center;
    font-size: 13px !important;
  }

  /* Modals */
  .map-modal {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
    align-items: flex-end;
    background: rgba(7,12,22,.58);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }

  .map-content {
    width: 100%;
    max-width: 680px;
    height: min(82vh, 690px);
    padding: 10px;
    gap: 8px;
    border-radius: 24px;
    box-shadow: 0 30px 80px rgba(0,0,0,.26);
  }

  .map-canvas {
    min-height: 280px;
    border-radius: 18px;
  }

  .map-content .btn {
    min-height: 48px;
  }

  .confirm-modal {
    padding: 18px;
    align-items: flex-end;
    background: rgba(7,12,22,.55);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }

  .confirm-content {
    width: 100%;
    max-width: 520px;
    padding: 20px;
    border-radius: 22px;
  }

  .confirm-content p {
    margin: 0 0 18px;
    font-size: 15px;
    line-height: 1.5;
  }

  .confirm-content .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .global-toast {
    left: 14px;
    right: 14px;
    bottom: calc(88px + env(safe-area-inset-bottom));
    width: auto;
    padding: 12px 14px;
    border-radius: 14px;
    text-align: center;
    font-size: 12px;
    box-shadow: 0 12px 30px rgba(15,23,42,.22);
  }

  /* Login */
  #loginPanel {
    padding: calc(18px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom)) !important;
    background:
      radial-gradient(circle at 100% 0, rgba(37,99,235,.16), transparent 22rem),
      linear-gradient(160deg, #f8fbff, #f1f5fb);
  }

  #loginPanel .card {
    max-width: 430px !important;
    padding: 26px 20px 20px !important;
    border-radius: 26px;
    border-color: rgba(226,232,240,.9);
    box-shadow: 0 24px 70px rgba(15,23,42,.13);
  }

  #loginPanel img {
    width: 148px !important;
    margin-bottom: 24px !important;
  }

  #loginPanel h2 {
    font-size: 25px;
    letter-spacing: -.035em;
  }

  #loginPanel .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px !important;
  }

  #loginPanel .actions .btn {
    width: 100%;
  }

  #authMsg {
    grid-column: 1 / -1;
  }

  /* Avoid desktop hover treatments on touch screens */
  @media (hover: none) {
    .btn:hover:not(:disabled):not(.primary),
    #logoutBtn:hover:not(:disabled),
    #leadDiscardBtn:hover:not(:disabled),
    #visitDiscardBtn:hover:not(:disabled),
    #conversionDiscardBtn:hover:not(:disabled),
    #leadClearBtn:hover:not(:disabled),
    #visitClearFilters:hover:not(:disabled),
    #conversionClearFilters:hover:not(:disabled),
    .actions-cell .btn-icon.danger:hover:not(:disabled) {
      transform: none;
      box-shadow: inherit;
      background: inherit;
      color: inherit;
      border-color: inherit;
    }
  }
}

/* Small-phone refinements */
@media (max-width: 390px) {
  .app {
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-header {
    margin-left: -10px;
    margin-right: -10px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .app-logo {
    width: 46px;
  }

  .app-header h1 {
    font-size: 16px !important;
  }

  .panel {
    padding-left: 12px;
    padding-right: 12px;
    border-radius: 21px;
  }

  .table td {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 9px;
  }
}

@media (max-width: 1024px) {
  #loginPanel .form > .actions {
    position: static;
    bottom: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* ========================================================================== 
   Premium desktop workspace — 1025px and above
   Keeps all existing IDs, forms, tables, and business logic intact.
   ========================================================================== */
@media (min-width: 1025px) {
  :root {
    --desk-ink: #0b1220;
    --desk-ink-2: #253248;
    --desk-muted: #718096;
    --desk-line: #e4eaf2;
    --desk-line-strong: #d8e0eb;
    --desk-surface: #ffffff;
    --desk-surface-soft: #f7f9fc;
    --desk-blue: #2463eb;
    --desk-blue-deep: #174bb8;
    --desk-blue-soft: #edf4ff;
    --desk-green: #0d9a72;
    --desk-red: #d43d4c;
    --desk-radius: 18px;
    --desk-shadow: 0 18px 48px rgba(15, 23, 42, .075);
    --desk-shadow-soft: 0 7px 22px rgba(15, 23, 42, .05);
  }

  html {
    min-height: 100%;
    background: #f3f6fa;
  }

  body {
    min-height: 100vh;
    overflow-x: hidden;
    background:
      radial-gradient(circle at 12% -8%, rgba(36,99,235,.11), transparent 31rem),
      radial-gradient(circle at 92% 8%, rgba(13,154,114,.055), transparent 27rem),
      linear-gradient(180deg, #f8faff 0, #f3f6fa 28rem, #f3f6fa 100%);
    color: var(--desk-ink);
    font-size: 15px;
    line-height: 1.5;
  }

  body::before {
    content: "";
    position: fixed;
    z-index: -1;
    inset: 0 0 auto;
    height: 190px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255,255,255,.74), rgba(255,255,255,0));
  }

  button,
  input,
  select,
  textarea {
    font: inherit;
  }

  .app {
    width: min(100% - 48px, 1540px);
    max-width: none;
    margin: 0 auto 64px;
    padding: 0;
  }

  /* Top command bar */
  .app-header {
    position: sticky;
    top: 0;
    z-index: 1400;
    margin: 0 -24px 24px;
    padding: 16px 24px 14px;
    border-bottom: 1px solid rgba(218,226,236,.78);
    background: rgba(248,250,255,.86);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    backdrop-filter: blur(20px) saturate(150%);
  }

  .header-row {
    min-height: 54px;
    align-items: center;
  }

  .logo-row {
    min-width: 0;
    gap: 14px;
  }

  .app-logo {
    width: 112px;
    max-height: 48px;
    object-fit: contain;
  }

  .app-header h1 {
    margin: 0;
    color: var(--desk-ink);
    font-size: 20px;
    line-height: 1.15;
    font-weight: 780;
    letter-spacing: -.025em;
  }

  .subtitle {
    margin: 4px 0 0;
    color: #7e899a;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: .055em;
    text-transform: uppercase;
  }

  #logoutBtn {
    min-height: 40px;
    padding: 9px 12px;
    gap: 7px;
    border-color: #dee5ee;
    border-radius: 11px;
    background: rgba(255,255,255,.8);
    color: #5b687c;
    box-shadow: 0 3px 10px rgba(15,23,42,.035);
    font-size: 12px;
  }

  #logoutBtn .logout-text {
    margin-left: 0;
  }

  #logoutBtn .icon-logout svg {
    width: 15px;
    height: 15px;
  }

  #logoutBtn:hover:not(:disabled) {
    transform: translateY(-1px);
    border-color: #f1c8cd;
    background: #fff5f5;
    color: #bd3442;
    box-shadow: 0 7px 18px rgba(190,52,66,.08);
  }

  /* Workspace navigation */
  .tabs {
    position: relative;
    z-index: 20;
    width: max-content;
    margin: 0 0 20px;
    padding: 5px;
    justify-content: flex-start;
    gap: 4px;
    flex-wrap: nowrap;
    border: 1px solid rgba(219,227,237,.95);
    border-radius: 14px;
    background: rgba(255,255,255,.82);
    box-shadow: var(--desk-shadow-soft);
  }

  .tab {
    min-height: 42px;
    padding: 9px 15px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: #68768a;
    box-shadow: none;
    font-size: 12px;
    font-weight: 760;
    transition: background .16s ease, color .16s ease, box-shadow .16s ease, transform .12s ease;
  }

  .tab-icon {
    width: 17px;
    height: 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .tab-icon svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .tab:hover {
    background: #f5f8fc;
    color: #34445c;
  }

  .tab.active {
    border: 0;
    background: linear-gradient(135deg, #17243a 0%, #203a68 100%);
    color: #fff;
    box-shadow: 0 7px 18px rgba(23,36,58,.17);
  }

  /* Panel becomes a composed workspace instead of one giant card */
  .panel {
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .panel.show {
    animation: desktopPanelIn .2s ease-out both;
  }

  @keyframes desktopPanelIn {
    from { opacity: .62; transform: translateY(3px); }
    to { opacity: 1; transform: translateY(0); }
  }

  .section-header {
    min-height: 54px;
    margin: 0 0 12px;
    align-items: flex-end !important;
  }

  .section-title {
    margin: 0 0 12px;
    color: var(--desk-ink);
    font-size: 24px;
    line-height: 1.14;
    font-weight: 790;
    letter-spacing: -.035em;
  }

  .section-title::before {
    display: block;
    margin-bottom: 6px;
    color: #8190a5;
    font-size: 9px;
    line-height: 1;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
  }

  #panel-lead .section-title::before { content: "Lead Intelligence"; }
  #panel-visit .section-title::before { content: "Field Activity"; }
  #panel-conversion .section-title::before { content: "Commercial Outcome"; }

  .section-title::after {
    display: block;
    margin-top: 6px;
    color: #78869a;
    font-size: 12px;
    line-height: 1.4;
    font-weight: 520;
    letter-spacing: 0;
  }

  #panel-lead .section-title::after { content: "Capture, qualify, and enrich a lead profile."; }
  #panel-visit .section-title::after { content: "Log customer touchpoints and next actions."; }
  #panel-conversion .section-title::after { content: "Turn qualified leads into customer records."; }

  .section-header .section-title {
    margin-bottom: 0;
  }

  #leadPrintBtn {
    min-height: 40px;
    padding: 9px 12px;
    border-color: #dce4ee;
    border-radius: 10px;
    background: rgba(255,255,255,.86);
    color: #47566c;
    font-size: 12px;
  }

  /* Entry card */
  .panel > .form {
    position: relative;
    padding: 24px;
    gap: 19px;
    overflow: visible;
    border: 1px solid rgba(224,231,240,.96);
    border-radius: var(--desk-radius);
    background: rgba(255,255,255,.96);
    box-shadow: var(--desk-shadow);
  }

  .panel > .form::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    border-radius: var(--desk-radius) var(--desk-radius) 0 0;
    background: linear-gradient(90deg, #2463eb, #2e7af0 52%, #11a47d);
    opacity: .88;
  }

  .form .grid.two {
    column-gap: 20px;
    row-gap: 17px;
  }

  .form label {
    margin-bottom: 7px;
    color: #405069;
    font-size: 11px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: .025em;
  }

  .form input,
  .form select,
  .form textarea {
    min-height: 43px;
    padding: 10px 12px;
    border: 1px solid #dce4ee;
    border-radius: 10px;
    background: #f9fbfd;
    color: #172236;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.9);
    font-size: 13px;
    line-height: 1.3;
    transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  }

  .form input:hover,
  .form select:hover,
  .form textarea:hover {
    border-color: #cfd9e6;
    background: #fff;
  }

  .form input:focus,
  .form select:focus,
  .form textarea:focus {
    border-color: #8eb4ff;
    background: #fff;
    box-shadow: 0 0 0 4px rgba(36,99,235,.09), 0 5px 14px rgba(36,99,235,.04);
  }

  .form textarea {
    min-height: 96px;
    resize: vertical;
  }

  .form input::placeholder,
  .records input::placeholder,
  .filters input::placeholder {
    color: #a0aabd;
  }

  .form input[readonly] {
    border-color: #e2e7ee;
    background: #eef2f6;
    color: #687589;
  }

  .location-row {
    margin-top: 3px;
    margin-bottom: 0;
    padding: 13px;
    gap: 12px !important;
    border: 1px solid #e7ecf3;
    border-radius: 12px;
    background: #f8fafc;
  }

  .location-btn {
    min-height: 43px;
    margin-top: 0;
    border-color: #d7e5ff;
    border-radius: 10px;
    background: #f0f5ff;
    color: #235fc9;
    box-shadow: none;
  }

  #pickLocationBtn {
    margin-bottom: 0;
  }

  /* Buttons */
  .btn {
    min-height: 40px;
    padding: 9px 13px;
    border: 1px solid #dce4ed;
    border-radius: 10px;
    background: #fff;
    color: #405069;
    box-shadow: 0 3px 9px rgba(15,23,42,.035);
    font-size: 12px;
    line-height: 1.2;
    font-weight: 780;
  }

  .btn:hover:not(:disabled):not(.primary) {
    transform: translateY(-1px);
    border-color: #c9d5e4;
    background: #f7f9fc;
    color: #273a56;
    box-shadow: 0 6px 16px rgba(15,23,42,.075);
  }

  .btn.primary {
    border-color: transparent;
    background: linear-gradient(135deg, #1d56cc 0%, #246ee8 54%, #168c7b 118%);
    color: #fff;
    box-shadow: 0 8px 20px rgba(36,99,235,.20);
  }

  .btn.primary:hover:not(:disabled) {
    transform: translateY(-1px);
    filter: none;
    background: linear-gradient(135deg, #194dbb 0%, #2166da 54%, #158474 118%);
    box-shadow: 0 11px 25px rgba(36,99,235,.25);
  }

  .actions {
    margin-top: 3px;
    gap: 8px;
  }

  .panel > .form > .actions {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid #edf1f5;
  }

  #form-conversion > .actions {
    border-top: 1px solid #edf1f5;
  }

  .hint {
    color: #7b8799;
    font-size: 11px;
    line-height: 1.45;
  }

  /* Choice chips */
  .multi-select-grid {
    gap: 7px;
    margin-top: 7px;
  }

  .multi-select-pill {
    min-height: 32px;
    padding: 6px 9px;
    gap: 5px;
    border-color: #e0e6ef;
    border-radius: 9px;
    background: #f8fafc;
    color: #536176;
    box-shadow: none;
    font-size: 11px;
    font-weight: 720;
  }

  .multi-select-pill:hover {
    transform: translateY(-1px);
    border-color: #cbd7e7;
    background: #fff;
    box-shadow: 0 4px 12px rgba(15,23,42,.06);
  }

  .multi-select-pill.selected {
    border-color: #bdd3ff;
    background: #edf4ff;
    color: #1f5fc8;
  }

  #productInterestsContainer,
  #productAvailabilityContainer,
  #marketingMaterialContainer {
    margin-bottom: 0;
  }

  /* Autocomplete */
  .picker-list {
    top: calc(100% + 5px);
    max-height: 280px;
    overflow-y: auto;
    border-color: #dfe6ef;
    border-radius: 12px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 18px 42px rgba(15,23,42,.14);
  }

  .picker-item {
    min-height: 42px;
    padding: 9px 11px;
    border-color: #eef2f6;
    color: #34445b;
    font-size: 12px;
  }

  .picker-item:hover {
    background: #f1f6ff;
  }

  .pill {
    padding: 3px 7px;
    border-color: #dbe3ee;
    border-radius: 7px;
    background: #f4f7fb;
    color: #66758a;
    font-size: 9px;
    font-weight: 820;
  }

  /* Record-management card */
  .records {
    margin-top: 22px;
    padding: 21px;
    border: 1px solid rgba(224,231,240,.96);
    border-radius: var(--desk-radius);
    background: rgba(255,255,255,.96);
    box-shadow: var(--desk-shadow);
  }

  .mobile-records-header {
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
  }

  .mobile-records-title {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .mobile-records-eyebrow {
    color: #8a97aa;
    font-size: 8px;
    line-height: 1;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
  }

  .mobile-records-title strong {
    color: #152136;
    font-size: 16px;
    line-height: 1.2;
    font-weight: 780;
    letter-spacing: -.02em;
  }

  .mobile-filter-toggle {
    display: none;
  }

  .records-controls,
  .filters {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .records > .records-controls,
  .records > .filters {
    margin: 0 0 8px;
    padding: 10px;
    border: 1px solid #e8edf4;
    border-radius: 12px;
    background: #f8fafc;
  }

  .records > .records-controls-bottom {
    margin-top: 8px;
  }

  .records-controls input,
  .records-controls select,
  .filters input,
  .filters select,
  .pager input {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid #dce4ee;
    border-radius: 9px;
    background: #fff;
    color: #28384f;
    outline: none;
    box-shadow: none;
    font-size: 11px;
    transition: border-color .15s ease, box-shadow .15s ease;
  }

  .records-controls input:focus,
  .records-controls select:focus,
  .filters input:focus,
  .filters select:focus,
  .pager input:focus {
    border-color: #93b7fb;
    box-shadow: 0 0 0 3px rgba(36,99,235,.075);
  }

  .records-controls label {
    margin-right: 1px;
    color: #6c798c;
    font-size: 9px;
    font-weight: 820;
    letter-spacing: .035em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .records .records-controls .btn,
  .records .filters .btn {
    min-height: 38px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .visit-filters-actions select#visitPageSize,
  #visitPageSize,
  #leadPageSize,
  #conversionPageSize {
    min-height: 38px;
    height: 38px;
    padding: 7px 9px;
    border-radius: 9px;
    font-size: 11px;
  }

  /* Data grid */
  .table {
    width: 100%;
    margin-top: 13px;
    overflow-x: auto;
    border: 1px solid #e5ebf2;
    border-radius: 13px;
    background: #fff;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
  }

  .table table {
    width: 100%;
    min-width: 760px;
    margin: 0;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 11px;
  }

  .table th,
  .table td {
    padding: 10px 11px;
    border: 0;
    border-bottom: 1px solid #edf1f5;
    vertical-align: middle;
  }

  .table th {
    position: relative;
    background: #f6f8fb;
    color: #6f7e91;
    text-align: left;
    font-size: 8.5px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
  }

  .table th + th::before {
    content: "";
    position: absolute;
    left: 0;
    top: 9px;
    bottom: 9px;
    width: 1px;
    background: #e5eaf1;
  }

  .table td {
    max-width: 250px;
    color: #34445a;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  .table tbody tr:last-child td {
    border-bottom: 0;
  }

  .table tbody tr {
    transition: background .12s ease;
  }

  .table tbody tr:hover td {
    background: #fbfdff;
  }

  .table td:first-child {
    color: #1758bd;
    font-weight: 760;
    white-space: nowrap;
  }

  .table th.actions-cell,
  .table td.actions-cell {
    width: 1%;
    min-width: 112px;
    text-align: right;
    white-space: nowrap;
  }

  .table .btn-icon {
    width: 32px;
    min-width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    border-radius: 8px;
    background: #fff;
    box-shadow: none;
  }

  .table .btn-icon:hover:not(:disabled) {
    transform: none;
    border-color: #bcd0ed;
    background: #edf4ff;
    color: #1c5bbd;
    box-shadow: none;
  }

  .table .btn-icon.danger {
    color: #a94a55;
  }

  .table .btn-icon.danger:hover:not(:disabled) {
    border-color: #f0c9cf;
    background: #fff3f4;
    color: #c63746;
  }

  /* Pagination */
  .pager {
    min-height: 44px;
    margin-top: 12px;
    gap: 6px;
    justify-content: flex-end;
    color: #7b8798;
    font-size: 10px;
  }

  .pager > span:first-child {
    margin-right: auto;
    color: #7b8798;
    font-size: 10px;
    font-weight: 650;
  }

  .pager .btn {
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 8px;
    font-size: 10px;
  }

  .pager input[type="number"] {
    width: 54px !important;
    min-height: 34px;
    padding: 6px 8px;
    text-align: center;
  }

  /* Desktop drawer */
  .overlay {
    z-index: 3000;
    background: rgba(9,17,30,.36);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
  }

  .drawer {
    z-index: 3100;
    width: 460px;
    border-left: 1px solid #dfe6ef;
    background: #fbfcfe;
    box-shadow: -24px 0 70px rgba(15,23,42,.15);
  }

  .drawer-header,
  .drawer-footer {
    min-height: 64px;
    padding: 14px 16px;
    border-color: #e6ebf2;
    background: rgba(255,255,255,.92);
  }

  .drawer-header h3 {
    margin: 0;
    font-size: 16px;
    letter-spacing: -.02em;
  }

  .drawer-body {
    padding: 18px;
  }

  /* Modals */
  .map-modal,
  .confirm-modal {
    background: rgba(7,13,24,.50);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
  }

  .map-content {
    width: min(760px, 90vw);
    max-width: 760px;
    height: min(620px, 82vh);
    padding: 12px;
    gap: 9px;
    border: 1px solid rgba(255,255,255,.7);
    border-radius: 20px;
    box-shadow: 0 28px 90px rgba(0,0,0,.23);
  }

  .map-canvas {
    border-radius: 13px;
  }

  .confirm-content {
    width: min(430px, 90vw);
    padding: 22px;
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(0,0,0,.18);
  }

  .confirm-content p {
    margin: 0 0 20px;
    color: #27374e;
    font-size: 13px;
    line-height: 1.55;
  }

  .confirm-content .actions {
    justify-content: flex-end;
  }

  .global-toast {
    right: 24px;
    bottom: 24px;
    padding: 11px 14px;
    border-radius: 10px;
    background: #172236;
    box-shadow: 0 14px 34px rgba(15,23,42,.20);
    font-size: 11px;
  }

  /* Authentication */
  #loginPanel {
    padding: 40px !important;
    background:
      radial-gradient(circle at 70% 10%, rgba(36,99,235,.13), transparent 28rem),
      radial-gradient(circle at 28% 90%, rgba(13,154,114,.07), transparent 24rem),
      #f4f7fb;
  }

  #loginPanel .card {
    max-width: 430px !important;
    padding: 32px !important;
    border-color: rgba(220,227,237,.95);
    border-radius: 22px;
    box-shadow: 0 28px 80px rgba(15,23,42,.12);
  }

  #loginPanel img {
    width: 155px !important;
    margin-bottom: 26px !important;
  }

  #loginPanel h2 {
    color: var(--desk-ink);
    font-size: 25px;
    letter-spacing: -.035em;
  }

  #loginPanel .hint {
    font-size: 11px;
  }

  #loginPanel .actions {
    gap: 8px !important;
  }

  /* Better native selection visibility */
  ::selection {
    background: rgba(36,99,235,.18);
    color: #102041;
  }
}

/* Large desktop: dedicated navigation rail */
@media (min-width: 1280px) {
  .app {
    display: grid;
    grid-template-columns: 212px minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 24px;
    align-items: start;
  }

  .app-header {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .tabs {
    grid-column: 1;
    grid-row: 2;
    position: sticky;
    top: 103px;
    width: 100%;
    margin: 0;
    padding: 9px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    border-radius: 16px;
  }

  .tabs::before {
    content: "Workspace";
    padding: 7px 9px 8px;
    color: #96a1b2;
    font-size: 8px;
    line-height: 1;
    font-weight: 850;
    letter-spacing: .14em;
    text-transform: uppercase;
  }

  .tab {
    width: 100%;
    min-height: 46px;
    padding: 9px 10px;
    justify-content: flex-start;
    text-align: left;
  }

  .tab-icon {
    width: 27px;
    height: 27px;
    border-radius: 8px;
    background: rgba(111,126,145,.07);
  }

  .tab.active .tab-icon {
    background: rgba(255,255,255,.12);
  }

  .panel {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
  }

  .panel > .form {
    padding: 26px 28px;
  }

  .records {
    padding: 23px 24px;
  }
}

/* Ultra-wide: more breathing room without making form controls cartoonishly large */
@media (min-width: 1500px) {
  .app {
    grid-template-columns: 224px minmax(0, 1fr);
    column-gap: 28px;
  }

  .panel > .form {
    padding: 28px 30px;
  }

  .form .grid.two {
    column-gap: 24px;
  }

  .records {
    padding: 24px 26px;
  }
}

@media print and (min-width: 1025px) {
  body {
    background: #fff !important;
  }

  .app {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
  }

  .app-header,
  .tabs,
  .records,
  #leadPrintBtn,
  #logoutBtn {
    display: none !important;
  }

  .panel,
  .panel > .form {
    border: 0 !important;
    box-shadow: none !important;
  }
}

/* ========================================================================== 
   iPhone / iPad Safari compatibility hardening
   Keeps desktop and non-iOS mobile presentation unchanged.
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
  }

  /* Dynamic viewport units follow Safari's expanding/collapsing browser chrome. */
  #loginPanel {
    min-height: 100vh !important;
    min-height: 100dvh !important;
  }

  .map-content {
    height: min(82vh, 690px);
    height: min(82dvh, 690px);
    max-height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 20px);
  }

  /* Prevent Safari intrinsic sizing from pushing native controls outside cards. */
  .grid > *,
  .form > *,
  .records-controls > *,
  .filters > *,
  .visit-filters-row > *,
  .visit-filters-actions > * {
    min-width: 0;
    max-width: 100%;
  }

  .form input,
  .form select,
  .form textarea,
  .records-controls input,
  .records-controls select,
  .filters input,
  .filters select,
  .pager input,
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    min-width: 0;
    max-width: 100%;
  }

  input[type="date"],
  input[type="time"],
  input[type="datetime-local"] {
    display: block;
    min-height: 50px;
  }

  input[type="date"]::-webkit-date-and-time-value,
  input[type="time"]::-webkit-date-and-time-value,
  input[type="datetime-local"]::-webkit-date-and-time-value {
    min-height: 1.25em;
    text-align: left;
  }

  /* iOS Safari/WebKit only. The class is added in app.js after feature detection. */
  html.ios-webkit,
  html.ios-webkit body {
    min-height: 100%;
    min-height: 100dvh;
    overscroll-behavior-y: none;
  }

  html.ios-webkit body {
    -webkit-font-smoothing: antialiased;
    padding-left: var(--safe-left);
    padding-right: var(--safe-right);
  }

  /* Solid-ish surfaces avoid WebKit backdrop-filter compositing glitches. */
  html.ios-webkit .app-header {
    background: rgba(248,250,255,.97);
    -webkit-backdrop-filter: blur(10px) saturate(125%);
    backdrop-filter: blur(10px) saturate(125%);
    transform: translateZ(0);
  }

  html.ios-webkit .tabs {
    background: rgba(255,255,255,.98);
    -webkit-backdrop-filter: blur(10px) saturate(125%);
    backdrop-filter: blur(10px) saturate(125%);
    transform: translateZ(0);
    will-change: transform, opacity;
  }

  html.ios-webkit .form > .actions {
    background: rgba(255,255,255,.97);
    -webkit-backdrop-filter: blur(8px) saturate(120%);
    backdrop-filter: blur(8px) saturate(120%);
  }

  html.ios-webkit .map-modal,
  html.ios-webkit .confirm-modal {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  /*
    A real iPhone keyboard changes visualViewport independently of the layout
    viewport. Fixed/sticky controls are removed while a form field is focused,
    preventing Safari from pinning them above or behind the keyboard.
  */
  html.ios-webkit.form-control-focused .tabs,
  html.ios-webkit.keyboard-open .tabs {
    opacity: 0;
    pointer-events: none;
    transform: translate3d(0, calc(100% + 32px), 0);
  }

  html.ios-webkit.form-control-focused .form > .actions,
  html.ios-webkit.keyboard-open .form > .actions {
    position: static;
    bottom: auto;
    margin-top: 8px;
  }

  html.ios-webkit.form-control-focused body,
  html.ios-webkit.keyboard-open body {
    padding-bottom: calc(24px + var(--safe-bottom));
  }

  html.ios-webkit.form-control-focused .global-toast,
  html.ios-webkit.keyboard-open .global-toast {
    bottom: calc(12px + var(--safe-bottom));
  }

  /* Keep focused controls visible without allowing horizontal page drift. */
  html.ios-webkit input:focus,
  html.ios-webkit select:focus,
  html.ios-webkit textarea:focus {
    scroll-margin-top: calc(76px + var(--safe-top));
    scroll-margin-bottom: 24px;
  }

  /* A little more room for the narrowest supported iPhones. */
  @media (max-width: 374px) {
    .app {
      padding-left: 8px;
      padding-right: 8px;
    }

    .app-header {
      margin-left: -8px;
      margin-right: -8px;
      padding-left: 9px;
      padding-right: 9px;
    }

    .tabs {
      left: max(6px, var(--safe-left));
      right: max(6px, var(--safe-right));
      padding: 5px;
      border-radius: 21px;
    }

    .tabs .tab {
      min-height: 52px;
      font-size: 10px !important;
    }

    .panel {
      padding-left: 10px;
      padding-right: 10px;
    }

    .form > .actions,
    #form-conversion > .actions > div {
      grid-template-columns: 1fr;
    }
  }

  /* iPhone landscape: preserve safe areas and reclaim vertical workspace. */
  @media (orientation: landscape) and (max-height: 500px) {
    .app {
      max-width: none;
      padding-left: max(12px, var(--safe-left));
      padding-right: max(12px, var(--safe-right));
      padding-bottom: 68px;
    }

    .app-header {
      margin-left: calc(-1 * max(12px, var(--safe-left)));
      margin-right: calc(-1 * max(12px, var(--safe-right)));
      padding-top: max(6px, var(--safe-top));
      padding-left: max(12px, var(--safe-left));
      padding-right: max(12px, var(--safe-right));
    }

    .header-row {
      min-height: 44px;
    }

    .app-logo {
      width: 46px;
      max-height: 30px;
    }

    .subtitle {
      display: none;
    }

    .tabs {
      left: max(8px, var(--safe-left));
      right: max(8px, var(--safe-right));
      bottom: max(5px, var(--safe-bottom));
      padding: 4px;
      border-radius: 20px;
    }

    .tabs .tab {
      min-height: 44px;
      flex-direction: row;
      gap: 7px;
      border-radius: 16px;
    }

    .tab-icon,
    .tab-icon svg {
      width: 18px;
      height: 18px;
    }

    .panel {
      padding-top: 14px;
    }

    .form > .actions {
      bottom: 58px;
    }

    .map-content {
      height: calc(100dvh - var(--safe-top) - var(--safe-bottom) - 12px);
      max-height: none;
    }
  }
}

/* ========================================================================== 
   iPhone clean-cascade guard
   This is intentionally small and explicit. It prevents legacy/base rules or
   Safari text autosizing from recreating the old oversized mobile header.
   ========================================================================== */
@media (max-width: 1024px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    font-size: 16px !important;
  }

  .app {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
  }

  .header-row {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
  }

  .logo-row {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
  }

  .app-logo-picture {
    display: flex;
    width: 42px;
    height: 42px;
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
  }

  .app-logo-picture .app-logo {
    display: block;
    width: 40px !important;
    max-width: 40px !important;
    height: 40px !important;
    max-height: 40px !important;
    object-fit: contain;
    flex: 0 0 40px;
  }

  .logo-row > div {
    min-width: 0;
    flex: 1 1 auto;
  }

  .app-header h1 {
    font-size: 18px !important;
    line-height: 1.15 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .subtitle {
    font-size: 11px !important;
    line-height: 1.2 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #logoutBtn {
    flex: 0 0 42px;
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
  }

  #logoutBtn .logout-text {
    display: none !important;
  }

  .tabs {
    flex-wrap: nowrap !important;
  }

  .tabs .tab {
    min-width: 0 !important;
    font-size: 11px !important;
    padding: 6px 5px 5px !important;
  }

  .section-title {
    font-size: 20px !important;
    line-height: 1.2;
  }

  .form label {
    font-size: 13px !important;
  }

  .form input,
  .form select,
  .form textarea {
    font-size: 16px !important;
  }

  .btn {
    font-size: 14px !important;
  }
}

@supports (-webkit-touch-callout: none) {
  @media (max-width: 1024px) {
    /* iOS Safari: never allow automatic text inflation to alter app geometry. */
    html, body {
      -webkit-text-size-adjust: 100% !important;
      overflow-x: hidden;
      overflow-x: clip;
    }

    /*
      Do NOT clamp .app-header to max-width:100% here. On mobile the header
      intentionally uses negative side margins to reach the viewport edges;
      clamping it first makes WebKit shift the header left and leave a blank
      strip on the right.
    */
    .tabs,
    .panel,
    .form,
    .records-card {
      max-width: 100%;
    }

    .app-header {
      max-width: none !important;
    }

    /*
      Safari gives date/time controls an intrinsic native width that can win
      over an ordinary width:100%. Force the control to use the parent's
      available inline size while preserving the date input semantics/picker.
    */
    .form input[type="date"],
    .form input[type="time"],
    .form input[type="datetime-local"],
    .filters input[type="date"],
    .records-controls input[type="date"] {
      display: block !important;
      box-sizing: border-box !important;
      width: 100% !important;
      width: -webkit-fill-available !important;
      min-width: 0 !important;
      max-width: 100% !important;
      inline-size: -webkit-fill-available !important;
      min-inline-size: 0 !important;
      max-inline-size: 100% !important;
      -webkit-appearance: none;
      appearance: none;
    }

    /* Keep every visit-field wrapper shrinkable, including the old inline grid. */
    #form-visit .grid.two > *,
    #form-visit .grid.two > [style*="grid-template-columns"] > * {
      width: 100% !important;
      min-width: 0 !important;
      max-width: 100% !important;
    }
  }
}

/* ========================================================================== 
   Desktop spacing refinement — 2026-09-07
   Adds deliberate breathing room between major workflow groups without
   changing mobile layouts or application behavior.
   ========================================================================== */
@media (min-width: 1025px) {
  /* Give the active workspace heading a clear visual break from navigation. */
  .panel.show > .section-header,
  .panel.show > .section-title {
    margin-top: 18px;
  }

  .panel.show > .section-header {
    margin-bottom: 18px;
  }

  /* Lead entry: separate major workflow groups while keeping each label
     attached to its own control. */
  #form-lead {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  #form-lead > .grid.two {
    margin-bottom: 20px;
  }

  #form-lead > #pickLocationBtn {
    margin: 0 0 28px;
  }

  #form-lead > #pickLocationBtn + div,
  #form-lead > #pickLocationBtn + div + div,
  #form-lead > #pickLocationBtn + div + div + div {
    margin-bottom: 28px;
  }

  /* Keep chip rows comfortably separated from the next field group. */
  #form-lead #productInterestsContainer,
  #form-lead #productAvailabilityContainer,
  #form-lead #marketingMaterialContainer {
    margin-bottom: 0;
  }

  #form-lead .leadpicker {
    margin-bottom: 10px;
  }

  /* Notes should read as its own final input stage. */
  #form-lead > div:has(> textarea[name="Notes"]) {
    margin-top: 2px;
    margin-bottom: 22px;
  }

  #form-lead > .actions {
    margin-top: 0;
    padding-top: 20px;
  }
}

/* Fallback for desktop browsers without :has(): the direct child immediately
   before the actions block is the Notes group in the lead form. */
@media (min-width: 1025px) {
  #form-lead > div:nth-last-child(2) {
    margin-bottom: 22px;
  }
}


/* Mobile compact brand mark: full wordmark remains on desktop. */
@media (min-width: 1025px) {
  .app-logo-picture {
    display: contents;
  }
}

/* ========================================================================== 
   Mobile brandmark hard switch — 2026-09-07
   Uses two explicit images instead of <picture> so Safari cannot fall back to
   the desktop wordmark on narrow viewports.
   ========================================================================== */
.app-brandmark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.app-logo-mobile {
  display: none !important;
}

.app-logo-desktop {
  display: block !important;
}

@media (max-width: 1024px) {
  .app-brandmark {
    width: 42px !important;
    height: 42px !important;
    flex: 0 0 42px !important;
  }

  .app-logo-desktop {
    display: none !important;
  }

  .app-logo-mobile {
    display: block !important;
    width: 40px !important;
    height: 40px !important;
    max-width: 40px !important;
    max-height: 40px !important;
    object-fit: contain !important;
  }
}

@media (min-width: 1025px) {
  .app-brandmark {
    width: auto;
    height: auto;
  }

  .app-logo-desktop {
    display: block !important;
  }

  .app-logo-mobile {
    display: none !important;
  }
}

/* === Custom prepared action icons === */
.icon-print img,
.icon-pencil img,
.icon-trash img {
  display: block;
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex: 0 0 auto;
}

#leadPrintBtn .icon-print img {
  width: 17px;
  height: 17px;
}

.table .btn-icon .icon-print img,
.table .btn-icon .icon-pencil img,
.table .btn-icon .icon-trash img {
  width: 17px;
  height: 17px;
}

@media (max-width: 1024px) {
  #leadPrintBtn .icon-print img {
    width: 19px;
    height: 19px;
  }

  .table .btn-icon .icon-print img,
  .table .btn-icon .icon-pencil img,
  .table .btn-icon .icon-trash img {
    width: 20px;
    height: 20px;
  }
}


/* ========================================================================== 
   Role administration — isolated component styles
   ========================================================================== */
.admin-only[hidden],
.admin-pending-badge[hidden] {
  display: none !important;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

#adminBtn {
  position: relative;
}

#adminBtn .icon-admin,
#adminBtn .icon-admin svg {
  display: block;
  width: 17px;
  height: 17px;
}

#adminBtn .icon-admin svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#adminBtn.active {
  border-color: rgba(37,99,235,.25);
  background: rgba(37,99,235,.08);
  color: #245cc7;
}

.admin-pending-badge {
  position: absolute;
  top: -7px;
  right: -7px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  line-height: 1;
  font-weight: 850;
  box-shadow: 0 4px 10px rgba(220,38,38,.18);
}

#panel-admin {
  overflow: hidden;
}

.admin-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 2px 2px 22px;
  border-bottom: 1px solid rgba(226,232,240,.9);
}

.admin-hero .section-title {
  margin: 3px 0 6px;
  font-size: 24px;
}

.admin-eyebrow {
  display: block;
  color: #64748b;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.admin-intro {
  max-width: 720px;
  margin: 0;
  color: #64748b;
  font-size: 13px;
}

.admin-hero-actions {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.admin-stat {
  min-width: 0;
  padding: 16px 17px;
  border: 1px solid #e5eaf1;
  border-radius: 14px;
  background: linear-gradient(180deg, #fff, #fbfcfe);
  box-shadow: 0 7px 20px rgba(15,23,42,.035);
}

.admin-stat span {
  display: block;
  margin-bottom: 4px;
  color: #7c8798;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.admin-stat strong {
  color: #101828;
  font-size: 25px;
  line-height: 1;
  letter-spacing: -.03em;
}

.admin-section {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid #e5eaf1;
  border-radius: 16px;
  background: rgba(255,255,255,.82);
}

.admin-section + .admin-section {
  margin-top: 18px;
}

.admin-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.admin-section-heading h3 {
  margin: 3px 0 0;
  color: #172033;
  font-size: 16px;
  line-height: 1.2;
}

.admin-count {
  min-width: 30px;
  height: 30px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  font-size: 12px;
  font-weight: 800;
}

.admin-directory-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  width: min(100%, 520px);
}

.admin-directory-tools input,
.admin-directory-tools select,
.admin-role-select {
  min-height: 40px;
  border: 1px solid #dfe5ed;
  border-radius: 10px;
  background: #fff;
  color: #243044;
  outline: none;
  font-size: 12px;
}

.admin-directory-tools input {
  width: 100%;
  padding: 8px 11px;
}

.admin-directory-tools select,
.admin-role-select {
  padding: 8px 30px 8px 10px;
}

.admin-user-list {
  display: grid;
  gap: 10px;
}

.admin-user-card {
  display: grid;
  grid-template-columns: minmax(220px, 1.15fr) auto minmax(360px, 1.8fr) auto;
  align-items: center;
  gap: 16px;
  padding: 14px;
  border: 1px solid #e7ebf1;
  border-radius: 13px;
  background: #fff;
}

.admin-user-card-pending {
  grid-template-columns: minmax(260px, 1.2fr) minmax(180px, .8fr) auto;
  border-color: #dbe6f8;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.admin-user-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.admin-avatar {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 11px;
  background: #eef4ff;
  color: #245cc7;
  font-size: 14px;
  font-weight: 850;
}

.admin-user-identity {
  min-width: 0;
}

.admin-user-identity strong,
.admin-user-identity > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-identity strong {
  color: #172033;
  font-size: 13px;
}

.admin-user-identity > span {
  margin-top: 2px;
  color: #8290a3;
  font-size: 11px;
}

.admin-user-titleline {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
}

.admin-user-titleline strong {
  min-width: 0;
}

.admin-you-badge {
  padding: 2px 6px;
  border-radius: 999px;
  background: #edf4ff;
  color: #2f65cb;
  font-size: 9px;
  font-weight: 850;
  text-transform: uppercase;
}

.admin-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-badge {
  padding: 4px 7px;
  border-radius: 999px;
  font-size: 9px;
  line-height: 1.2;
  font-weight: 850;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.admin-badge.role-admin { background: #eef2ff; color: #4338ca; }
.admin-badge.role-viewer { background: #f1f5f9; color: #475569; }
.admin-badge.status-approved { background: #ecfdf5; color: #047857; }
.admin-badge.status-pending { background: #fff7ed; color: #c2410c; }
.admin-badge.status-disabled { background: #fef2f2; color: #b91c1c; }
.admin-badge.status-locked { background: #fff1f2; color: #be123c; }

.admin-user-meta {
  color: #738096;
  font-size: 11px;
}

.admin-user-facts {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.admin-fact {
  min-width: 0;
}

.admin-fact span,
.admin-fact strong {
  display: block;
}

.admin-fact span {
  margin-bottom: 2px;
  color: #98a2b3;
  font-size: 9px;
  font-weight: 750;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.admin-fact strong {
  overflow: hidden;
  color: #4d5b70;
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-user-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 7px;
  flex-wrap: wrap;
}

.admin-user-controls .btn,
.admin-user-controls .admin-role-select {
  min-height: 36px;
  font-size: 11px;
}

.admin-danger-btn {
  border-color: #f2d7db;
  color: #b42334;
}

.admin-empty {
  min-height: 92px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 20px;
  border: 1px dashed #dfe5ed;
  border-radius: 12px;
  color: #8390a2;
  text-align: center;
}

.admin-empty strong {
  color: #4a586d;
  font-size: 13px;
}

.admin-empty span {
  font-size: 11px;
}

.admin-security-note {
  margin: 16px 2px 0;
}

@media (max-width: 1220px) and (min-width: 1025px) {
  .admin-user-card {
    grid-template-columns: minmax(220px, 1fr) auto minmax(300px, 1.5fr);
  }
  .admin-user-card > .admin-user-controls {
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-left: 49px;
  }
}

@media (max-width: 1024px) {
  .header-actions {
    gap: 7px;
  }

  #adminBtn {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border-radius: 14px;
    background: rgba(255,255,255,.84);
    border: 1px solid var(--mobile-line);
    color: #64748b;
    box-shadow: 0 4px 14px rgba(15,23,42,.05);
  }

  #adminBtn .admin-text {
    display: none !important;
  }

  #adminBtn .icon-admin svg {
    width: 19px;
    height: 19px;
  }

  .admin-pending-badge {
    top: -5px;
    right: -5px;
  }

  #panel-admin {
    padding: 18px 14px 116px;
  }

  .admin-hero {
    display: block;
    padding-bottom: 18px;
  }

  .admin-hero .section-title {
    font-size: 21px !important;
  }

  .admin-intro {
    font-size: 12px;
  }

  .admin-hero-actions {
    margin-top: 14px;
  }

  .admin-hero-actions .btn {
    flex: 1 1 0;
    min-height: 42px;
  }

  .admin-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
    margin: 16px 0;
  }

  .admin-stat {
    padding: 13px 14px;
  }

  .admin-stat strong {
    font-size: 22px;
  }

  .admin-section {
    margin-top: 14px;
    padding: 15px 13px;
    border-radius: 16px;
  }

  .admin-section-heading,
  .admin-directory-heading {
    align-items: flex-start;
  }

  .admin-directory-heading {
    display: block;
  }

  .admin-directory-tools {
    width: 100%;
    margin-top: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .admin-directory-tools input,
  .admin-directory-tools select,
  .admin-role-select {
    min-height: 44px;
    font-size: 16px !important; /* Prevent iOS focus zoom. */
  }

  .admin-user-card,
  .admin-user-card-pending {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px;
  }

  .admin-user-meta {
    padding-left: 49px;
  }

  .admin-badges {
    padding-left: 49px;
  }

  .admin-user-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 11px;
    border-radius: 11px;
    background: #f8fafc;
  }

  .admin-user-controls,
  .admin-user-controls-directory {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .admin-user-controls .btn,
  .admin-user-controls .admin-role-select {
    width: 100%;
    min-height: 42px;
  }

  .admin-security-note {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

@media (max-width: 390px) {
  .admin-user-controls,
  .admin-user-controls-directory,
  .admin-directory-tools {
    grid-template-columns: 1fr;
  }
}

@media print {
  #adminBtn,
  #panel-admin {
    display: none !important;
  }
}

@media (min-width: 1025px) {
  #adminBtn {
    min-height: 40px;
    padding: 9px 12px;
    gap: 7px;
    border-color: #dee5ee;
    border-radius: 11px;
    background: rgba(255,255,255,.8);
    color: #5b687c;
    box-shadow: 0 3px 10px rgba(15,23,42,.035);
    font-size: 12px;
  }

  #adminBtn:hover:not(:disabled),
  #adminBtn.active {
    transform: translateY(-1px);
    border-color: #cfdcf2;
    background: #f4f8ff;
    color: #245cc7;
    box-shadow: 0 7px 18px rgba(37,92,199,.07);
  }
}

/* ========================================================================== 
   Secure startup / authentication gate
   Keeps protected CRM chrome out of the first paint until authWhoAmI resolves.
   ========================================================================== */
.auth-gate {
  --gate-card: rgba(13, 26, 46, .82);
  --gate-line: rgba(255,255,255,.10);
  --gate-muted: rgba(224,232,244,.67);
  --gate-orange: #ff9427;
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -10%, rgba(40, 101, 190, .22), transparent 42%),
    linear-gradient(145deg, #07101d 0%, #0b1627 48%, #08111f 100%);
  color: #fff;
  opacity: 1;
  visibility: visible;
  transition: opacity .24s ease, visibility .24s ease;
  isolation: isolate;
}

.auth-gate.is-leaving {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.auth-gate-card {
  position: relative;
  z-index: 2;
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--gate-line);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(15,29,50,.88), rgba(10,22,39,.76));
  box-shadow: 0 30px 90px rgba(0,0,0,.34), inset 0 1px 0 rgba(255,255,255,.04);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
}

.auth-gate-orb {
  position: absolute;
  z-index: 1;
  border-radius: 999px;
  filter: blur(1px);
  opacity: .65;
  pointer-events: none;
}

.auth-gate-orb-one {
  width: 340px;
  height: 340px;
  top: -140px;
  right: -100px;
  background: radial-gradient(circle, rgba(37,99,235,.22), transparent 67%);
  animation: authGateFloatOne 7s ease-in-out infinite alternate;
}

.auth-gate-orb-two {
  width: 290px;
  height: 290px;
  bottom: -120px;
  left: -90px;
  background: radial-gradient(circle, rgba(255,148,39,.16), transparent 67%);
  animation: authGateFloatTwo 8s ease-in-out infinite alternate;
}

.auth-gate-brand {
  display: flex;
  align-items: center;
  gap: 13px;
}

.auth-gate-logo-wrap {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 15px;
  background: rgba(255,255,255,.055);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.auth-gate-logo {
  display: block;
  width: 31px;
  height: 31px;
  object-fit: contain;
}

.auth-gate-brand-copy {
  display: flex;
  align-items: baseline;
  gap: 8px;
  letter-spacing: .04em;
}

.auth-gate-brand-copy span {
  color: rgba(255,255,255,.78);
  font-size: 13px;
  font-weight: 800;
}

.auth-gate-brand-copy strong {
  color: #fff;
  font-size: 17px;
  font-weight: 850;
  letter-spacing: -.01em;
}

.auth-gate-copy {
  margin-top: 40px;
}

.auth-gate-kicker {
  display: block;
  margin-bottom: 10px;
  color: rgba(255,255,255,.46);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.auth-gate-copy h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(25px, 5vw, 31px);
  line-height: 1.12;
  font-weight: 760;
  letter-spacing: -.035em;
}

.auth-gate-copy p {
  margin: 10px 0 0;
  color: var(--gate-muted);
  font-size: 13px;
  line-height: 1.55;
}

.auth-gate-progress {
  position: relative;
  height: 3px;
  margin-top: 34px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
}

.auth-gate-progress span {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,148,39,.25), #ff9427, rgba(255,184,79,.8));
  box-shadow: 0 0 16px rgba(255,148,39,.35);
  animation: authGateProgress 1.15s cubic-bezier(.4,0,.2,1) infinite;
}

.auth-gate-security {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 15px;
  color: rgba(224,232,244,.52);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .035em;
}

.auth-gate-security-dot {
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 999px;
  background: #38c98f;
  box-shadow: 0 0 0 4px rgba(56,201,143,.08), 0 0 10px rgba(56,201,143,.25);
}

@keyframes authGateProgress {
  0%   { transform: translateX(-125%); }
  55%  { transform: translateX(110%); }
  100% { transform: translateX(250%); }
}

@keyframes authGateFloatOne {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(-26px,18px,0) scale(1.08); }
}

@keyframes authGateFloatTwo {
  from { transform: translate3d(0,0,0) scale(1); }
  to   { transform: translate3d(30px,-18px,0) scale(1.08); }
}

@media (max-width: 1024px) {
  .auth-gate {
    padding-left: max(18px, env(safe-area-inset-left, 0px));
    padding-right: max(18px, env(safe-area-inset-right, 0px));
  }

  .auth-gate-card {
    width: min(100%, 390px);
    padding: 25px 22px 23px;
    border-radius: 22px;
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
  }

  .auth-gate-copy {
    margin-top: 34px;
  }

  .auth-gate-copy h1 {
    font-size: 27px;
  }

  .auth-gate-copy p {
    font-size: 12px;
  }
}

@media (max-width: 374px) {
  .auth-gate-card {
    padding: 22px 19px 21px;
  }

  .auth-gate-logo-wrap {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .auth-gate-logo {
    width: 28px;
    height: 28px;
  }

  .auth-gate-copy h1 {
    font-size: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-gate,
  .auth-gate-orb,
  .auth-gate-progress span {
    animation: none !important;
    transition-duration: .01ms !important;
  }

  .auth-gate-progress span {
    width: 72%;
  }
}

@media print {
  #authGate {
    display: none !important;
  }
}


/* ========================================================================== 
   Login spacing refinement
   Dedicated login rhythm so the authentication form does not inherit the
   tighter CRM form spacing used by the desktop workspace.
   ========================================================================== */
#loginPanel.login-panel {
  min-height: 100vh !important;
  min-height: 100dvh !important;
  align-items: center;
  justify-content: center;
}

#loginPanel .login-card {
  width: 100%;
  max-width: 440px !important;
}

#loginPanel .login-logo {
  display: block;
  height: auto;
  margin-left: auto !important;
  margin-right: auto !important;
}

#loginPanel .login-intro {
  margin: 0 0 28px;
}

#loginPanel .login-title {
  margin: 0 0 10px !important;
}

#loginPanel .login-copy {
  margin: 0 !important;
  line-height: 1.55;
}

#loginPanel .login-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

#loginPanel .login-field {
  min-width: 0;
}

#loginPanel .login-field label {
  margin: 0 0 8px !important;
}

#loginPanel .login-field input {
  display: block;
}

#loginPanel .login-actions {
  position: static !important;
  bottom: auto !important;
  margin: 2px 0 0 !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

#loginPanel #authMsg:empty {
  display: none;
}

@media (min-width: 1025px) {
  #loginPanel.login-panel {
    padding: 48px !important;
  }

  #loginPanel .login-card {
    padding: 38px 36px 36px !important;
  }

  #loginPanel .login-logo {
    width: 164px !important;
    margin-bottom: 34px !important;
  }

  #loginPanel .login-intro {
    margin-bottom: 30px;
  }

  #loginPanel .login-form {
    gap: 23px;
  }

  #loginPanel .login-field input {
    min-height: 48px;
  }

  #loginPanel .login-actions {
    display: flex;
    align-items: center;
    gap: 10px !important;
  }

  #loginPanel .login-actions .btn {
    min-height: 44px;
    padding-left: 18px;
    padding-right: 18px;
  }
}

@media (max-width: 1024px) {
  #loginPanel.login-panel {
    padding: calc(24px + env(safe-area-inset-top, 0px)) 18px
             calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  }

  #loginPanel .login-card {
    padding: 30px 24px 26px !important;
  }

  #loginPanel .login-logo {
    width: 150px !important;
    margin-bottom: 30px !important;
  }

  #loginPanel .login-intro {
    margin-bottom: 26px;
  }

  #loginPanel .login-form {
    gap: 21px;
  }

  #loginPanel .login-field label {
    margin-bottom: 9px !important;
  }

  #loginPanel .login-field input {
    min-height: 52px;
  }

  #loginPanel .login-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 10px !important;
  }

  #loginPanel .login-actions .btn {
    width: 100%;
    min-height: 48px;
  }

  #loginPanel #authMsg {
    grid-column: 1 / -1;
    margin-top: 2px;
  }
}

@media (max-width: 374px) {
  #loginPanel .login-card {
    padding: 26px 20px 22px !important;
  }

  #loginPanel .login-logo {
    width: 138px !important;
    margin-bottom: 26px !important;
  }

  #loginPanel .login-intro {
    margin-bottom: 24px;
  }
}


/* ========================================================================== 
   Admin simplification + password reset — 2026-09-07
   ========================================================================== */
/* The CRM navigation belongs to the CRM workspace. Admin has its own Back to CRM action. */
.app.admin-mode > .tabs {
  display: none !important;
}

.admin-password-reset-content {
  width: min(470px, calc(100vw - 32px));
  max-width: 470px;
  padding: 24px;
}

.admin-password-reset-heading h3 {
  margin: 4px 0 0;
  color: #172033;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: -.025em;
}

.admin-password-reset-target {
  margin: 12px 0 18px !important;
  color: #667085 !important;
  font-size: 13px !important;
}

.admin-password-reset-fields {
  display: grid;
  gap: 14px;
}

.admin-password-reset-fields > div {
  display: grid;
  gap: 6px;
}

.admin-password-reset-fields label {
  color: #344054;
  font-size: 12px;
  font-weight: 750;
}

.admin-password-reset-fields input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #dbe3ed;
  border-radius: 11px;
  background: #fff;
  color: #172033;
  outline: none;
  font: inherit;
  font-size: 14px;
}

.admin-password-reset-fields input:focus {
  border-color: #8fb3f6;
  box-shadow: 0 0 0 3px rgba(37,99,235,.10);
}

.admin-password-reset-note {
  margin: 14px 0 0 !important;
  color: #7a8699 !important;
  font-size: 11px !important;
}

.admin-password-reset-error {
  min-height: 17px;
  margin: 6px 0 0 !important;
  color: #b42334 !important;
  font-size: 11px !important;
}

.admin-password-reset-actions {
  margin-top: 14px;
}

@media (min-width: 1280px) {
  .app.admin-mode {
    grid-template-columns: minmax(0, 1fr);
  }

  .app.admin-mode > #panel-admin {
    grid-column: 1 / -1;
    grid-row: 2;
  }
}

@media (max-width: 1024px) {
  .app.admin-mode #panel-admin {
    padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px));
  }

  .admin-password-reset-content {
    padding: 20px;
  }

  .admin-password-reset-fields input {
    min-height: 48px;
    font-size: 16px !important; /* Prevent iOS focus zoom. */
  }

  .admin-password-reset-actions {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 390px) {
  .admin-password-reset-actions {
    grid-template-columns: 1fr;
  }
}

/* Protected bootstrap administrator marker */
.admin-protected-badge {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}


/* ========================================================================== 
   Prepared Admin / Logout header icons
   ========================================================================== */
.header-actions > #adminBtn,
.header-actions > #logoutBtn {
  align-items: center;
  justify-content: center;
}

.header-actions .icon-admin,
.header-actions .icon-logout {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  flex: 0 0 18px;
  width: 18px !important;
  height: 18px !important;
  margin: 0 !important;
  line-height: 0;
}

.header-actions .icon-admin img,
.header-actions .icon-logout img {
  display: block;
  width: 18px;
  height: 18px;
  max-width: 18px;
  max-height: 18px;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

#adminBtn .admin-text,
#logoutBtn .logout-text {
  line-height: 1;
}

@media (min-width: 1025px) {
  .header-actions > #adminBtn,
  .header-actions > #logoutBtn {
    min-height: 40px;
  }
}

@media (max-width: 1024px) {
  .header-actions .icon-admin,
  .header-actions .icon-logout {
    flex-basis: 20px;
    width: 20px !important;
    height: 20px !important;
  }

  .header-actions .icon-admin img,
  .header-actions .icon-logout img {
    width: 20px;
    height: 20px;
    max-width: 20px;
    max-height: 20px;
  }
}


/* ========================================================================== 
   Header action state icons + final alignment refinement
   ========================================================================== */
/* Idle label colors only; borders/backgrounds keep the existing button design. */
#adminBtn .admin-text {
  color: #b4caf8 !important;
}

#logoutBtn .logout-text {
  color: #fee2e2 !important;
  transform: translateY(-1px);
}

/* Two prepared images share one exact footprint, preventing any layout shift. */
.header-actions .header-state-icon {
  position: relative;
  overflow: visible;
}

.header-actions .header-state-icon .header-action-icon-img {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity .14s ease;
}

.header-actions .header-state-icon .icon-state-idle {
  opacity: 1;
}

.header-actions .header-state-icon .icon-state-hover {
  opacity: 0;
}

#adminBtn:hover:not(:disabled) .icon-state-idle,
#adminBtn:active:not(:disabled) .icon-state-idle,
#adminBtn:focus-visible .icon-state-idle,
#logoutBtn:hover:not(:disabled) .icon-state-idle,
#logoutBtn:active:not(:disabled) .icon-state-idle,
#logoutBtn:focus-visible .icon-state-idle {
  opacity: 0;
}

#adminBtn:hover:not(:disabled) .icon-state-hover,
#adminBtn:active:not(:disabled) .icon-state-hover,
#adminBtn:focus-visible .icon-state-hover,
#logoutBtn:hover:not(:disabled) .icon-state-hover,
#logoutBtn:active:not(:disabled) .icon-state-hover,
#logoutBtn:focus-visible .icon-state-hover {
  opacity: 1;
}

/* Text follows the exact prepared icon palette: light at rest, saturated on interaction. */
#adminBtn:hover:not(:disabled) .admin-text,
#adminBtn:active:not(:disabled) .admin-text,
#adminBtn:focus-visible .admin-text {
  color: #245cc7 !important;
}

#logoutBtn:hover:not(:disabled) .logout-text,
#logoutBtn:active:not(:disabled) .logout-text,
#logoutBtn:focus-visible .logout-text {
  color: #ef4444 !important;
}

/* Admin user deletion mirrors the icon-only record delete treatment. */
.admin-user-controls .admin-delete-user-btn {
  width: 36px;
  min-width: 36px;
  max-width: 36px;
  height: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #f2d7db;
  background: #fff;
  color: #b42334;
  flex: 0 0 36px;
}

.admin-user-controls .admin-delete-user-btn .icon-trash {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}

.admin-user-controls .admin-delete-user-btn .icon-trash img {
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 17px !important;
  height: 17px !important;
  max-width: 17px !important;
  max-height: 17px !important;
  object-fit: contain;
}

.admin-user-controls .admin-delete-user-btn {
  font-size: 0 !important;
  overflow: visible;
}

.admin-user-controls .admin-delete-user-btn .icon-trash {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.admin-user-controls .admin-delete-user-btn:hover:not(:disabled) {
  transform: none;
  border-color: #f0c9cf;
  background: #fff3f4;
  color: #c63746;
  box-shadow: none;
}

@media (max-width: 1024px) {
  .admin-user-controls .admin-delete-user-btn {
    width: 42px;
    min-width: 42px;
    max-width: 42px;
    height: 42px;
    min-height: 42px;
    border-radius: 12px;
    flex-basis: 42px;
  }

  .admin-user-controls .admin-delete-user-btn .icon-trash,
  .admin-user-controls .admin-delete-user-btn .icon-trash img {
    width: 20px !important;
    height: 20px !important;
    max-width: 20px !important;
    max-height: 20px !important;
    flex-basis: 20px;
  }
}

/* ========================================================================== 
   Final auth reset flow + premium header ghost buttons — 2026-09-09
   ========================================================================== */

/* Admin and Sign out: confident idle states, stronger interaction states. */
.header-actions > #adminBtn,
.header-actions > #logoutBtn {
  transition: background-color .16s ease, color .16s ease, box-shadow .16s ease, transform .16s ease;
}

#adminBtn {
  background: rgba(37, 99, 235, .045) !important;
  border-color: #dfe6ef !important;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .035) !important;
}

#adminBtn .admin-text {
  color: #4a6fa8 !important;
  font-weight: 700;
}

#logoutBtn {
  background: rgba(220, 38, 38, .035) !important;
  border-color: #e4e8ee !important;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .03) !important;
}

#logoutBtn .logout-text {
  color: #E07A7A !important;
  font-weight: 700;
  transform: translateY(-1px);
}

#adminBtn:hover:not(:disabled),
#adminBtn:focus-visible,
#adminBtn.active {
  background: #f2f7ff !important;
  border-color: #d8e2f2 !important;
  box-shadow: 0 7px 18px rgba(37, 92, 199, .075) !important;
}

#adminBtn:hover:not(:disabled) .admin-text,
#adminBtn:focus-visible .admin-text,
#adminBtn.active .admin-text {
  color: #245cc7 !important;
}

#logoutBtn:hover:not(:disabled),
#logoutBtn:focus-visible {
  background: #fff5f5 !important;
  border-color: #eadfe1 !important;
  box-shadow: 0 7px 18px rgba(185, 28, 28, .06) !important;
}

#logoutBtn:hover:not(:disabled) .logout-text,
#logoutBtn:focus-visible .logout-text {
  color: #d92d20 !important;
}

/* Keep prepared hover artwork in sync with active Admin state. */
#adminBtn.active .icon-state-idle { opacity: 0; }
#adminBtn.active .icon-state-hover { opacity: 1; }

/* Password reset self-service inside the normal login card. */
#authNormalLogin[hidden],
#authPasswordResetPanel[hidden] {
  display: none !important;
}

.login-reset-form {
  gap: 18px;
}

.login-reset-account {
  display: grid;
  gap: 3px;
  padding: 12px 14px;
  border: 1px solid #e1e7ef;
  border-radius: 12px;
  background: #f8fafc;
}

.login-reset-account-label {
  color: #7a8699;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.login-reset-account strong {
  color: #1f2937;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.login-reset-actions {
  margin-top: 4px;
}

/* Admin no longer creates passwords; it issues one-time codes. */
.admin-reset-code-card[hidden] {
  display: none !important;
}

.admin-reset-code-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 14px;
  margin: 4px 0 16px;
  padding: 16px;
  border: 1px solid #d9e4f4;
  border-radius: 14px;
  background: linear-gradient(180deg, #f8fbff 0%, #f4f8ff 100%);
}

.admin-reset-code-label {
  grid-column: 1 / -1;
  color: #60708a;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.admin-reset-code-value {
  color: #172033;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 28px;
  line-height: 1;
  letter-spacing: .18em;
  font-variant-numeric: tabular-nums;
}

.admin-reset-copy-btn {
  white-space: nowrap;
}

@media (max-width: 1024px) {
  .admin-reset-code-card {
    grid-template-columns: 1fr;
  }

  .admin-reset-code-value {
    font-size: 26px;
  }

  .admin-reset-copy-btn {
    width: 100%;
  }
}


/* ========================================================================== 
   Mobile bottom-navigation clearance + navigation rhythm — 2026-09-09
   Keep sticky form actions physically above the fixed page navigation on
   every mobile browser, including iPhones with a Home Indicator safe area.
   ========================================================================== */
@media (max-width: 1024px) {
  :root {
    --crm-mobile-nav-height: 70px;
    --crm-mobile-nav-edge: max(9px, env(safe-area-inset-bottom, 0px));
    --crm-mobile-nav-action-gap: 16px;
    --crm-mobile-nav-clearance: calc(
      var(--crm-mobile-nav-height) +
      var(--crm-mobile-nav-edge) +
      var(--crm-mobile-nav-action-gap)
    );
  }

  /* Leave enough document space for the fixed navigation at the true bottom. */
  body {
    padding-bottom: calc(106px + env(safe-area-inset-bottom, 0px));
  }

  /*
    Save / Log / Discard remains sticky, but its bottom edge now clears the
    complete nav bar + iOS safe area + a deliberate visual gap.
  */
  html:not(.form-control-focused):not(.keyboard-open) .form > .actions {
    bottom: var(--crm-mobile-nav-clearance) !important;
  }

  /* A little local separation even when the action bar returns to document flow. */
  .form > .actions {
    margin-top: 10px;
    margin-bottom: 10px;
  }
}

@media (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  :root {
    --crm-mobile-nav-height: 54px;
    --crm-mobile-nav-edge: max(5px, env(safe-area-inset-bottom, 0px));
    --crm-mobile-nav-action-gap: 10px;
  }
}

/* Preserve the existing iOS keyboard behavior: actions return to normal flow
   while Safari's keyboard is open instead of competing with visualViewport. */
@media (max-width: 1024px) {
  html.ios-webkit.form-control-focused .form > .actions,
  html.ios-webkit.keyboard-open .form > .actions {
    position: static !important;
    bottom: auto !important;
  }
}

/* ===== 2026-09-19 registration + lead lifecycle refinement ===== */
#authRegisterPanel[hidden],
#authPasswordResetPanel[hidden] {
  display: none !important;
}

#loginPanel .login-register-form {
  width: 100%;
}

#loginPanel .login-register-actions {
  margin-top: 4px;
}

#loginPanel .login-register-actions .hint {
  flex-basis: 100%;
}

#leadTable td[data-label="LeadStatus"] {
  font-weight: 650;
}

#leadTable td[data-label="LeadStatus"].lead-status-not-interested {
  color: #9b4b4b;
}

@media (max-width: 1024px) {
  #loginPanel .login-register-form {
    gap: 18px;
  }
}

@media (max-width: 1024px) {
  #loginPanel .login-register-actions #authRegisterMsg {
    grid-column: 1 / -1;
    margin-top: 2px;
  }
}

/* ===== 2026-09-19 client lifecycle + private lead documents ===== */
#leadTable td[data-label="LeadStatus"].lead-status-client {
  color: #245fa8;
}

.lead-documents {
  margin-top: 28px;
  padding: 20px;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(248, 250, 252, .92), rgba(255, 255, 255, .98));
  box-shadow: 0 10px 26px rgba(15, 23, 42, .045);
}

.lead-documents-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.lead-documents-eyebrow {
  display: block;
  margin-bottom: 4px;
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.lead-documents-heading h3 {
  margin: 0;
  color: #172033;
  font-size: 18px;
  line-height: 1.25;
}

.lead-documents-heading p {
  margin: 5px 0 0;
  color: #718096;
  font-size: 13px;
}

.lead-documents-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eef4ff;
  color: #315f9e;
  font-size: 13px;
  font-weight: 800;
}

.lead-documents-new,
.lead-document-empty {
  padding: 15px 16px;
  border: 1px dashed rgba(148, 163, 184, .45);
  border-radius: 13px;
  background: rgba(248, 250, 252, .75);
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}

.lead-document-upload-row {
  display: grid;
  grid-template-columns: minmax(150px, .7fr) minmax(240px, 1.6fr) auto;
  align-items: end;
  gap: 12px;
}

.lead-document-upload-row > div,
.lead-document-file-field {
  min-width: 0;
}

.lead-document-upload-row label {
  display: block;
  margin-bottom: 6px;
}

.lead-document-upload-row input[type="file"] {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 9px 10px;
  background: #fff;
}

.lead-document-upload-btn {
  min-height: 44px;
  white-space: nowrap;
}

.lead-document-status {
  min-height: 18px;
  margin: 10px 0 4px;
}

.lead-document-list {
  display: grid;
  gap: 9px;
  margin-top: 12px;
}

.lead-document-item {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, .23);
  border-radius: 14px;
  background: #fff;
}

.lead-document-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  background: #f1f5f9;
  color: #475569;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .04em;
}

.lead-document-body {
  min-width: 0;
}

.lead-document-body strong {
  display: block;
  overflow: hidden;
  color: #1f2937;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-document-meta {
  overflow: hidden;
  margin-top: 4px;
  color: #7c8798;
  font-size: 11px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-document-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.lead-document-action {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 12px;
  text-decoration: none;
}

.lead-document-delete {
  width: 36px;
  height: 36px;
  min-width: 36px;
  padding: 7px;
}

.lead-document-delete img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 1024px) {
  .lead-documents {
    margin-top: 24px;
    padding: 16px;
    border-radius: 16px;
  }

  .lead-document-upload-row {
    grid-template-columns: 1fr;
  }

  .lead-document-upload-btn {
    width: 100%;
  }

  .lead-document-item {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .lead-document-icon {
    width: 40px;
    height: 40px;
  }

  .lead-document-actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr 42px;
    margin-top: 2px;
  }

  .lead-document-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
  }

  .lead-document-delete {
    width: 42px;
    height: 42px;
    min-width: 42px;
  }
}

/* === Admin push notification controls === */
.admin-push-btn {
  white-space: nowrap;
}

.admin-push-btn.is-on {
  color: #1d4ed8;
  border-color: rgba(37,99,235,.22);
  background: rgba(239,246,255,.9);
  box-shadow: 0 5px 16px rgba(37,99,235,.07);
}

.admin-push-btn.is-off {
  color: #475569;
}

.admin-push-btn.is-unavailable {
  color: #94a3b8;
  background: #f8fafc;
  cursor: default;
}

@media (max-width: 1024px) {
  .admin-hero-actions {
    flex-wrap: wrap;
  }

  .admin-hero-actions .admin-push-btn {
    flex: 1 0 100%;
  }
}

/* ========================================================================== 
   Supervisor routing + viewer notification controls — 2026-09-19
   ========================================================================== */
.user-push-header-btn[hidden] { display: none !important; }

#userPushBtn {
  min-height: 40px;
  padding: 9px 11px;
  gap: 7px;
  border-radius: 11px;
  border-color: #dfe6ef;
  background: rgba(37, 99, 235, .035);
  color: #59739d;
  box-shadow: 0 3px 10px rgba(15, 23, 42, .03);
}

#userPushBtn .user-push-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

#userPushBtn .user-push-icon svg {
  display: block;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#userPushBtn .user-push-text {
  font-weight: 700;
  line-height: 1;
}

#userPushBtn.is-on {
  background: #f2f7ff;
  color: #245cc7;
  border-color: #d8e2f2;
}

#userPushBtn:hover:not(:disabled),
#userPushBtn:focus-visible {
  background: #eef5ff;
  color: #245cc7;
  border-color: #d8e2f2;
  box-shadow: 0 7px 18px rgba(37, 92, 199, .07);
}

#userPushBtn.is-unavailable {
  opacity: .58;
}

.admin-supervisor-select {
  min-width: 170px;
}

.admin-badge.supervisor-assigned {
  background: #eef6ff;
  border: 1px solid #d7e8fb;
  color: #315f9b;
}

@media (max-width: 1024px) {
  #userPushBtn {
    width: 42px !important;
    min-width: 42px !important;
    max-width: 42px !important;
    height: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border-radius: 14px;
    flex: 0 0 42px;
  }

  #userPushBtn .user-push-text { display: none !important; }
  #userPushBtn .user-push-icon,
  #userPushBtn .user-push-icon svg {
    width: 20px;
    height: 20px;
  }

  .admin-supervisor-select {
    min-width: 0;
    width: 100%;
  }
}

@media print {
  #userPushBtn { display: none !important; }
}

.admin-badge.push-ready {
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #047857;
}
.admin-badge.push-off {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #c2410c;
}


/* Header brand/title acts as Home → Leads. */
.header-home-link {
  cursor: pointer;
  border-radius: 12px;
}

.header-home-link:focus-visible {
  outline: 2px solid rgba(43, 108, 176, 0.65);
  outline-offset: 5px;
}


/* === Protected bootstrap backup & recovery === */
.admin-backups-section[hidden] { display: none !important; }
.admin-backups-section {
  border: 1px solid rgba(37, 99, 235, .16);
  background: linear-gradient(180deg, rgba(239,246,255,.72), rgba(255,255,255,.96));
}
.admin-backups-heading { align-items: flex-start; }
.admin-backups-intro {
  margin: 7px 0 0;
  color: #64748b;
  font-size: 13px;
  line-height: 1.5;
}
.admin-backups-list { display: grid; gap: 10px; margin-top: 16px; }
.admin-backup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 15px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 5px 18px rgba(15,23,42,.035);
}
.admin-backup-main { min-width: 0; display: grid; gap: 5px; }
.admin-backup-main > strong { color: #0f172a; font-size: 14px; }
.admin-backup-details { display: flex; flex-wrap: wrap; gap: 8px 16px; color: #64748b; font-size: 12px; }
.admin-backup-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; flex: 0 0 auto; }
a.admin-backup-download { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.admin-backups-note { margin-top: 13px; }
@media (max-width: 1024px) {
  .admin-backups-heading { gap: 14px; }
  .admin-backups-heading #adminBackupNowBtn { width: 100%; }
  .admin-backup-row { align-items: stretch; flex-direction: column; gap: 12px; }
  .admin-backup-actions { justify-content: stretch; }
  .admin-backup-actions .btn { flex: 1 1 150px; }
}
