:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --surface2: #1a1a26;
  --surface3: #202030;
  --border: #2a2a3a;
  --accent: #6ee7b7;
  --accent2: #818cf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --text: #e2e8f0;
  --muted: #64748b;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Syne, system-ui, sans-serif;
}

button, input, select {
  font: inherit;
}

.hidden { display: none !important; }
.mono { font-family: "DM Mono", monospace; }
.muted { color: var(--muted); font-size: 11px; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 16px;
  background: linear-gradient(135deg, #0f0f1a, #1a1030);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(20px);
}

.header-top, .toolbar, .actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-top { justify-content: space-between; margin-bottom: 12px; }

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

.brand img {
  width: 132px;
  height: 52px;
  border-radius: 8px;
  border: 1px solid rgba(110, 231, 183, .25);
  background: #f4f4f4;
  object-fit: contain;
  padding: 4px 6px;
}

.logo-text {
  font-size: 20px;
  font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.header-status {
  display: grid;
  justify-items: end;
  gap: 5px;
  margin-left: auto;
}

.app-version {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 700;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 10px;
  border-radius: 20px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
}

.balance-overdue-notice {
  display: grid;
  gap: 3px;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid rgba(251, 191, 36, .65);
  border-radius: 8px;
  background: rgba(251, 191, 36, .16);
  color: #fde68a;
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, .12);
}

.balance-overdue-notice span,
.balance-overdue-notice strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.balance-overdue-notice strong {
  color: var(--warn);
}

.sync-badge.connected { color: var(--accent); border-color: rgba(110, 231, 183, .4); }
.sync-badge.syncing { color: var(--accent2); border-color: rgba(129, 140, 248, .4); animation: pulse 1.2s infinite; }
.sync-badge.error { color: var(--danger); border-color: rgba(248, 113, 113, .4); }

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.sync-dot.connected { background: var(--accent); }
.sync-dot.syncing { background: var(--accent2); }
.sync-dot.error { background: var(--danger); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 12px;
  position: relative;
  width: min(100%, 760px);
}

.local-import {
  min-height: 39px;
  white-space: nowrap;
}

.connection-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid rgba(248, 113, 113, .45);
  border-radius: 8px;
  background: rgba(248, 113, 113, .1);
  color: var(--danger);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 800;
}

.internal-login-fields {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(150px, 210px);
  gap: 8px;
  width: min(100%, 460px);
}

.internal-login-fields input {
  min-height: 34px;
  padding: 8px 10px;
}

