/* ==========================================================================
   Theme: warm teal + amber, built for a real-estate CRM. Colorful but not
   noisy - one confident brand hue (teal) carries structure/navigation,
   amber carries emphasis/accents, and status badges use a distinct,
   easily-scannable color per state.
   ========================================================================== */
:root {
  --brand: #0d9488;          /* teal-600 */
  --brand-dark: #0f766e;     /* teal-700 */
  --brand-darker: #134e4a;   /* teal-900 */
  --brand-light: #14b8a6;    /* teal-500 */
  --brand-pale: #ccfbf1;     /* teal-100 */

  --accent: #f59e0b;         /* amber-500 */
  --accent-dark: #b45309;    /* amber-700 */
  --accent-pale: #fef3c7;    /* amber-100 */

  --bg: #f4faf9;
  --card-bg: #ffffff;
  --border: #d9ede9;
  --text: #16302c;
  --text-muted: #5f7a75;

  --danger: #e11d48;
  --danger-pale: #ffe4e9;
  --success: #059669;
  --success-pale: #d1fae5;
  --info: #2563eb;
  --info-pale: #dbeafe;
  --warning: #d97706;
  --warning-pale: #fef3c7;

  --shadow-sm: 0 1px 3px rgba(15, 60, 55, 0.08);
  --shadow-md: 0 6px 18px rgba(15, 60, 55, 0.10);
}

* { box-sizing: border-box; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
}



/* ---- Company branding ----
   The default company logo is intentionally transparent in both locations.
   The sidebar uses a larger 60x60 logo beside CRM; the topbar uses a compact
   logo beside the company name. Do not add a background or white padding so
   transparent PNG/SVG logos remain transparent. */
