/* CRM Pro — base styles. Matches TLP's general look: dark-blue topbar, dense tables. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 14px;
  color: #1f2937;
  background: #f3f4f6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }
a.disabled { color: #9ca3af; pointer-events: none; }
.link-muted { color: #6b7280; font-size: 0.85rem; }

/* Topbar */
.topbar {
  background: #1e3a5f;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  min-height: 52px;
}
.topbar-left { display: flex; align-items: center; gap: 1rem; }
.brand { font-weight: 700; font-size: 1.1rem; color: #fff; letter-spacing: 0.02em; }
.brand:hover { text-decoration: none; }
.tenant { opacity: 0.8; font-size: 0.9rem; }

.quick-submit {
  flex: 1;
  display: flex;
  gap: 0.25rem;
  background: #2c4a6b;
  padding: 0.25rem;
  border-radius: 4px;
  align-items: center;
}
.quick-submit input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.5rem;
  border: none;
  border-radius: 3px;
  background: #3a5877;
  color: #fff;
  font-size: 0.85rem;
}
.quick-submit input::placeholder { color: #cbd5e1; }
.quick-submit button {
  padding: 0.35rem 0.9rem;
  border: none;
  border-radius: 3px;
  background: #10b981;
  color: #fff;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
}
.quick-submit button:hover { background: #059669; }
.super-search {
  padding: 0.35rem 0.75rem;
  background: #475569;
  color: #fff;
  border-radius: 3px;
  font-size: 0.85rem;
  white-space: nowrap;
}
.super-search:hover { background: #64748b; text-decoration: none; }

.topbar-right { display: flex; align-items: center; gap: 1rem; }
.user-name { font-size: 0.9rem; }
button.link {
  background: none; border: none; color: #93c5fd; cursor: pointer; padding: 0; font: inherit;
}
button.link:hover { text-decoration: underline; }
form.inline { display: inline; }

/* Subnav */
.subnav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  padding: 0 1rem;
}
.subnav a {
  padding: 0.75rem 1.25rem;
  color: #4b5563;
  border-bottom: 2px solid transparent;
  font-size: 0.9rem;
}
.subnav a:hover { text-decoration: none; color: #1e3a5f; }

.content {
  max-width: 1500px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* Page headers */
.page-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.page-header h1 { margin: 0; font-size: 1.5rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
.muted { color: #6b7280; }

/* Buttons */
.btn, button, input[type="submit"] {
  padding: 0.5rem 0.9rem;
  background: #1e3a5f;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover, button:hover { background: #2c4a6b; text-decoration: none; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }

/* Filter row */
.filter-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}
.filter-row input, .filter-row select {
  padding: 0.4rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 0.9rem;
}
.filter-row input[type="search"] { flex: 1; max-width: 400px; }

/* Tiles (home dashboard) */
.tile-row { display: flex; gap: 1rem; margin: 1.5rem 0; flex-wrap: wrap; }
.tile {
  flex: 1; min-width: 180px;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 1rem 1.25rem;
}
.tile-label {
  font-size: 0.8rem; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.tile-value {
  font-size: 2rem; font-weight: 600; color: #1e3a5f; margin-top: 0.25rem;
}

.empty-note {
  margin-top: 1rem;
  padding: 1rem 1.25rem;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 6px;
  color: #713f12;
}

/* Data tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  overflow: hidden;
}
.data-table th, .data-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.9rem;
  vertical-align: top;
}
.data-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.data-table tr:hover td { background: #f9fafb; }

/* Login */
.login-wrap { min-height: 80vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 8px;
  padding: 2rem; width: 100%; max-width: 380px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.login-card h1 { margin: 0 0 0.25rem; color: #1e3a5f; text-align: center; }
.tenant-label { margin: 0 0 1.5rem; text-align: center; color: #6b7280; }
.login-card label { display: block; margin-bottom: 1rem; font-size: 0.85rem; color: #374151; }
.login-card input {
  width: 100%; padding: 0.5rem; margin-top: 0.25rem;
  border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.95rem;
}
.login-card button { width: 100%; padding: 0.6rem; font-size: 0.95rem; }
.alert {
  background: #fef2f2; border: 1px solid #fecaca; color: #991b1b;
  padding: 0.5rem 0.75rem; border-radius: 4px; margin-bottom: 1rem; font-size: 0.9rem;
}

/* Forms */
.form-grid { background: #fff; border: 1px solid #e5e7eb; border-radius: 6px; padding: 1.25rem; }
.form-grid fieldset { border: none; padding: 0; margin: 0 0 1.25rem; }
.form-grid legend { font-weight: 600; color: #374151; margin-bottom: 0.5rem; padding: 0; }
.form-grid label {
  display: block; margin-bottom: 0.75rem; font-size: 0.85rem; color: #4b5563;
}
.form-grid input, .form-grid select, .form-grid textarea {
  width: 100%; padding: 0.4rem 0.6rem; margin-top: 0.15rem;
  border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.9rem; font-family: inherit;
}
.form-grid label.checkbox { display: flex; align-items: center; gap: 0.4rem; }
.form-grid label.checkbox input { width: auto; margin: 0; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.row-3 { display: grid; grid-template-columns: 1fr 80px 1fr; gap: 0.75rem; }
.row-4 { display: grid; grid-template-columns: 2fr 80px 1fr 120px; gap: 0.75rem; }
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; }

/* Lead detail */
.lead-header {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.lead-header-main {
  display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.lead-header-main h1 { margin: 0; font-size: 1.3rem; }
.lead-header-contact {
  display: flex; gap: 1.5rem; flex-wrap: wrap;
  font-size: 0.9rem; color: #4b5563;
}

.step-pill {
  padding: 0.2rem 0.7rem; color: #fff; border-radius: 12px;
  font-size: 0.8rem; font-weight: 600;
}
.status-pill {
  padding: 0.15rem 0.55rem; border-radius: 3px;
  font-size: 0.75rem; font-weight: 600;
}
.status-closed_dead, .status-pill.status-closed_dead { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.status-sold, .status-pill.status-sold { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }

.contact-status {
  display: inline-block;
  padding: 0.15rem 0.55rem; border-radius: 3px;
  font-size: 0.75rem; font-weight: 600;
  text-transform: uppercase;
}
.contact-status.status-hot     { background: #fef2f2; color: #991b1b; }
.contact-status.status-warm    { background: #fef3c7; color: #92400e; }
.contact-status.status-cold    { background: #dbeafe; color: #1e40af; }
.contact-status.status-dead    { background: #f3f4f6; color: #374151; }
.contact-status.status-customer{ background: #ecfdf5; color: #065f46; }

.lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1rem; margin: 0; }
dl.kv dt { color: #6b7280; font-size: 0.85rem; }
dl.kv dd { margin: 0; }

.action-block { border-bottom: 1px solid #f3f4f6; padding: 0.75rem 0; }
.action-block:last-child { border-bottom: none; }
.action-block summary {
  font-weight: 600; cursor: pointer; color: #1e3a5f; padding: 0.25rem 0;
}
.action-block .stack { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.5rem; }
.action-block .stack label { font-size: 0.85rem; color: #4b5563; display: block; }
.action-block .stack input,
.action-block .stack select,
.action-block .stack textarea {
  width: 100%; padding: 0.35rem 0.5rem; margin-top: 0.15rem;
  border: 1px solid #d1d5db; border-radius: 4px; font-size: 0.9rem; font-family: inherit;
}

/* Pills (log types, activities, statuses) */
.pill {
  display: inline-block; padding: 0.15rem 0.5rem;
  border-radius: 3px; font-size: 0.75rem; font-weight: 600;
  background: #e5e7eb; color: #374151;
}
.pill-log { background: #1e3a5f; color: #fff; }
.pill-activity { background: #475569; color: #fff; }
.pill-status.pill-open     { background: #fef3c7; color: #92400e; }
.pill-status.pill-overdue  { background: #fef2f2; color: #991b1b; }
.pill-status.pill-completed { background: #ecfdf5; color: #065f46; }
.pill-status.pill-completed-late { background: #ffedd5; color: #9a3412; }

/* Step circle (planner list) */
.step-circle {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid; font-weight: 700;
}

/* Planner buckets */
.bucket { margin-bottom: 1.5rem; }
.bucket-header {
  font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem; border-radius: 4px;
  margin: 0 0 0.5rem; color: #374151;
}
.bucket-today .bucket-header       { background: #dcfce7; color: #14532d; }
.bucket-overdue-1 .bucket-header   { background: #fef3c7; color: #78350f; }
.bucket-overdue-2 .bucket-header   { background: #ffedd5; color: #7c2d12; }
.bucket-overdue-3 .bucket-header   { background: #fee2e2; color: #7f1d1d; }
.bucket-upcoming .bucket-header    { background: #e0e7ff; color: #3730a3; }

/* Kanban */
.scope-toggle { display: flex; gap: 0.25rem; }
.scope-toggle a {
  padding: 0.35rem 0.75rem; border: 1px solid #d1d5db; border-radius: 4px;
  font-size: 0.85rem; color: #4b5563; background: #fff;
}
.scope-toggle a.active { background: #1e3a5f; color: #fff; border-color: #1e3a5f; }
.scope-toggle a:hover { text-decoration: none; }

.kanban {
  display: flex; gap: 0.5rem;
  overflow-x: auto; padding-bottom: 1rem;
  align-items: flex-start;
}
.kanban-col {
  flex: 0 0 240px; background: #f9fafb; border-radius: 6px;
  display: flex; flex-direction: column;
  max-height: 75vh;
}
.kanban-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.5rem 0.75rem;
  background: #fff; border-top: 3px solid #ccc;
  border-radius: 6px 6px 0 0;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0;
}
.kanban-step { font-weight: 700; font-size: 0.85rem; color: #374151; }
.kanban-count {
  background: #e5e7eb; color: #374151;
  padding: 0.1rem 0.5rem; border-radius: 10px;
  font-size: 0.75rem; font-weight: 600;
}
.kanban-cards { padding: 0.5rem; overflow-y: auto; flex: 1; }
.kanban-card {
  display: block; background: #fff; border: 1px solid #e5e7eb;
  border-radius: 4px; padding: 0.6rem 0.75rem; margin-bottom: 0.5rem;
  color: #1f2937;
}
.kanban-card:hover { border-color: #1e3a5f; text-decoration: none; }
.kanban-name { font-weight: 600; color: #1e3a5f; font-size: 0.9rem; }
.kanban-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.25rem; font-size: 0.75rem;
}
.last-log { font-weight: 600; color: #475569; }
.owner {
  padding: 0.05rem 0.4rem; background: #e5e7eb;
  border-radius: 2px; font-size: 0.7rem; font-weight: 600;
}
.kanban-unit { font-size: 0.75rem; margin-top: 0.25rem; }
.kanban-legend { margin-top: 1rem; font-size: 0.8rem; }

.dot { font-size: 1rem; line-height: 1; }
.dot.overdue { color: #dc2626; }
.dot.upcoming { color: #2563eb; }

/* Unit condition / status pills (Inventory) */
.pill-cond-new    { background: #dcfce7; color: #14532d; }
.pill-cond-used   { background: #fef3c7; color: #78350f; }
.pill-cond-demo   { background: #ede9fe; color: #4c1d95; }
.pill-status-available   { background: #ecfdf5; color: #065f46; }
.pill-status-on_deal     { background: #fef3c7; color: #78350f; }
.pill-status-sold        { background: #f3f4f6; color: #374151; }
.pill-status-transferred { background: #dbeafe; color: #1e40af; }
.pill-status-held        { background: #fee2e2; color: #7f1d1d; }

/* Generic bucket header (Today's Logs) */
.bucket-generic { background: #f3f4f6; color: #374151; }

/* Wrap long comment text in tables */
.data-table td.wrap { white-space: normal; max-width: 420px; }

/* Admin landing tiles & reports hub */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}
.admin-tile {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  padding: 1rem 1.25rem;
  color: #1f2937;
}
.admin-tile:hover { border-color: #1e3a5f; text-decoration: none; }
.admin-tile h3 { margin: 0 0 0.25rem; color: #1e3a5f; font-size: 1rem; }
.admin-tile p { margin: 0; font-size: 0.85rem; }

.subnav-end { margin-left: auto; }

pre.code-block {
  background: #0f172a; color: #e2e8f0;
  padding: 0.75rem 1rem; border-radius: 4px;
  overflow-x: auto;
  font-size: 0.85rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* Realtime inline-SVG-style bar charts (built with flex, no SVG needed) */
.chart {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  min-height: 200px;
  padding: 1rem 0;
  overflow-x: auto;
}
.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
}
.chart-stack {
  display: flex;
  flex-direction: column-reverse;
  height: 160px;
  justify-content: flex-start;
  width: 40px;
}
.chart-stack .bar {
  width: 100%;
  border-top: 1px solid rgba(255,255,255,0.3);
}
.chart-stack .bar:first-child { border-top: none; }
.chart-user { margin-top: 0.5rem; font-size: 0.8rem; font-weight: 600; color: #374151; }
.chart-legend {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
}
.legend-item { display: inline-flex; align-items: center; gap: 0.25rem; }
.legend-swatch {
  display: inline-block; width: 12px; height: 12px;
  border-radius: 2px;
}
