:root {
  --ink: #1e2528;
  --muted: #677176;
  --line: #dde4e0;
  --soft: #f5f7f2;
  --panel: #ffffff;
  --nav: #1f2422;
  --nav-soft: #2d3531;
  --blue: #2563eb;
  --green: #177245;
  --amber: #a15c07;
  --red: #b42318;
  --shadow: 0 18px 45px rgba(31, 36, 34, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: #edf1ed;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  overflow-x: hidden;
}

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

button {
  border: 0;
}

.app-shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--nav);
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 14px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 4px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #eef3ea;
  color: var(--nav);
  font-weight: 800;
  letter-spacing: 0;
}

.brand-name {
  font-weight: 800;
}

.brand-subtitle,
.sidebar-note span {
  color: #9ba7a2;
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-group,
.nav-subgroup {
  display: grid;
  gap: 4px;
}

.nav-group-toggle,
.nav-item {
  color: #cad2ce;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  padding: 0 12px;
  text-align: left;
}

.nav-group-toggle {
  width: 100%;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.nav-sub-toggle {
  min-height: 32px;
  color: #aeb9b4;
  font-size: 11px;
  padding-left: 20px;
}

.nav-group-toggle:hover,
.nav-item:hover,
.nav-item.active {
  background: var(--nav-soft);
  color: #fff;
}

.nav-caret {
  color: #8d9994;
  font-size: 11px;
  transition: transform 0.14s ease;
}

.nav-group:not(.open) > .nav-group-toggle .nav-caret,
.nav-subgroup:not(.open) > .nav-group-toggle .nav-caret {
  transform: rotate(-90deg);
}

.nav-children {
  display: none;
  gap: 4px;
  padding-left: 8px;
}

.nav-group.open > .nav-children,
.nav-subgroup.open > .nav-children {
  display: grid;
}

.nav-child {
  padding-left: 22px;
}

.nav-grandchild {
  padding-left: 34px;
  min-height: 34px;
  font-size: 13px;
}

.nav-badge {
  min-width: 22px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: #d94735;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  padding: 0 7px;
}

.nav-top {
  font-weight: 700;
}

.sidebar-note {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.sidebar-account {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.sidebar-account + .sidebar-note {
  margin-top: 0;
}

.account-top {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #eef3ea;
  color: var(--nav);
  font-weight: 800;
  flex: 0 0 auto;
}

.account-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.account-name {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-email {
  color: #9ba7a2;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-roles,
.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: rgba(238, 243, 234, 0.12);
  color: #eef3ea;
  font-size: 11px;
  font-weight: 800;
  padding: 0 8px;
}

.muted-role {
  color: #9ba7a2;
}

.account-link {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
  text-decoration: none;
}

.account-link[type="button"] {
  background: transparent;
}

.primary-account-link {
  background: rgba(238, 243, 234, 0.1);
}

.account-link:hover {
  background: var(--nav-soft);
}

.account-recovery {
  color: #9ba7a2;
  font-size: 12px;
}

.account-recovery summary {
  cursor: pointer;
  font-weight: 800;
  list-style-position: inside;
}

.account-recovery[open] {
  display: grid;
  gap: 8px;
}

.recovery-link {
  color: #f8d7d4;
  border-color: rgba(242, 184, 181, 0.35);
}

.hidden {
  display: none !important;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 82px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 24px;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 14px;
  min-width: 0;
}

.topbar-account {
  margin-top: 0;
  width: min(420px, 38vw);
  border-color: var(--line);
  background: #fbfcfa;
  color: var(--ink);
  padding: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 10px;
}

.topbar-account .account-top {
  grid-row: span 2;
}

.topbar-account .account-avatar {
  background: var(--nav);
  color: #fff;
}

.topbar-account .account-email,
.topbar-account .muted-role {
  color: var(--muted);
}

.topbar-account .role-pill {
  background: #e9f1eb;
  color: var(--green);
}

.topbar-account .account-roles {
  justify-content: end;
  max-width: 180px;
}

.topbar-account .account-actions {
  justify-content: end;
}

.topbar-account .account-link {
  color: var(--ink);
  border-color: var(--line);
}

.topbar-account .account-link:hover {
  background: #edf1ed;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 15px;
}

.search-wrap {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-width: min(420px, 44vw);
}

.search-wrap input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  outline: none;
  padding: 8px 10px;
}

.search-wrap input:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--blue);
  background: #fff;
}

.view {
  display: none;
  padding: 20px 24px 28px;
}

.active-view {
  display: block;
}

.auth-locked .nav-item,
.auth-locked .nav-group-toggle {
  cursor: not-allowed;
  opacity: 0.55;
}

.locked-view {
  min-height: calc(100vh - 82px);
  display: none;
  place-items: center;
}

.locked-view.active-view {
  display: grid;
}

.locked-panel {
  width: min(560px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 26px;
}

.locked-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--nav);
  color: #fff;
  font-weight: 800;
}

.locked-panel h2 {
  font-size: 24px;
  line-height: 1.2;
}

.locked-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.locked-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.locked-actions a {
  text-decoration: none;
}

.locked-note {
  border-top: 1px solid var(--line);
  font-size: 12px;
  padding-top: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.debt-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.invoice-summary-panel {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.invoice-date-range,
.invoice-category-totals {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.invoice-date-range {
  display: grid;
  gap: 12px;
}

.invoice-date-presets,
.invoice-custom-dates {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.invoice-date-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-right: 8px;
}

.invoice-preset-btn {
  min-height: 34px;
  padding: 0 10px;
}

.invoice-custom-dates label {
  display: grid;
  gap: 4px;
}

.invoice-custom-dates label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-custom-dates input {
  width: 126px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-weight: 700;
}

.invoice-custom-dates p {
  color: #237451;
  font-size: 13px;
  font-weight: 700;
  margin-left: 12px;
}

.invoice-summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
}

.invoice-summary-card {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.invoice-summary-card::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 7px;
  background: #e8eef8;
}

.invoice-summary-card.green::after {
  background: #dcefdc;
}

.invoice-summary-card.amber::after {
  background: #ffedc0;
}

.invoice-summary-card.red::after {
  background: #ffdcd6;
}

.invoice-category-totals h3 {
  font-size: 18px;
  margin-bottom: 14px;
}

.invoice-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 16px;
}

.invoice-category-total {
  display: grid;
  gap: 4px;
}

.invoice-category-total span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.invoice-category-total strong {
  font-size: 24px;
}

.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 16px;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
}

.metric-sub {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.panel {
  overflow: hidden;
}

.panel-header {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: #fafbf8;
  border-bottom: 1px solid var(--line);
}

.breakdown-list {
  padding: 12px 14px 16px;
  display: grid;
  gap: 12px;
}

.breakdown-row {
  display: grid;
  gap: 6px;
}

.breakdown-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
}

.bar-bg {
  height: 8px;
  border-radius: 999px;
  background: #edf1ed;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.entity-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.segmented,
.toolbar-actions,
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-btn,
.secondary-btn,
.primary-btn {
  min-height: 36px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0 13px;
}

.filter-btn,
.secondary-btn {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
}

.filter-btn.active,
.primary-btn {
  background: var(--nav);
  color: #fff;
}

.filter-btn.danger-filter {
  border-color: rgba(190, 62, 48, 0.28);
  color: var(--red);
}

.entity-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.75fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.table-scroll {
  overflow: auto;
}

.records-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.records-table th,
.records-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #edf1ed;
  vertical-align: middle;
  overflow-wrap: anywhere;
}

.records-table th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  background: #fbfcfa;
}

