:root {
  --bg: #10131a;
  --surface: #171b24;
  --surface-2: #1d2230;
  --border: #2b3142;
  --text: #e8ebef;
  --text-muted: #8992a6;
  /* Brand green, matched to vocallogic.ai's own design tokens (--primary:
     hsl(130 46% 33%) = #2D7A3A) - brightened here for legibility on a dark
     dashboard background using the site's own lighter chart steps rather
     than an invented tint. */
  --accent: #42b355;
  --accent-dim: #42b35533;
  --accent-bright: #75cc84;
  --accent-deep: #2d7a3a;
  /* The site's secondary/highlight hue (hsl(88 50% 53%)) - used sparingly
     for decorative glow, not as an interactive color. */
  --lime: #8bc34b;
  --amber: #f2a93b;
  --amber-dim: #f2a93b22;
  /* Shifted further toward teal/cyan (was #33d6a6) so "success" stays
     visually distinct from the brand-green accent above, rather than
     reading as the same hue for two different meanings. */
  --green: #2dd4bf;
  --green-dim: #2dd4bf22;
  --red: #ff6767;
  --red-dim: #ff676722;
  --radius: 10px;
  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }

.topbar {
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #12151d, #10131a);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: radial-gradient(circle at 30% 30%, var(--accent), var(--accent-deep));
  box-shadow: 0 0 0 1px var(--border), 0 6px 18px -6px var(--accent-dim);
  flex-shrink: 0;
}
.brand h1 { font-size: 19px; }
.subtitle { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }

.container { max-width: 1080px; margin: 0 auto; padding: 32px 24px 80px; }
section { margin-bottom: 44px; }

.section-head {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap;
}
.section-head h2 { font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.count-pill {
  font-family: var(--font-mono); font-size: 12px; color: var(--accent);
  background: var(--accent-dim); border-radius: 20px; padding: 2px 9px;
}

/* Buttons */
.btn {
  font-family: var(--font-body); font-size: 13.5px; font-weight: 500;
  border-radius: 8px; padding: 9px 16px; border: 1px solid transparent;
  cursor: pointer; transition: transform .12s ease, background .15s ease, border-color .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-bright); }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); border-color: #3c4459; }
.btn-ghost.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent-dim); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red-dim); }
.btn-danger:hover { background: var(--red-dim); }
.icon-btn {
  background: none; border: none; color: var(--text-muted); font-size: 20px;
  cursor: pointer; line-height: 1;
}
.icon-btn:hover { color: var(--text); }

/* Client cards */
.client-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px;
}
.client-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 10px;
}
.client-card h3 { font-size: 16px; }
.client-email { color: var(--text-muted); font-size: 13px; font-family: var(--font-mono); }
.client-number { color: var(--text-muted); font-size: 12px; font-family: var(--font-mono); }
.client-template {
  font-size: 12.5px; color: var(--text-muted); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  line-height: 1.5; max-height: 62px; overflow: hidden;
}
.client-template mark { background: var(--accent-dim); color: var(--accent); border-radius: 4px; padding: 0 3px; font-family: var(--font-mono); }
.client-error {
  font-size: 12px; color: var(--red); background: var(--red-dim);
  border: 1px solid var(--red-dim); border-radius: 8px; padding: 8px 10px; line-height: 1.5;
}
.client-stats { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }
.client-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.client-actions .btn { padding: 7px 12px; font-size: 12.5px; }

/* CRM (deals) */
.followups-widget {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 18px; margin-bottom: 16px;
}
.followups-widget h3 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 10px;
}
.followup-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 0;
  border-bottom: 1px solid var(--border); cursor: pointer; font-size: 13.5px;
}
.followup-item:last-child { border-bottom: none; }
.followup-item:hover .followup-desc { color: var(--accent); }
.followup-due {
  font-family: var(--font-mono); font-size: 11.5px; color: var(--amber);
  background: var(--amber-dim); padding: 3px 8px; border-radius: 20px; white-space: nowrap;
}
.followup-due-overdue { color: var(--red); background: var(--red-dim); }
.followup-desc { flex: 1; }
.followup-company { color: var(--text-muted); font-size: 12.5px; white-space: nowrap; }

.kanban-board {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr);
  gap: 14px; overflow-x: auto; padding-bottom: 4px;
}
.kanban-column {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  display: flex; flex-direction: column; min-height: 120px;
}
.kanban-column-head {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border); font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
}
.kanban-column-body {
  display: flex; flex-direction: column; gap: 10px; padding: 12px; flex: 1;
  max-height: 65vh; overflow-y: auto;
}
.kanban-empty { color: var(--text-muted); font-size: 12.5px; text-align: center; margin: 10px 0; }