.sidebar-brand {
  min-height: 78px;
  padding: 6px 18px 16px !important;
  margin: 0 !important;
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar-brand-logo {
  width: 60px;
  height: 60px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  flex: 0 0 60px;
}
.sidebar-brand-placeholder {
  width: 60px;
  height: 60px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex: 0 0 60px;
}
.sidebar-brand-no-logo,
.topbar-company-no-logo {
  color: currentColor;
  opacity: .75;
}
.topbar-company {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--brand-dark);
  font-weight: 600;
  font-size: 0.84rem;
  white-space: nowrap;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  max-width: 42%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-company-logo {
  width: 28px;
  height: 28px;
  display: block;
  object-fit: contain;
  object-position: center;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  flex: 0 0 28px;
}
@media (max-width: 700px) {
  .sidebar-brand-logo,
  .sidebar-brand-placeholder {
    width: 48px;
    height: 48px;
    flex-basis: 48px;
  }
  .sidebar-brand {
    min-height: 64px;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }
  .topbar-company {
    max-width: 34%;
    font-size: 0.78rem;
  }
  .topbar-company-logo {
    width: 24px;
    height: 24px;
    flex-basis: 24px;
  }
}

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

.sidebar {
  width: 226px;
  background: linear-gradient(180deg, var(--brand-darker) 0%, var(--brand-dark) 55%, var(--brand) 100%);
  color: #fff;
  flex-shrink: 0;
  padding: 22px 0;
  box-shadow: 2px 0 12px rgba(0,0,0,0.08);
}
.sidebar h1 {
  font-size: 1.2rem;
  padding: 0 22px 22px;
  margin: 0;
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar a {
  display: block;
  color: #d6f3ee;
  padding: 10px 22px;
  text-decoration: none;
  font-size: 0.92rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.sidebar a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar a.active {
  background: rgba(255,255,255,0.14);
  color: #fff;
  border-left-color: var(--accent);
  font-weight: 600;
}

.sidebar-group { margin: 0; position: relative; }

/* Parent text and arrow are separate controls. */
.sidebar-parent-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.sidebar-parent-link {
  position: relative;
  display: flex !important;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
  text-decoration: none !important;
}

.sidebar-parent-arrow {
  flex: 0 0 34px;
  width: 34px;
  min-width: 34px;
  border: 0;
  background: transparent;
  color: #d6f3ee;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  line-height: 1;
  opacity: .9;
}

.sidebar-parent-arrow:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
  opacity: 1;
}

.sidebar-parent-arrow span {
  display: inline-block;
  transition: transform .18s ease;
}

.sidebar-group.open .sidebar-parent-arrow span {
  transform: rotate(90deg);
}

/* Submenus open directly below their parent menu item. They are controlled by the arrow button only. */
.sidebar-submenu {
  position: static;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 4px 0 6px 0;
  display: none !important;
  background: transparent;
  color: #d6f3ee;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.sidebar-group.open .sidebar-submenu {
  display: block !important;
}

.sidebar-subitem {
  display: block !important;
  padding: 8px 14px !important;
  font-size: .82rem !important;
  color: #d6f3ee !important;
  border-left: 3px solid transparent !important;
  background: transparent !important;
  white-space: nowrap;
}

.sidebar-subitem:hover {
  background: rgba(255,255,255,0.08) !important;
  color: #fff !important;
}

.sidebar-subitem.active {
  background: rgba(255,255,255,0.14) !important;
  border-left-color: var(--accent) !important;
  color: #fff !important;
  font-weight: 600;
}

.sidebar-logout { margin-top: 8px; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: relative;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.topbar strong { color: var(--brand-darker); font-size: 1.05rem; }

.content { padding: 26px; }

/* ---- Cards ---- */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

/* ---- Tables / grids ---- */
table.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  border-spacing: 0;
  background: #fff;
  font-size: 0.82rem;
}
table.data-table th,
table.data-table td {
  text-align: left;
  padding: 9px 11px;
  border: 1px solid #dfe4e9;
  font-size: 0.82rem;
  line-height: 1.25;
  vertical-align: middle;
  white-space: nowrap;
}
table.data-table th {
  color: #53677b;
  font-weight: 700;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  background: #f4f6f8;
  height: 41px;
}
table.data-table td {
  height: 49px;
  color: #31465a;
  background: #fff;
}
table.data-table tbody tr:nth-child(even) td {
  background: #fbfcfd;
}
table.data-table tbody tr:hover td {
  background: #f3f8fa;
}
table.data-table td strong {
  color: #172b3f;
  font-weight: 700;
}
table.data-table td a:not(.btn) {
  color: var(--brand-dark);
}
table.data-table th:first-child {
  border-top-left-radius: 0;
}
table.data-table th:last-child {
  border-top-right-radius: 0;
}

/* Keep action buttons compact and on one line inside grids. */
table.data-table td:last-child {
  text-align: right;
  white-space: nowrap;
}
table.data-table td:last-child .btn,
table.data-table td:last-child form {
  display: inline-flex;
  vertical-align: middle;
}

/* ---- Status badges: each state gets its own confident color ---- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2px; }
.badge-new { background: var(--info-pale); color: #1d4ed8; }
.badge-contacted { background: var(--accent-pale); color: var(--accent-dark); }
.badge-pending { background: #ede9fe; color: #6d28d9; }
.badge-inprogress { background: #dbeafe; color: #1e40af; }
.badge-notresponding { background: #ffedd5; color: #c2410c; }
.badge-notinterested { background: var(--danger-pale); color: #9f1239; }
.badge-won { background: var(--success-pale); color: #047857; }
.badge-lost { background: var(--danger-pale); color: #9f1239; }
.badge-qualified { background: var(--success-pale); color: #047857; }
.badge-disqualified { background: var(--danger-pale); color: #9f1239; }
.badge-converted { background: #cffafe; color: #0e7490; }
.badge-completed { background: var(--success-pale); color: #047857; }
.badge-cancelled { background: var(--danger-pale); color: #9f1239; }
.badge-open { background: var(--info-pale); color: #1d4ed8; }

/* Quick status-change control on the Manage Leads grid: same shape/color
   language as .badge, but it's a real <select> so it stays a proper form
   control (keyboard-operable, no JS needed to look right). */
.badge-select {
  display: inline-block; border: none; border-radius: 999px;
  padding: 3px 22px 3px 10px; font-size: 0.74rem; font-weight: 700; letter-spacing: 0.2px;
  cursor: pointer; appearance: none; -webkit-appearance: none; -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23555' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
.badge-select:focus { outline: 2px solid var(--accent, #0d9488); outline-offset: 1px; }

/* ---- Buttons ---- */
.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.15;
  white-space: nowrap;
  box-sizing: border-box;
  vertical-align: middle;
  transition: transform 0.08s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, #18b3a4, #0d9488);
  color: #fff;
  box-shadow: 0 2px 6px rgba(13, 148, 136, 0.25);
}
.btn-primary:hover {
  box-shadow: 0 3px 9px rgba(13, 148, 136, 0.35);
  transform: translateY(-1px);
  color: #fff;
}
.btn-outline {
  background: #fff;
  border: 1px solid #08a49b;
  color: #087e79;
  font-weight: 600;
}
.btn-outline:hover {
  background: #effaf8;
  border-color: #087e79;
}
.btn-accent {
  background: linear-gradient(135deg, #fbbf24, #d97706);
  color: #fff;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.25);
}
.btn-accent:hover {
  box-shadow: 0 3px 9px rgba(217, 119, 6, 0.35);
  transform: translateY(-1px);
  color: #fff;
}
.btn-info {
  background: linear-gradient(135deg, #818cf8, #4f46e5);
  color: #fff;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.24);
}
.btn-info:hover {
  box-shadow: 0 3px 9px rgba(79, 70, 229, 0.32);
  transform: translateY(-1px);
  color: #fff;
}
.btn-danger {
  background: linear-gradient(135deg, #ef476f, #d72f59);
  color: #fff;
  border-color: #d72f59;
}
.btn-danger:hover {
  box-shadow: 0 3px 9px rgba(225, 29, 72, 0.28);
  transform: translateY(-1px);
}

/* Small/grid buttons: similar proportions to the compact buttons shown on Manage Leads. */
.btn-sm {
  min-height: 32px;
  height: 32px;
  padding: 5px 9px;
  font-size: 0.75rem;
  min-width: 0;
  border-radius: 6px;
}
table.data-table .btn-sm {
  min-height: 31px;
  height: 31px;
  padding: 4px 8px;
  font-size: 0.74rem;
  margin-left: 2px;
}
table.data-table td:last-child .btn-sm:first-child {
  margin-left: 0;
}

/* ---- Forms: base styling applies to every input/select/textarea on the
   site, not just ones inside .form-group - the filter bars at the top of
   Manage Leads / Follow-ups use bare <select>/<input type=date> elements
   and need the same themed look. ---- */
input, select, textarea {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-light);
  box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.15);
}
input:hover, select:hover { border-color: var(--brand-light); }

/* Custom dropdown arrow instead of the plain OS-default one */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230f766e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 11px;
  padding-right: 32px;
  cursor: pointer;
}

/* Tint the native date-picker calendar icon to match the brand teal */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(34%) sepia(80%) saturate(485%) hue-rotate(131deg) brightness(93%) contrast(92%);
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover {
  background: var(--brand-pale);
}

/* ---- Forms ---- */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 0.85rem; margin-bottom: 5px; color: var(--brand-dark); font-weight: 600; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
}
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }
.text-danger { color: var(--danger); font-size: 0.82rem; }

/* ---- Searchable select: progressive enhancement over a plain <select>
   (see wwwroot/js/searchable-select.js). The original <select> stays in
   the DOM so asp-for binding/validation/posting are unaffected - it's
   just visually hidden in favor of the text input + custom list below. ---- */
.searchable-select { position: relative; }
.searchable-select-native { display: none; }
.searchable-select-input { width: 100%; cursor: text; }
.searchable-select-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  margin: 0;
  padding: 4px;
  list-style: none;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow-md);
  max-height: 230px;
  overflow-y: auto;
}
.searchable-select-option {
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.9rem;
}
.searchable-select-option:hover,
.searchable-select-option.is-active { background: var(--brand-pale); }
.searchable-select-option.is-selected { font-weight: 600; color: var(--brand-dark); }
.searchable-select-empty { padding: 8px 10px; color: var(--text-muted); font-size: 0.85rem; }

