:root {
  --bg-main:      #ffffff;
  --bg-subtle:    #f7f8fa;
  --bg-hover:     #f0f2f5;

  --border-soft:  #e5e5ea;
  --border-muted: #ededf0;

  --text-main:    #1c1c1e;
  --text-muted:   #6e6e73;

  --accent:       #1e3a5f;
  --accent-soft:  rgba(30, 58, 95, 0.10);
  --accent-hover: rgba(30, 58, 95, 0.16);

  --color-success: #2e7d32;
  --color-error:   #c62828;
  --color-warning: #e65100;

  /* Valores financeiros — marinho/cinza/cinza-claro */
  --val-recebido:  #1e3a5f;   /* azul marinho = accent */
  --val-pendente:  #6e6e73;   /* cinza médio */
  --val-total:     #aeaeb2;   /* cinza claro */
  --val-despesa:   #a01f3a;   /* vinho vivo — despesas */

  --radius-lg:   18px;
  --radius-md:   14px;
  --radius-pill: 999px;

  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  font-size: 15px;
  background: var(--bg-subtle);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────── */

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

#sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-main);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 100;
}

#content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ── Sidebar ─────────────────────────────────────────────── */

.sidebar-logo {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border-muted);
}

.sidebar-logo-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.sidebar-logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 10px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

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

.nav-item svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg { opacity: 1; }

.nav-divider {
  height: 1px;
  background: var(--border-muted);
  margin: 8px 12px;
}

.nav-group { display: flex; flex-direction: column; }

.nav-group-header { position: relative; }

.nav-chevron {
  display: flex;
  align-items: center;
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.nav-chevron.open {
  transform: rotate(90deg);
}

.nav-group-children {
  padding: 2px 0 4px 40px;
}

.nav-subitem {
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
  padding: 7px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}

.nav-subitem:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

.nav-subitem.active {
  color: var(--accent);
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-muted);
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  margin-right: 8px;
}

/* ── Page header ─────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* ── Cards ───────────────────────────────────────────────── */

.card {
  background: var(--bg-main);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04), 0 4px 16px rgba(0,0,0,0.04);
  padding: 20px;
  box-sizing: border-box;
}

.card + .card { margin-top: 16px; }

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 14px;
}

/* ── KPI row ─────────────────────────────────────────────── */

.kpi-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg-main);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.kpi-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.03em;
}

.kpi-value.success { color: var(--color-success); }
.kpi-value.warning { color: var(--color-warning); }
.kpi-value.accent  { color: var(--accent); }

/* ── Buttons ─────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background 0.12s, opacity 0.12s;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary:hover { opacity: 0.88; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-soft);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-main); }

.btn-danger {
  background: rgba(198,40,40,0.08);
  color: var(--color-error);
  border: none;
}

.btn-danger:hover { background: rgba(198,40,40,0.14); }

.btn-sm { padding: 5px 11px; font-size: 13px; }
.btn-icon { padding: 7px; border-radius: 10px; }

/* ── Badges ──────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  border: 0.5px solid transparent;
}

.badge-success { background: #e8f0e6; color: #3b5e2b; border-color: #c2d4bc; } /* verde militar */
.badge-warning { background: #f5ede8; color: #7a3520; border-color: #e0c4b4; } /* terracota escuro */
.badge-error   { background: #f2e6ea; color: #7a1f38; border-color: #d4b0bb; } /* vinho */
.badge-accent  { background: #e6ebf2; color: #1e3a5f; border-color: #b8c8dc; } /* marinho */
.badge-muted   { background: #ebebed; color: #4a4a4f; border-color: #d0d0d4; }

/* ── Table ───────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  background: var(--bg-main);
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-muted);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

/* Coluna que absorve espaço restante */
th.col-expand, td.col-expand { width: 100%; }

tbody tr:hover td { background: var(--bg-subtle); }

.td-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.12s;
}

tbody tr:hover .td-actions { opacity: 1; }

/* ── Forms ───────────────────────────────────────────────── */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}

.form-input,
.form-select {
  height: 40px;
}

.form-select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* Remove spinner nativo de input[type=number] */
.form-input[type="number"]::-webkit-inner-spin-button,
.form-input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.form-input[type="number"] { -moz-appearance: textfield; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: var(--bg-main);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: 0 8px 40px rgba(0,0,0,0.16);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.18s ease;
}

.modal-lg { max-width: 720px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-muted);
  flex-shrink: 0;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-muted);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Filters bar ─────────────────────────────────────────── */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-select {
  height: 34px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--bg-main);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
}

