:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --line: #e3e8ef;
  --brand: #0f766e;
  --brand-strong: #0f544f;
  --danger: #b42318;
  --ok: #e8f7ef;
  --warn: #fff4df;
  font-family: "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
}

a {
  color: var(--brand);
  text-decoration: none;
}

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

.sidebar {
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  min-height: 100vh;
  padding: 20px 14px;
  position: sticky;
  top: 0;
}

.main-shell {
  min-width: 0;
}

.workspace-bar {
  align-items: center;
  background: rgba(246, 247, 249, 0.94);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: 68px;
  padding: 14px 32px;
  position: sticky;
  top: 0;
  z-index: 3;
}

.workspace-bar strong {
  display: block;
  font-size: 18px;
}

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

.brand {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  font-size: 17px;
  font-weight: 700;
  gap: 12px;
  line-height: 1.15;
}

.brand img {
  height: 34px;
  object-fit: contain;
  width: 34px;
}

.side-nav {
  display: grid;
  gap: 4px;
  overflow-y: auto;
  padding-right: 2px;
}

.side-nav a {
  align-items: center;
  border-radius: 7px;
  color: #344054;
  display: flex;
  font-weight: 600;
  justify-content: space-between;
  min-height: 36px;
  padding: 8px 10px;
}

.side-nav a:hover {
  background: #f2f5f7;
  color: var(--brand-strong);
}

.side-nav a.active {
  background: #eef6f5;
  color: var(--brand-strong);
}

.side-nav strong {
  background: #e8f7ef;
  border-radius: 999px;
  color: var(--brand-strong);
  font-size: 12px;
  min-width: 24px;
  padding: 2px 7px;
  text-align: center;
}

.nav-label,
.eyebrow {
  color: #7a8699;
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.nav-label {
  margin: 18px 10px 6px;
}

.page {
  margin: 0;
  max-width: none;
  padding: 32px;
}

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

.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 420px;
  padding: 24px;
  width: 100%;
}

