/* Shared shell sizing and accessible controls. Loaded after the page styles. */
.app-body *,
.app-body *::before,
.app-body *::after {
  box-sizing: border-box;
}

.app-sidebar {
  align-self: start;
}

.mobile-menu-toggle,
.mobile-menu-toggle[hidden],
.sidebar-nav[hidden] {
  display: none;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 12px 16px;
  border-radius: 8px;
  background: var(--theme-surface, #ffffff);
  color: var(--theme-ink, #0f172a);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-body :focus-visible {
  outline: 3px solid var(--theme-line, #2563eb);
  outline-offset: 3px;
}

.app-sidebar :focus-visible {
  outline-color: var(--theme-line, #93c5fd);
}

.workspace-content {
  width: 100%;
  min-width: 0;
}

.support-contact {
  margin: 0 28px 28px;
  padding-top: 16px;
  border-top: 1px solid var(--theme-line, #d1d5db);
  color: var(--theme-ink, #475569);
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.support-contact p {
  margin: 0;
}

.support-contact a {
  display: inline-block;
  max-width: 100%;
  min-height: 44px;
  padding: 12px 0;
  color: var(--theme-muted, #1d4ed8);
  text-decoration: underline;
}

.workspace-content img,
.workspace-content svg,
.workspace-content canvas {
  max-width: 100%;
}

.table-scroll,
.table-wrap {
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 980px) {
  .app-shell {
    display: block;
  }

  .app-sidebar {
    position: static;
    top: 0;
    z-index: 50;
    width: 100%;
    height: auto;
    padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
    overflow: visible;
    border-right: 0;
    box-shadow: 0 2px 10px rgb(15 23 42 / 12%);
  }

  .navigation-ready .app-sidebar {
    position: sticky;
  }

  .sidebar-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 44px;
  }

  .brand-block {
    min-width: 0;
    gap: 10px;
    margin: 0;
  }

  .brand-mark {
    flex: 0 0 34px;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    font-size: 18px;
  }

  .brand-title {
    font-size: 17px;
  }

  .brand-subtitle {
    display: none;
  }

  .mobile-menu-toggle:not([hidden]) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-shrink: 0;
    min-height: 44px;
    padding: 9px 12px;
    border: 1px solid var(--theme-line, #475569);
    border-radius: 10px;
    background: var(--theme-featured, #1e293b);
    color: #ffffff;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
  }

  .menu-toggle-icon {
    width: 18px;
    font-size: 20px;
    line-height: 1;
  }

  .sidebar-nav {
    gap: 16px;
    max-height: calc(100vh - 84px);
    max-height: calc(100dvh - 84px);
    margin-top: 10px;
    padding: 6px 2px 16px;
    overflow-y: auto;
    overscroll-behavior-y: contain;
  }

  .nav-section {
    gap: 2px;
  }

  .nav-section-title {
    margin: 0 10px 4px;
    color: var(--theme-muted, #94a3b8);
  }

  .nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 10px 12px;
    font-size: 15px;
  }

  .workspace-header {
    position: static;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
  }

  .app-body:not(.guest-shell) .workspace-intro {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }

  .workspace-actions {
    gap: 8px;
    margin-left: auto;
  }

  .header-link {
    min-height: 44px;
    padding: 10px 12px;
  }

  .workspace-content {
    margin: 0 auto 16px;
    padding: 16px 14px max(20px, env(safe-area-inset-bottom));
    border-radius: 0;
    scroll-margin-top: 76px;
  }

  .support-contact {
    margin: 0 14px max(20px, env(safe-area-inset-bottom));
  }

  .workspace-content > *,
  .dashboard-grid > *,
  .modular-dashboard > * {
    min-width: 0;
  }

  .workspace-content p {
    overflow-wrap: anywhere;
  }

  .modular-dashboard .widget-card {
    grid-column: 1 / -1;
  }

  .wide-data-table {
    min-width: 640px;
  }

  .workspace-content input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  .workspace-content select,
  .workspace-content textarea {
    min-width: 0;
    max-width: 100%;
    min-height: 44px;
    font-size: 16px;
  }

  .workspace-content input[type="file"] {
    width: 100%;
  }

  .workspace-content button,
  .workspace-content .action-link,
  .workspace-content .tiny-link,
  .workspace-content summary {
    min-height: 44px;
  }

  .filter-form > input,
  .filter-form > select {
    flex: 1 1 160px;
  }
}

@media (max-width: 600px) {
  .workspace-content h1,
  .dashboard-hero-title,
  .page-section-title {
    font-size: 26px;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }

  .workspace-content h2 {
    font-size: 20px;
    line-height: 1.3;
  }

  .dashboard-grid,
  .dashboard-hero,
  .summary-cards {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .dashboard-panel,
  .dashboard-hero-copy,
  .dashboard-hero-panel,
  .hero-summary-card {
    padding: 16px;
    border-radius: 14px;
  }

  /* Put the next action and actual balances ahead of introductory copy on phones. */
  .dashboard-hero-compact-copy {
    display: none;
  }

  .dashboard-hero-compact-side {
    padding: 12px;
    border-radius: 14px;
  }

  .hero-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .hero-summary-card {
    padding: 14px;
  }

  .hero-summary-number {
    font-size: 21px;
    line-height: 1.2;
  }

  .hero-summary-card .muted {
    font-size: 13px;
    line-height: 1.4;
  }

  .workspace-content form {
    max-width: 100%;
    min-width: 0;
  }

  .filter-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
  }

  .filter-form > input,
  .filter-form > select,
  .filter-form > button {
    width: 100%;
  }

  .page-actions > .action-link {
    flex: 1 1 140px;
    white-space: normal;
  }

  .summary-value,
  .hero-summary-number,
  .widget-hero-number {
    overflow-wrap: anywhere;
  }
}

@media (max-width: 359px) {
  .hero-summary-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media print {
  .app-sidebar,
  .skip-link {
    display: none;
  }

  .app-shell {
    display: block;
  }

  .table-scroll,
  .table-wrap {
    overflow: visible;
  }
}