.filter-select:focus { border-color: var(--accent); }

/* ── Toggle inline ───────────────────────────────────────── */

.toggle-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border-soft);
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.toggle-btn.on {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

/* ── Drawer (painel lateral) ─────────────────────────────── */

.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  z-index: 500;
  animation: fadeIn 0.15s ease;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 420px;
  background: var(--bg-main);
  border-left: 1px solid var(--border-soft);
  box-shadow: -4px 0 24px rgba(0,0,0,0.10);
  z-index: 501;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.2s ease;
  overflow-y: auto;
}

.drawer-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.drawer-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.drawer-body { padding: 20px 24px; flex: 1; }

/* ── Auth ────────────────────────────────────────────────── */

#auth-screen,
#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
}

.auth-box {
  background: var(--bg-main);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 36px 40px;
  width: 100%;
  max-width: 400px;
}

.auth-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.auth-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

/* ── Toast ───────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--text-main);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.18);
  animation: slideUp 0.2s ease;
  max-width: 340px;
}

.toast.success { background: var(--color-success); }
.toast.error   { background: var(--color-error); }

/* ── Empty state ─────────────────────────────────────────── */

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

.empty-state-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  opacity: 0.3;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state-sub {
  font-size: 13px;
}

/* ── Upload ──────────────────────────────────────────────── */

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border: 1px dashed var(--border-soft);
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  transition: all 0.12s;
}

.upload-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.upload-btn.has-file { border-style: solid; border-color: var(--color-success); color: var(--color-success); background: rgba(46,125,50,0.07); }

/* ── Month selector ──────────────────────────────────────── */

.month-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-pill);
  padding: 5px 12px;
}

.month-selector-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-main);
  min-width: 100px;
  text-align: center;
}

.month-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 2px 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
}

.month-nav:hover { background: var(--bg-hover); color: var(--text-main); }

/* ── Tabs ────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-subtle);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: 20px;
  width: fit-content;
}

.tab {
  padding: 6px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: all 0.15s;
}

.tab.active {
  background: var(--bg-main);
  color: var(--text-main);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* ── Animations ──────────────────────────────────────────── */

@keyframes fadeIn   { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp  { from { opacity: 0; transform: translateY(8px) } to { opacity: 1; transform: translateY(0) } }
@keyframes slideInRight { from { transform: translateX(100%) } to { transform: translateX(0) } }

/* ── Misc ────────────────────────────────────────────────── */

.text-muted  { color: var(--text-muted); }
.text-success { color: var(--color-success); }
.text-error   { color: var(--color-error); }
.text-accent  { color: var(--accent); }
.fw-600 { font-weight: 600; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* ── Mobile drawer ───────────────────────────────────────── */

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-main);
}

@media (max-width: 768px) {
  #content { padding: 20px 16px; }

  .hamburger { display: flex; }

  #sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    transition: left 0.22s ease;
    z-index: 200;
  }

  #sidebar.open { left: 0; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.40);
    z-index: 199;
    display: none;
  }

  .sidebar-backdrop.open { display: block; }

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

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

  .drawer { width: 100%; }
}

/* ── Settings accordion ──────────────────────────────────── */

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 680px;
}

.settings-item {
  background: var(--bg-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s;
}

.settings-item.open {
  border-color: var(--accent);
}

.settings-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}

.settings-item-header:hover {
  background: var(--bg-hover);
}

.settings-item-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: var(--bg-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  flex-shrink: 0;
}

.settings-item.open .settings-item-icon {
  background: var(--accent-soft);
  color: var(--accent);
}

.settings-item-label {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
}

.settings-item.open .settings-item-label {
  color: var(--accent);
  font-weight: 600;
}

.settings-chevron {
  color: var(--text-muted);
  transition: transform 0.2s;
  display: flex;
  align-items: center;
}

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

.settings-item-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--border-muted);
  padding-top: 16px;
}
