
:root {
  --royal: #4169E1;
  --ink: #0f172a;
  --bg: #f8fafc;
  --card: #ffffff;
  --muted: #64748b;
}
* { box-sizing: border-box; }
body { margin:0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial; background: var(--bg); color: var(--ink); }
/* Top bar in three parts: logo on the left, the page links as one centred group,
   Admin and Account on the right. The group keeps natural spacing on any screen:
   it never stretches on a wide monitor and tightens, then drops to its own row,
   as the screen narrows. */
.topbar {
  display: grid; grid-template-columns: minmax(max-content, 1fr) auto minmax(max-content, 1fr);
  align-items: center; column-gap: 20px; padding: 10px 24px;
  background: var(--card); border-bottom: 3px solid var(--royal);
}
.topbar .brand { justify-self: start; }
.topbar nav { display: flex; align-items: center; justify-content: center; gap: clamp(0px, .55vw, 10px); margin: 0; }
.topbar .nav-side { display: flex; align-items: center; justify-self: end; gap: 2px; }
.topbar nav a, .topbar .nav-dropdown-toggle, .topbar .nav-side > a {
  margin: 0; padding: 7px 12px; border-radius: 8px; font-size: 14.5px; font-weight: 500;
  color: #334155; white-space: nowrap; text-decoration: none;
}
.topbar .nav-side > a.nav-admin { color: #d97706; }
.topbar nav a:hover, .topbar .nav-dropdown-toggle:hover, .topbar .nav-side > a:hover { background: #f1f5f9; }
.topbar a.nav-current, .topbar .nav-dropdown-toggle.nav-current { background: #eef2ff; color: var(--royal); font-weight: 600; }
.topbar .nav-dropdown-menu a { padding: 10px 16px; border-radius: 0; font-weight: 400; color: var(--ink); }
.topbar .nav-side .nav-dropdown-menu { left: auto; right: 0; }
@media (max-width: 1400px) {
  .topbar { column-gap: 12px; padding: 10px 16px; }
  .topbar nav { gap: 0; }
  .topbar nav a, .topbar .nav-dropdown-toggle, .topbar .nav-side > a { padding: 6px 8px; font-size: 14px; }
}
@media (max-width: 1120px) {
  .topbar { grid-template-columns: 1fr auto; row-gap: 6px; }
  .topbar nav { grid-column: 1 / -1; grid-row: 2; flex-wrap: wrap; justify-content: flex-start; }
}
.brand { font-weight: 800; font-size: 20px; } .brand .plus { color: var(--royal); }
nav a { margin-left:12px; text-decoration:none; color: var(--ink); padding:6px 10px; border-radius: 10px; }
nav a:hover { background: #eef2ff; }
.container { max-width: 1080px; margin: 20px auto; padding: 0 16px; }
.container.container-wide { max-width: 98vw; }
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: 0 6px 20px rgba(0,0,0,.06); margin-bottom: 16px; }
.grid { display:grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.stat .k { color: var(--muted); font-size: 12px; } .stat .v { font-size: 36px; font-weight: 800; }
.table-wrapper { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.tbl { width:100%; border-collapse: separate; border-spacing: 0 8px; min-width: 800px; }
.tbl th { text-align:left; padding:12px 16px; border-bottom: 2px solid #e2e8f0; background: #f8fafc; white-space: nowrap; }
.tbl td { text-align:left; padding:14px 16px; }
.tbl tbody tr { border-radius: 12px; transition: transform 0.15s ease, box-shadow 0.15s ease; }
.tbl tbody tr:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
form label { display:block; margin: 10px 0; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], textarea, select { width:100%; padding:10px; border: 1px solid #e2e8f0; border-radius: 10px; font-family: inherit; font-size: inherit; }
textarea { resize: vertical; min-height: 80px; }
input[type="file"] { padding:8px; background:#fff; border-radius: 10px; border:1px solid #e2e8f0; }
button { background: var(--royal); color:#fff; border:0; padding:10px 14px; border-radius: 12px; cursor:pointer; }
.client-link { color: var(--royal); text-decoration: none; font-weight: 700; padding: 6px 12px; border-radius: 8px; background: rgba(79, 70, 229, 0.15); transition: all 0.2s ease; display: inline-block; font-size: 15px; }
.client-link:hover { background: rgba(79, 70, 229, 0.25); transform: translateY(-1px); box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2); }
.btn { color: white; background: linear-gradient(135deg, var(--royal) 0%, #6366f1 100%); text-decoration: none; padding: 6px 14px; border-radius: 10px; font-weight: 500; font-size: 13px; transition: all 0.2s ease; display: inline-block; box-shadow: 0 2px 6px rgba(79, 70, 229, 0.3); }
.btn:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(79, 70, 229, 0.4); }
.flashes { list-style:none; padding:0; }
.flash { padding:10px; border-radius: 10px; margin: 10px 0; }
.f-success { background:#dcfce7; } .f-error { background:#fee2e2; } .f-info { background:#dbeafe; }
.tip { color: var(--muted); font-size: 13px; }

/* Stage color coding - light shades */
.stage-uncontacted { background-color: #fee2e2; }
.stage-quoted { background-color: #fee2e2; }
.stage-awaiting-terms { background-color: #fef3c7; }
.stage-pre-rnl-sent { background-color: #dbeafe; }
.stage-sent-to-insurer { background-color: #e0e7ff; }
.stage-awaiting-client-declaration { background-color: #fce7f3; }
.stage-more-info-required { background-color: #fed7aa; }
.stage-awaiting-client-reply { background-color: #fed7aa; }
.stage-client-dec-proposal-outstanding { background-color: #cffafe; }
.stage-in-progress---referred { background-color: #fef3c7; }
.stage-in-progress---one-half { background-color: #e8d5b7; }
.stage-in-progress---remarket { background-color: #ddd6fe; }
.stage-ready-for-processing { background-color: #dcfce7; }
.stage-completed { background-color: #d1d5db; }
.stage-badge { font-size: 11px; padding: 4px 8px; border-radius: 6px; background: rgba(0,0,0,0.05); font-weight: 500; }

/* Gantt Chart Styles */
.gantt-container { margin-top: 20px; }
.gantt-header, .gantt-row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid #e2e8f0; }
.gantt-header { font-weight: 600; background: #f1f5f9; padding: 10px 0; position: sticky; top: 0; z-index: 10; }
.gantt-row { min-height: 60px; align-items: center; }
.gantt-labels { padding: 8px 12px; border-right: 2px solid #e2e8f0; }
.gantt-timeline { position: relative; padding: 8px 12px; }
.gantt-bar { position: absolute; top: 50%; transform: translateY(-50%); width: 4px; height: 30px; background: var(--royal); border-radius: 4px; cursor: pointer; transition: all 0.2s; }
.gantt-bar:hover { transform: translateY(-50%) scale(1.2); box-shadow: 0 4px 12px rgba(0,0,0,0.2); }
.gantt-event { position: absolute; top: 50%; transform: translateY(-50%); display: flex; flex-direction: column; align-items: center; cursor: pointer; transition: all 0.2s; }
.event-marker { font-size: 24px; line-height: 1; }
.event-info { display: none; position: absolute; top: 100%; margin-top: 8px; background: white; border: 1px solid #e2e8f0; border-radius: 6px; padding: 8px 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); white-space: nowrap; z-index: 20; }
.gantt-event:hover .event-info { display: flex; flex-direction: column; gap: 4px; }
.event-info span { font-size: 12px; }
.event-date { font-weight: 600; color: var(--royal); }
.event-note { color: #64748b; font-style: italic; }
.event-row { background: #fafafa; }
.bar-link { text-decoration: none; color: inherit; display: block; }
.bar-content { position: absolute; left: 6px; top: 0; white-space: nowrap; font-size: 11px; }
.bar-date { font-weight: 600; }
.bar-days { margin-left: 8px; color: var(--muted); }
.today-marker { position: absolute; top: -10px; bottom: -10px; width: 2px; background: #ef4444; z-index: 5; }
.today-label { position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: 10px; font-weight: 600; color: #ef4444; white-space: nowrap; }
.date-markers { position: absolute; top: -8px; left: 0; right: 0; font-size: 11px; color: var(--muted); }
.date-markers span { position: absolute; }
.policy-info { font-size: 13px; }
.policy-num { font-size: 11px; color: var(--muted); }
.policy-class { font-size: 11px; color: var(--royal); font-weight: 600; }
.legend-item { padding: 6px 12px; border-radius: 6px; font-size: 12px; display: inline-block; }

/* Archive Income Comparison Styles */
.archive-tbl .num { text-align: right; }
.delta-pos { color: #16a34a; font-weight: 600; }
.delta-neg { color: #dc2626; font-weight: 600; }
.delta-neu { color: #6b7280; }
.delta-pct { font-size: 11px; font-weight: 400; margin-left: 4px; }
.status-badge { font-size: 11px; padding: 5px 10px; border-radius: 6px; font-weight: 600; display: inline-block; }
.status-renewed { background: #dcfce7; color: #166534; }
.status-cancelled { background: #fee2e2; color: #991b1b; }
.status-new-business { background: #dbeafe; color: #1e40af; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Helper styles */
.row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.row.space-between { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.badge { padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; background: #e0e7ff; color: #4338ca; display: inline-block; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.num { text-align: right; }

/* Kanban Board Styles */
.kanban { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-top: 20px; }
.kanban .col { background: #f8fafc; border-radius: 12px; display: flex; flex-direction: column; }
.col-head { padding: 12px; border-bottom: 2px solid #e2e8f0; }
.col-head .title { font-weight: 700; font-size: 14px; margin-bottom: 4px; }
.col-head .total { color: var(--royal); font-weight: 600; font-size: 13px; }
.col-body { padding: 8px; flex: 1; min-height: 400px; }
.card-kanban { background: white; padding: 12px; border-radius: 10px; margin-bottom: 8px; cursor: grab; box-shadow: 0 2px 4px rgba(0,0,0,0.08); transition: all 0.2s; }
.card-kanban:active { cursor: grabbing; }
.card-kanban:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.kclient { font-weight: 700; color: var(--royal); margin-bottom: 6px; font-size: 13px; }
.ktext { font-size: 12px; margin-bottom: 8px; color: var(--ink); }
.kmeta { font-size: 11px; color: var(--muted); margin-bottom: 10px; }
.empty { text-align: center; color: var(--muted); padding: 20px; font-size: 12px; }

/* Incumbent Quote Styling */
.incumbent-quote { background-color: #fffbeb !important; border-left: 4px solid #f59e0b; }
.incumbent-quote td { font-weight: 500; }

/* Renewals Card — zero horizontal padding so table fills edge-to-edge */
.card-renewals { padding-left: 0 !important; padding-right: 0 !important; }
.card-renewals .renewals-inner { padding: 0 16px; }
.renewals-wrapper { overflow-x: auto; }
.renewals-tbl { table-layout: auto; width: 100% !important; min-width: 800px; }
.renewals-tbl td { padding: 10px 10px; font-size: 13px; }
.renewals-tbl th { padding: 10px 10px; font-size: 12px; white-space: nowrap; }
.renewals-tbl td:first-child, .renewals-tbl th:first-child { padding-left: 16px; }
.renewals-tbl td:last-child, .renewals-tbl th:last-child { padding-right: 16px; }
.renewals-tbl .client-link { font-size: 13px; padding: 3px 8px; }

/* Loading Spinner */
.spinner {
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--royal);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Sticky Return Button */
.return-btn-wrapper {
  position: sticky;
  top: 20px;
  z-index: 100;
  margin-bottom: 12px;
}

.return-btn {
  background: #64748b !important;
  display: inline-block;
}

/* Colorful Edit/Delete Buttons */
.btn-edit {
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%) !important;
  color: white;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  display: inline-block;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(59, 130, 246, 0.3);
}

.btn-edit:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-delete {
  background: linear-gradient(135deg, #ef4444 0%, #f97316 100%) !important;
  color: white;
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.btn-delete:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
}

/* Dropdown Navigation Styles */
.nav-dropdown {
  position: relative;
  display: inline-block;
}

.nav-dropdown-toggle {
  margin-left: 12px;
  text-decoration: none;
  color: var(--ink);
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.nav-dropdown-toggle:hover {
  background: #eef2ff;
}

.nav-dropdown-arrow {
  font-size: 10px;
  transition: transform 0.2s ease;
}

.nav-dropdown:hover .nav-dropdown-arrow {
  transform: rotate(180deg);
}

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background: white;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  min-width: 200px;
  padding: 8px 0;
  margin-top: 4px;
  z-index: 1000;
  display: none;
}

.nav-dropdown:hover .nav-dropdown-menu {
  display: block;
}

.nav-dropdown-menu a {
  display: block;
  padding: 10px 16px;
  color: var(--ink);
  text-decoration: none;
  margin: 0;
  transition: background 0.15s ease;
}

.nav-dropdown-menu a:hover {
  background: #eef2ff;
}

.nav-dropdown-separator {
  height: 1px;
  background: #e2e8f0;
  margin: 4px 0;
}

/* Ensure edit row takes full table width */

/* ================================================
   Quote Edit Form Styles - Clean 3-Column Layout
   ================================================ */

/* Table row containing the edit form - overlay approach */
tr.quote-edit-row {
  position: relative;
}

tr.quote-edit-row:hover {
  transform: none !important;
  box-shadow: none !important;
}

tr.quote-edit-row > td {
  padding: 0 !important;
  position: relative;
}

/* Modal-style popup that centers and takes full width */
tr.quote-edit-row > td > .quote-edit-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  width: 90%;
  max-width: 1000px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Dark overlay behind the modal */
tr.quote-edit-row::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(1px);
  z-index: 999;
}

/* The edit panel container */
.quote-edit-panel {
  display: block;
  width: 100%;
  max-width: 100%;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px 24px;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.quote-edit-panel h4 {
  margin: 0 0 16px 0;
  color: #1e293b;
  font-size: 1rem;
  font-weight: 600;
}

/* 3-column grid for form fields */
.quote-edit-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px 20px;
  width: 100%;
}

/* Individual field wrapper */
.quote-edit-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quote-edit-field span {
  font-weight: 500;
  font-size: 0.85rem;
  color: #475569;
}

.quote-edit-field input,
.quote-edit-field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  background: #fff;
  color: #1e293b;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.quote-edit-field input:focus,
.quote-edit-field textarea:focus {
  outline: none;
  border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.quote-edit-field input::placeholder {
  color: #9ca3af;
}

/* Checkboxes section */
.quote-edit-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e5e7eb;
}

.quote-edit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.9rem;
}

.quote-edit-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Action buttons */
.quote-edit-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.quote-edit-actions button {
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.quote-edit-actions .btn-save {
  background: #4f46e5;
  color: white;
}

.quote-edit-actions .btn-save:hover {
  background: #4338ca;
}

.quote-edit-actions .btn-cancel {
  background: #6b7280;
  color: white;
}

.quote-edit-actions .btn-cancel:hover {
  background: #4b5563;
}

/* Responsive: 2 columns on tablet */
@media (max-width: 900px) {
  .quote-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Responsive: 1 column on mobile */
@media (max-width: 600px) {
  .quote-edit-grid {
    grid-template-columns: 1fr;
  }
  
  .quote-edit-panel {
    padding: 16px;
  }
  
  .quote-edit-checkboxes {
    gap: 16px;
  }
}

/* Full-width field for spanning all columns */
.quote-edit-field.full-width {
  grid-column: 1 / -1;
}

.quote-edit-field.full-width input,
.quote-edit-field.full-width textarea {
  width: 100%;
}

.drop-zone {
  border: 2px dashed #d1d5db;
  border-radius: 10px;
  padding: 1.5rem;
  text-align: center;
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: #6366f1;
  background: #eef2ff;
}
.drop-zone.drag-over {
  border-style: solid;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.drop-zone.has-file {
  border-color: #10b981;
  background: #ecfdf5;
}
.drop-zone-file {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #059669;
}
.drop-zone-file .remove-file {
  color: #ef4444;
  cursor: pointer;
  font-weight: 700;
  margin-left: 0.25rem;
  font-size: 1rem;
}

/* ── HTMX indicator ─────────────────────────────────────── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }

/* ── Risk / extraction detail display (archive & web views) ─ */
.rpt-tbl { border-collapse: collapse; width: 100%; font-size: 13px; margin-bottom: 8px; }
.rpt-tbl thead th { background: #374151; color: #fff; padding: 7px 10px; text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap; }
.rpt-tbl thead th.num { text-align: right; }
.rpt-tbl tbody td { padding: 6px 10px; border-bottom: 1px solid #e5e7eb; font-size: 13px; vertical-align: top; }
.rpt-tbl tbody td.num { text-align: right; }
.rpt-tbl tbody tr:nth-child(even) { background: #f9fafb; }
.info-grid { border-collapse: collapse; width: 100%; }
.info-grid td.lbl { font-weight: 600; font-size: 12px; color: #6b7280; padding: 4px 10px 4px 0; width: 38%; vertical-align: top; }
.info-grid td.val { padding: 4px 0; font-size: 13px; }
.sec-hdr { font-size: 14px; font-weight: 700; color: #fff; background: #1e3a5f; padding: 8px 14px; border-radius: 6px; margin: 18px 0 10px 0; border-left: 4px solid #7c3aed; }
.two-col { width: 100%; border-collapse: collapse; }
.two-col > tbody > tr > td { vertical-align: top; width: 50%; padding-right: 12px; }
.no-data { color: #6b7280; font-style: italic; font-size: 13px; padding: 6px 0; }

/* Quote preference is shared record data, including completed/archive views. */
tr[data-preferred="Y"] > td {
  background: #f0fdf4 !important;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
tr[data-preferred="Y"] > td:first-child {
  box-shadow: inset 3px 0 0 #16a34a;
}
.quote-preferred-label {
  display: inline-block;
  margin-left: 4px;
  color: #15803d;
  font-size: 0.8em;
  font-weight: 600;
}