.deal-card {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 4px;
}
.deal-card:hover { border-color: var(--accent-dim); }
.deal-card-company { font-size: 13.5px; font-weight: 600; }
.deal-card-contact { font-size: 12px; color: var(--text-muted); }
.deal-card-industry { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.deal-card-value { font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.deal-card-close-date {
  font-size: 11.5px; color: var(--text-muted); background: var(--surface-2);
  border-radius: 6px; padding: 4px 7px; margin-top: 4px; width: fit-content;
}
.deal-card-task {
  font-size: 11.5px; color: var(--amber); background: var(--amber-dim);
  border-radius: 6px; padding: 4px 7px; margin-top: 4px;
}
.deal-card-task-overdue { color: var(--red); background: var(--red-dim); }

.deal-edit-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}

.deal-detail-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.deal-detail-columns h4 {
  font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 10px;
}
.activity-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.activity-head h4 { margin-bottom: 0; }
.activity-compose-toggle { display: flex; gap: 6px; flex-wrap: wrap; }
.activity-compose-toggle .btn { padding: 5px 12px; font-size: 12px; }

.deal-compose-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.deal-compose-form textarea, .deal-compose-form input { margin-top: 0; }
.deal-compose-form button { align-self: flex-end; }

.template-picker-row { display: flex; gap: 8px; }
.template-picker-row select { flex: 1; margin-top: 0; }
.template-picker-row .btn { padding: 8px 14px; font-size: 12.5px; white-space: nowrap; }

.template-list-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px;
  font-size: 12.5px; font-weight: 600;
}
.template-list-head .btn { padding: 3px 9px; font-size: 11px; margin-left: 6px; }

.deal-notes-list, .deal-tasks-list {
  display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto;
  margin-bottom: 10px; padding-right: 2px;
}
.deal-note {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
.deal-note-meta {
  font-size: 11px; color: var(--text-muted); font-family: var(--font-mono);
  margin-bottom: 5px; display: flex; align-items: center;
}
.deal-note-body { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }

.activity-type-badge {
  display: inline-block; font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 2px 7px; border-radius: 10px; margin-right: 6px;
}
.activity-type-note { background: var(--surface); color: var(--text-muted); }
.activity-type-sms { background: var(--accent-dim); color: var(--accent); }
.activity-type-email { background: var(--green-dim); color: var(--green); }
.activity-type-stage_change { background: var(--amber-dim); color: var(--amber); }
.activity-type-call { background: #8bc34b22; color: var(--lime); }

.deal-task {
  display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
}
.deal-task input[type="checkbox"] { width: auto; margin: 0; accent-color: var(--accent); cursor: pointer; }
.deal-task-desc { flex: 1; }
.deal-task-done .deal-task-desc { text-decoration: line-through; color: var(--text-muted); }
.deal-task-due { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.deal-task-due-overdue { color: var(--red); font-weight: 600; }

#deal-note-form textarea { margin-bottom: 8px; }
#deal-task-form { display: flex; gap: 8px; align-items: flex-start; }
#deal-task-form input[type="text"] { flex: 2; margin-top: 0; }
#deal-task-form input[type="date"] { flex: 1; margin-top: 0; }
#deal-task-form button { white-space: nowrap; }

/* Reports */
.report-period-toggle { display: flex; gap: 8px; margin-bottom: 8px; }
.report-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px;
  margin-bottom: 22px;
}
.report-stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.report-stat-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin-bottom: 6px;
}
.report-stat-value { font-family: var(--font-display); font-size: 22px; }
.report-stat-goal { font-family: var(--font-mono); font-size: 13px; color: var(--text-muted); }
.report-progress-track {
  background: var(--surface-2); border-radius: 20px; height: 6px; margin-top: 10px; overflow: hidden;
}
.report-progress-fill { background: var(--accent); height: 100%; border-radius: 20px; }
.report-progress-fill.report-progress-complete { background: var(--green); }
.report-progress-pct { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.report-stat-nogoal { font-size: 11.5px; color: var(--text-muted); margin-top: 10px; }

.report-goals-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }

.pipeline-close-lists {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 22px;
}
.pipeline-close-lists h5 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); margin: 0 0 8px;
}
.pipeline-deal-list {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  max-height: 220px; overflow-y: auto;
}
.pipeline-deal-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.pipeline-deal-row:last-child { border-bottom: none; }
.pipeline-deal-row:hover { background: var(--surface-2); }
.pipeline-deal-company { font-size: 12.5px; font-weight: 600; flex: 1; }
.pipeline-deal-meta { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); }
.pipeline-deal-date {
  font-size: 11.5px; color: var(--text-muted); background: var(--surface-2);
  border-radius: 6px; padding: 3px 7px; white-space: nowrap;
}
.pipeline-deal-date.deal-card-task-overdue { color: var(--red); background: var(--red-dim); }
.pipeline-deal-list .kanban-empty { padding: 14px; margin: 0; }

