/* ---------- App shell layout ---------- */

#app {
  display: none;
  min-height: 100vh;
}

#app.is-unlocked {
  display: block;
}

/* Top bar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-5);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

.topbar__brand {
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.topbar__sep {
  color: var(--muted);
}

.topbar__page {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__spacer {
  flex: 1;
}

.account-scope {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  padding: 5px var(--space-3) 5px 10px;
  color: var(--muted);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.account-scope__icon {
  flex-shrink: 0;
}

/* A specific account is selected (not "All accounts") — make the scope
   unmissable, since every number on screen now reflects just this account. */
.account-scope--active {
  border-color: var(--green);
  color: var(--green);
}

.account-filter {
  max-width: 160px;
  background: transparent;
  border: none;
  color: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0;
}

.account-filter:focus-visible {
  outline-offset: 3px;
}

.topbar__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--muted);
  transition: border-color var(--transition-fast), color var(--transition-fast);
}

.topbar__icon-btn:hover {
  color: var(--text);
  border-color: var(--border);
}

.topbar__icon-btn.is-active {
  color: var(--green);
}

.sync-dot {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.75rem;
  color: var(--muted);
}

.sync-dot__led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  transition: background var(--transition-fast);
}

.sync-dot__led--saving {
  background: var(--amber);
}

.sync-dot__led--error {
  background: var(--red);
}

.topbar__version {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

/* Body: sidebar + content */

.app-body {
  display: flex;
  min-height: calc(100vh - var(--topbar-height));
}

.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  bottom: 0;
  z-index: 15;
  width: var(--sidebar-width);
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: var(--space-4) var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--bg);
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.nav-item.is-active {
  color: var(--green);
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.25);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: var(--sidebar-width);
}

/* Collapsed sidebar: hide the fixed panel and let content take the width
   back. State lives in settings.sidebarCollapsed (see js/app.js) so it
   persists between sessions. */
.app-body.is-sidebar-collapsed .sidebar {
  display: none;
}

.app-body.is-sidebar-collapsed .main {
  margin-left: 0;
}

/* Page header */

.page-header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-header__info {
  flex: 1;
  min-width: 200px;
}

.page-header__welcome {
  font-size: 1.1rem;
  font-weight: 600;
}

.page-header__meta {
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: 0.85rem;
}

.page-header__meta .count {
  font-family: var(--font-mono);
}

.page-header__actions {
  display: flex;
  gap: var(--space-2);
}

.btn {
  display: inline-block;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

/* a:link/a:visited in the UA stylesheet outrank a plain .btn class on
   specificity (pseudo-class + element beats class alone), so an <a class="btn">
   needs this element+class selector to actually lose the underline. */
a.btn {
  text-decoration: none;
}

.btn:hover {
  border-color: var(--muted);
}

.btn--primary {
  background: var(--green);
  border-color: var(--green);
  color: #0a0a0a;
  font-weight: 600;
}

.btn--primary:hover {
  filter: brightness(1.05);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Page content */

#page-content {
  flex: 1;
  padding: var(--space-5);
}

.page-placeholder {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: var(--space-6);
  color: var(--muted);
}

.page-placeholder h2 {
  color: var(--text);
  font-size: 1.1rem;
  margin-bottom: var(--space-2);
}

/* Amounts hidden mode */

body.amounts-hidden .amount {
  filter: blur(6px);
  user-select: none;
}

/* Bottom tab bar (mobile) */

.bottombar {
  display: none;
}

@media (max-width: 899px) {
  .sidebar {
    display: none;
  }

  .main {
    margin-left: 0;
  }

  #sidebar-toggle-btn {
    display: none;
  }

  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-3);
  }

  .topbar__version,
  .topbar__user {
    display: none;
  }

  .account-filter {
    max-width: 110px;
  }

  .topbar__sep,
  .topbar__page {
    display: none;
  }

  .sync-dot {
    font-size: 0;
  }

  .sync-dot__led {
    margin: 0;
  }

  .bottombar {
    display: flex;
    position: sticky;
    bottom: 0;
    z-index: 20;
    overflow-x: auto;
    background: var(--surface);
    border-top: 1px solid var(--border);
    height: var(--bottombar-height);
  }

  .bottombar .nav-item {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    min-width: 72px;
    font-size: 0.7rem;
    border-radius: 0;
  }

  .bottombar .nav-item.is-active {
    border-color: transparent;
    border-top: 2px solid var(--green);
  }

  #page-content {
    padding: var(--space-4);
  }

  .page-header {
    padding: var(--space-4);
  }
}

/* ---------- PIN lock ---------- */

.lock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
}

.lock-card {
  width: 100%;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-6) var(--space-5);
  text-align: center;
}

.lock-card h1 {
  font-size: 1.1rem;
  margin-bottom: var(--space-2);
}

.lock-card p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: var(--space-5);
}

.lock-card input[type="password"],
.lock-card input[type="text"],
.lock-card input[type="email"] {
  width: 100%;
  text-align: center;
  letter-spacing: 0.3em;
  font-family: var(--font-mono);
  font-size: 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
}

.lock-card .btn {
  width: 100%;
}

.lock-card__error {
  color: var(--red);
  font-size: 0.8rem;
  min-height: 1.2em;
  margin-top: var(--space-2);
}

.lock-card__note {
  margin-top: var(--space-5);
  font-size: 0.75rem;
  color: var(--muted);
}

.lock-card__error--success {
  color: var(--green);
}

.lock-card__switch {
  margin-top: var(--space-4);
  font-size: 0.8rem;
  color: var(--muted);
}

.lock-card__switch a {
  color: var(--green);
  text-decoration: none;
  cursor: pointer;
}

.lock-card__switch a:hover {
  text-decoration: underline;
}

.topbar__user {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}