.notice-login {
  min-height: 32px;
  padding: 7px 11px;
  border: 1px solid rgba(110, 231, 183, .45);
  border-radius: 8px;
  background: rgba(110, 231, 183, .12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.day-state-badge,
.previous-date-notice {
  display: inline-flex;
  align-items: center;
  min-height: 39px;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface2);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.day-state-badge.neutral { color: var(--muted); }
.day-state-badge.info { color: var(--accent2); border-color: rgba(129, 140, 248, .35); background: rgba(129, 140, 248, .08); }
.day-state-badge.ok { color: var(--accent); border-color: rgba(110, 231, 183, .35); background: rgba(110, 231, 183, .08); }
.day-state-badge.warn,
.previous-date-notice { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.day-state-badge.danger { color: var(--danger); border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); }

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.field.compact {
  min-width: 150px;
}

.calendar-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 50;
  width: min(320px, calc(100vw - 28px));
  max-height: min(440px, calc(100vh - 190px));
  overflow-y: auto;
  padding: 12px;
  margin-top: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
}

.calendar-head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px 48px 34px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.calendar-head button {
  width: 100%;
  height: 30px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.calendar-title {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
}

.calendar-dow,
.calendar-day {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.calendar-dow {
  color: var(--muted);
  font-weight: 800;
}

.calendar-day {
  border: 1px solid transparent;
  background: var(--surface2);
  color: var(--text);
  cursor: pointer;
}

.calendar-day.out {
  opacity: .35;
}

.calendar-day.active {
  color: #0a0a0f;
  background: var(--accent);
}

.calendar-day.readonly-day:not(.active) {
  border-color: rgba(251, 191, 36, .45);
  color: var(--warn);
  background: rgba(251, 191, 36, .08);
}

.calendar-day:disabled {
  opacity: .22;
  cursor: not-allowed;
}

input, select {
  width: 100%;
  min-height: 39px;
  padding: 10px 11px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  font-family: "DM Mono", monospace;
  font-size: 12px;
}

input[type="number"] {
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

select option {
  background: var(--surface);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  padding: 10px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-weight: 800;
  color: var(--text);
  background: var(--surface2);
  cursor: pointer;
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), #34d399);
  color: #0a0a0f;
  border-color: transparent;
}

.btn.secondary {
  background: var(--surface2);
}

.btn.small {
  min-height: 42px;
  padding: 10px 13px;
  font-size: 13px;
}

.file-btn {
  position: relative;
  width: 100%;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

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

.stat {
  padding: 9px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  text-align: center;
}

.stat strong {
  display: block;
  color: var(--accent);
  font-size: 16px;
  line-height: 1.2;
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  margin-top: 3px;
  text-transform: uppercase;
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

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

.panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 220px);
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
}

.panel-head > .pill,
.panel-head > .btn {
  justify-self: start;
  min-width: 0;
  width: 100%;
  text-align: center;
}

.panel h2 {
  margin: 0;
  font-size: 14px;
  letter-spacing: .7px;
  text-transform: uppercase;
}

.module-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.module-title-wrap > div {
  min-width: 0;
}

.module-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  flex: 0 0 auto;
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 800;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.module[data-module="bills"] { --module-color: #c08497; --module-color-2: #d8a7b8; --module-ink: #fff7fb; }
.module[data-module="closure"] { --module-color: #10b981; --module-color-2: #34d399; --module-ink: #052e22; }
.module[data-module="differences"] { --module-color: #ef4444; --module-color-2: #fb7185; --module-ink: #fff1f2; }
.module[data-module="payments"] { --module-color: #f97316; --module-color-2: #fb923c; --module-ink: #431407; }
.module[data-module="balances"] { --module-color: #0ea5e9; --module-color-2: #38bdf8; --module-ink: #f0f9ff; }
.module[data-module="summary"] { --module-color: #f59e0b; --module-color-2: #fbbf24; --module-ink: #451a03; }
.module[data-module="dashboard"] { --module-color: #14b8a6; --module-color-2: #2dd4bf; --module-ink: #042f2e; }

.module {
  border-color: color-mix(in srgb, var(--module-color, var(--border)) 28%, var(--border));
}

.module-icon,
.module h2 {
  color: var(--module-color, var(--accent));
}

.module-icon {
  border-color: color-mix(in srgb, var(--module-color, var(--border)) 34%, var(--border));
  background: color-mix(in srgb, var(--module-color, var(--surface2)) 12%, var(--surface2));
}

.module .btn.primary {
  background: linear-gradient(135deg, var(--module-color), var(--module-color-2));
  color: #05050a;
  border-color: transparent;
}

.module-chevron {
  color: var(--muted);
  font-size: 11px;
  flex: 0 0 auto;
  transition: transform .18s ease;
}

.module.is-open .module-chevron {
  transform: rotate(180deg);
}

.module-body {
  display: none;
}

.module.is-open .module-body {
  display: block;
}

.panel p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.stack {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.stack .btn {
  margin-top: 2px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 620px;
  table-layout: fixed;
  font-family: "DM Mono", monospace;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

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

td {
  font-size: 12px;
}

td input {
  min-height: 34px;
  text-align: center;
}

td:first-child,
th:first-child {
  text-align: left;
}

td input[data-kind="note"],
td input[type="text"][placeholder*="Comentario"] {
  text-align: left;
}

td input[readonly], td input:disabled, input:disabled, select:disabled {
  opacity: .7;
  cursor: not-allowed;
}

tfoot td {
  color: var(--accent);
  font-weight: 800;
}

.actions {
  padding: 14px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: stretch;
}

.actions .btn,
.stack .btn {
  width: 100%;
  min-height: 42px;
}

.btn.subtle {
  min-height: 36px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
  border-color: var(--border);
}

.action-note {
  width: 100%;
}

.bill-mode {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 14px;
  border-bottom: 1px solid var(--border);
}

.seg-btn {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface2);
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.seg-btn.active {
  color: #0a0a0f;
  background: linear-gradient(135deg, var(--module-color, var(--accent)), var(--module-color-2, #34d399));
  border-color: transparent;
}

.locked {
  position: relative;
}

.locked .module-body {
  opacity: .72;
}

.pill {
  flex-shrink: 0;
  padding: 6px 9px;
  border-radius: 20px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-weight: 800;
  border: 1px solid var(--border);
}

.pill.ok { color: var(--accent); border-color: rgba(110, 231, 183, .35); background: rgba(110, 231, 183, .08); }
.pill.warn { color: var(--warn); border-color: rgba(251, 191, 36, .35); background: rgba(251, 191, 36, .08); }
.pill.danger { color: var(--danger); border-color: rgba(248, 113, 113, .35); background: rgba(248, 113, 113, .08); }

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

.amount-positive {
  color: var(--accent) !important;
}

.amount-negative {
  color: var(--danger) !important;
}

.amount-zero {
  color: var(--muted) !important;
}

.pill.amount-positive {
  background: rgba(110, 231, 183, .08);
  border-color: rgba(110, 231, 183, .35);
}

.pill.amount-negative {
  background: rgba(248, 113, 113, .08);
  border-color: rgba(248, 113, 113, .35);
}

.pill.amount-zero {
  background: var(--surface2);
  border-color: var(--border);
}

.list {
  display: grid;
  gap: 8px;
  padding: 0 14px 14px;
}

.list-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.list-item strong {
  display: block;
  font-size: 12px;
}

.list-item span {
  display: block;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  margin-top: 2px;
}

.list-item button {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .12);
  color: var(--danger);
  cursor: pointer;
}

.payment-table {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.payment-row {
  display: grid;
  grid-template-columns: 98px minmax(110px, .8fr) minmax(150px, 1.2fr) minmax(110px, .8fr) minmax(100px, .7fr) minmax(140px, auto);
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.payment-row-head {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  background: var(--surface3);
}

.payment-row strong {
  color: var(--accent);
  text-align: right;
}

.payment-row input,
.payment-row select {
  min-height: 34px;
  padding: 7px 8px;
  font-size: 10px;
}

.payment-row.editing {
  border-color: rgba(129, 140, 248, .45);
  background: rgba(129, 140, 248, .08);
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.btn.tiny {
  min-height: 30px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 10px;
}

.btn.tiny.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .1);
}

.balance-total {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 2px 0 0;
  padding: 13px;
  background: rgba(110, 231, 183, .08);
  border: 1px solid rgba(110, 231, 183, .25);
  border-radius: 8px;
}

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

.balance-total strong {
  color: var(--accent);
  font-size: 19px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 0 14px 14px;
}

.summary-card {
  padding: 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.summary-card span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.summary-card strong {
  display: block;
  margin-top: 7px;
  color: var(--accent);
  font-size: 20px;
}

.module-done {
  margin: 12px 14px 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--module-color, var(--accent)) 45%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--module-color, var(--accent)) 13%, transparent);
  color: var(--module-color, var(--accent));
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

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

.dashboard-period {
  display: flex;
  gap: 8px;
  padding: 0 14px 10px;
}

.dashboard-period button {
  min-height: 34px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--module-color) 34%, var(--border));
  border-radius: 8px;
  background: var(--surface2);
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
}

.dashboard-period button.active {
  background: color-mix(in srgb, var(--module-color) 22%, var(--surface2));
  color: var(--module-color-2);
  border-color: var(--module-color);
}

.dashboard-kpi-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.dashboard-kpi,
.dashboard-card {
  padding: 13px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.dashboard-kpi {
  display: grid;
  gap: 5px;
  min-height: 94px;
  align-content: center;
}

.dashboard-kpi span,
.dashboard-card-head span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.dashboard-kpi strong {
  overflow-wrap: anywhere;
  color: var(--accent);
  font-size: 21px;
  line-height: 1.05;
}

.dashboard-kpi em {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  font-style: normal;
}

.dashboard-kpi.payments strong { color: var(--module-color-2); }
.dashboard-kpi.danger strong { color: var(--danger); }
.dashboard-kpi.ok strong { color: var(--accent); }

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

.dashboard-main-row {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, .95fr);
  gap: 10px;
  align-items: start;
}

.dashboard-share-stack {
  display: grid;
  gap: 10px;
}

.dashboard-exec-card {
  min-height: 180px;
}

.dashboard-donut-card {
  min-height: 0;
}

.dashboard-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dashboard-card-head strong {
  color: var(--accent);
  font-size: 18px;
  line-height: 1.05;
  text-align: right;
}

.dashboard-exec-card p {
  margin: 5px 0 14px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.dashboard-card h3 {
  margin: 0 0 10px;
  color: var(--module-color, var(--accent2));
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.dashboard-rows {
  display: grid;
  gap: 7px;
}

.dashboard-rows div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.dashboard-rows span,
.dashboard-list span {
  color: var(--muted);
}

.dashboard-rows strong {
  color: var(--accent);
  text-align: right;
}

.dashboard-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.dashboard-stackbar {
  display: flex;
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface3);
}

.dashboard-stackbar i {
  display: block;
  width: var(--segment-width);
  min-width: 0;
  background: var(--segment-color);
}

.dashboard-stack-legend,
.dashboard-legend,
.dashboard-alerts {
  display: grid;
  gap: 7px;
  margin-top: 13px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.dashboard-stack-legend span,
.dashboard-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
}

.dashboard-stack-legend i,
.dashboard-legend i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.dashboard-insight,
.dashboard-empty {
  margin-top: 12px;
  color: var(--accent);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  font-weight: 800;
}

.dashboard-bars {
  display: grid;
  gap: 9px;
}

.dashboard-bar-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 10px;
  align-items: center;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.dashboard-bar-row span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-bar-row strong {
  color: var(--accent);
}

.dashboard-bar-row i {
  grid-column: 1 / -1;
  display: block;
  width: var(--bar-width);
  height: 7px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--module-color), var(--module-color-2));
}

.dashboard-donut-wrap {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 15px;
  align-items: center;
}

.dashboard-donut-card .dashboard-donut-wrap {
  align-items: center;
  min-height: 118px;
}

.dashboard-donut {
  width: 112px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: conic-gradient(var(--donut));
  position: relative;
}

.dashboard-donut::after {
  content: "";
  position: absolute;
  inset: 27px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
}

.dashboard-legend {
  margin-top: 0;
}

.dashboard-legend strong {
  margin-left: auto;
  color: var(--accent);
}

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

.dashboard-balance-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.dashboard-balance-meter span {
  color: var(--muted);
}

.dashboard-alerts {
  display: grid;
  gap: 8px;
}

.dashboard-alert-item {
  display: grid;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
}

.dashboard-alert-item strong {
  font-size: 10px;
}

.dashboard-alert-item span {
  color: var(--muted);
  font-size: 10px;
}

.dashboard-alert-item.danger {
  color: var(--danger);
  border-color: rgba(248, 113, 113, .35);
  background: rgba(248, 113, 113, .08);
}

.dashboard-alert-item.warn {
  color: var(--warn);
  border-color: rgba(251, 191, 36, .35);
  background: rgba(251, 191, 36, .08);
}

.dashboard-alert-item.ok {
  color: var(--accent);
  border-color: rgba(110, 231, 183, .35);
  background: rgba(110, 231, 183, .08);
}

.dashboard-line-chart {
  display: grid;
  gap: 8px;
}

.dashboard-line-chart svg {
  width: 100%;
  height: 190px;
  overflow: visible;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
}

.dashboard-line-chart polyline {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.dashboard-line-chart .dashboard-grid-line {
  stroke: rgba(255, 255, 255, .06);
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.dashboard-line-chart .dashboard-zero-line {
  stroke: rgba(148, 163, 184, .35);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.dashboard-line-chart .dashboard-axis-label {
  fill: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  text-anchor: end;
  vector-effect: non-scaling-stroke;
}

.dashboard-line-chart .line-sales {
  stroke: #22c55e;
  background: #22c55e;
}

.dashboard-line-chart .line-payments {
  stroke: #ef4444;
  background: #ef4444;
}

.dashboard-line-chart circle {
  stroke: var(--surface2);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.dashboard-line-chart .point-sales {
  fill: #22c55e;
}

.dashboard-line-chart .point-payments {
  fill: #ef4444;
}

.dashboard-line-labels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 5px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  text-align: center;
}

.dashboard-line-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.dashboard-line-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dashboard-line-legend i {
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

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

.mini-series {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.mini-series-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.mini-series-head span {
  color: var(--muted);
}

.mini-series-head strong {
  color: var(--accent);
  text-align: right;
}

.mini-bars {
  display: grid;
  grid-template-columns: repeat(5, minmax(18px, 1fr));
  align-items: end;
  gap: 6px;
  height: 96px;
  padding: 8px 8px 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
}

.mini-bar {
  display: grid;
  align-items: end;
  gap: 4px;
  height: 100%;
  min-width: 0;
}

.mini-bar i {
  display: block;
  width: 100%;
  height: var(--bar-height);
  min-height: 5px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, var(--module-color-2, var(--accent)), var(--module-color, var(--accent)));
}

.mini-bar.is-negative i {
  background: linear-gradient(180deg, #fb7185, #ef4444);
}

.mini-bar em {
  overflow: hidden;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-style: normal;
  text-align: center;
  text-overflow: clip;
  white-space: nowrap;
}

.toast {
  position: fixed;
  left: 50%;
  top: 14px;
  bottom: auto;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 28px));
  z-index: 30;
  padding: 14px 16px;
  background: rgba(26, 26, 38, .98);
  border: 1px solid rgba(110, 231, 183, .35);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .35);
}

@media (max-width: 900px) {
  .main-grid { grid-template-columns: 1fr; }
  .stats-row, .summary-grid, .dashboard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-main-row { grid-template-columns: 1fr; }
  .mini-chart { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-evolution { grid-template-columns: 1fr; }
  .panel-head { grid-template-columns: minmax(0, 1fr) minmax(120px, 180px); }
  .payment-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .payment-row-head {
    display: none;
  }
  .row-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }
  .row-actions .btn {
    flex: 1;
  }
}

@media (max-width: 560px) {
  .app-header { padding: 13px; }
  .header-top {
    align-items: flex-start;
    gap: 8px;
  }
  .brand img { width: 104px; height: 44px; }
  .logo-text { font-size: 17px; }
  .muted { font-size: 10px; }
  .header-status {
    justify-items: end;
    max-width: 150px;
  }
  .sync-badge {
    max-width: 150px;
    padding: 7px 9px;
  }
  .sync-badge span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .toolbar {
    width: 100%;
  }
  .toolbar > * { flex: 1 1 100%; }
  .calendar-panel {
    width: min(100%, calc(100vw - 26px));
    max-height: min(390px, calc(100vh - 170px));
  }
  .stats-row, .summary-grid, .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-kpi-row { grid-template-columns: 1fr; }
  .dashboard-main-row { grid-template-columns: 1fr; }
  .mini-chart { grid-template-columns: 1fr; }
  .dashboard-period { flex-wrap: wrap; }
  .dashboard-period button { flex: 1 1 100px; }
  .dashboard-donut-wrap { grid-template-columns: 1fr; }
  .dashboard-donut { width: 104px; }
  .bill-mode { grid-template-columns: 1fr; }
  .panel-head {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px;
  }
  .panel-head > .pill,
  .panel-head > .btn {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }
  .module-title-wrap {
    align-items: flex-start;
  }
  .module-title-wrap p {
    display: none;
  }
  table {
    min-width: 560px;
  }
}

@media (max-width: 380px) {
  .brand {
    gap: 7px;
  }
  .brand img {
    width: 92px;
  }
  .logo-text {
    font-size: 15px;
  }
  .sync-badge,
  .app-version {
    font-size: 9px;
  }
}
