:root {
  --bg: #f4f7f6;
  --panel: #ffffff;
  --panel-soft: #eef5f3;
  --text: #182321;
  --muted: #6d7a77;
  --line: #dce5e2;
  --brand: #126a60;
  --brand-dark: #0d4e48;
  --accent: #c79a37;
  --danger: #b44747;
  --blue: #356c9a;
  --shadow: 0 18px 46px rgba(25, 44, 40, .12);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

body.dark-mode {
  --bg: #101614;
  --panel: #17211f;
  --panel-soft: #20302d;
  --text: #eef7f4;
  --muted: #aab8b4;
  --line: #2d403b;
  --brand: #58c7b8;
  --brand-dark: #8ee1d5;
  --shadow: 0 18px 46px rgba(0, 0, 0, .34);
}

body.dark-mode .brand,
body.dark-mode .kpi-card,
body.dark-mode .panel,
body.dark-mode .table-panel,
body.dark-mode .module-card,
body.dark-mode .quick-menu-panel,
body.dark-mode .dialog-card,
body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea,
body.dark-mode .check-row,
body.dark-mode .archive-box,
body.dark-mode .detail-hero {
  background: var(--panel);
  color: var(--text);
}

body.dark-mode .kpi-card {
  border-color: var(--line);
}

body.dark-mode .kpi-orange { color: #d47a1f; }
body.dark-mode .kpi-green { color: #176448; }
body.dark-mode .kpi-red { color: #a83f3f; }
body.dark-mode .kpi-blue { color: #356c9a; }

body.dark-mode .kpi-card:hover,
body.dark-mode .kpi-card:focus-visible {
  background: #203247;
}

body.dark-mode th,
body.dark-mode td,
body.dark-mode .muted,
body.dark-mode .brand span,
body.dark-mode label {
  color: var(--muted);
}

body.dark-mode strong,
body.dark-mode h1,
body.dark-mode h2,
body.dark-mode h3,
body.dark-mode .app-footer strong {
  color: var(--text);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  padding-bottom: 62px;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 240px;
  height: 100vh;
  padding: 0 16px 22px;
  background: #10201d;
  color: #f7fbfa;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 -16px;
  padding: 18px 16px 14px;
  background: #fff;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, .18);
  background: #fff;
  color: var(--brand);
  font-weight: 800;
  overflow: hidden;
  padding: 5px;
}

.brand-mark::after {
  content: attr(data-fallback);
}

.brand-mark img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

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

.brand span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel);
  box-shadow: 0 8px 20px rgba(25, 44, 40, .08);
}

.user-card strong,
.user-card span {
  display: block;
}

.user-card span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.avatar-picker {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--brand);
  background: var(--panel-soft);
  overflow: hidden;
  cursor: pointer;
}

.session-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 12px;
  white-space: nowrap;
}

.avatar-picker img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-picker input {
  display: none;
}

.nav {
  display: grid;
  gap: 6px;
  padding-top: 18px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  color: #cddad7;
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: #fff;
  background: rgba(255, 255, 255, .1);
}

.content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  margin-left: 240px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 18;
  margin: -24px -24px 18px;
  padding: 20px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 246, .96);
  backdrop-filter: blur(10px);
}

body.dark-mode .topbar {
  background: rgba(16, 22, 20, .96);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  margin-bottom: 12px;
  font-size: 22px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

.top-actions,
.section-actions,
.dialog-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.logged-out .sidebar,
.logged-out .topbar,
.logged-out .app-footer {
  display: none;
}

.logged-out .content {
  min-height: 100vh;
  margin-left: 0;
  padding: 32px;
  justify-content: center;
}

.login-panel {
  width: min(540px, 100%);
  margin: 0 auto;
}

.top-currency {
  display: flex;
  align-items: center;
}

.currency-compact {
  display: grid;
  gap: 3px;
}

.currency-compact .currency-row {
  min-width: 142px;
  min-height: 27px;
  padding: 4px 8px;
  line-height: 1.1;
}

.currency-compact .currency-source {
  display: none;
}

.icon-only {
  width: 42px;
  justify-content: center;
  padding-inline: 0;
}

.quick-menu {
  position: relative;
}

.quick-menu-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  display: grid;
  min-width: 240px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.quick-menu-panel[hidden] {
  display: none !important;
}

.quick-menu-panel button {
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  text-align: left;
}

.quick-menu-panel button:hover {
  background: var(--panel-soft);
}

.primary-button,
.ghost-button,
.print-button,
.icon-button,
.tab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}

