:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef2f3;
  --line: #d9e1e5;
  --line-strong: #bdc8ce;
  --text: #182126;
  --muted: #63717a;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --accent-soft: #d8f1ee;
  --danger: #b42318;
  --danger-soft: #fee4df;
  --warning: #9a6700;
  --warning-soft: #fff1c2;
  --ok: #166534;
  --ok-soft: #dcfce7;
  --focus: 0 0 0 3px rgba(15, 118, 110, 0.22);
  --radius: 8px;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
  font-family: "Aptos", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 247, 248, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.brand-logo {
  display: block;
  width: 76px;
  height: 46px;
  object-fit: contain;
  object-position: left center;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: var(--muted);
  margin-top: 2px;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 28px 10px;
  overflow: visible;
}

.nav-group {
  position: relative;
  margin: 0;
}

.nav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: none;
}

.nav-title:hover,
.nav-group:focus-within .nav-title,
.nav-group:hover .nav-title,
.nav-group.active .nav-title {
  background: var(--surface);
  border-color: var(--line);
  color: var(--accent-dark);
}

.nav-title::after {
  content: "v";
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
}

.nav-group.single .nav-title::after {
  content: "";
}

.submenu {
  position: absolute;
  top: 100%;
  left: 0;
  display: none;
  min-width: 260px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.nav-group:hover .submenu,
.nav-group:focus-within .submenu,
.nav-group.open .submenu {
  display: grid;
  gap: 3px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 10px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.nav-item:hover {
  background: var(--surface-muted);
}

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.nav-count {
  min-width: 24px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: inherit;
  font-size: 0.72rem;
  text-align: center;
}

.main {
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 14px 28px 10px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(1.3rem, 1.6vw, 1.85rem);
  line-height: 1.15;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

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

.current-user-label {
  max-width: 210px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.search input {
  width: min(360px, 42vw);
}

.content {
  padding: 24px 28px 36px;
}

.content.dashboard-content {
  padding-top: 18px;
  padding-bottom: 14px;
}

.stack {
  display: grid;
  gap: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: minmax(300px, 0.9fr) minmax(360px, 1.3fr);
  align-items: start;
}

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

.grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-body {
  padding: 18px;
}

.metric {
  padding: 16px;
  min-height: 112px;
}

.metric span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin: 10px 0 8px;
  font-size: 1.9rem;
  line-height: 1;
}

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

.metric-pairs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.metric-pairs strong {
  margin: 0 0 6px;
  font-size: 1.65rem;
}

.metric-pairs small {
  display: block;
  font-size: 0.78rem;
  line-height: 1.25;
}

.dashboard-stack {
  --dashboard-pie-size: 226px;
  display: grid;
  gap: 10px;
}

.dashboard-summary-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.05fr;
  gap: 12px;
}

.dashboard-overview-card {
  display: grid;
  align-content: center;
  gap: 8px;
  min-height: 86px;
  padding: 12px 14px;
}

.dashboard-overview-card h2 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: 0;
}

.dashboard-overview-values {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-overview-values div {
  min-width: 0;
}

.dashboard-overview-values strong {
  display: block;
  font-size: 1.15rem;
  line-height: 1;
  overflow-wrap: anywhere;
}

.dashboard-overview-values span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  line-height: 1.15;
}

.dashboard-chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.dashboard-chart-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 300px;
}

.dashboard-chart-panel .panel-header {
  min-height: 52px;
  padding: 10px 14px;
}

.dashboard-chart-panel .panel-body {
  display: grid;
  align-items: center;
  min-height: 0;
  padding: 10px;
}

.dashboard-chart-panel .cashflow-bars .bar-chart-item {
  height: 176px;
}

.dashboard-chart-panel .cashflow-bars .bar-chart-track {
  min-height: 102px;
}

.dashboard-pie-panel .panel-body {
  justify-items: center;
}

.dashboard-alert-panel .panel-header {
  padding: 10px 14px;
}

.dashboard-alert-panel .panel-body {
  padding: 10px 14px;
}