/* ---- Status filter: multi-select checkbox dropdown on Manage Leads ---- */
.status-filter { position: relative; }
.status-filter-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 0.85rem; background: var(--card-bg);
  min-width: 160px; white-space: nowrap;
}
.status-filter-summary::-webkit-details-marker { display: none; }
.status-filter-summary::after { content: "▾"; margin-left: auto; color: var(--text-muted); }
.status-filter[open] .status-filter-summary::after { content: "▴"; }
.status-filter-panel {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0;
  min-width: 200px; padding: 6px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 7px; box-shadow: var(--shadow-md);
  max-height: 260px; overflow-y: auto;
}
.status-filter-option {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 5px; font-size: 0.88rem; cursor: pointer;
}
.status-filter-option:hover { background: var(--brand-pale); }
.status-filter-option input { margin: 0; }

/* Delete buttons in Manage Receiving / Manage Commission stay hidden until
   revealed with Ctrl+Alt+Shift+D (see the reveal script in _Layout.cshtml).
   Keeps a destructive action out of the way of everyday use while it's
   still reachable for authorized users. */
.danger-action { display: none !important; }
body.show-danger-actions .danger-action { display: inline-block !important; margin: 0; }

/* ---- Kanban (kept for any future pipeline view) ---- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; }
.kanban-col { background: var(--brand-pale); border-radius: 10px; min-width: 250px; flex-shrink: 0; padding: 10px; }
.kanban-col h3 { font-size: 0.9rem; margin: 4px 6px 10px; display: flex; justify-content: space-between; }
.kanban-card { background: #fff; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; box-shadow: var(--shadow-sm); cursor: grab; font-size: 0.85rem; }
.kanban-card.dragging { opacity: 0.4; }
.kanban-col.drag-over { background: #b8ece3; }

/* ---- Notification bell ---- */
.bell-wrap { position: relative; }
.bell-dot { position: absolute; top: -3px; right: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #fff; }
.notif-panel { position: absolute; top: 42px; right: 0; width: 320px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md); z-index: 40; max-height: 400px; overflow-y: auto; }
.notif-item { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 0.85rem; }
.notif-item.unread { background: var(--brand-pale); border-left: 3px solid var(--brand); }