.primary-button {
  padding: 9px 14px;
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}

.print-button {
  padding: 9px 12px;
  border-color: #d47a1f;
  background: #d47a1f;
  color: #fff;
  font-weight: 800;
}

.ghost-button,
.tab-button {
  padding: 9px 12px;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.danger-button {
  color: var(--danger);
}

.view-root {
  display: grid;
  gap: 18px;
}

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

.kpi-card,
.panel,
.table-panel,
.module-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-card {
  display: grid;
  grid-template-rows: auto 1fr 22px;
  gap: 10px;
  min-height: 146px;
  padding: 16px;
  color: #0e211e;
  background: #fff;
  box-shadow: 0 12px 28px rgba(25, 44, 40, .1);
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}

.kpi-card:not(:has(.delta))::after {
  content: "";
  display: block;
  min-height: 22px;
}

.kpi-card:hover,
.kpi-card:focus-visible {
  transform: translateY(-2px);
  background: #e8f3ff;
  box-shadow: 0 18px 34px rgba(25, 44, 40, .16);
  outline: none;
}

.kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.kpi-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  color: currentColor;
  background: rgba(255, 255, 255, .52);
}

.kpi-label {
  color: currentColor;
  font-size: 13px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 850;
}

.delta {
  display: inline-flex;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .58);
  color: rgba(14, 33, 30, .82);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delta.up {
  background: rgba(24, 135, 97, .14);
  color: #176448;
}

.delta.down {
  background: rgba(216, 100, 100, .16);
  color: var(--danger);
}

.delta.neutral {
  background: rgba(255, 255, 255, .58);
  color: rgba(14, 33, 30, .82);
}

.kpi-teal,
.kpi-blue,
.kpi-violet,
.kpi-mint,
.kpi-amber,
.kpi-indigo,
.kpi-slate,
.kpi-orange {
  background: #fff;
  border-color: var(--line);
}

.kpi-maroon {
  background: #fff;
  border-color: #d7b8c0;
  color: #7a1230;
}

.kpi-green {
  background: #fff;
  border-color: #b9ddc8;
  color: #176448;
}

.kpi-red {
  background: #fff;
  border-color: #e4b9b9;
  color: #a83f3f;
}

.kpi-orange {
  color: #d47a1f;
}

.kpi-blue {
  color: #356c9a;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 18px;
}

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

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

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

.due-groups > div {
  display: grid;
  gap: 16px;
}

.graph-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 14px;
}

.graph-card {
  min-height: 220px;
  cursor: grab;
}

.graph-positive {
  background: #eefaf3;
  border-color: #bfe8cf;
}

.graph-negative {
  background: #fff0ef;
  border-color: #edc1bc;
}

.graph-balanced {
  background: #fff;
}

.graph-card.drag-over {
  outline: 2px dashed var(--brand);
  outline-offset: 3px;
}