.dashboard-alert-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.dashboard-mini-list {
  min-width: 0;
}

.dashboard-mini-list h3 {
  margin: 0 0 8px;
  font-size: 0.88rem;
}

.dashboard-mini-row {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1fr);
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.dashboard-mini-row strong,
.dashboard-mini-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-mini-row strong {
  font-size: 0.82rem;
}

.dashboard-mini-row span,
.dashboard-mini-empty {
  color: var(--muted);
  font-size: 0.78rem;
}

.segmented-control {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-muted);
}

.segmented-button {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.segmented-button.active {
  background: var(--surface);
  color: var(--accent-dark);
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

.segmented-button:focus {
  outline: none;
  box-shadow: var(--focus);
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  min-height: 220px;
  align-items: end;
}

.bar-chart-item {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 8px;
  min-width: 0;
  height: 210px;
  text-align: center;
}

.bar-chart-value {
  min-height: 34px;
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.bar-chart-track {
  display: flex;
  align-items: end;
  min-height: 132px;
  padding: 0 9px;
  border-bottom: 1px solid var(--line);
}

.bar-chart-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #0f766e, #164e63);
}

.bar-chart-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: capitalize;
}

.cashflow-chart {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-height: 220px;
}

.cashflow-chart.single {
  grid-template-columns: 1fr;
}

.cashflow-series {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  min-width: 0;
}

.cashflow-series-title {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.cashflow-bars {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 4px;
  align-items: end;
  min-width: 0;
}

.cashflow-chart.single .cashflow-bars {
  gap: 9px;
}

.cashflow-bars .bar-chart-item {
  grid-template-rows: 28px 1fr auto;
  gap: 5px;
  height: 200px;
}

.cashflow-chart.single .bar-chart-item {
  height: 210px;
}

.cashflow-bars .bar-chart-value {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 28px;
  color: var(--text);
  font-size: 0.58rem;
  font-weight: 800;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.cashflow-chart.single .bar-chart-value {
  font-size: 0.68rem;
}

.cashflow-bars .bar-chart-track {
  min-height: 124px;
  padding: 0 2px;
}

.cashflow-chart.single .bar-chart-track {
  padding: 0 5px;
}

.cashflow-bars .bar-chart-bar {
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, #0f766e, #164e63);
}

.cashflow-bars .bar-chart-bar.future {
  background: linear-gradient(180deg, #2563eb, #1e3a8a);
}

.cashflow-bars .bar-chart-label {
  display: grid;
  gap: 0;
  font-size: 0.58rem;
  line-height: 1.05;
  text-transform: capitalize;
}

.cashflow-chart.single .bar-chart-label {
  font-size: 0.66rem;
}

.cashflow-bars .bar-chart-label small {
  color: var(--muted);
  font-size: 0.56rem;
  font-weight: 700;
}

.task-pie-layout {
  display: grid;
  place-items: center;
  min-height: var(--dashboard-pie-size, 252px);
}

.task-pie-frame {
  position: relative;
  width: var(--dashboard-pie-size, 226px);
  max-width: 100%;
  aspect-ratio: 1;
}

.task-pie {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.task-pie-label {
  position: absolute;
  display: inline-grid;
  min-width: 46px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.72rem;
  line-height: 1.1;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: none;
  pointer-events: none;
}

.task-pie-label strong,
.task-pie-label small {
  overflow-wrap: anywhere;
}

.task-pie-label small {
  color: var(--muted);
  font-weight: 800;
}

.task-pie-count-label {
  position: absolute;
  display: inline-grid;
  place-items: center;
  min-width: 0;
  height: auto;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1;
  transform: translate(-50%, -50%);
  text-shadow: 0 1px 3px rgba(15, 23, 42, 0.65);
  box-shadow: none;
  pointer-events: none;
}

.task-pie-total {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: min(86px, 34%);
  color: #fff;
  text-align: center;
  line-height: 1;
  transform: translate(-50%, -50%);
  text-shadow: 0 1px 4px rgba(15, 23, 42, 0.7);
  pointer-events: none;
}

.task-pie-total strong {
  font-size: 1.45rem;
  font-weight: 900;
}

.task-pie-total small {
  font-size: 0.68rem;
  font-weight: 800;
}

.task-pie-summary {
  grid-area: summary;
  display: grid;
  gap: 4px;
  align-content: center;
  width: max-content;
  max-width: 120px;
}

.task-pie-summary strong {
  font-size: 2rem;
  line-height: 1;
}

.task-pie-summary span {
  font-weight: 800;
}

.task-pie-summary small {
  color: var(--muted);
}

.finance-euro-pie-layout {
  display: grid;
  justify-items: center;
  align-items: center;
  min-height: var(--dashboard-pie-size, 252px);
}

.finance-euro-pie-frame {
  position: relative;
  width: var(--dashboard-pie-size, 226px);
  max-width: 100%;
  aspect-ratio: 1;
}

.finance-euro-pie {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.finance-euro-pie-label,
.finance-euro-pie-total {
  position: absolute;
  display: grid;
  justify-items: center;
  gap: 2px;
  width: min(100px, 44%);
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  text-align: center;
  line-height: 1.12;
  transform: translate(-50%, -50%);
  box-shadow: none;
  pointer-events: none;
}

.finance-euro-pie-label strong,
.finance-euro-pie-total strong {
  font-size: 0.82rem;
  font-weight: 900;
}

.finance-euro-pie-label span {
  font-size: 0.78rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.finance-euro-pie-label small,
.finance-euro-pie-total small {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
}

.finance-euro-pie-total {
  top: 50%;
  left: 50%;
  width: min(138px, 38%);
}

.finance-euro-pie-total strong {
  font-size: 0.98rem;
}

.task-pie-label,
.task-pie-count-label,
.task-pie-total,
.finance-euro-pie-label,
.finance-euro-pie-total {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}

.finance-pie-layout {
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
}

.finance-pie-summary {
  grid-area: summary;
  display: grid;
  gap: 4px;
  align-content: center;
  min-width: 0;
}

.finance-pie-summary > strong {
  font-size: 2rem;
  line-height: 1;
}

.finance-pie-summary > span {
  font-weight: 800;
}

.finance-pie-summary > small {
  color: var(--muted);
}

.finance-currency-list {
  display: grid;
  gap: 0;
  margin-top: 12px;
}

.finance-currency-row {
  display: grid;
  grid-template-columns: auto minmax(92px, 0.45fr) minmax(180px, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.chart-dot {
  width: 10px;
  height: 10px;
  margin-top: 6px;
  border-radius: 50%;
}

.finance-currency-row strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.2;
}

.finance-currency-row small,
.finance-currency-breakdown span {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.3;
}

.finance-currency-breakdown {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.finance-currency-breakdown span {
  overflow-wrap: anywhere;
}

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

.edit-mode-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
.icon-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  min-height: 36px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-weight: 700;
}

.btn-compact {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.76rem;
  text-decoration: none;
}

.btn:hover,
.icon-button:hover {
  border-color: var(--accent);
}

.btn:focus,
.icon-button:focus,
input:focus,
select:focus,
textarea:focus {
  outline: none;
  box-shadow: var(--focus);
}

.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.btn-danger {
  border-color: #f2b8b1;
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-muted {
  background: var(--surface-muted);
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.2);
  font-weight: 900;
}

.btn:not(.btn-primary) .btn-icon {
  background: var(--surface-muted);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  font-weight: 800;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.process-type-combo {
  position: relative;
}

.process-type-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  text-align: left;
}

.process-type-trigger:hover {
  border-color: var(--accent);
}

.process-type-combo.invalid .process-type-trigger {
  border-color: var(--danger);
}

.process-type-trigger:focus {
  outline: none;
  box-shadow: var(--focus);
}

.process-type-trigger-text,
.process-type-option {
  min-width: 0;
}

.process-type-trigger-text {
  display: grid;
  gap: 2px;
}

.process-type-trigger-title,
.process-type-option span {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.process-type-trigger-description,
.process-type-option small {
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.process-type-caret {
  color: var(--muted);
  font-size: 0.9rem;
}

.process-type-options {
  position: absolute;
  z-index: 40;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 310px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.16);
}

.process-type-combo.open .process-type-options {
  display: grid;
  gap: 4px;
}

.process-type-option {
  display: grid;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.process-type-option:hover,
.process-type-option.selected {
  background: var(--accent-soft);
}

.process-type-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.inline-action-field {
  align-content: end;
}

.inline-action-field .btn {
  width: fit-content;
  min-width: 150px;
}

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

.readonly-fieldset {
  display: contents;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.readonly-form input,
.readonly-form select,
.readonly-form textarea,
.readonly-form .process-type-trigger {
  background: var(--surface-muted);
  color: var(--muted);
  cursor: default;
}

.readonly-form .process-type-trigger {
  pointer-events: none;
}

.form-section {
  margin: 8px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text);
  font-size: 0.94rem;
  letter-spacing: 0;
}

.field label,
.checkbox label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  min-height: 38px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.email-body-field textarea {
  min-height: 320px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.checkbox input {
  width: 18px;
  height: 18px;
  min-height: 18px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

.table-input {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
}

.list-filter {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr) auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.list-filter .field:nth-child(3) {
  grid-column: 1 / 2;
}

.list-filter .field:nth-child(4) {
  grid-column: 2 / 3;
}

.list-filter .filter-actions {
  grid-column: 3 / 4;
}

.list-filter label {
  font-size: 0.78rem;
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.process-finance {
  display: grid;
  gap: 12px;
}

.consultation-finance {
  margin-top: 18px;
}

.process-finance h3 {
  margin: 6px 0 0;
  font-size: 0.94rem;
}

.installments-table table {
  min-width: 820px;
  table-layout: fixed;
}

.installments-table th:nth-child(1),
.installments-table td:nth-child(1) {
  width: 7%;
}

.installments-table th:nth-child(2),
.installments-table td:nth-child(2),
.installments-table th:nth-child(5),
.installments-table td:nth-child(5) {
  width: 18%;
}

.installments-table th:nth-child(3),
.installments-table td:nth-child(3) {
  width: 14%;
}

.installments-table th:nth-child(4),
.installments-table td:nth-child(4) {
  width: 12%;
}

.installments-table th:nth-child(6),
.installments-table td:nth-child(6) {
  width: 31%;
}

.receivables-filter {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.receivables-filter .field:nth-child(1),
.receivables-filter .field:nth-child(2) {
  grid-column: span 2;
}

.receivables-filter label {
  font-size: 0.78rem;
}

.tasks-filter {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.tasks-filter label {
  font-size: 0.78rem;
}

.history-filter {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.history-filter label {
  font-size: 0.78rem;
}

.task-manager {
  margin-top: 18px;
}

.task-quick-form {
  grid-template-columns: minmax(0, 1fr) minmax(160px, 190px) auto;
}

.task-list {
  margin-top: 14px;
}

.tasks-table table {
  min-width: 920px;
}

.task-list table {
  min-width: 760px;
}

.tasks-table th:last-child,
.tasks-table td:last-child {
  width: 124px;
  text-align: right;
}

.tasks-table .task-row-actions {
  flex-wrap: nowrap;
}

.task-list table {
  table-layout: fixed;
}

.task-list th:nth-child(1),
.task-list td:nth-child(1) {
  width: 55%;
}

.task-list th:nth-child(2),
.task-list td:nth-child(2) {
  width: 12%;
}

.task-list th:nth-child(3),
.task-list td:nth-child(3) {
  width: 11%;
}

.task-list th:nth-child(4),
.task-list td:nth-child(4) {
  width: 22%;
  text-align: center;
}

.task-text {
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.task-row-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.task-row-actions .btn {
  min-height: 32px;
  padding: 6px 8px;
}

.task-row-actions .icon-button {
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
}

.task-list .task-row-actions {
  transform: translateX(-6px);
}

.task-date-input {
  max-width: 145px;
}

.task-name-input {
  min-width: 0;
  width: 100%;
}

.receivables-table table {
  min-width: 1480px;
  table-layout: fixed;
}

.receivables-table th,
.receivables-table td {
  white-space: nowrap;
  vertical-align: middle;
}

.receivables-table th:nth-child(1),
.receivables-table td:nth-child(1) {
  width: 14%;
}

.receivables-table th:nth-child(2),
.receivables-table td:nth-child(2),
.receivables-table th:nth-child(3),
.receivables-table td:nth-child(3) {
  width: 8%;
}

.receivables-table th:nth-child(4),
.receivables-table td:nth-child(4),
.receivables-table th:nth-child(6),
.receivables-table td:nth-child(6) {
  width: 11%;
}

.receivables-table th:nth-child(5),
.receivables-table td:nth-child(5),
.receivables-table th:nth-child(7),
.receivables-table td:nth-child(7) {
  width: 9%;
}

.receivables-table th:nth-child(8),
.receivables-table td:nth-child(8) {
  width: 30%;
}

.receivables-table .table-input {
  min-height: 32px;
  padding: 5px 7px;
}

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

.receivables-table .installment-actions .btn {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 6px 8px;
}

.installment-value-input {
  text-align: right;
  appearance: textfield;
  -moz-appearance: textfield;
}

.installment-value-input::-webkit-inner-spin-button,
.installment-value-input::-webkit-outer-spin-button {
  margin: 0;
  appearance: none;
  -webkit-appearance: none;
}

.installment-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(76px, 1fr));
  gap: 8px;
}

.installment-actions .btn {
  min-height: 36px;
  padding: 7px 10px;
  white-space: nowrap;
}

input[data-action="toggle-history-update"],
input[data-action="toggle-document"],
input[data-action="toggle-pending-document-charge"] {
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  padding: 0;
  margin: 0;
  vertical-align: middle;
}

.pending-documents-table th:nth-child(1),
.pending-documents-table td:nth-child(1) {
  width: 52px;
  padding-left: 6px;
  padding-right: 6px;
  text-align: center;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0;
  background: #f9fbfb;
}

tr.selectable {
  cursor: pointer;
}

tr.selectable:hover {
  background: #f8fafb;
}

tr.selected {
  background: var(--accent-soft);
}

.empty {
  padding: 28px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.badge.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge.warn {
  background: var(--warning-soft);
  color: var(--warning);
}

.badge.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge.info {
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 12px 12px 0;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tab.active {
  color: var(--accent-dark);
  border-bottom-color: var(--accent);
}

.split-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.help {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.email-online-help {
  margin: 0;
  padding: 0 18px 16px;
}

.backup-warning {
  margin-top: 12px;
  padding: 10px 12px;
  border-left: 4px solid var(--danger);
  border-radius: 7px;
  background: var(--danger-soft);
  color: #7f1d1d;
}

.backup-auto-info {
  margin-top: 12px;
  padding: 9px 12px;
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--text);
}

.system-note,
.doc-preview-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  padding: 10px 12px;
}

.system-note {
  display: grid;
  gap: 4px;
}

.exchange-note {
  margin-bottom: 12px;
}

.exchange-note .btn {
  justify-self: start;
  margin-top: 4px;
}

.exchange-note small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.warn-text {
  color: var(--danger) !important;
  font-weight: 800;
}

.system-note span,
.doc-preview-box strong {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.doc-list {
  margin: 8px 0 0;
  padding-left: 20px;
}

.doc-list li + li {
  margin-top: 4px;
}

.inline-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.inline-list li {
  padding: 6px 8px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17252b;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 0;
}

.modal::backdrop {
  background: rgba(15, 23, 42, 0.45);
}

.modal form {
  margin: 0;
}

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

.modal-head h2 {
  margin: 2px 0 0;
  font-size: 1.25rem;
}

.modal-actions {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.email-preview {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.email-meta {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.email-render-shell {
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  background: #fff;
}

.email-render-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.email-render {
  display: block;
  width: 100%;
  min-height: 380px;
  border: 0;
  background: #fff;
}

.email-preview pre {
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8fafb;
  max-height: 360px;
  overflow: auto;
}

.hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(15, 118, 110, 0.14), transparent 36%),
    linear-gradient(145deg, #eef3f3, #f9fbfb);
}

.login-card {
  width: min(430px, 100%);
  display: grid;
  gap: 17px;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.16);
}

.login-logo {
  width: 150px;
  height: 68px;
  object-fit: contain;
  object-position: left center;
}

.login-card h1 {
  margin: -8px 0 0;
  font-size: 1.7rem;
}

.login-copy {
  margin: -7px 0 2px;
  color: var(--muted);
  line-height: 1.5;
}

.login-card .field {
  display: grid;
  gap: 6px;
  color: var(--text);
  font-size: 0.86rem;
  font-weight: 700;
}

.login-card .field input {
  width: 100%;
}

.login-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #f2b8b1;
  border-radius: 7px;
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.86rem;
}

.login-submit {
  width: 100%;
}

@media (max-width: 1080px) {
  .top-nav {
    padding-left: 16px;
    padding-right: 16px;
  }

  .nav-group {
    flex: 0 0 auto;
  }

  .grid.two,
  .grid.three,
  .grid.four {
    grid-template-columns: 1fr;
  }

  .dashboard-summary-grid,
  .dashboard-chart-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-chart-panel {
    min-height: auto;
  }

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

  .topbar-actions {
    width: 100%;
    justify-content: flex-start;
  }

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

  .search input {
    width: min(100%, 520px);
  }

  .email-meta {
    grid-template-columns: 1fr;
  }

  .list-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receivables-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .receivables-filter .field:nth-child(1),
  .receivables-filter .field:nth-child(2) {
    grid-column: auto;
  }

  .tasks-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .history-filter {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-filter .field:nth-child(3),
  .list-filter .field:nth-child(4),
  .list-filter .filter-actions {
    grid-column: auto;
  }

  .filter-actions {
    justify-content: flex-start;
  }

  .bar-chart {
    grid-template-columns: repeat(6, minmax(92px, 1fr));
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .task-pie-layout {
    grid-template-columns: minmax(220px, 250px) max-content;
  }
}

@media (max-width: 640px) {
  .content,
  .topbar {
    padding-left: 16px;
    padding-right: 16px;
  }

  .brand {
    min-width: 0;
  }

  .top-nav {
    padding-bottom: 8px;
  }

  .submenu {
    left: 0;
    min-width: min(280px, calc(100vw - 32px));
  }

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

  .task-quick-form {
    grid-template-columns: 1fr;
  }

  .list-filter {
    grid-template-columns: 1fr;
  }

  .receivables-filter {
    grid-template-columns: 1fr;
  }

  .receivables-filter .field:nth-child(1),
  .receivables-filter .field:nth-child(2) {
    grid-column: auto;
  }

  .tasks-filter {
    grid-template-columns: 1fr;
  }

  .history-filter {
    grid-template-columns: 1fr;
  }

  .list-filter .field:nth-child(3),
  .list-filter .field:nth-child(4),
  .list-filter .filter-actions {
    grid-column: auto;
  }

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

  .btn,
  .search,
  .search input {
    width: 100%;
  }

  .session-actions,
  .session-actions .btn {
    width: 100%;
  }

  .current-user-label {
    max-width: none;
  }

  .task-pie-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "chart"
      "summary";
    justify-items: center;
  }

  .dashboard-alert-grid,
  .dashboard-overview-values {
    grid-template-columns: 1fr;
  }

  .task-pie-summary {
    text-align: center;
  }

  .cashflow-chart {
    grid-template-columns: 1fr;
  }

  .finance-pie-summary {
    text-align: left;
  }

  .finance-currency-row {
    grid-template-columns: auto 1fr;
  }

  .finance-currency-breakdown {
    grid-column: 2;
  }
}