/* ---- Misc ---- */
.text-muted { color: var(--text-muted); }
.empty-state { text-align: center; color: var(--text-muted); padding: 40px 0; }
.alert { padding: 11px 15px; border-radius: 9px; font-size: 0.88rem; margin-bottom: 14px; border-left: 4px solid transparent; }
.alert-success { background: var(--success-pale); color: #065f46; border-left-color: var(--success); }
.alert-danger { background: var(--danger-pale); color: #9f1239; border-left-color: var(--danger); }
.alert-info { background: var(--info-pale); color: #1e3a8a; border-left-color: var(--info); }
.hidden { display: none !important; }

/* ---- Dashboard stat cards ---- */
.stat-card {
  border-radius: 12px;
  padding: 18px;
  color: #fff;
  box-shadow: var(--shadow-md);
}
.stat-card .stat-label { font-size: 0.8rem; opacity: 0.9; font-weight: 600; text-transform: uppercase; letter-spacing: 0.3px; }
.stat-card .stat-value { font-size: 1.8rem; font-weight: 800; margin-top: 4px; }
.stat-card .stat-sub { font-size: 0.78rem; opacity: 0.85; margin-top: 2px; }
.stat-teal   { background: linear-gradient(135deg, #14b8a6, #0d9488); }
.stat-amber  { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-rose   { background: linear-gradient(135deg, #fb7185, #e11d48); }
.stat-indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); }

/* ---- Global list/grid polish ---- */
.card:has(> table.data-table) {
  overflow-x: auto;
}

/* Filter/action rows should stay horizontal where there is enough room. */
.lead-filter-form,
.filter-form {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  flex-wrap: nowrap;
  gap: 8px;
  white-space: nowrap;
}

.lead-actions,
.grid-actions {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

.lead-actions .btn,
.grid-actions .btn {
  flex: 0 0 auto;
}

@media (max-width: 1100px) {
  .content { padding: 18px; }
  .card { padding: 15px; }
  table.data-table { min-width: 860px; }
}

@media (max-width: 760px) {
  .sidebar { width: 190px; }
  .content { padding: 12px; }
  .topbar { padding: 12px 16px; }
}


/* ==========================================================================\n   Global Theme Color Picker\n   The primary CRM color is controlled by CSS variables and can be changed\n   from Companies. The value is persisted in the browser with localStorage.
   ========================================================================== */
:root {
  --theme-primary: var(--brand);
  --theme-primary-dark: var(--brand-dark);
  --theme-primary-darker: var(--brand-darker);
  --theme-primary-light: var(--brand-light);
  --theme-primary-pale: var(--brand-pale);
}

/* Theme-aware global accents */
.sidebar { background: linear-gradient(180deg, var(--theme-primary-darker) 0%, var(--theme-primary-dark) 55%, var(--theme-primary) 100%); }
.sidebar a.active { border-left-color: var(--accent); }
.topbar strong { color: var(--theme-primary-darker); }
.form-group label { color: var(--theme-primary-dark); }
.text-muted { color: var(--text-muted); }
a { color: var(--theme-primary-dark); }
a:hover { color: var(--theme-primary-darker); }

.btn-primary {
  background: linear-gradient(135deg, var(--theme-primary-light), var(--theme-primary));
  border-color: var(--theme-primary);
  box-shadow: 0 2px 6px color-mix(in srgb, var(--theme-primary) 25%, transparent);
}
.btn-primary:hover { box-shadow: 0 3px 9px color-mix(in srgb, var(--theme-primary) 35%, transparent); }
.btn-outline { border-color: var(--theme-primary); color: var(--theme-primary-dark); }
.btn-outline:hover { background: var(--theme-primary-pale); border-color: var(--theme-primary-dark); }

input:focus, select:focus, textarea:focus {
  border-color: var(--theme-primary-light);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--theme-primary-light) 15%, transparent);
}
input:hover, select:hover { border-color: var(--theme-primary-light); }
select { background-image: var(--theme-select-arrow, url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230f766e' d='M1 1l5 5 5-5'/%3E%3C/svg%3E")); }

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator { filter: none; opacity: .65; }
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover { background: var(--theme-primary-pale); }

table.data-table td a:not(.btn) { color: var(--theme-primary-dark); }
.badge-qualified { background: var(--theme-primary-pale); color: var(--theme-primary-darker); }
.notif-item.unread { background: var(--theme-primary-pale); border-left-color: var(--theme-primary); }
.kanban-col { background: var(--theme-primary-pale); }
.kanban-col.drag-over { background: color-mix(in srgb, var(--theme-primary-light) 30%, white); }

/* Theme picker */
.theme-picker {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  padding: 14px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.theme-picker-header { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.theme-picker-title { font-weight:700; color:var(--theme-primary-darker); }
.theme-picker-controls { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.theme-color-input { width:44px !important; height:36px; padding:3px !important; cursor:pointer; }
.theme-hex-input { width:120px !important; text-transform:uppercase; font-family:Consolas,monospace; }
.theme-preview { width:24px; height:24px; border-radius:6px; border:1px solid rgba(0,0,0,.12); background:var(--theme-primary); display:inline-block; vertical-align:middle; }
.theme-help { font-size:.76rem; color:var(--text-muted); margin-top:7px; }
.theme-error { color:var(--danger); font-size:.76rem; display:none; margin-top:6px; }
@media (max-width: 760px) {
  .theme-picker-header { align-items:flex-start; flex-direction:column; }
  .theme-picker-controls { width:100%; }
}

/* ---- Presentable dashboard / admin action area ---- */
.dashboard-header {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  margin-bottom:18px;
}
.dashboard-header h2 { margin:0; }
.dashboard-header .text-muted { font-size:.82rem; margin-top:3px; }
.dashboard-stats {
  display:grid;
  grid-template-columns:repeat(4, minmax(0, 1fr));
  gap:14px;
  margin-bottom:18px;
}
.dashboard-actions {
  display:grid;
  grid-template-columns:repeat(5, minmax(0, 1fr));
  gap:10px;
  margin-bottom:18px;
}
.dashboard-action {
  min-height:70px;
  border-radius:10px;
  padding:11px 13px;
  color:#fff !important;
  text-decoration:none !important;
  display:flex;
  align-items:center;
  gap:10px;
  box-shadow:var(--shadow-sm);
  transition:transform .12s ease, box-shadow .12s ease;
}
.dashboard-action:hover { transform:translateY(-1px); box-shadow:var(--shadow-md); color:#fff !important; }
.dashboard-action .action-icon {
  width:34px;
  height:34px;
  border-radius:9px;
  display:grid;
  place-items:center;
  background:rgba(255,255,255,.18);
  font-size:1.2rem;
  flex:0 0 34px;
}
.dashboard-action strong { display:block; font-size:.88rem; }
.dashboard-action small { display:block; opacity:.84; font-size:.7rem; margin-top:2px; line-height:1.25; }
.action-leads { background:linear-gradient(135deg,#0f766e,#0d9488); }
.action-followups { background:linear-gradient(135deg,#4f46e5,#6366f1); }
.action-import { background:linear-gradient(135deg,#0369a1,#0ea5e9); }
.action-unassigned { background:linear-gradient(135deg,#b45309,#f59e0b); }
.action-new { background:linear-gradient(135deg,#15803d,#22c55e); }
.dashboard-charts {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}
.dashboard-chart-card { min-width:0; }
.chart-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  margin-bottom:16px;
}
.chart-heading h3 { margin:0; font-size:1rem; }
.chart-heading .text-muted { font-size:.72rem; }
.bar-row { margin:12px 0; }
.bar-label { display:flex; justify-content:space-between; align-items:center; font-size:.78rem; margin-bottom:5px; }
.bar-label strong { font-size:.78rem; }
.bar-track { height:10px; border-radius:99px; background:#eef2f4; overflow:hidden; }
.bar-fill { height:100%; border-radius:99px; min-width:0; transition:width .35s ease; }
.status-new { background:#0d9488; }
.status-contacted { background:#2563eb; }
.status-pending { background:#f59e0b; }
.status-inprogress { background:#6366f1; }
.status-notresponding { background:#64748b; }
.status-notinterested { background:#e11d48; }
.status-won { background:#16a34a; }
.followup-bar { background:var(--theme-primary); }

@media (max-width:1100px) {
  .dashboard-actions { grid-template-columns:repeat(3,1fr); }
  .dashboard-stats { grid-template-columns:repeat(2,1fr); }
}
@media (max-width:760px) {
  .dashboard-header { align-items:flex-start; flex-direction:column; }
  .dashboard-actions, .dashboard-stats, .dashboard-charts { grid-template-columns:1fr; }
}


/* ==========================================================================
   Grid fit / action alignment
   Keep wide grids inside the content area and make action buttons compact.
   ========================================================================== */
.table-responsive {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}
.leads-table-responsive {
  border-top: 1px solid #dfe4e8;
}
.leads-grid {
  width: 100%;
  min-width: 1080px;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .72rem;
}
.leads-grid th,
.leads-grid td {
  padding: 7px 8px;
  font-size: .72rem;
  line-height: 1.2;
}
.leads-grid th {
  padding: 8px 8px;
  font-size: .69rem;
  letter-spacing: .3px;
  height: 37px;
}
.leads-grid td {
  height: 43px;
}
.leads-grid .badge {
  font-size: .67rem;
  padding: 3px 7px;
}
.lead-actions-cell {
  width: 1%;
  min-width: 235px;
  text-align: right !important;
  white-space: nowrap !important;
  padding-left: 5px !important;
  padding-right: 5px !important;
}
.leads-grid .lead-actions-cell .btn,
.leads-grid .lead-actions-cell form .btn {
  min-height: 25px;
  height: 25px;
  padding: 3px 6px;
  font-size: .63rem;
  line-height: 1;
  border-radius: 4px;
  margin-left: 2px;
}
.leads-grid .lead-actions-cell form {
  margin: 0;
}
.leads-grid .lead-actions-cell .btn[disabled] {
  opacity: .48;
  cursor: not-allowed;
}

/* Admin All Users Activity shortcuts: equal-width, neatly aligned cards. */
.dashboard-actions {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}
.dashboard-action {
  width: 100%;
  min-width: 0;
  min-height: 68px;
  height: 68px;
  padding: 10px 11px;
  align-items: center;
}
.dashboard-action > span:last-child {
  min-width: 0;
  overflow: hidden;
}
.dashboard-action strong,
.dashboard-action small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.dashboard-action strong { font-size: .82rem; }
.dashboard-action small { font-size: .67rem; }
.dashboard-action .action-icon {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  font-size: 1rem;
}

@media (max-width: 1250px) {
  .dashboard-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .dashboard-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-action { height: 64px; min-height: 64px; }
}
@media (max-width: 520px) {
  .dashboard-actions { grid-template-columns: 1fr; }
}

/* Consistent action/notification popup */
.crm-toast {
  position: fixed;
  right: 22px;
  top: 22px;
  z-index: 99999;
  min-width: 300px;
  max-width: 430px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
  font-size: .84rem;
  animation: crmToastIn .2s ease-out;
}
.crm-toast strong { white-space: nowrap; }
.crm-toast span { flex: 1; }
.crm-toast button { border:0; background:transparent; font-size:20px; line-height:1; cursor:pointer; padding:0 2px; }
.crm-toast-success { background:#ecfdf5; color:#065f46; border-left:4px solid #10b981; }
.crm-toast-error { background:#fff1f2; color:#9f1239; border-left:4px solid #ef4444; }
.crm-toast-info { background:#eff6ff; color:#1e3a8a; border-left:4px solid #3b82f6; }
@keyframes crmToastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

.crm-confirm-backdrop { position:fixed; inset:0; z-index:100000; background:rgba(15,23,42,.42); display:flex; align-items:center; justify-content:center; padding:20px; }
.crm-confirm { width:min(420px,100%); background:#fff; border-radius:12px; box-shadow:0 20px 50px rgba(0,0,0,.25); padding:20px; }
.crm-confirm h3 { margin:0 0 8px; font-size:1rem; }
.crm-confirm p { margin:0 0 18px; color:#64748b; font-size:.85rem; line-height:1.45; }
.crm-confirm-actions { display:flex; justify-content:flex-end; gap:8px; }

@media (max-width: 700px) {
  .crm-toast { left:12px; right:12px; top:12px; min-width:0; max-width:none; }
}


.crm-assign-dialog { max-width: 430px; width: calc(100% - 30px); }
.crm-assign-dialog select { min-height: 145px; }
.crm-assign-dialog input { box-sizing: border-box; }

/* Manage Follow-ups status colors */
.followup-pending-row { background: rgba(220, 53, 69, 0.055); }
.followup-pending-text { color: #c82333; font-weight: 600; }
.followup-done-row { background: rgba(40, 167, 69, 0.075); }
.followup-done-row td { color: #287a3a; }
.followup-done-text { color: #218838; font-weight: 600; }

/* ---- Receiving / Accounts ---- */
.receiving-form-card { max-width: 1050px; }
.receiving-form-header,
.page-header { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; }
.receiving-form-header h2,
.page-header h2 { margin:0 0 4px; }
.receiving-form-header p,
.page-header p { margin:0; }
.receiving-search { margin-bottom:6px; }
.receiving-select { width:100%; min-height:145px; background:#fff; }
.receiving-search:focus,
.receiving-select:focus { outline:2px solid rgba(13,148,136,.22); border-color:var(--brand); }
.receiving-section-title { font-size:.95rem; margin:24px 0 4px; }
.receiving-help { margin:0 0 9px; font-size:.8rem; }
.receiving-lines-table { min-width:760px !important; }
.receiving-lines-table input { width:100%; min-width:0; padding:7px 8px; }
.receiving-lines-table th,
.receiving-lines-table td { padding:7px 8px; }
.receiving-lines-table .line-number { width:42px; text-align:center; color:#6b7d8d; font-weight:700; }
.receiving-total-preview { margin:12px 0 0 auto; width:min(300px,100%); display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border:1px solid var(--border); border-radius:8px; background:#f8fffd; }
.receiving-total-preview strong { color:var(--brand-dark); font-size:1rem; }
.receiving-grid { min-width:900px !important; }
.receiving-filter-form { display:flex; align-items:flex-end; gap:10px; flex-wrap:wrap; margin-bottom:14px; }
.receiving-filter-form .filter-item { min-width:180px; flex:1; }
.receiving-filter-form .filter-item label { display:block; font-size:.72rem; color:#53677b; font-weight:700; margin-bottom:4px; }
.receiving-filter-form .filter-item input { width:100%; }
.receiving-filter-form .filter-actions { display:flex; gap:6px; padding-bottom:1px; }
@media (max-width:700px) {
  .receiving-form-header,.page-header { align-items:flex-start; flex-direction:column; }
  .receiving-filter-form { display:block; }
  .receiving-filter-form .filter-item { margin-bottom:9px; }
  .receiving-filter-form .filter-actions { padding-bottom:0; }
}

/* ---- Global menu + button icons ---- */
.nav-icon {
  width: 19px;
  min-width: 19px;
  margin-right: 9px;
  text-align: center;
  font-size: .86rem;
  opacity: .92;
}
.sidebar-subitem .nav-icon {
  width: 17px;
  min-width: 17px;
  margin-right: 8px;
  font-size: .75rem;
}
.sidebar-parent-link > span,
.sidebar-subitem > span,
.sidebar-parent-link,
.sidebar-subitem {
  align-items: center;
}
.sidebar-parent-link,
.sidebar-subitem {
  display: flex !important;
}
.btn-icon {
  margin-right: 6px;
  font-size: .82em;
  line-height: 1;
  flex: 0 0 auto;
}
.btn-icon:only-child { margin-right: 0; }