@media (max-width: 720px) {
  .deal-edit-grid, .deal-detail-columns { grid-template-columns: 1fr; }
  .report-goals-form { grid-template-columns: 1fr 1fr; }
  .pipeline-close-lists { grid-template-columns: 1fr; }
}

/* Activity table */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-x: auto; -webkit-overflow-scrolling: touch;
}
.activity-table { width: 100%; min-width: 640px; border-collapse: collapse; }
.activity-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-muted); font-weight: 500; padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.activity-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle;
}
.activity-table tr:last-child td { border-bottom: none; }
.activity-table tr[data-clickable] { cursor: pointer; }
.activity-table tr[data-clickable]:hover td { background: var(--surface-2); }
.mono { font-family: var(--font-mono); color: var(--text-muted); font-size: 12.5px; }
.photo-count-btn {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 20px;
  background: var(--accent-dim); color: var(--accent); font-family: var(--font-mono);
  font-size: 12px; border: none; padding: 4px 10px; cursor: pointer;
}
.photo-count-btn:hover { background: var(--accent); color: #fff; }
.delivery-warning {
  display: inline-block; margin-left: 8px; font-size: 11px; color: var(--red);
  font-family: var(--font-mono); cursor: help;
}
.activity-row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.activity-row-actions .btn { padding: 6px 12px; font-size: 12px; white-space: nowrap; }

.status-pill {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 20px; font-family: var(--font-mono);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; }
.status-awaiting { background: var(--amber-dim); color: var(--amber); }
.status-awaiting .status-dot { background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.status-reminder_sent { background: var(--amber-dim); color: var(--amber); }
.status-reminder_sent .status-dot { background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.status-completed { background: var(--green-dim); color: var(--green); }
.status-completed .status-dot { background: var(--green); }
.status-no_response { background: var(--red-dim); color: var(--red); }
.status-no_response .status-dot { background: var(--red); }
.status-declined { background: var(--surface-2); color: var(--text-muted); }
.status-declined .status-dot { background: var(--text-muted); }

/* Ticket status pills (reuses the same .status-pill/.status-dot shell) */
.status-open { background: var(--amber-dim); color: var(--amber); }
.status-open .status-dot { background: var(--amber); animation: pulse 1.6s ease-in-out infinite; }
.status-answered { background: var(--green-dim); color: var(--green); }
.status-answered .status-dot { background: var(--green); }
.status-closed { background: var(--surface-2); color: var(--text-muted); }
.status-closed .status-dot { background: var(--text-muted); }

/* Ticket priority pills (reuses the .status-pill shell, no dot) */
.priority-low { background: var(--surface-2); color: var(--text-muted); }
.priority-normal { background: var(--accent-dim); color: var(--accent); }
.priority-high { background: var(--amber-dim); color: var(--amber); }
.priority-urgent { background: var(--red-dim); color: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-state p { margin: 4px 0; }
.empty-sub { font-size: 13px; }

.pagination {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.pagination-info { font-size: 12.5px; color: var(--text-muted); font-family: var(--font-mono); }
.pagination-controls { display: flex; align-items: center; gap: 8px; }
.pagination-controls select {
  width: auto; margin-top: 0; font-size: 12.5px; padding: 7px 10px;
}
.pagination-controls .btn { padding: 7px 14px; font-size: 12.5px; }
.pagination-controls .btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Modals */
.modal-backdrop {
  position: fixed; inset: 0; background: #05070bcc; backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  width: 100%; max-width: 440px; padding: 22px 24px 24px;
  max-height: 90vh; overflow-y: auto;
}
.modal-narrow { max-width: 400px; }
.modal-wide { max-width: 720px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.deal-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.deal-nav .btn { padding: 6px 12px; font-size: 12px; }
.deal-nav-position { font-size: 11.5px; color: var(--text-muted); font-family: var(--font-mono); white-space: nowrap; }
.modal-sub { color: var(--text-muted); font-size: 13px; margin: 0 0 14px; line-height: 1.6; }
.modal-sub code { font-family: var(--font-mono); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

form label {
  display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 14px;
}
form input, form textarea, select {
  width: 100%; margin-top: 6px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 12px; color: var(--text); font-family: var(--font-body);
  font-size: 14px; resize: vertical;
}
form input:focus, form textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
#thread-status-select, #activity-client-filter, #activity-status-filter, #ticket-status-filter {
  width: auto; margin-top: 0;
}
#activity-client-filter, #activity-status-filter, #ticket-status-filter {
  font-size: 13px; padding: 8px 10px;
}

.date-range-label {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-muted);
  white-space: nowrap;
}
.date-range-label input[type="date"] {
  width: auto; margin-top: 0; padding: 7px 9px; font-size: 12.5px; color-scheme: dark;
}
.hint { display: block; margin-top: 6px; font-size: 11.5px; color: var(--text-muted); }
.hint code { font-family: var(--font-mono); }
.checkbox-field {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text);
  margin-bottom: 4px; cursor: pointer;
}
.checkbox-field input[type="checkbox"] {
  width: auto; margin: 0; accent-color: var(--accent); cursor: pointer;
}
.checkbox-field + .hint { margin-top: 0; margin-bottom: 14px; }
.optional { color: var(--text-muted); font-weight: 400; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

.secret-row {
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px;
}
.secret-row code { font-family: var(--font-mono); font-size: 12.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.photo-gallery-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px;
  max-height: 60vh; overflow-y: auto;
}
.photo-gallery-grid img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); display: block;
}

/* Portal stats row + ticket thread (public/portal.html, admin ticket modal) */
.stats-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
}
.stat-box {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat-box .stat-value { font-family: var(--font-display); font-size: 22px; }
.stat-box .stat-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.lead-detail-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  margin-bottom: 18px;
}
.lead-detail-grid .stat-box .stat-value { font-size: 15px; font-family: var(--font-body); }
.gallery-empty { color: var(--text-muted); font-size: 13.5px; padding: 8px 0; }

.lead-call-details { margin-bottom: 18px; }
.lead-call-details h4 { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-bottom: 8px; }
.call-details-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.call-details-table td { padding: 5px 12px 5px 0; vertical-align: top; border-bottom: 1px solid var(--border); }
.call-details-table td:first-child { color: var(--text-muted); white-space: nowrap; width: 1%; }

/* Quote builder */
.quote-branding-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 16px; flex-wrap: wrap;
}
.quote-logo-preview {
  width: 64px; height: 64px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0;
}
.quote-logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.quote-logo-preview #logo-preview-empty { font-size: 10px; color: var(--text-muted); text-align: center; padding: 4px; }
.quote-upload-label { display: inline-flex; }