.debt-sort-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font: inherit;
  font-weight: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
}

.debt-sort-button:hover,
.debt-sort-button:focus-visible {
  color: var(--ink);
}

.debt-sort-arrow {
  position: relative;
  flex: 0 0 auto;
  width: 9px;
  height: 14px;
}

.debt-sort-arrow::before,
.debt-sort-arrow::after {
  content: "";
  position: absolute;
  left: 1px;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
}

.debt-sort-arrow::before {
  top: 0;
  border-bottom: 5px solid #a4aea7;
}

.debt-sort-arrow::after {
  bottom: 0;
  border-top: 5px solid #a4aea7;
}

.debt-sort-button.asc .debt-sort-arrow::before {
  border-bottom-color: var(--ink);
}

.debt-sort-button.asc .debt-sort-arrow::after,
.debt-sort-button.desc .debt-sort-arrow::before {
  opacity: 0.2;
}

.debt-sort-button.desc .debt-sort-arrow::after {
  border-top-color: var(--ink);
}

.truncate-cell {
  max-width: 190px;
}

.truncate-cell > span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.records-table td.money-cell {
  font-weight: 800;
  white-space: nowrap;
}

.records-table th {
  white-space: nowrap;
}

.records-table td.money-cell.blue {
  background: rgba(54, 115, 214, 0.07);
  color: #244e8c;
}

