/*
  Design system aligned to the Insurely "Tester Program" dashboard and the
  @insurely/ui tokens. Brand fonts (Insurely Sans, Gelica), brand green, the
  dashboard palette and component shapes (pill chips/badges, flat cards, a
  data table). Re-theme from the tokens block. Fonts live in /public/fonts.
*/

@font-face {
  font-family: "Insurely Sans";
  src: url("/fonts/InsurelySans-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Insurely Sans";
  src: url("/fonts/InsurelySans-Semibold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Gelica";
  src: url("/fonts/Gelica-Light.woff2") format("woff2");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Gelica";
  src: url("/fonts/Gelica-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

:root {
  --bg: #f6f7f6;
  --surface: #ffffff;
  --text: #213123;
  --muted: #606060;
  --muted-2: #9f9f9f;
  --border: #eaeaea;
  --border-strong: #dedede;
  --primary: #00824c;
  --primary-hover: #005f37;
  --primary-contrast: #ffffff;

  --green-bg: #daf4dd;
  --green-text: #005f37;
  --blue-bg: #e7f0fb;
  --blue-text: #1a5fb4;
  --purple-bg: #ece4fb;
  --purple-text: #5b3fa6;
  --amber-bg: #fbedcf;
  --amber-text: #8a6100;
  --red-bg: #fdecec;
  --red-text: #c01a12;

  --radius: 12px;
  --radius-sm: 8px;
  --pill: 1000px;
  --shadow: 0 1px 2px rgba(33, 49, 35, 0.04);
}

* {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

html,
body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: "Insurely Sans", -apple-system, system-ui, sans-serif;
  font-weight: 500;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.5;
}

input,
select,
button,
textarea {
  font-family: inherit;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

h1,
h2,
.display {
  font-family: "Gelica", Georgia, serif;
  font-weight: 400;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 26px;
  margin-bottom: 6px;
}
h2 {
  font-size: 19px;
  margin-bottom: 14px;
}
.subtitle {
  color: var(--muted);
  margin-bottom: 20px;
}

/* ---- App chrome ---- */

.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
}
.appbar-inner {
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.brand-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.brand-link:hover {
  text-decoration: none;
}
.brand {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--text);
}
.brand-divider {
  width: 1px;
  height: 18px;
  background: var(--border-strong);
  margin: 0 4px;
}
.brand-tag {
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
}
/* Internal-console nav in the app bar (Payments / Tester Details). */
.appnav {
  display: flex;
  gap: 4px;
}
.appnav-link {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-radius: var(--pill);
}
.appnav-link:hover {
  color: var(--text);
  text-decoration: none;
}
.appnav-link.active {
  color: var(--text);
  background: var(--bg);
}

/* ---- Layout ---- */

.container {
  max-width: 1040px;
  margin: 32px auto;
  padding: 0 20px;
}
/* The Tester Details registry table has many columns; give it more room. */
.container-wide {
  max-width: 1440px;
}
.center-narrow {
  max-width: 520px;
  margin: 56px auto;
  padding: 0 20px;
}

/* ---- Tabs ---- */

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}
.tab {
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab.active {
  color: var(--text);
  border-bottom-color: var(--primary);
}
.tab.future {
  color: var(--muted-2);
  cursor: default;
}

/* ---- Filter chips ---- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 22px;
}
.chip {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  border-radius: var(--pill);
  background: var(--surface);
  color: var(--muted);
}
.chip.active {
  border-color: var(--text);
  color: var(--text);
}
.chip {
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s;
}
.chip:hover {
  border-color: var(--text);
}

/* ---- Toolbar (search + status filter) ---- */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.toolbar-search {
  display: flex;
  gap: 8px;
  flex: 1 1 280px;
}
.toolbar-search .input {
  flex: 1;
}
.toolbar-select {
  flex: 0 0 auto;
  width: auto;
}

/* ---- Pager ---- */

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin: 16px 0 8px;
}
.pager-info {
  font-size: 13px;
  color: var(--muted);
}

/* ---- Clickable tester name ---- */

.name-link {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.name-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* ---- Detail modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 49, 35, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 28px;
  width: 100%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(33, 49, 35, 0.22);
}
.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: 0;
  font-size: 24px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.detail-section {
  margin-top: 18px;
}
.detail-section h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.detail-value {
  font-weight: 600;
  text-align: right;
  word-break: break-word;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 28px; /* clear the close button */
}
.edit-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

/* ---- Read-only agreed-amount callout on the pay form ---- */

.amount-callout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  background: var(--green-bg);
  color: var(--green-text);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
}
.amount-callout strong {
  font-size: 18px;
}

/* ---- Stat cards ---- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 26px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.stat-num {
  font-family: "Gelica", Georgia, serif;
  font-size: 32px;
  line-height: 1.1;
  color: var(--text);
}
.stat-label {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
/* Attention-drawing stat value (e.g. agreements expiring soon). */
.stat-num-alert {
  color: var(--red-text);
}

/* ---- Card ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
  overflow: hidden;
}
.card-accent {
  height: 3px;
  background: var(--primary);
  margin: -28px -28px 24px;
}

/* ---- Forms ---- */

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
}
.input {
  width: 100%;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.input:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(33, 49, 35, 0.08);
}
.input::placeholder {
  color: var(--muted-2);
}
.hint {
  font-size: 13px;
  color: var(--muted);
  margin-top: 6px;
}
/* Per-send attachments in the compose modals. */
.attachment-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.attachment-list li {
  display: flex;
  align-items: center;
  font-size: 14px;
}
.attachment-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 420px;
}
/* Inline checkbox group (car coverage on the tester forms). */
.checkline {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 11px 0;
}
.checkline-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.row > * {
  flex: 1;
  min-width: 160px;
}