.quote-line-items { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.quote-line-item-row {
  display: grid; grid-template-columns: 140px 1fr 60px 90px 90px 28px; gap: 8px; align-items: center;
}
.quote-line-item-row input, .quote-line-item-row select, .price-book-row input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 7px 9px; font-size: 13px; color: var(--text); width: 100%;
}
.quote-item-line-total { font-family: var(--font-mono); font-size: 13px; text-align: right; color: var(--text-muted); }
.quote-line-item-header {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  padding: 0 0 4px;
}
.quote-line-item-header span:nth-child(3), .quote-line-item-header span:nth-child(4), .quote-line-item-header span:nth-child(5) {
  text-align: right;
}
.quote-total-row {
  display: flex; justify-content: flex-end; gap: 14px; align-items: baseline;
  font-family: var(--font-display); font-size: 18px; margin: 10px 0 18px; padding-top: 10px;
  border-top: 1px solid var(--border);
}
.quote-total-row span:first-child { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-family: var(--font-body); }

.price-book-row {
  display: grid; grid-template-columns: 1fr 110px 28px; gap: 8px; align-items: center;
}
.price-book-header {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted);
  padding: 0 0 4px;
}
.price-book-header span:nth-child(2) { text-align: right; }

@media (max-width: 720px) {
  .quote-line-item-row, .price-book-row { grid-template-columns: 1fr; }
  .quote-line-item-header, .price-book-header { display: none; }
}

.ticket-thread {
  display: flex; flex-direction: column; gap: 10px; max-height: 44vh; overflow-y: auto;
  margin-bottom: 14px; padding-right: 2px;
}
.ticket-message {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 13.5px; line-height: 1.5;
}
.ticket-message.author-admin { border-color: var(--accent-dim); background: #16261c; }
.ticket-message .msg-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-family: var(--font-mono); }
.ticket-message .msg-body { white-space: pre-wrap; }