.records-table td.money-cell.green {
  background: rgba(38, 142, 90, 0.07);
  color: #237451;
}

.records-table td.money-cell.red {
  background: rgba(207, 68, 54, 0.07);
  color: #9b3329;
}

.records-table tbody tr.handled-row {
  background: #fbfcfa;
}

.records-table tbody tr.handled-row td {
  color: #66716a;
}

.subtle-cell {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-top: 2px;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.mini-action {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 0 9px;
}

.scheduled-col-due {
  width: 78px;
}

.scheduled-col-debtor {
  width: 150px;
}

.scheduled-col-debt {
  width: 180px;
  max-width: 180px;
}

.scheduled-col-plan {
  width: 110px;
}

.scheduled-col-money {
  width: 108px;
}

.scheduled-col-status {
  width: 94px;
}

.scheduled-col-action {
  width: 98px;
  min-width: 98px;
}

.records-table th.scheduled-col-debt,
.records-table td.scheduled-col-debt,
.records-table th.scheduled-col-action,
.records-table td.scheduled-col-action,
.records-table td.scheduled-col-debtor,
.records-table td.scheduled-col-plan,
.records-table td.scheduled-col-status {
  overflow-wrap: normal;
  word-break: normal;
}

.records-table td.scheduled-col-debt strong,
.records-table td.scheduled-col-debt span,
.records-table td.scheduled-col-debtor strong,
.records-table td.scheduled-col-debtor span,
.records-table td.scheduled-col-plan {
  overflow-wrap: normal;
  word-break: normal;
}

.scheduled-col-action .mini-action {
  min-width: 64px;
  white-space: nowrap;
}

.scheduled-deductions-footer {
  display: flex;
  justify-content: flex-end;
  min-height: 42px;
  padding: 10px 0 0;
}

.scheduled-clear-all {
  border-color: rgba(190, 62, 48, 0.28);
  color: var(--red);
  white-space: nowrap;
}

.mini-action.primary {
  background: var(--nav);
  border-color: var(--nav);
  color: #fff;
}

.mini-action:disabled,
.primary-btn:disabled,
.secondary-btn:disabled {
  cursor: wait;
  opacity: 0.65;
}

.records-table tbody tr {
  cursor: pointer;
}

.records-table tbody tr:hover,
.records-table tbody tr.selected {
  background: #f3f8ff;
}

.driver-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.driver-name-cell > span {
  overflow-wrap: anywhere;
}

.warning-indicator {
  flex: 0 0 auto;
  display: inline-grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: #fff4de;
  color: var(--amber);
  cursor: help;
  font-size: 12px;
  font-weight: 800;
  padding: 0 7px;
}

.warning-tooltip {
  position: fixed;
  z-index: 30;
  width: min(320px, calc(100vw - 24px));
  border: 1px solid #f1d4a2;
  border-radius: 8px;
  background: #fffaf0;
  box-shadow: var(--shadow);
  color: #613800;
  display: grid;
  gap: 7px;
  font-size: 12px;
  line-height: 1.35;
  padding: 10px 12px;
  pointer-events: none;
}

.count-pill,
.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: #edf1ed;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 0 9px;
  white-space: nowrap;
}

.badge.blue {
  background: #e9f0ff;
  color: var(--blue);
}