.login-brand {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.login-brand img {
  height: 42px;
  width: 42px;
}

.login-brand h1 {
  margin: 0;
}

.login-help {
  font-size: 13px;
  margin: 14px 0 0;
}

.toolbar,
.section-head,
.actions {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.toolbar {
  align-items: flex-start;
  flex-wrap: wrap;
}

.toolbar-actions {
  display: flex;
  flex: 1 1 420px;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0 4px;
}

.quick-filters a {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 11px;
}

.quick-filters a.active {
  background: #eef6f5;
  border-color: #9fd0c8;
  color: var(--brand-strong);
}

.filters {
  display: grid;
  flex: 1;
  gap: 10px;
  grid-template-columns: minmax(260px, 2fr) repeat(3, minmax(145px, 1fr));
  min-width: min(100%, 720px);
}

.filters button {
  min-width: 110px;
}

input,
select,
textarea,
button,
.button {
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  min-height: 40px;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

button,
.button {
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 600;
  justify-content: center;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

button:hover,
.button:hover {
  background: #f8fafc;
}

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

.primary {
  background: var(--brand);
  border-color: var(--brand);
  border-radius: 7px;
  color: #fff;
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  padding: 10px 14px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: #9fd0c8;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .10);
  outline: 0;
}

.danger {
  border-color: #f3b4ae;
  color: var(--danger);
}

.summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  margin: 18px 0;
}

.dashboard-hero {
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #eef8f6 100%);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-bottom: 18px;
  padding: 24px;
}

.dashboard-hero h1 {
  font-size: 30px;
  letter-spacing: 0;
  margin: 6px 0 6px;
}

.dashboard-hero p {
  color: var(--muted);
  margin: 0;
}

.hero-total {
  background: rgba(255, 255, 255, .78);
  border: 1px solid #d6e8e5;
  border-radius: 8px;
  min-width: 240px;
  padding: 18px;
}

.hero-total span,
.hero-total small {
  color: var(--muted);
  display: block;
}

.hero-total strong {
  display: block;
  font-size: 28px;
  margin: 6px 0;
}

.metric-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 18px;
}

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #cfd8e3;
  border-radius: 8px;
  color: var(--ink);
  display: block;
  padding: 16px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.metric-card:hover,
.mini-list a:hover {
  border-color: #cfd8e3;
  box-shadow: 0 8px 22px rgba(16, 24, 40, .07);
  transform: translateY(-1px);
}

.metric-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-bottom: 10px;
}

.metric-card strong {
  display: block;
  font-size: 28px;
}

.metric-card.urgent {
  border-left-color: #2b7fff;
}

.metric-card.danger-soft {
  border-left-color: #d92d20;
}

.metric-card.warn-soft {
  border-left-color: #f79009;
}

.metric-card.ok-soft {
  border-left-color: #12b76a;
}

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

.dashboard-grid h2 {
  font-size: 18px;
  margin: 0;
}

.mini-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.mini-list a {
  background: #f9fafb;
  border: 1px solid #eef1f5;
  border-radius: 7px;
  color: var(--ink);
  display: block;
  padding: 10px;
  transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.mini-list span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.bottom-summary {
  margin-top: 28px;
}

.summary > div,
.panel,
.table-wrap,
.preview {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary > div {
  min-height: 86px;
  padding: 13px 14px;
}

.summary-number {
  display: block;
  font-size: 18px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.25;
  margin-bottom: 5px;
  word-break: normal;
}

.summary-label,
.muted {
  color: var(--muted);
}

.summary-label {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.table-wrap {
  margin-bottom: 18px;
  overflow: auto;
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.mobile-cards {
  display: none;
}

.month-head {
  align-items: center;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr);
  margin: 22px 0 8px;
}

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

.month-head span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

.month-head strong {
  display: block;
  font-size: 18px;
  text-align: right;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 0;
  table-layout: fixed;
  width: 100%;
}

th,
td {
  border-bottom: 1px solid #edf1f5;
  font-size: 13px;
  overflow-wrap: normal;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #fbfcfd;
  color: #667085;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  white-space: nowrap;
}

td:nth-child(2),
td:nth-child(4),
td:nth-child(5),
td:nth-child(7),
td:nth-child(8) {
  white-space: nowrap;
}

td:nth-child(6) {
  overflow-wrap: anywhere;
}

tbody tr:hover td {
  background: #fbfcfd;
}

tbody tr.row-cobrado:hover td {
  background: #e8f7ef;
}

tbody tr.row-incompleto:hover td {
  background: #eef5ff;
}

tbody tr.row-proximo:hover td {
  background: #fff4d7;
}

tbody tr.row-vencido:hover td {
  background: #fff0ee;
}

tr.row-cobrado td {
  background: #e8f7ef;
}

tr.row-incompleto td {
  background: #eef5ff;
}

tr.row-proximo td {
  background: #fff4d7;
}

tr.row-vencido td {
  background: #fff0ee;
}

.marks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.marks span:not(.muted) {
  background: #edf2f7;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 7px;
}

.mark-checks {
  display: grid;
  gap: 5px;
  grid-template-columns: 1fr;
}

.mark-checks label {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  flex-direction: row;
  font-size: 11px;
  gap: 4px;
  white-space: nowrap;
}

.inline-money {
  background: rgba(255, 255, 255, .74);
  min-height: 34px;
  padding: 6px 8px;
  width: 100%;
  white-space: nowrap;
}

.inline-money:disabled {
  opacity: .7;
}

.mark-checks input {
  min-height: auto;
  padding: 0;
  width: auto;
}

.month-totals {
  background: #fbfcfd;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 28px;
  justify-content: flex-end;
  padding: 12px 14px;
}

.month-totals span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  text-align: right;
}

.month-totals strong {
  display: block;
  font-size: 18px;
  text-align: right;
}

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

.badge {
  background: #eef6f5;
  border: 1px solid #c8e3df;
  border-radius: 999px;
  color: var(--brand-strong);
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 9px;
}

.badge-warning {
  background: #fff4d7;
  border-color: #f2d27c;
  color: #7a4e00;
}

.row-action {
  background: #eef6f5;
  border: 1px solid #c8e3df;
  border-radius: 7px;
  color: var(--brand-strong);
  display: inline-flex;
  font-weight: 700;
  justify-content: center;
  min-width: 58px;
  padding: 6px 8px;
  white-space: nowrap;
}

.row-actions {
  gap: 6px;
  text-align: right;
  white-space: nowrap;
}

.inline-delete {
  margin: 0;
}

.link-danger {
  background: transparent;
  border: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
  min-height: 0;
  padding: 0;
}

.thumb-link {
  display: inline-flex;
}

.list-thumb {
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 6px;
  display: block;
  height: 46px;
  object-fit: cover;
  width: 62px;
}

.quick-upload p {
  margin: -6px 0 14px;
}

.compact-message {
  margin: 14px 0;
}

.bank-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.bank-picks button {
  background: #f8fafb;
  border-radius: 999px;
  font-size: 12px;
  min-height: 34px;
  padding: 6px 10px;
}

.concept-picks {
  margin-top: -6px;
}

.panel {
  padding: 22px;
}

.clean-panel {
  box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
}

.narrow {
  margin: 0 auto;
  max-width: 640px;
}

h1 {
  font-size: 24px;
  margin: 0 0 16px;
}

.section-head h1 {
  margin: 0;
}

.form,
.grid {
  display: grid;
  gap: 14px;
}

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

.primary-fields {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.primary-fields input,
.primary-fields select {
  min-height: 44px;
}

.secondary-fields {
  margin-top: 4px;
}

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

label input,
label select,
label textarea {
  color: var(--ink);
  font-weight: 400;
  width: 100%;
}

.check-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 0;
  padding: 12px;
}

.check-row legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 6px;
}

.check-row label {
  align-items: center;
  color: var(--ink);
  display: inline-flex;
  flex-direction: row;
  gap: 7px;
}

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

.editor,
.detail-layout {
  align-items: start;
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 420px;
}

.editor-pending {
  grid-template-columns: minmax(0, 1fr) 520px;
}

.editor-pending .preview {
  position: sticky;
  top: 78px;
}

.preview {
  overflow: hidden;
}

.preview-actions {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 10px;
}

.preview img {
  display: block;
  max-height: 720px;
  object-fit: contain;
  width: 100%;
}

.editor-pending .preview img {
  max-height: calc(100vh - 150px);
}

.image-empty {
  align-items: center;
  color: var(--muted);
  display: flex;
  min-height: 260px;
  justify-content: center;
}

details {
  border-top: 1px solid var(--line);
  padding: 12px;
}

pre {
  overflow: auto;
  white-space: pre-wrap;
}

.facts {
  display: grid;
  gap: 10px 18px;
  grid-template-columns: 150px 1fr;
  margin: 18px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
}

.messages {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.message {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
}

.message.ok {
  background: var(--ok);
}

.message.warning {
  background: var(--warn);
}

.message.error {
  background: #fff0ee;
  border-color: #f3b4ae;
}

.detail-warning {
  margin: 14px 0 0;
}

.backup-layout {
  display: grid;
  gap: 24px;
  grid-template-columns: minmax(0, 1fr) 360px;
}

.backup-layout h2 {
  font-size: 18px;
  margin: 10px 0 12px;
}

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

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

.backup-item span {
  color: var(--muted);
  display: block;
  font-size: 13px;
}

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

.agenda-column {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.agenda-column h2 {
  font-size: 16px;
  margin: 0 0 10px;
}

.agenda-item,
.history-item {
  background: #f8fafb;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 8px;
  padding: 10px;
}

.agenda-item.row-vencido {
  background: #fff0ee;
}

.agenda-item.row-proximo {
  background: #fff4d7;
}

.agenda-item p,
.history-item p {
  margin: 5px 0;
}

.agenda-item span,
.history-item span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.history-block {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}

.history-block h2 {
  font-size: 18px;
  margin: 0 0 10px;
}

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

.small-empty {
  padding: 14px;
}

.report-panel {
  background: #fff;
}

.report-head {
  margin-bottom: 18px;
}

.report-head h1 {
  margin-bottom: 4px;
}

.report-head p {
  color: var(--muted);
  margin: 4px 0;
}

.report-totals {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.report-totals div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.report-totals span {
  color: var(--muted);
  display: block;
  font-size: 12px;
}

.report-totals strong {
  display: block;
  font-size: 18px;
}

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

  .sidebar {
    border-bottom: 1px solid var(--line);
    border-right: 0;
    height: auto;
    min-height: 0;
    min-width: 0;
    position: static;
    width: 100%;
  }

  .main-shell,
  .workspace-bar,
  .page,
  .toolbar,
  .filters {
    min-width: 0;
    width: 100%;
  }

  .side-nav {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .side-nav a {
    flex: 0 0 auto;
  }

  .nav-label {
    display: none;
  }

  .workspace-bar,
  .toolbar,
  .section-head {
    align-items: stretch;
    flex-direction: column;
  }

  .workspace-bar {
    position: static;
    padding: 14px 18px;
  }

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

  .toolbar-actions {
    flex: 1 1 100%;
    justify-content: flex-start;
  }

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

  .hero-total {
    min-width: 0;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions button {
    width: 100%;
  }

  .filters,
  .month-head,
  .grid,
  .editor,
  .detail-layout,
  .backup-layout,
  .dashboard-grid,
  .agenda-grid {
    grid-template-columns: 1fr;
  }

  .month-head strong {
    text-align: left;
  }

  .month-totals {
    justify-content: flex-start;
  }

  .month-totals span,
  .month-totals strong {
    text-align: left;
  }

  .page {
    padding: 16px;
  }

  .editor-pending .preview {
    position: static;
  }
}

@media print {
  .sidebar,
  .workspace-bar,
  .no-print,
  .messages {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page {
    max-width: none;
    padding: 0;
  }

  .app-shell {
    display: block;
  }

  .panel,
  .report-panel {
    border: 0;
    border-radius: 0;
    padding: 0;
  }

  table {
    min-width: 0;
    page-break-inside: auto;
  }

  th,
  td {
    font-size: 11px;
    padding: 6px;
  }
}

@media (max-width: 700px) {
  .table-wrap {
    display: none;
  }

  .mobile-cards {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
  }

  .cheque-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .cheque-card.row-cobrado {
    background: #e8f7ef;
  }

  .cheque-card.row-incompleto {
    background: #eef5ff;
  }

  .cheque-card.row-proximo {
    background: #fff4d7;
  }

  .cheque-card.row-vencido {
    background: #fff0ee;
  }

  .card-photo {
    background: #f8fafb;
    display: block;
  }

  .card-photo img {
    aspect-ratio: 16 / 9;
    display: block;
    object-fit: cover;
    width: 100%;
  }

  .card-main,
  .card-actions {
    align-items: center;
    display: flex;
    gap: 10px;
    justify-content: space-between;
    padding: 12px;
  }

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

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

  .card-facts {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin: 0;
    padding: 0 12px 12px;
  }

  .card-facts div {
    min-width: 0;
  }

  .card-facts dt {
    font-size: 12px;
  }

  .card-facts dd {
    overflow-wrap: anywhere;
  }

  .card-actions {
    border-top: 1px solid var(--line);
    justify-content: flex-start;
  }

  .card-actions form {
    margin: 0;
  }

  .card-actions a,
  .card-actions button {
    min-height: 38px;
  }
}
