/* Navegação e moldura do aplicativo. Os componentes financeiros usam o tema comum. */
:root {
  --sidebar-width: 220px;
  --shell-gutter: clamp(20px, 3.2vw, 44px);
  --shell-mobile-nav-height: 64px;
}

.sidebar {
  padding: 28px 16px 20px;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scrollbar-width: thin;
  background: var(--surface);
  color: var(--text);
  border-inline-end: 1px solid var(--line);
}

.sidebar .brand {
  margin: 0 6px 34px;
  color: var(--text);
  font-size: 19px;
  font-weight: 650;
}

.sidebar .brand-mark {
  width: 42px;
  height: 42px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.sidebar .brand-mark svg { width: 28px; height: 28px; }
.sidebar .brand-dot { color: var(--accent-ink); }
.sidebar .brand-second { margin-top: 3px; }
.sidebar .nav-label { margin: 0 12px 9px; color: var(--muted); }
.sidebar .side-nav { gap: 5px; }

.sidebar .nav-link {
  min-height: 45px;
  padding: 10px 12px;
  gap: 10px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius-control, 10px);
  font-size: 13px;
}

.sidebar .nav-link:hover {
  color: var(--text);
  background: var(--surface-subtle, var(--surface-soft));
}

.sidebar .nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  box-shadow: none;
}

.sidebar .nav-link[aria-current="page"] svg { color: currentColor; }
.sidebar-tools { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.sidebar-bottom { padding-top: 24px; }

.sidebar .sidebar-caption {
  align-items: center;
  margin: 16px 0 0;
  padding: 14px 12px 0;
  color: var(--muted);
  border-top: 1px solid var(--line);
  font-size: 11px;
}

.sidebar .status-dot { flex: none; background: var(--muted); box-shadow: none; }

.topbar {
  min-height: 70px;
  padding: 12px var(--shell-gutter);
  background: var(--chrome, var(--surface));
  border-bottom-color: var(--line);
}

.topbar .topbar-caption { color: var(--muted); font-size: 13px; font-weight: 600; }
.topbar-actions { min-width: 0; justify-content: flex-end; gap: 8px; }
.topbar-actions .button, .topbar-actions .icon-button { min-height: 40px; }
.topbar-actions .icon-button { width: 40px; flex: none; }
.topbar-actions .button { max-width: 100%; }

.theme-control { position: relative; flex: none; }
.theme-control svg {
  position: absolute;
  top: 50%;
  inset-inline-start: 11px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  pointer-events: none;
}

#theme-select {
  width: 114px;
  min-height: 40px;
  padding: 7px 10px 7px 33px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control, 10px);
  font-size: 13px;
  cursor: pointer;
}

#theme-select:focus-visible,
.sidebar .nav-link:focus-visible,
.mobile-nav button:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.workspace {
  max-width: 1480px;
  padding: clamp(22px, 3.3vw, 40px) var(--shell-gutter) 22px;
}

.page-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 16px;
  margin-bottom: 23px;
}

.page-heading h1 { font-size: clamp(24px, 2.8vw, 34px); }
.page-heading-copy > p:last-child { margin-top: 6px; }
.page-heading-actions { flex-wrap: wrap; max-width: none; min-width: 0; margin-top: 0; gap: 8px; }
.page-heading-actions .icon-button, .page-heading-actions .button { min-height: 42px; }
.month-control { min-height: 42px; max-width: 100%; color: var(--muted); background: var(--surface); }
.month-control input { min-width: 0; color: var(--text); }

.workspace-footer {
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

#mobile-new-button { display: none; }

@media (max-width: 1020px) {
  :root { --sidebar-width: 195px; }
  .sidebar { padding-inline: 12px; }
  .sidebar .brand { font-size: 17px; }
}

@media (max-width: 950px) {
  .page-heading { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .page-heading-actions { justify-content: flex-start; }
}

@media (max-width: 720px) {
  :root { --shell-gutter: clamp(12px, 3.8vw, 20px); }

  .topbar {
    min-height: 62px;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 12px;
    padding-block: max(8px, env(safe-area-inset-top)) 8px;
    padding-inline: max(var(--shell-gutter), env(safe-area-inset-left)) max(var(--shell-gutter), env(safe-area-inset-right));
    background: var(--chrome, var(--surface));
  }

  .mobile-brand { display: inline-flex; align-items: center; gap: 8px; color: var(--text); font-size: 14px; font-weight: 700; }
  .mobile-brand img { width: 29px; height: 29px; }
  .topbar-actions { flex-wrap: wrap; gap: 6px; }
  .topbar-actions .button, .topbar-actions .icon-button, #theme-select { min-height: 44px; }
  .topbar-actions .icon-button { width: 44px; }
  .topbar-actions .button { padding-inline: 9px; font-size: 11px; }
  #install-button { min-width: 44px; font-size: 11px; }
  #theme-select { font-size: 16px; }

  .workspace {
    padding-top: 21px;
    padding-bottom: calc(var(--shell-mobile-nav-height) + 22px + env(safe-area-inset-bottom));
    padding-inline: max(var(--shell-gutter), env(safe-area-inset-left)) max(var(--shell-gutter), env(safe-area-inset-right));
  }

  .page-heading { margin-bottom: 19px; }
  .month-control, .page-heading-actions .button, .page-heading-actions .icon-button { min-height: 44px; }
  .page-heading-actions .icon-button { width: 44px; }
  #new-button:not([hidden]) { display: inline-flex; }
  .month-control input { width: 11.4rem; font-size: 16px; }

  .mobile-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 3px;
    min-height: calc(var(--shell-mobile-nav-height) + env(safe-area-inset-bottom));
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: var(--chrome, var(--surface));
    border-top-color: var(--line);
    box-shadow: none;
  }

  .mobile-nav button {
    min-height: 51px;
    padding: 5px 1px;
    gap: 4px;
    color: var(--muted);
    font-size: clamp(8.5px, 2.6vw, 11px);
    line-height: 1.2;
    text-align: center;
  }

  .mobile-nav button span { max-width: 100%; overflow-wrap: anywhere; }
  .mobile-nav button[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
  .mobile-nav button:focus-visible { outline-offset: -2px; }
  .toast-region { bottom: calc(var(--shell-mobile-nav-height) + 12px + env(safe-area-inset-bottom)); }
}

@media (max-width: 440px) {
  .topbar {
    position: relative;
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) minmax(44px, max-content);
    gap: 4px 8px;
  }

  .topbar-actions { display: contents; }
  .mobile-brand { grid-row: 1; grid-column: 1 / 3; }
  .topbar #privacy-button { grid-row: 1; grid-column: 3; justify-self: end; }
  .topbar .theme-control { grid-row: 2; grid-column: 1; }
  .theme-control svg { display: none; }
  #theme-select { width: 96px; padding-inline: 8px; }

  .topbar #install-button {
    grid-row: 2;
    grid-column: 2;
    justify-self: start;
    min-width: 0;
    padding-inline: 6px;
  }

  #install-button svg { display: none; }

  .topbar #connection-button {
    grid-row: 2;
    grid-column: 3;
    justify-self: end;
    max-width: clamp(108px, 38vw, 145px);
    min-width: 0;
    white-space: normal;
    text-align: center;
    overflow-wrap: anywhere;
  }
}

@media print {
  .workspace { max-width: none; padding: 0; }
  .page-heading { display: block; margin-bottom: 14px; }
}