.badge.green {
  background: #e8f4ed;
  color: var(--green);
}

.badge.amber {
  background: #fff4de;
  color: var(--amber);
}

.badge.red {
  background: #ffe6e3;
  color: var(--red);
}

.badge.neutral {
  background: #eef1f3;
  color: var(--ink);
}

.detail-panel {
  position: sticky;
  top: 16px;
  min-width: 0;
}

.empty-detail {
  min-height: 260px;
  display: grid;
  place-content: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  padding: 26px;
}

.detail-content {
  display: grid;
  gap: 14px;
  padding: 14px;
  min-width: 0;
}

.detail-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  min-width: 0;
}

.detail-title h2 {
  font-size: 20px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex: 0 1 auto;
}

.danger-btn {
  color: var(--red);
  border-color: #f2b8b5;
}

.danger-btn:hover {
  background: #fff5f5;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid #edf1ed;
  padding-top: 10px;
}

.detail-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-value {
  overflow-wrap: anywhere;
}

.doc-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  padding: 0 9px;
  white-space: nowrap;
}

.doc-status.ok {
  background: #e8f4ed;
  color: var(--green);
}

.doc-status.warn {
  background: #fff4de;
  color: var(--amber);
}

.doc-status.bad {
  background: #fff0ef;
  color: var(--red);
}

.pdf-link {
  text-decoration: none;
}

.driver-documents {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 12px;
  padding-top: 12px;
}

.driver-documents-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.driver-documents-header h3 {
  font-size: 15px;
  margin: 0 0 3px;
}

.driver-documents-header span {
  color: var(--muted);
  font-size: 12px;
}

.driver-doc-list {
  display: grid;
  gap: 10px;
}

.driver-doc-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.compact-segmented {
  flex-wrap: wrap;
}

.driver-doc-search {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  min-width: min(280px, 100%);
}

.driver-doc-search input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  color: var(--ink);
  padding: 7px 9px;
}

.driver-doc-workspace {
  display: block;
}

.driver-doc-list {
  display: grid;
  gap: 12px;
}

.driver-doc-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.driver-doc-pair.editing {
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
}

.driver-doc-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  align-items: stretch;
  padding: 11px;
  min-width: 0;
}

