:root {
  --bg: #e9edf3; --panel: #f0f3f7; --white: #fff; --bd: #b9c2ce; --bd2: #cfd6df;
  --ink: #1f2937; --legend: #2f7d64; --label: #2f7d64; --tabbg: #dde3ec; --tabink: #2b3440;
  --accent: #7a1f2b; --alert: #cf222e; --warn: #9a6700;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: "Segoe UI", Tahoma, Arial, sans-serif; font-size: 13px;
}
.app { display: flex; flex-direction: column; height: 100vh; }

/* top tab strip */
.tabstrip {
  display: flex; gap: 2px; padding: 6px 8px 0; background: var(--bg);
  border-bottom: 1px solid var(--bd); overflow-x: auto;
}
.tab {
  border: 1px solid var(--bd2); border-bottom: none; background: var(--tabbg);
  color: var(--tabink); font-weight: 700; font-size: 13px; padding: 8px 16px;
  border-radius: 6px 6px 0 0; cursor: pointer; white-space: nowrap;
}
.tab:hover { background: #edf2f8; }
.tab.active { background: var(--white); color: #0f172a; }

.body { flex: 1; display: flex; min-height: 0; }

/* left rail */
.leftrail { width: 210px; padding: 8px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.leftrail label { display: block; color: var(--label); margin: 6px 0 2px; }
.leftrail input, .leftrail select { width: 100%; }

/* titled group == Tkinter LabelFrame */
.lf { border: 1px solid var(--bd); border-radius: 3px; padding: 8px; margin: 0; background: transparent; }
.lf > legend { color: var(--legend); font-weight: 600; padding: 0 4px; }
.lf label { color: var(--label); }

input, select {
  font: inherit; padding: 3px 5px; border: 1px solid var(--bd); border-radius: 2px; background: var(--white);
}
.btn {
  display: block; width: 100%; text-align: center; padding: 5px 8px; margin: 4px 0;
  border: 1px solid var(--bd); border-radius: 3px; background: #f7f9fb; color: var(--accent);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: #eef2f7; }
.btn.accent { color: var(--accent); }

/* main screens */
.screens { flex: 1; padding: 10px 12px; overflow: auto; min-width: 0; }
.screen { display: none; }
.screen.active { display: block; }
.screen.placeholder { color: #6b7280; padding: 2rem; }
.section { font-size: 15px; font-weight: 700; color: #111827; margin: 6px 0 6px; }
.src { font-size: 12px; font-weight: 400; color: #6b7280; margin-left: 12px; }

.mvrrecord {
  background: var(--white); border: 1px solid var(--bd2); border-radius: 2px; margin: 0;
  font-family: "Courier New", monospace; font-size: 12px; padding: 8px; min-height: 210px;
  white-space: pre; overflow-x: auto;
}

.insurance-row { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 10px; }
.lf.details { min-width: 240px; }
.lf.details .pair { display: flex; gap: 8px; }
.lf.details input { margin-bottom: 6px; }
.lf.grow { flex: 1; }

/* tables */
.tablewrap { overflow: auto; border: 1px solid var(--bd2); background: var(--white); }
.tablewrap.short { max-height: 110px; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { border: 1px solid var(--bd2); padding: 3px 6px; text-align: left; white-space: nowrap; }
th { background: var(--panel); font-weight: 600; }
tr.flag td { background: #fbe9e9; }
.pill { font-size: 11px; padding: .02rem .35rem; border-radius: 7px; }
.pill.tp { background: #eef3ff; color: #0969da; }
.flags { color: var(--alert); font-weight: 600; }

/* sub-tabs (Convictions / Claims / Policy History) */
.subtabs { margin-top: 6px; }
.subtab-strip { display: flex; gap: 2px; }
.subtab {
  border: 1px solid var(--bd2); border-bottom: none; background: var(--tabbg); color: var(--tabink);
  padding: 5px 12px; border-radius: 5px 5px 0 0; cursor: pointer; font: inherit;
}
.subtab.active { background: var(--white); }
.subpanel { display: none; border: 1px solid var(--bd2); background: var(--white); padding: 6px; }
.subpanel.active { display: block; }
.mono { font-family: "Courier New", monospace; font-size: 12px; margin: 0; white-space: pre; overflow-x: auto; min-height: 80px; }

.statusbar { border-top: 1px solid var(--bd); padding: 4px 10px; color: #374151; background: var(--panel); font-size: 12px; }
.status-err { color: var(--alert); }

/* ---- CQ form screens (Quote Information / Vehicles / Drivers) ---- */
.cqscreen { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.cqcol { display: flex; flex-direction: column; gap: 6px; }
.cqheader { background: #8f8f8f; color: #fff; padding: 3px 6px; font-size: 12px; font-weight: 600; border-radius: 2px; }
.cqscreen fieldset.lf { margin-bottom: 6px; }
.cqscreen legend { color: #333; }
.frow { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.f { display: flex; flex-direction: column; }
.f label { color: var(--label); margin: 2px 0; font-size: 12px; }
.f input, .f select { min-width: 80px; }
.f.w-sm input { width: 70px; } .f.w-md input { width: 130px; } .f.w-lg input { flex: 1; min-width: 220px; }
.opts { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; padding: 2px 0; }
.opts label { display: inline-flex; gap: 4px; align-items: center; color: var(--ink); }
.cqtabsel { display: flex; gap: 0; margin-bottom: 6px; }
.cqtabsel .t { border: 1px solid var(--bd2); background: #fff; padding: 3px 10px; font-size: 12px; }
.cqtabsel .t.sel { border-bottom: 2px solid var(--accent); font-weight: 600; }

/* ---- modal dialogs (port of the Tkinter Toplevel popups) ---- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .38);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.modal {
  background: var(--bg); border: 1px solid #8a95a3; border-radius: 3px;
  box-shadow: 0 12px 44px rgba(0, 0, 0, .4);
  display: flex; flex-direction: column; max-width: 94vw; max-height: 92vh;
}
.modal-title {
  background: var(--tabbg); border-bottom: 1px solid var(--bd);
  padding: 7px 12px; font-weight: 700; color: #0f172a;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.modal-title .x { cursor: pointer; border: none; background: none; font-size: 16px; line-height: 1; color: #475569; padding: 0 2px; }
.modal-title .x:hover { color: var(--alert); }
.modal-body { padding: 12px; overflow: auto; }
.modal-foot { padding: 8px 12px; border-top: 1px solid var(--bd); display: flex; justify-content: flex-end; gap: 8px; }
.modal-foot .btn { width: auto; display: inline-block; min-width: 74px; margin: 0; }
.modal .cols { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.modal .grid2 { display: grid; grid-template-columns: auto auto; gap: 4px 10px; align-items: center; }
.modal .grid2 label { color: var(--label); font-size: 12px; }
#claimsTable tbody tr { cursor: pointer; }
#claimsTable tbody tr:hover td { background: #eef3ff; }
/* selectable entry rows inside the Claims popup */
#clEntries tbody tr { cursor: pointer; }
#clEntries tbody tr:hover td { background: #eef3ff; }
#clEntries tbody tr.selrow td { background: #dbe7ff; font-weight: 600; }
.muted { color: #6b7280; font-size: 12px; }

/* fields we'd normally fill from the parse but couldn't (data missing from the
   report) — flagged very light red so the broker knows to enter them by hand */
input.gap, select.gap { background: #fdecec !important; }
/* fields we estimated (e.g. G date = G1 + 2 yrs) — light amber, needs the
   broker to confirm the real value with the client */
input.estimate, select.estimate { background: #fff3cd !important; }
/* prominent warning banner for the conservative licence-date assumption */
.flagbanner { background: #fff3cd; border: 1px solid #e0b400; color: #7a5b00;
  border-radius: 4px; padding: 7px 10px; margin: 0 0 8px; font-size: 12px; line-height: 1.4; }
.flagbanner b { color: #8a4b00; }
