:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #273449;
  --border: #334155;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --danger: #f87171;
  --success: #4ade80;
  --scrollbar-thumb: rgba(148, 163, 184, 0.28);
  --scrollbar-thumb-hover: rgba(56, 189, 248, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* Scrollbars                                                         */
/* ------------------------------------------------------------------ */

/* A slim, quiet scrollbar: transparent track, a soft muted pill for the thumb
   and the accent colour only while the thumb is hovered or dragged. Keeps the
   broker list, the wide tables and the settings modal from showing a heavy
   grey bar against the slate background. */

/* Chromium, Edge and Safari. */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner {
  background: transparent;
}

/* The 2px transparent border with background-clip insets the thumb, so the
   visible pill is narrower than the 10px gutter and never touches the edge. */
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
  border: 2px solid transparent;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
  background-clip: padding-box;
}

::-webkit-scrollbar-thumb:active {
  background: var(--accent);
  background-clip: padding-box;
}

/* Firefox has no scrollbar pseudo-elements. The -moz-appearance guard keeps
   these standard properties away from Chromium, where a non-initial
   scrollbar-width/scrollbar-color would override the rules above. */
@supports (-moz-appearance: none) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }
}

/* ------------------------------------------------------------------ */
/* Login                                                              */
/* ------------------------------------------------------------------ */

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}

.login-title {
  margin: 0 0 4px;
  font-size: 22px;
}

.login-subtitle {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.login-card label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

.login-card input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
}

.login-card input:focus {
  outline: none;
  border-color: var(--accent);
}

.login-card button {
  width: 100%;
  margin-top: 22px;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: var(--accent-strong);
  color: #06121f;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.login-card button:hover {
  background: var(--accent);
}

.remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 0;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.remember input {
  width: auto;
  margin: 0;
  accent-color: var(--accent-strong);
}

.msg {
  min-height: 20px;
  margin: 14px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.msg.error {
  color: var(--danger);
}

.msg.success {
  color: var(--success);
}

/* ------------------------------------------------------------------ */
/* App shell                                                          */
/* ------------------------------------------------------------------ */

.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
}

.userbox {
  display: flex;
  align-items: center;
  gap: 14px;
}

.lang-switcher {
  display: flex;
  gap: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-switcher button {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.lang-switcher button:hover {
  color: var(--text);
}

.lang-switcher button.active {
  background: var(--accent-strong);
  color: #06121f;
}

.login-card .lang-switcher {
  margin-bottom: 18px;
}

.username {
  color: var(--muted);
  font-size: 14px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  padding: 20px 24px;
  align-items: start;
}

/* ------------------------------------------------------------------ */
/* Sidebar                                                            */
/* ------------------------------------------------------------------ */

.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  position: sticky;
  top: 20px;
}

.sidebar h2 {
  margin: 0 0 12px;
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}

.sidebar input {
  width: 100%;
  padding: 9px 11px;
  margin-bottom: 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.sidebar input:focus {
  outline: none;
  border-color: var(--accent);
}

.broker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 62vh;
  overflow-y: auto;
}

.broker-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}

.broker-item:hover {
  background: var(--surface-2);
}

.broker-item.active {
  background: var(--surface-2);
  border-color: var(--accent);
}

.broker-item.muted {
  color: var(--muted);
  cursor: default;
}

.broker-name {
  font-weight: 600;
  font-size: 14px;
}

.broker-sub {
  font-size: 12px;
  color: var(--muted);
}

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

.content {
  min-width: 0;
}