.driver-doc-main {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.driver-doc-main h4 {
  margin: 0 0 3px;
  font-size: 14px;
}

.driver-doc-main span:not(.doc-status),
.driver-doc-meta span,
.muted-doc-note {
  color: var(--muted);
  font-size: 12px;
}

.driver-doc-main span:not(.doc-status) {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.driver-doc-meta {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.driver-doc-meta span {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.driver-doc-note-preview {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.driver-doc-note-preview span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.doc-note-chip {
  flex: 0 0 auto;
  border-radius: 999px;
  background: #eef5ff;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  padding: 3px 7px;
}

.driver-doc-row-warnings {
  display: grid;
  gap: 5px;
}

.driver-doc-row-warnings span {
  border-left: 3px solid var(--amber);
  background: #fff8ea;
  color: #7a4303;
  font-size: 12px;
  line-height: 1.35;
  padding: 7px 9px;
}

.driver-doc-editor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
  padding: 14px;
}

.driver-doc-editor-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.driver-doc-editor-header h3 {
  margin: 2px 0 0;
  font-size: 16px;
}

.driver-doc-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: end;
}

.driver-doc-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.driver-doc-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.driver-doc-top h4 {
  font-size: 14px;
  margin: 0 0 3px;
}

.driver-doc-top span:not(.doc-status) {
  color: var(--muted);
  display: block;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.doc-field {
  display: grid;
  gap: 5px;
}

.doc-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.doc-field input,
.doc-field select,
.doc-field textarea,
.doc-file-input {
  min-height: 36px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px 9px;
}

.doc-warning {
  border-left: 3px solid var(--amber);
  background: #fff8ea;
  color: #7a4303;
  font-size: 12px;
  line-height: 1.35;
  padding: 8px 10px;
}

.driver-doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.driver-doc-actions .doc-file-input {
  flex: 1 1 180px;
}

.date-picker {
  position: fixed;
  z-index: 40;
  width: 292px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.date-picker-header {
  min-height: 48px;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  background: var(--green);
  color: #fff;
}

.date-picker-header button {
  height: 40px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 26px;
  font-weight: 700;
}

.date-picker-header strong {
  text-align: center;
}

.date-picker-weekdays,
.date-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.date-picker-weekdays {
  color: #8290a0;
  font-size: 12px;
  padding: 12px 12px 4px;
  text-align: center;
}

.date-picker-grid {
  gap: 2px;
  padding: 4px 12px 12px;
}

.date-picker-day {
  aspect-ratio: 1;
  border-radius: 999px;
  background: transparent;
  color: #4e6d89;
  cursor: pointer;
}

.date-picker-day:hover,
.date-picker-day.selected {
  background: #5fba61;
  color: #fff;
  font-weight: 800;
}

.date-picker-day.muted {
  color: #b9c0c6;
}

.invoice-total-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(78px, 1fr));
  gap: 8px;
  min-width: 0;
}

.invoice-total {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: grid;
  gap: 4px;
  padding: 10px;
  min-width: 0;
}

.invoice-total span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.invoice-total strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.strong-total {
  background: #eef3ea;
}

.invoice-total.tone-blue,
.debt-mini.tone-blue {
  background: rgba(54, 115, 214, 0.09);
  border-color: rgba(54, 115, 214, 0.28);
  color: #244e8c;
}

.invoice-total.tone-green,
.debt-mini.tone-green {
  background: rgba(38, 142, 90, 0.09);
  border-color: rgba(38, 142, 90, 0.28);
  color: #237451;
}

.invoice-total.tone-red,
.debt-mini.tone-red {
  background: rgba(207, 68, 54, 0.09);
  border-color: rgba(207, 68, 54, 0.28);
  color: #9b3329;
}

.invoice-total.tone-blue span,
.invoice-total.tone-green span,
.invoice-total.tone-red span,
.debt-mini.tone-blue span,
.debt-mini.tone-green span,
.debt-mini.tone-red span {
  color: currentColor;
}

.invoice-workflow {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  display: grid;
  gap: 10px;
  padding: 12px;
}

.invoice-workflow-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  flex-wrap: wrap;
}

.invoice-workflow-header h3 {
  font-size: 15px;
  margin: 0;
}

.invoice-workflow-header span,
.workflow-step span,
.workflow-void-note span {
  color: var(--muted);
  font-size: 12px;
}

.workflow-step {
  border-top: 1px solid #edf1ed;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding-top: 10px;
  flex-wrap: wrap;
}

.workflow-step > div,
.workflow-void-note {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.workflow-step.complete strong {
  color: var(--green);
}

.workflow-step button {
  flex: 0 1 auto;
  white-space: normal;
}

.workflow-danger {
  border-top: 1px solid #edf1ed;
  padding-top: 10px;
}

.workflow-void-note {
  border-top: 1px solid #f2b8b5;
  color: var(--red);
  padding-top: 10px;
}

.workflow-void-note p {
  color: var(--ink);
  margin: 3px 0 0;
}

.invoice-sections {
  display: grid;
  gap: 10px;
}

.invoice-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.invoice-section h3 {
  background: #fafbf8;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  margin: 0;
  padding: 10px 12px;
}

.invoice-line-list {
  display: grid;
}

.invoice-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  min-width: 0;
}

.invoice-line + .invoice-line {
  border-top: 1px solid #edf1ed;
}

.invoice-line div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.invoice-line span {
  color: var(--muted);
  font-size: 12px;
}

.invoice-line strong {
  overflow-wrap: anywhere;
}

.debt-detail {
  gap: 12px;
}

.debt-card-list {
  display: grid;
  gap: 12px;
}

.debt-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  padding: 12px;
  min-width: 0;
}

.debt-card[open] {
  display: grid;
  gap: 12px;
}

.debt-card-summary {
  cursor: pointer;
  display: grid;
  gap: 10px;
  list-style: none;
}

.debt-card-summary::-webkit-details-marker {
  display: none;
}

.debt-card-summary::after {
  content: "Open";
  justify-self: end;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.debt-card[open] .debt-card-summary::after {
  content: "Close";
}

.debt-card-expanded {
  display: grid;
  gap: 12px;
}

.debt-card-top,
.debt-payment-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.debt-card-top h3,
.debt-payment-header h4 {
  margin: 0;
}

.debt-card-top h3 {
  font-size: 15px;
}

.debt-card-top span,
.debt-payment-header span,
.debt-note,
.debt-payment span {
  color: var(--muted);
  font-size: 12px;
}

.debt-mini-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
  gap: 8px;
}

.debt-summary-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.debt-mini {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px;
}

.debt-mini span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.debt-mini strong {
  overflow-wrap: anywhere;
}

.debt-note {
  line-height: 1.4;
}

.debt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.debt-payment-log {
  border-top: 1px solid #edf1ed;
  display: grid;
  gap: 8px;
  padding-top: 10px;
}

.debt-payment-list {
  display: grid;
  gap: 8px;
}

.payment-log-filter {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
  white-space: nowrap;
}

.debt-payment {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
}

.debt-payment.reversed {
  background: #fff5f5;
  border-color: #f2b8b5;
}

.debt-payment > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.debt-payment-amounts {
  justify-items: end;
  text-align: right;
}

.debt-payment-amounts button {
  min-height: 30px;
  margin-top: 4px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(14, 21, 18, 0.48);
  padding: 18px;
  z-index: 10;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(760px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f2f4f0;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 16px;
}

.field {
  display: grid;
  gap: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

.modal-actions {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  padding: 14px 16px;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.shell-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px;
  margin-bottom: 16px;
}

.shell-hero h2 {
  font-size: 24px;
  margin-top: 2px;
}

.shell-hero p {
  color: var(--muted);
  line-height: 1.5;
  max-width: 780px;
  margin-top: 8px;
}

.status-pill {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #ecf3f7;
  color: #22577a;
  font-size: 12px;
  font-weight: 800;
  padding: 0 10px;
}

.shell-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.field-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px;
}

.field-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfa;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 0 10px;
}

.shell-register {
  min-height: 180px;
}

.empty-shell {
  display: grid;
  place-content: center;
  gap: 8px;
  min-height: 150px;
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

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

  .detail-panel {
    position: static;
  }
}

@media (max-width: 960px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    max-height: 48vh;
    overflow: auto;
  }

  .brand {
    border-bottom: 0;
    padding-bottom: 6px;
  }

  .nav-list {
    display: grid;
  }

  .sidebar-note {
    display: none;
  }

  .sidebar-account {
    margin-top: 0;
  }

  .topbar,
  .entity-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-right {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-account {
    width: 100%;
  }

  .search-wrap {
    min-width: 100%;
  }

  .metric-grid,
  .debt-metrics,
  .invoice-summary-cards,
  .dashboard-grid,
  .entity-layout,
  .form-grid,
  .shell-grid,
  .invoice-total-grid {
    grid-template-columns: 1fr;
  }

  .detail-panel {
    position: static;
  }

  .driver-doc-pair.editing {
    grid-template-columns: 1fr;
  }

  .invoice-custom-dates p {
    flex-basis: 100%;
    margin-left: 0;
  }
}

@media (max-width: 560px) {
  .view {
    padding: 16px;
  }

  .topbar {
    padding: 14px 16px;
  }

  h1 {
    font-size: 21px;
  }

  .metric-value {
    font-size: 25px;
  }

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }

  .topbar-account {
    grid-template-columns: 1fr;
  }

  .topbar-account .account-top {
    grid-row: auto;
  }

  .topbar-account .account-roles,
  .topbar-account .account-actions {
    justify-content: start;
    max-width: none;
  }

  .shell-hero {
    flex-direction: column;
  }

  .driver-doc-row {
    grid-template-columns: 1fr;
  }

  .debt-payment {
    flex-direction: column;
  }

  .debt-payment-amounts {
    justify-items: start;
    text-align: left;
  }
}