.panel,
.table-panel {
  padding: 18px;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

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

.chart {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 110px;
  align-items: center;
  gap: 12px;
  min-height: 30px;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #e5ece9;
  overflow: hidden;
}

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

.bar-fill.alt {
  background: var(--accent);
}

.pie-wrap {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  min-height: 112px;
}

.pie {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: conic-gradient(#188761 0 var(--first), #d86464 var(--first) 360deg);
  box-shadow: inset 0 0 0 11px rgba(255, 255, 255, .72);
}

.pie-legend {
  display: grid;
  gap: 8px;
  font-size: 12px;
}

.pie-legend span {
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 8px;
  color: var(--muted);
}

.pie-legend strong {
  grid-column: 2;
  color: var(--text);
  font-size: 15px;
  font-weight: 850;
}

.legend-dot {
  width: 12px;
  height: 12px;
  margin-top: 3px;
  border-radius: 50%;
}

.sale-dot { background: #188761; }
.purchase-dot { background: #d86464; }

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

.currency-row {
  display: grid;
  grid-template-columns: 44px 1fr 1fr;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font-size: 12px;
}

.currency-row strong {
  color: var(--brand);
}

.currency-row span {
  color: var(--muted);
}

.currency-row span:last-child {
  color: var(--text);
  font-weight: 800;
}

.currency-row .rate-buy {
  color: #b44747;
  font-weight: 800;
}

.currency-row .rate-sell {
  color: #176448;
  font-weight: 800;
}

.due-list {
  max-height: 160px;
  min-height: 160px;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.due-empty {
  min-height: 136px;
  color: var(--muted);
  background: var(--panel-soft) !important;
  cursor: default;
}

.panel-title-button {
  border: 0;
  padding: 0;
  color: var(--text);
  background: transparent;
  font-size: 20px;
  font-weight: 800;
  text-align: left;
}

.due-green .panel-title-button { color: #176448; }
.due-blue .panel-title-button { color: #356c9a; }
.due-red .panel-title-button { color: #a32020; }
.due-purple .panel-title-button { color: #6f42a3; }

.due-row {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 110px 130px;
  align-items: center;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}

.due-row:hover,
.due-row:focus-visible {
  transform: none;
  background: rgba(18, 106, 96, .08);
  box-shadow: 0 10px 22px rgba(25, 44, 40, .1);
  outline: 2px solid rgba(18, 106, 96, .18);
}

.due-row time {
  justify-self: start;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.due-row strong {
  justify-self: end;
  font-size: 14px;
}

.due-total {
  font-size: 22px;
  color: var(--text);
}

.due-row.due-today.sale-move {
  animation: pulseSale 1.05s ease-in-out infinite;
  animation-delay: var(--pulse-delay);
}

.due-row.due-today.purchase-move {
  animation: pulsePurchase 1.05s ease-in-out infinite;
  animation-delay: var(--pulse-delay);
}

@keyframes pulseSale {
  0%, 100% {
    background: rgba(24, 135, 97, .32);
    box-shadow: 0 0 0 2px rgba(24, 135, 97, .24), 0 10px 24px rgba(24, 135, 97, .22);
  }
  50% {
    background: rgba(230, 236, 236, .96);
    box-shadow: 0 0 0 1px rgba(24, 135, 97, .08);
  }
}

@keyframes pulsePurchase {
  0%, 100% {
    background: rgba(216, 100, 100, .34);
    box-shadow: 0 0 0 2px rgba(216, 100, 100, .24), 0 10px 24px rgba(216, 100, 100, .2);
  }
  50% {
    background: rgba(230, 236, 236, .96);
    box-shadow: 0 0 0 1px rgba(216, 100, 100, .08);
  }
}

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

.module-card {
  padding: 16px;
}

.wide-card {
  grid-column: 1 / -1;
}

.module-card ul,
.timeline {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.module-card li,
.timeline li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}

.timeline li.movement {
  padding: 10px 12px;
  border-bottom: 0;
  border-left: 4px solid transparent;
  border-radius: 8px;
}

.sale-move {
  border-left-color: #188761 !important;
  background: rgba(24, 135, 97, .12);
}

.purchase-move {
  border-left-color: #d86464 !important;
  background: rgba(216, 100, 100, .13);
}

.module-card li:last-child,
.timeline li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

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

.customer-table-scroll {
  height: 390px;
  max-height: 390px;
  overflow: auto;
}

.fixed-table-scroll {
  height: 390px;
  max-height: 390px;
  overflow: auto;
}

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

th,
td {
  padding: 8px 9px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.sort-button {
  border: 0;
  padding: 0;
  width: 100%;
  color: inherit;
  background: transparent;
  font-size: inherit;
  font-weight: 800;
  text-align: inherit;
  text-transform: uppercase;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: #f7fbfa;
}

.cell-sub {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.customer-filters {
  display: grid !important;
  grid-template-columns: minmax(170px, 1.55fr) minmax(76px, .55fr) minmax(76px, .55fr) minmax(110px, .78fr) !important;
  align-items: end;
  margin-bottom: 14px;
}

.customer-filters label {
  min-width: 0;
  font-size: 12px;
}

.customer-filters input {
  min-height: 34px;
  padding: 7px 8px;
}

.total-row td {
  border-top: 2px solid var(--brand);
  background: var(--panel-soft);
  font-weight: 900;
}

.money-cell {
  text-align: right;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance-pill {
  display: inline-flex;
  justify-content: flex-end;
  min-width: 112px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.balance-pill.ok {
  background: #e8f6ef;
  color: #176448;
}

.balance-pill.warn {
  background: #fde8e8;
  color: #a32020;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.detail-hero {
  grid-column: 1 / -1;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7fbfa;
}

.detail-hero h3 {
  margin-bottom: 4px;
  font-size: 20px;
}

.detail-metric {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.detail-metric strong {
  font-size: 20px;
}

.detail-metric.receivable strong {
  color: #176448;
}

.detail-metric.payable strong {
  color: #a32020;
}

.detail-metric.status-metric strong {
  color: #356c9a;
}

.wide-field {
  grid-column: span 2;
}

.detail-sections {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: 1fr;
  gap: 12px;
}

.detail-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.detail-section h4 {
  margin: 0;
}

.compact-table table {
  min-width: 760px;
}

.statement-total {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-column: 1 / -1;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  color: #fff;
}

.statement-total.positive { background: #176448; }
.statement-total.negative { background: #a32020; }

.statement-total span {
  display: grid;
  gap: 4px;
}

.compact-table th,
.compact-table td {
  padding: 8px;
}

.status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #eef2f6;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.status.ok {
  background: #e8f6ef;
  color: #176448;
}

.status.warn {
  background: #fff4dc;
  color: #8a5d12;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-button.active {
  border-color: var(--brand);
  color: var(--brand);
  font-weight: 800;
}

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

.form-grid.two-col {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.settings-form {
  align-items: end;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  grid-column: 1 / -1;
  padding-top: 4px;
}

.save-note {
  color: var(--brand);
  font-weight: 800;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

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

.archive-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px dashed #aebfba;
  border-radius: 8px;
  background: #f9fbfa;
}

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

.app-footer {
  display: grid;
  gap: 4px;
  position: fixed;
  right: 0;
  bottom: 0;
  left: 240px;
  z-index: 12;
  padding: 9px 24px;
  border-top: 1px solid var(--line);
  background: rgba(244, 247, 246, .96);
  backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.app-footer strong {
  color: var(--text);
}

body.dark-mode .app-footer {
  color: #cfdad7;
  background: rgba(16, 22, 20, .96);
}

body.dark-mode .app-footer strong {
  color: #ffffff;
}

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

.warning-settings {
  display: grid;
  grid-column: 1 / -1;
  gap: 10px;
}

.warning-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 56px;
  gap: 10px;
}

.warning-row input[type="color"] {
  padding: 4px;
}

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

.mini-metrics span {
  display: grid;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
}

.mini-metrics strong {
  color: var(--text);
  font-size: 15px;
}

.cash-flow-panel {
  margin-top: 16px;
}

.cash-flow-chart {
  display: grid;
  grid-template-columns: repeat(30, minmax(22px, 1fr));
  gap: 6px;
  min-height: 220px;
  overflow-x: auto;
}

.cash-flow-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.cash-flow-summary span {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--muted);
  font-weight: 800;
}

.cash-flow-summary strong {
  color: var(--text);
  font-size: 18px;
}

.cash-flow-summary .summary-receipt {
  background: #e8f6ef;
}

.cash-flow-summary .summary-payment {
  background: #fde8e8;
}

.cash-flow-summary .summary-difference {
  background: #e8f1fb;
}

.cash-flow-summary .summary-receipt strong {
  color: #176448;
}

.cash-flow-summary .summary-payment strong {
  color: #a32020;
}

.cash-flow-summary .summary-difference strong {
  color: #356c9a;
}

.cash-flow-day {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 6px;
  min-width: 24px;
  text-align: center;
}

.flow-bars {
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 3px;
  min-height: 160px;
  border-bottom: 1px solid var(--line);
}

.flow-bars i {
  display: block;
  width: 8px;
  border-radius: 999px 999px 0 0;
}

.flow-in { background: #46a76f; }
.flow-out { background: #d05a5a; }

.document-preview {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
}

.voucher-preview {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), var(--panel-soft));
}

.voucher-preview .eyebrow,
.voucher-preview h3 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.voucher-preview div {
  display: grid;
  gap: 4px;
}

.voucher-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-page {
  display: grid;
  place-items: center;
  width: min(520px, 100%);
  min-height: 260px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #fff;
}

.check-row input {
  width: auto;
  min-height: auto;
}

dialog {
  width: min(1180px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(12, 24, 22, .5);
}

.dialog-card {
  padding: 18px;
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.dialog-fields {
  display: grid;
  gap: 12px;
}

#entry-dialog[data-kind="party-customer"] .dialog-fields,
#entry-dialog[data-kind="party-supplier"] .dialog-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}

#entry-dialog[data-kind="party-customer"] .dialog-fields label,
#entry-dialog[data-kind="party-supplier"] .dialog-fields label {
  min-width: 0;
}

#entry-dialog[data-kind="party-customer"] .dialog-fields label:has(textarea),
#entry-dialog[data-kind="party-supplier"] .dialog-fields label:has(textarea),
#entry-dialog[data-kind="party-customer"] .dialog-fields label:last-child,
#entry-dialog[data-kind="party-supplier"] .dialog-fields label:last-child {
  grid-column: 1 / -1;
}

.dialog-actions {
  justify-content: flex-end;
  margin: 18px 0 0;
  padding: 0;
}

.icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

@media (max-width: 1100px) {
  .app-shell {
    min-height: 100vh;
  }

  .sidebar {
    width: 86px;
  }

  .content {
    margin-left: 86px;
  }

  .brand div:last-child,
  .nav-item {
    font-size: 0;
  }

  .nav-item {
    justify-content: center;
  }

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

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

  .graph-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .app-footer {
    left: 86px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: static;
    width: auto;
    height: auto;
    padding: 12px;
  }

  .brand {
    padding-bottom: 12px;
  }

  .nav {
    grid-auto-flow: column;
    grid-auto-columns: 54px;
    overflow-x: auto;
  }

  .content {
    margin-left: 0;
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
    margin: -16px -16px 16px;
    padding: 14px 16px;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .quick-menu-panel {
    right: auto;
    left: 0;
  }

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

  #entry-dialog[data-kind="party-customer"] .dialog-fields,
  #entry-dialog[data-kind="party-supplier"] .dialog-fields {
    grid-template-columns: 1fr;
  }

  .customer-filters,
  .detail-sections {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .bar-row strong {
    grid-column: 1 / -1;
  }

  .graph-grid,
  .dashboard-grid-two {
    grid-template-columns: 1fr;
  }

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

  .due-row time {
    justify-self: start;
  }

  .app-footer {
    left: 0;
    padding: 8px 16px;
  }
}

@media print {
  .sidebar,
  .topbar,
  .app-footer,
  .section-actions,
  .customer-filters,
  .row-actions {
    display: none !important;
  }

  body {
    padding: 0;
    background: #fff;
  }

  .content {
    margin: 0;
    padding: 0;
  }

  .table-panel {
    box-shadow: none;
    border: 0;
  }

  .customer-table-scroll,
  .fixed-table-scroll {
    height: auto;
    max-height: none;
    overflow: visible;
  }

  table {
    min-width: 0;
    font-size: 11px;
  }
}