.empty {
  padding: 40px;
  text-align: center;
  color: var(--muted);
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.detail {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.detail-head h2 {
  margin: 0 0 18px;
  font-size: 20px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.report-table th,
.report-table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.report-table thead th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.report-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.report-table tfoot th,
.report-table tfoot td {
  border-top: 2px solid var(--border);
  border-bottom: none;
  font-weight: 700;
}

.num.neg {
  color: var(--danger);
}

.num.pos {
  color: var(--success);
}

/* ------------------------------------------------------------------ */
/* Payment report (top of dashboard)                                   */
/* ------------------------------------------------------------------ */

.report {
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.report-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.report-head h2 {
  margin: 0;
  font-size: 16px;
}

.report-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.report-controls label {
  font-size: 13px;
  color: var(--muted);
}

.report-grid {
  display: grid;
  /* auto-fit so the row reflows cleanly now that it also holds expenses. */
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.report-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.report-item.report-total {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
}

/* Expenses are money going out, so they are flagged in red. */
.report-item.report-expenses {
  border-color: rgba(248, 113, 113, 0.35);
}

.report-expenses .report-value {
  color: var(--danger);
}

/* The bottom line after the period's expenses are taken off. */
.report-item.report-net-total {
  background: rgba(74, 222, 128, 0.12);
  border-color: rgba(74, 222, 128, 0.45);
}

.report-net-total .report-value {
  color: var(--success);
}

.report-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.3;
}

.report-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.report-msg {
  margin: 12px 0 0;
}

/* The whole cash-inflow block is a native <details>: clicking its title folds
   the figures away, with the keyboard and screen-reader behaviour the browser
   already provides. dashboard.js remembers the state that was chosen. */
.report-cashinflow {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

/* The title line is the toggle. The native triangle is replaced by a chevron
   so the title keeps the site's look (uppercase, muted, small). */
.report-cashinflow > summary {
  display: flex;
  width: fit-content;
  max-width: 100%;
  cursor: pointer;
  list-style: none;
  border-radius: 6px;
}

.report-cashinflow > summary::-webkit-details-marker {
  display: none;
}

.report-cashinflow > summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.report-cashinflow > summary:hover .report-subtitle {
  color: var(--text);
}

.report-cashinflow > summary .report-subtitle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.report-cashinflow:not([open]) > summary .report-subtitle {
  margin-bottom: 0;
}

/* A small triangle: it points down while the block is open and to the right
   once it is folded. */
.report-subtitle-chevron {
  flex: none;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.15s ease;
}

.report-cashinflow:not([open]) .report-subtitle-chevron {
  transform: rotate(-90deg);
}

.report-subtitle {
  margin: 0 0 12px;
  font-size: 14px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cashinflow-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.cashinflow-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.cashinflow-card.cashinflow-total {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.45);
  border-left-color: var(--accent);
}

.cashinflow-name {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.3;
  word-break: break-word;
}

.cashinflow-amount {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--success);
  word-break: break-word;
}

.cashinflow-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 10px;
  margin-top: 2px;
}

.cashinflow-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.cashinflow-stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

/* Every label carries a tooltip with the definition of its number; the dotted
   underline that advertises it only appears where hovering is possible. */
@media (hover: hover) and (pointer: fine) {
  .cashinflow-stat-label {
    cursor: help;
    border-bottom: 1px dotted rgba(148, 163, 184, 0.55);
    width: fit-content;
  }

  .cashinflow-stat-sort .cashinflow-stat-label {
    cursor: pointer;
  }
}

.cashinflow-stat-value {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}

.cashinflow-stat-sort {
  cursor: pointer;
  border-radius: 6px;
  padding: 4px 6px;
  margin: -4px -6px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.cashinflow-stat-sort:hover {
  background: rgba(56, 189, 248, 0.14);
}

.cashinflow-stat-sort.active {
  background: rgba(56, 189, 248, 0.12);
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.45);
}

.cashinflow-stat-sort:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Hover/focus tooltip for a stat, matching the banner cut-off hint. */
.cashinflow-stat[data-tooltip] {
  position: relative;
}

.cashinflow-stat[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 30;
  width: max-content;
  max-width: 240px;
  padding: 9px 11px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  letter-spacing: normal;
  text-align: left;
  text-transform: none;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  pointer-events: none;
}

.cashinflow-stat[data-tooltip]:hover::after,
.cashinflow-stat[data-tooltip]:focus-visible::after,
.cashinflow-stat[data-tooltip]:focus-within::after {
  opacity: 1;
  visibility: visible;
}

/* Phones and tablets cannot hover, so the popovers are switched off there and
   the "What do these numbers mean?" glossary above the cards is used instead. */
@media (hover: none), (max-width: 640px) {
  .cashinflow-stat[data-tooltip]::after {
    display: none;
  }
}

.cashinflow-inflow {
  color: var(--success);
}

.cashinflow-weekly-pos {
  color: var(--success);
}

.cashinflow-weekly-neg {
  color: var(--danger);
}

.cashinflow-leftover {
  color: #fbbf24;
}

.cashinflow-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

/* Tap-friendly glossary of the four cash-inflow stats. It holds the same text
   as the hover tooltips, so touch, keyboard and screen-reader users can read
   the definitions too. */
.cashinflow-help {
  margin: 0 0 12px;
  font-size: 13px;
}

.cashinflow-help summary {
  width: fit-content;
  padding: 4px 0;
  color: var(--accent);
  cursor: pointer;
  font-size: 13px;
}

.cashinflow-help summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cashinflow-help-list {
  display: grid;
  gap: 10px;
  max-width: 720px;
  margin: 8px 0 0;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cashinflow-help-item dt {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.cashinflow-help-item dd {
  margin: 2px 0 0;
  font-size: 13px;
  line-height: 1.45;
}

/* ------------------------------------------------------------------ */
/* Responsive                                                         */
/* ------------------------------------------------------------------ */

@media (max-width: 1000px) {
  .report-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .cashinflow-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 860px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .report-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cashinflow-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report {
    padding: 14px 16px;
  }

  .report-head {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
  }

  .userbox {
    flex-wrap: wrap;
    gap: 8px;
  }

  .layout {
    padding: 16px;
    gap: 16px;
  }

  .stat-grid {
    grid-template-columns: 1fr;
  }

  .detail {
    padding: 16px;
  }

  .detail-title {
    flex-direction: column;
    align-items: stretch;
  }

  .detail-actions {
    flex-wrap: wrap;
  }

  .policies-head {
    flex-direction: column;
    align-items: stretch;
  }

  .policies-controls {
    flex-wrap: wrap;
  }

  .overlay {
    padding: 12px;
  }

  .modal-head,
  .modal-body {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 400px) {
  .report-grid {
    grid-template-columns: 1fr;
  }

  .cashinflow-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------------ */
/* Policies button + payment banner + policies panel                  */
/* ------------------------------------------------------------------ */

.detail-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.detail-title h2 {
  margin: 0;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--accent-strong);
  color: #06121f;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover {
  background: var(--accent);
}

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.4;
  border: 1px solid var(--border);
}

.banner.info {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.4);
  color: #bae6fd;
}

.banner.warn {
  background: rgba(250, 204, 21, 0.1);
  border-color: rgba(250, 204, 21, 0.45);
  color: #fde68a;
}

.banner.danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

.banner-cutoff {
  margin-top: 10px;
  color: #fbbf24;
  font-weight: 700;
  cursor: help;
  border-bottom: 1px dashed #fbbf24;
  width: fit-content;
  position: relative;
}

.banner-cutoff::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  width: 280px;
  padding: 10px 12px;
  background: #0f172a;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.45;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 30;
  pointer-events: none;
}

.banner-cutoff:hover::after,
.banner-cutoff:focus::after {
  opacity: 1;
  visibility: visible;
}

.policies-panel {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

/* Dim the table while a newly picked date range is being fetched. */
.policies-panel.is-loading .table-wrap {
  opacity: 0.55;
}

/* Payments table: money the broker actually handed over (a branch top-up or a
   hand-over to the owner). */
.payments-panel {
  margin-top: 22px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}

/* Dim the table while the payment history is being fetched. */
.payments-panel.is-loading .table-wrap {
  opacity: 0.55;
}

.payments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.payments-head h3 {
  margin: 0;
  font-size: 15px;
}

.payments-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.payments-count {
  font-size: 13px;
  color: var(--muted);
}

.policies-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
}

.policies-head h3 {
  margin: 0;
  font-size: 15px;
}

.policies-since {
  font-size: 13px;
  color: var(--muted);
}

.policies-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.policies-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.date-input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  min-width: 110px;
}

.date-input:focus {
  outline: none;
  border-color: var(--accent);
}

/* Calendar glyph on native date inputs: recolor it white (borrowed from the
   Insurance client) so it is visible on the dark field and reads as clickable.
   The whole field opens the picker (see dashboard.js openDatePicker). */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(1);
  cursor: pointer;
}

.date-clear {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

.date-clear:hover {
  color: var(--text);
  border-color: var(--accent);
}

.policies-total {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

/* Count of policies per price ("By price: 10× 19 EUR, 20× 30 EUR"). */
.policies-breakdown {
  margin: -2px 0 12px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}

/* The annulled policies' own line ("Annulled: 2× 9 EUR"), tinted like their
   table rows so the two never get mixed up. */
.policies-breakdown-annulled {
  color: #f43f5e;
  font-style: italic;
}

/* A cell whose price is the live annulled price, not the policy's original. */
.report-table td.annulled-price {
  font-style: italic;
}

.history-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.history-filter-label {
  font-size: 13px;
  color: var(--muted);
}

.history-filters input[type="date"] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.history-filters input[type="date"]:focus {
  outline: none;
  border-color: var(--accent);
}

.history-pager {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.history-pager span {
  font-size: 13px;
  color: var(--muted);
}

.history-pager button:disabled {
  opacity: 0.45;
  cursor: default;
  border-color: var(--border);
  color: var(--text);
}

.report-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.report-table th.sortable:hover {
  color: var(--text);
}

.report-table th.sortable.sort-asc::after {
  content: " ▲";
}

.report-table th.sortable.sort-desc::after {
  content: " ▼";
}

.policies-empty {
  color: var(--muted);
  text-align: center;
  padding: 18px 0;
}

tr.annulled td {
  color: var(--muted);
}

.annulled-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(244, 63, 94, 0.14);
  color: #f43f5e;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
}

/* ------------------------------------------------------------------ */
/* Non-selectable UI chrome (text that doesn't need to be copied)      */
/* ------------------------------------------------------------------ */

button,
.report-table th,
.stat-label,
.brand,
.sidebar h2,
.login-title,
.login-subtitle,
.login-card label,
.policies-head h3,
.banner-cutoff {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}


/* ------------------------------------------------------------------ */
/* Register link + settings/registrations overlays                     */
/* ------------------------------------------------------------------ */

.login-alt {
  margin: 18px 0 0;
  font-size: 14px;
  text-align: center;
}

.login-alt a {
  color: var(--accent);
  text-decoration: none;
}

.login-alt a:hover {
  text-decoration: underline;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 20px 22px 24px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.settings-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.settings-section label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin: 14px 0 6px;
}

.settings-section input,
.pending-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.settings-section input:focus,
.pending-select:focus {
  outline: none;
  border-color: var(--accent);
}

.settings-section form .btn-primary {
  width: 100%;
  margin-top: 20px;
}

.email-add {
  display: flex;
  gap: 8px;
  margin: 12px 0;
}

.email-add input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14px;
}

.email-add input:focus {
  outline: none;
  border-color: var(--accent);
}

.email-add .btn-ghost {
  flex: 0 0 auto;
}

#EmailSaveBtn {
  margin-top: 4px;
}

.email-list,
.pending-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.email-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.email-item,
.pending-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.email-item span {
  word-break: break-all;
}

.pending-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.pending-item {
  align-items: stretch;
  flex-direction: column;
}

.pending-info {
  margin-bottom: 10px;
}

.pending-name {
  font-weight: 600;
}

.pending-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.pending-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}