/* ---- Buttons ---- */

.btn {
  display: inline-block;
  padding: 10px 18px;
  font-size: 15px;
  font-weight: 600;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--primary);
  color: var(--primary-contrast);
  transition: background 0.12s;
}
.btn:hover {
  background: var(--primary-hover);
  text-decoration: none;
}
.btn:disabled {
  opacity: 0.6;
  cursor: default;
}
.btn-full {
  width: 100%;
}
.btn-pill {
  border-radius: var(--pill);
}
/* Inline, low-emphasis action (e.g. row actions in a table). */
.btn-link {
  padding: 4px 6px;
  background: transparent;
  color: var(--primary);
  font-size: 14px;
}
.btn-link:hover {
  background: transparent;
  text-decoration: underline;
}
.btn-danger {
  color: var(--red-text);
  margin-left: 6px;
}
.btn-danger:hover {
  color: var(--red-text);
}

/* ---- Alerts ---- */

.alert {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
}
.alert-error {
  background: var(--red-bg);
  border-color: #f3c9c7;
  color: var(--red-text);
}
.alert-success {
  background: var(--green-bg);
  border-color: #bfe2c5;
  color: var(--green-text);
}

/* ---- Trust note ---- */

.trust {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: 18px;
}

/* ---- Table ---- */

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
}
.table th,
.table td {
  text-align: left;
  padding: 13px 16px;
  font-size: 14px;
}
.table thead th {
  background: #fbfbfb;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.table tbody tr + tr td {
  border-top: 1px solid var(--border);
}
.table tbody tr:hover td {
  background: #fbfbfb;
}
/* Wide registry table: scroll inside the card, never the page. */
.table-wrap-scroll {
  overflow-x: auto;
}
.table-wrap-scroll .table th,
.table-wrap-scroll .table td {
  white-space: nowrap;
}
/* Pinned trailing cell (row actions) — stays visible while the wide table
   scrolls horizontally, so Email/Edit can't disappear off-screen. */
.table-wrap-scroll th.sticky-right,
.table-wrap-scroll td.sticky-right {
  position: sticky;
  right: 0;
  background: var(--surface);
  box-shadow: -10px 0 10px -10px rgba(33, 49, 35, 0.25);
}
.table-wrap-scroll thead th.sticky-right {
  background: #fbfbfb;
}
.table-wrap-scroll tbody tr:hover td.sticky-right {
  background: #fbfbfb;
}
/* Sortable column headers */
.th-sort {
  cursor: pointer;
  user-select: none;
}
.th-sort:hover {
  color: var(--text);
}
.th-dir {
  margin-left: 4px;
}
/* Accounts cell (tester signups): one line per account type, its providers
   muted after it. Flat (pre-grouping) rows stack their two strings instead. */
