/* ── Shell ───────────────────────────────────────────────────────────────
   No padding on the sidebar itself: the buttons run edge to edge and supply
   their own, so nothing has to line up across a gutter. The middle scrolls;
   the header and the check button do not. */
#sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 3;
  width: 240px;
  padding: 0;
  flex: none;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
#sidebar[data-collapsed] { width: auto; }

main {
  flex: 1;
  min-width: 0;
  padding: var(--space-medium);
  margin-left: var(--rail);
}

nav li{
  border-bottom: 1px solid var(--border);
}

nav a,
#toggle,
#check-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-regular);
  padding: var(--space-regular);
  font-size: var(--fs-regular);
  line-height: var(--lh-regular);
  width: 100%;
  background: var(--bg);
  color: var(--muted);
  text-decoration: none;
}
#toggle {
  font-weight: 700;
  color: var(--ink);
}

/* Nav/toggle/check-now icons — Lucide, masked so `currentColor` recolors them
   with the rest of the control's text. See tokens.css for the --icon-* set. */
#toggle::after,
nav a::after,
#check-now::after {
  content: "";
  width: var(--lh-regular);
  height: var(--lh-regular);
  flex: none;
  background-color: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}
#toggle::after {
  -webkit-mask-image: var(--icon-close);
  mask-image: var(--icon-close);
}
nav a[href="#dashboard"]::after {
  -webkit-mask-image: var(--icon-dashboard);
  mask-image: var(--icon-dashboard);
}
nav a[href="#forecast"]::after {
  -webkit-mask-image: var(--icon-forecast);
  mask-image: var(--icon-forecast);
}
nav a[href="#movements"]::after {
  -webkit-mask-image: var(--icon-movements);
  mask-image: var(--icon-movements);
}
nav a[href="#settings"]::after {
  -webkit-mask-image: var(--icon-settings);
  mask-image: var(--icon-settings);
}
#check-now::after {
  -webkit-mask-image: var(--icon-search);
  mask-image: var(--icon-search);
}
#check-now[data-running]::after {
  -webkit-mask-image: var(--icon-spinner);
  mask-image: var(--icon-spinner);
  animation: spin var(--duration-slow) linear infinite;
}
@keyframes spin {
  to { transform: rotate(1turn); }
}

nav a[aria-current] {
  color: var(--ink);
  font-weight: 700;
}
@media (hover: hover) {
  nav a:hover,
  #toggle:hover,
  #check-now:hover:not(:disabled) {
    color: var(--ink);
    background: var(--faint);
  }
}

/* The basis is the only part that may need to scroll; the rest is pinned. */
#basis {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  margin: var(--space-medium) 0;
  padding: 0 12px;
  display: flex;
  flex-direction: column;
  gap: var(--space-regular);
}

#status {
  flex: none;
  margin-top: auto;
}
#status p {
  padding: var(--space-small) var(--space-regular);
  font-size: var(--fs-regular);
  border-top: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
/* A track drawn as a background fill rather than a nested element: nothing to
   add or remove from the DOM as progress advances, just a size to transition.
   The 0% starting point has no transition, so removing `data-running` snaps
   the fill away instead of rewinding it — appropriate for a stop or a reset,
   not a completion in progress. */
#status p::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: linear-gradient(var(--faint), var(--faint));
  background-repeat: no-repeat;
  background-size: 0% 100%;
}
#status p[data-running]::before {
  background-size: var(--fill, 0%) 100%;
  transition: background-size var(--duration-slow) ease-out;
}
#status p[data-scheduler-off] {
  color: var(--warning);
  font-weight: 700;
}

#sidebar[data-collapsed] :is(#toggle, nav a, #check-now) { justify-content: center; }
#sidebar[data-collapsed] :is(#toggle, nav a, #check-now) > span { display: none; }
#sidebar[data-collapsed] #toggle::after {
  -webkit-mask-image: var(--icon-menu);
  mask-image: var(--icon-menu);
}
#sidebar[data-collapsed] :is(#basis, #status p) { display: none; }

/* Tapping the page behind an expanded sidebar puts it away, and must not also
   press whatever sat underneath. */
#scrim {
  position: fixed;
  inset: 0;
  z-index: 2;
  background: rgb(0 0 0 / .4);
}

#summary {
  font-size: var(--fs-small);
  color: var(--muted);
}
#summary[data-filtered] {
  color: var(--warning);
  font-weight: 700;
}