.pending-select {
  flex: 1 1 auto;
  min-width: 0;
}

.btn-small {
  padding: 6px 10px;
  font-size: 12px;
}

/* The policies Excel export: a larger accent-coloured action so it is easy to
   spot next to the date filters. */
.btn-export {
  background: var(--accent-strong);
  color: #06121f;
  border: none;
  padding: 12px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(14, 165, 233, 0.35);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-export:hover {
  background: var(--accent);
  box-shadow: 0 8px 22px rgba(56, 189, 248, 0.45);
}

.btn-export:active {
  transform: translateY(1px);
}

.btn-export:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.branch-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.branch-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}

.branch-name {
  font-weight: 600;
  word-break: break-word;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--border);
  transition: background 0.15s ease;
}

.switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}

.switch input:checked + .switch-track {
  background: var(--accent-strong);
}

.switch input:checked + .switch-track .switch-knob {
  transform: translateX(18px);
}

.switch-label {
  font-size: 13px;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}

/* --- Sub-brokers (underlings) & per-broker pricing ------------------------- */

.date-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.date-row label {
  font-size: 13px;
  color: var(--muted);
}

.date-row input[type="date"] {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

/* Arrows that move the From/To range one payment cycle at a time. */
.cycle-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.cycle-arrow:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.cycle-arrow:disabled {
  color: var(--muted);
  border-color: var(--border);
  background: transparent;
  cursor: default;
  opacity: 0.5;
}

.underling-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.underling-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
}

.underling-name {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.underling-name:hover {
  text-decoration: underline;
}

.underling-meta {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.underling-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.underling-export {
  white-space: nowrap;
}

.balance-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 12px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.balance-chip .balance-label {
  color: var(--muted);
}

.balance-chip .balance-value {
  font-weight: 700;
}

.balance-chip.show {
  color: var(--accent);
  border-color: rgba(56, 189, 248, 0.4);
  background: rgba(56, 189, 248, 0.12);
}

.balance-chip.main {
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.12);
}

.balance-chip.profit {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.12);
}

.balance-chip.profit.negative {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
}

.balance-chip.owed {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.12);
}

.balance-chip.leftover {
  color: var(--success);
  border-color: rgba(74, 222, 128, 0.4);
  background: rgba(74, 222, 128, 0.12);
}

.underling-totals {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.underling-totals-head {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
}

.underling-totals-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pricing-table input.pricing-input {
  width: 90px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
}

.pricing-table input.pricing-input:focus {
  outline: none;
  border-color: var(--accent);
}

#PricingOverlay .modal-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#PricingOverlay .table-wrap {
  max-height: 60vh;
  overflow: auto;
}