/* Login page */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 20px; position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 18% 20%, #42b3552e, transparent 42%),
    radial-gradient(circle at 84% 78%, #8bc34b24, transparent 40%),
    radial-gradient(circle at 50% 100%, #42b35514, transparent 55%),
    var(--bg);
}
.login-wrap::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0;
  background-image: radial-gradient(circle, #ffffff10 1px, transparent 1px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 38%, black, transparent);
          mask-image: radial-gradient(ellipse 70% 55% at 50% 38%, black, transparent);
}
.login-card {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, #1b2030f2, #171b24f2);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 20px;
  width: 100%; max-width: 380px; padding: 40px 32px 34px;
  box-shadow: 0 0 0 1px #ffffff0a inset, 0 30px 70px -24px #000c, 0 0 90px -30px var(--accent);
  animation: login-card-in .5s cubic-bezier(.16,1,.3,1);
}
@keyframes login-card-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-brand {
  flex-direction: column; align-items: center; text-align: center;
  gap: 14px; margin-bottom: 28px;
}
.login-brand .brand-mark {
  width: 54px; height: 54px; border-radius: 15px;
  box-shadow: 0 0 0 1px var(--border), 0 12px 28px -10px var(--accent), 0 0 0 0 var(--accent-dim);
  animation: login-glow-pulse 3.2s ease-in-out infinite;
}
@keyframes login-glow-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--border), 0 12px 28px -10px var(--accent), 0 0 30px -12px var(--accent); }
  50%      { box-shadow: 0 0 0 1px var(--border), 0 14px 32px -8px var(--accent), 0 0 46px -8px var(--accent); }
}
.login-brand h1 {
  font-size: 22px;
  background: linear-gradient(135deg, #ffffff, #c7e8cd 60%, #8bd39c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-brand .subtitle { font-size: 13.5px; margin-top: 4px; }

.login-card form label { margin-bottom: 16px; font-weight: 500; letter-spacing: .01em; color: #b3c2b6; }
.login-card form input {
  background: #0d0f16; border: 1px solid var(--border); padding: 12px 14px; font-size: 14.5px;
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.login-card form input:hover { border-color: #3c4459; }
.login-card form input:focus {
  outline: none; border-color: var(--accent); background: #10131a;
  box-shadow: 0 0 0 3px var(--accent-dim);
}
.login-card .btn-primary {
  margin-top: 6px; padding: 12px 16px; font-size: 14.5px; font-weight: 600; letter-spacing: .01em;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 10px 24px -8px var(--accent);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
}
.login-card .btn-primary:hover { filter: brightness(1.1); box-shadow: 0 12px 28px -6px var(--accent); }
.login-card .btn-primary:active { transform: scale(0.98); }

.login-error {
  color: var(--red); background: var(--red-dim); border: 1px solid #ff676744;
  border-radius: 9px; padding: 10px 12px; font-size: 13px; margin: 0 0 16px;
  display: flex; align-items: center; gap: 8px;
}
.login-footer {
  text-align: center; margin-top: 24px; font-size: 11.5px; color: var(--text-muted);
  letter-spacing: .02em;
}

@media (prefers-reduced-motion: reduce) {
  .login-card, .login-brand .brand-mark { animation: none; }
}

.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 20px; font-size: 13px; z-index: 200;
}

@media (prefers-reduced-motion: reduce) {
  .status-dot { animation: none !important; }
}

/* Phones and small tablets (iPhone portrait, iPad Mini portrait, etc.) */
@media (max-width: 640px) {
  .topbar-inner { flex-wrap: wrap; padding: 16px; gap: 12px; }
  .brand h1 { font-size: 17px; }
  .subtitle { font-size: 12px; }
  .container { padding: 20px 16px 60px; }
  section { margin-bottom: 32px; }
  .client-grid { grid-template-columns: 1fr; }
  .client-actions .btn { flex: 1 1 auto; }
  .modal { padding: 18px 18px 20px; }
  .modal-actions { flex-wrap: wrap-reverse; }
  .modal-actions .btn { flex: 1 1 auto; }

  /* Denser tables - more columns fit before the row needs to scroll */
  .activity-table th, .activity-table td { padding: 10px 10px; font-size: 12.5px; }

  /* Section-head controls (filters, page-size, refresh/import buttons) can
     get cramped stacked next to the heading - let them take the full row. */
  .section-head select, .section-head .btn { flex: 1 1 auto; }
  .section-head h2, .section-head .count-pill { flex: 0 0 auto; }

  .deal-edit-grid { gap: 0; }
  .report-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .report-goals-form { grid-template-columns: 1fr 1fr; }
  .deal-detail-columns { gap: 24px; }
}

/* iPad portrait and similar mid-width tablets */
@media (min-width: 641px) and (max-width: 900px) {
  .client-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}
