html, body { margin: 0; padding: 0; background: #F1F4F6; }
body { font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased; color: #14171C; }
* { box-sizing: border-box; }
a { color: #17C3A2; text-decoration: none; }
a:hover { color: #0FA689; text-decoration: underline; }
::selection { background: #CDE9E1; }

.card { background: #fff; border: 1px solid #E4E8EB; border-radius: 14px; padding: 20px 22px; }
.section-title { margin: 0; font-size: 14px; font-weight: 600; }
.muted { color: #71767F; }
.small-muted { color: #8A9099; font-size: 11.5px; }

.layout { display: flex; min-height: 100vh; }
.sidebar { width: 252px; flex: 0 0 252px; background: #fff; border-right: 1px solid #E4E8EB; display: flex; flex-direction: column; padding: 22px 14px; gap: 26px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px; object-fit: cover; background: #fff; border: 1px solid #EEF1F3; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; cursor: pointer; font-family: inherit; font-size: 13.5px; padding: 9px 10px; border-radius: 9px; background: transparent; color: #4A5059; font-weight: 400; text-decoration: none; }
.nav-item:hover { background: #F7F9F9; text-decoration: none; }
.nav-item.active { background: #CFF7EE; color: #17C3A2; font-weight: 600; }
.nav-dot { width: 6px; height: 6px; border-radius: 99px; flex: 0 0 6px; background: #D3D9DD; }
.nav-item.active .nav-dot { background: #17C3A2; }
.patrimonio { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 14px; background: #E3FBF4; border: 1px solid #E4E8EB; border-radius: 12px; }

.drawer-close { display: none; }

.mobile-topbar { display: none; }
.hamburger-btn { border: 0; background: transparent; padding: 6px; margin: -6px; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.hamburger-btn span { width: 20px; height: 2px; border-radius: 2px; background: #14171C; display: block; }

.backdrop { display: none; }

.main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 26px 34px 20px; background: #fff; border-bottom: 1px solid #E4E8EB; flex-wrap: wrap; position: sticky; top: 0; z-index: 5; }
.content { padding: 26px 34px 46px; display: flex; flex-direction: column; gap: 22px; }

.btn-primary { border: 0; border-radius: 10px; background: #17C3A2; color: #fff; font-size: 13px; font-weight: 500; padding: 10px 15px; cursor: pointer; font-family: inherit; }
.btn-primary:hover { background: #0FA689; }
.btn-ghost { border: 1px solid #E4E8EB; border-radius: 10px; background: #fff; color: #4A5059; font-size: 13px; font-weight: 500; padding: 9px 14px; cursor: pointer; font-family: inherit; }
.month-nav { display: flex; align-items: center; gap: 6px; border: 1px solid #E4E8EB; border-radius: 10px; padding: 7px 12px; font-size: 13px; font-weight: 500; }
.month-nav a { color: #71767F; font-size: 14px; padding: 0 2px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; }
.kpi-card { background: #fff; border: 1px solid #E4E8EB; border-radius: 14px; padding: 16px 17px; display: flex; flex-direction: column; gap: 9px; }
.kpi-label { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #71767F; letter-spacing: 0.3px; text-transform: uppercase; }
.kpi-dot { width: 8px; height: 8px; border-radius: 2px; }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.9px; }
.delta-up { font-size: 12px; font-weight: 500; color: #17C3A2; }
.delta-down { font-size: 12px; font-weight: 500; color: #FF6B6B; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; }

.progress-track { height: 9px; border-radius: 99px; background: #F1F4F6; overflow: hidden; }
.progress-track.thin { height: 7px; }
.progress-fill { height: 100%; border-radius: 99px; }

.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #F3F5F7; }
.row:last-child { border-bottom: 0; }
.chip { width: 34px; height: 34px; border-radius: 10px; flex: 0 0 34px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; }
.row-name { font-size: 13.5px; font-weight: 500; }
.row-meta { font-size: 11.5px; color: #8A9099; }
.row-amount { font-size: 13.5px; font-weight: 600; }

.amt-pos { font-size: 13.5px; font-weight: 600; color: #17C3A2; }
.amt-neg { font-size: 13.5px; font-weight: 600; color: #14171C; }
.amt-zero { font-size: 13.5px; font-weight: 600; color: #8A9099; }

.dark-card { background: #132A24; border-radius: 14px; padding: 20px 22px; display: flex; flex-direction: column; gap: 14px; color: #E8F5F0; }
.dark-card a { color: #33F5D0; }

.insight-card { background: #fff; border: 1px solid #E4E8EB; border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.insight-tag { font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; }

.form-grid { display: flex; flex-direction: column; gap: 12px; }
.form-grid label { font-size: 11px; color: #8A9099; letter-spacing: 0.3px; text-transform: uppercase; display: block; margin-bottom: 5px; }
.form-grid input, .form-grid select { width: 100%; font-family: inherit; font-size: 13.5px; padding: 9px 11px; background: #F8FAFB; border: 1px solid #E4E8EB; border-radius: 9px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }

.flash { font-size: 12.5px; padding: 10px 14px; border-radius: 10px; margin: 0 0 4px; }
.flash-ok { background: #CFF7EE; color: #0FA689; border: 1px solid #A8ECD9; }
.flash-error { background: #FFE0E0; color: #C23636; border: 1px solid #FFC2C2; }

table.plain { width: 100%; border-collapse: collapse; }
table.plain th { text-align: left; font-size: 11px; color: #8A9099; letter-spacing: 0.3px; text-transform: uppercase; font-weight: 500; padding: 0 0 12px; border-bottom: 1px solid #EEF1F3; }
table.plain th.num, table.plain td.num { text-align: right; }
table.plain td { padding: 14px 0; border-bottom: 1px solid #F3F5F7; font-size: 13.5px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }

  /* Sidebar becomes an off-canvas drawer, closed by default. */
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 84%;
    max-width: 300px;
    height: 100vh;
    flex: none;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 60;
    box-shadow: 4px 0 28px rgba(20, 23, 28, 0.18);
  }
  body.drawer-open .sidebar { transform: translateX(0); }

  .drawer-close {
    display: block;
    align-self: flex-end;
    border: 0; background: transparent; color: #8A9099;
    font-size: 26px; line-height: 1; padding: 4px 8px; margin: -8px -8px 0 0;
    cursor: pointer;
  }

  .backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(20, 23, 28, 0.4);
    z-index: 55;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  body.drawer-open .backdrop { opacity: 1; pointer-events: auto; }
  body.drawer-open { overflow: hidden; }

  /* Compact top bar with the menu button, shown only on phone widths. */
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: #fff;
    border-bottom: 1px solid #E4E8EB;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  .mobile-topbar-logo { width: 24px; height: 24px; border-radius: 7px; object-fit: cover; }
  .mobile-topbar-title { font-size: 14px; font-weight: 600; letter-spacing: -0.2px; }

  .patrimonio { margin-top: auto; }
  .topbar { padding: 16px 18px; align-items: flex-start; }
  .content { padding: 16px 18px; }
}