.account-groups {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.account-group {
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.account-type {
  font-weight: 600;
}
.account-companies {
  color: var(--muted);
}
.account-groups-flat .account-type {
  font-weight: 500;
}
/* Account-type / provider filter dropdowns in the signups toolbar. */
.input-filter {
  width: auto;
  padding: 6px 30px 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--pill);
  color: var(--muted);
}
/* One account group in the signups modal: type, providers, remove. */
.account-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.account-edit-row .input:first-child {
  flex: 0 0 40%;
}
.account-edit-row .input {
  flex: 1;
  padding: 8px 10px;
  font-size: 14px;
}
.account-edit-hint {
  font-size: 13px;
  color: var(--muted);
  margin: -4px 0 10px;
}
/* Tag pills in a cell (car coverage) — one line, like the design. */
.taglist {
  display: inline-flex;
  gap: 4px;
  flex-wrap: nowrap;
}

/* ---- Renewals / Invoices sub-tabs ---- */

/* Banner explaining the renewals scope (expiring next month). */
.scope-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 22px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}
/* A <select> dressed as a status badge (renewal status column). */
.pill-select {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  outline: none;
  cursor: pointer;
  padding-right: 22px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='6'%3E%3Cpath d='M0 0l4 6 4-6z' fill='%23606060'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
/* Compact in-cell input (renewal notes, invoice due date). */
.input-slim {
  width: 150px;
  padding: 5px 9px;
  font-size: 12.5px;
  border-radius: 7px;
}
/* Row action: open the email compose modal. */
.btn-email {
  padding: 6px 13px;
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #c9dcef;
  background: var(--blue-bg);
  color: var(--blue-text);
  cursor: pointer;
}
/* Amount cell with the market's currency symbol (volume table). */
.money-cell {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  padding: 4px 9px;
  background: var(--surface);
  width: 110px;
}
.money-cell input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  padding: 0;
}
.money-sym {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted-2);
}
/* Computed, non-editable value in a form (Total GC amount). */
.readonly-box {
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  background: #fafafa;
  color: var(--text);
}

/* Neutral row action (the design's per-row Edit button). */
.btn-row {
  padding: 6px 13px;
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-row:hover {
  border-color: var(--text);
}

/* ---- Documents column (Tester Details registry) ---- */

.doclist {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-wrap: nowrap;
}
.doc-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 5px 3px 10px;
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 600;
  background: var(--blue-bg);
  color: var(--blue-text);
  max-width: 150px;
}
.doc-chip a {
  color: inherit;
  display: inline-block;
  /* min-width: 0 lets the flex item actually shrink, so long filenames get an
     ellipsis instead of being clipped to their tail. */
  min-width: 0;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-x {
  background: none;
  border: 0;
  padding: 0 2px;
  font-size: 14px;
  line-height: 1;
  color: var(--blue-text);
  cursor: pointer;
  flex: none;
}
.doc-upload {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  flex: none;
}
.doc-upload:hover {
  border-color: var(--text);
  color: var(--text);
}

/* ---- Inline cell editing (Tester Details registry) ---- */

/* The whole cell content is a click target; keep the cell's look. */
.cell-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  padding: 4px 6px;
  margin: -4px -6px;
  border-radius: var(--radius-sm);
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cell-btn:hover {
  background: #f0f2f0;
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* Fixed-position popover: escapes the table's horizontal scroll clipping. */
.pop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
}
.pop {
  position: fixed;
  z-index: 61;
  min-width: 200px;
  max-width: 280px;
  max-height: 320px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 32px rgba(33, 49, 35, 0.18);
  padding: 8px;
}
.pop-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.pop-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
}
.pop-option:hover {
  background: var(--bg);
}
.pop-option.active {
  background: var(--green-bg);
  color: var(--green-text);
}
.pop-option.pop-muted {
  color: var(--muted);
}
.pop-list {
  margin-top: 8px;
}
.pop-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* How many testers already carry the value. */
.pop-count {
  font-size: 12px;
  color: var(--muted-2);
}
.pop-hint {
  font-size: 13px;
  color: var(--muted);
  padding: 8px 10px;
}
.pop-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 4px;
}

/* ---- Status / market badges (pills) ---- */

.badge {
  display: inline-block;
  padding: 4px 11px;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--pill);
  background: #f0f0f0;
  color: var(--muted);
}
.badge-green {
  background: var(--green-bg);
  color: var(--green-text);
}
.badge-blue {
  background: var(--blue-bg);
  color: var(--blue-text);
}
.badge-purple {
  background: var(--purple-bg);
  color: var(--purple-text);
}
.badge-amber {
  background: var(--amber-bg);
  color: var(--amber-text);
}
.badge-red {
  background: var(--red-bg);
  color: var(--red-text);
}

.section-gap {
  margin-bottom: 28px;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

/* Funnel button in filterable column headers (Tester Details). */
.th-filter {
  background: none;
  border: 0;
  padding: 2px 3px;
  margin-left: 5px;
  cursor: pointer;
  color: #c5c5c5;
  vertical-align: middle;
  line-height: 0;
}
.th-filter:hover {
  color: var(--text);
}
.th-filter.active {
  color: var(--primary);
}

/* The Volume testers table has 16 columns; on a big monitor use the full
   width instead of clamping at 1440px (Anessa's feedback). */
.container-full {
  max-width: min(96vw, 2200px);
}
/* Long emails eat width the other columns need; clip with the full address
   in the tooltip. */
.cell-email {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
