html { -webkit-text-size-adjust: 100%; }
.mono-install-button { min-width: 36px; height: 34px; padding: 0 9px; border: 1px solid var(--line, #dfe3dc); border-radius: 9px; color: var(--muted, #737a71); background: var(--surface, var(--card, #fff)); font: inherit; font-size: 10px; cursor: pointer; touch-action: manipulation; }
.mono-install-dialog { box-sizing: border-box; width: min(360px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line, #dfe3dc); border-radius: 18px; color: var(--ink, #20241f); background: var(--surface, var(--card, #fff)); box-shadow: 0 20px 60px #0003; }
.mono-install-dialog::backdrop { background: #0006; }
.mono-install-dialog h2 { margin: 0 0 14px; font-size: 18px; }
.mono-install-dialog p { color: var(--muted, #737a71); font-size: 13px; line-height: 1.8; }
.mono-install-dialog > button { width: 100%; min-height: 42px; margin-top: 8px; border: 0; border-radius: 9px; background: var(--ink, #20241f); color: var(--surface, var(--card, #fff)); font-size: 14px; cursor: pointer; }
.login-card footer .mono-install-button { margin-left: auto; }
@media (pointer: coarse) {
  button, a, select { touch-action: manipulation; }
  input, select { font-size: 16px; }
  .chart-tooltip { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }
  .chart-tooltip, .panel, .surface, .kpi-card, .sidebar { transition: none; }
  .history-week-scroll, .table-wrap, .dashboard-page main { -webkit-overflow-scrolling: touch; }
}
@media (max-width: 760px) {
  :root { --mobile-nav-height: 60px; --mobile-nav-space: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px)); }
  /* Standalone WebKit can subtract safe areas from dynamic viewport units.
     The full viewport and a fixed dock keep its background at the screen edge. */
  html.dashboard-page.mono-standalone { height: 100vh; }
  .dashboard-page .sidebar {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    height: var(--mobile-nav-space);
    flex-direction: row;
    align-items: flex-start;
    padding: 4px max(12px, env(safe-area-inset-right, 0px)) calc(7px + env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    border: 0;
    border-top: 1px solid var(--sidebar-border);
    border-radius: 0;
    background: var(--sidebar-bg);
    box-shadow: none;
  }
  .dashboard-page .nav-list { height: 48px; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
  .dashboard-page .nav-item { width: min(100%, 96px); height: 48px; min-height: 48px; justify-self: center; align-content: center; gap: 4px; border-radius: 10px; }
  .dashboard-page .nav-icon { font-size: 19px; }
  .dashboard-page .nav-label { font-size: 10px; line-height: 1.2; }
  .dashboard-page .nav-count { top: 2px; right: calc(50% - 25px); }
  .dashboard-page main { scroll-padding-bottom: calc(var(--mobile-nav-space) + 12px); }
  .dashboard-page .main-content, .dashboard-page .trade-shell, .dashboard-page .daily-shell { padding-bottom: calc(var(--mobile-nav-space) + 12px); }
  .dashboard-page .toast { bottom: calc(var(--mobile-nav-space) + 12px); }
}
@media (max-width: 760px) and (display-mode: standalone) {
  html.dashboard-page { height: 100vh; }
}


/* Use page-owned controls and vector icons from the first paint on iOS. */
[hidden] { display: none !important; }
button, select, input[type="button"], input[type="submit"], input[type="search"] { -webkit-appearance: none; appearance: none; -webkit-tap-highlight-color: transparent; }
button { font-family: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--green, #14795e); outline-offset: 3px; }
button:disabled { cursor: default; }
.ui-icon { display: block; width: 18px; height: 18px; flex: 0 0 auto; }
[data-icon], .refresh-button > i, .sort-button > i, .ledger-sort { display: inline-flex; align-items: center; justify-content: center; font-style: normal; vertical-align: middle; }
.icon-button { display: inline-flex; align-items: center; justify-content: center; }
#theme-icon, .theme-button span, .alert-notification-button > span { transform: none; }
.sort-button .ui-icon, .ledger-sort .ui-icon { width: 13px; height: 13px; }
.sort-button[data-sort-direction="asc"] > i, .sort-button[data-sort-direction="desc"] > i { color: var(--green); }
.nav-icon .ui-icon { width: 19px; height: 19px; }
.history-chart-foot button { display: inline-flex; align-items: center; gap: 4px; }
.history-chart-foot .ui-icon { width: 12px; height: 12px; }
.weight-sort-control select {
  -webkit-appearance: none; appearance: none; padding-right: 25px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23747a73' stroke-width='1.6' viewBox='0 0 24 24'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 14px;
}
input[type="search"]::-webkit-search-decoration, input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; }
.mono-connection { position: fixed; z-index: 90; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: calc(100% - 24px); padding: 10px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted); box-shadow: var(--shadow); font-size: 11px; }
.mono-connection button { min-height: 32px; flex: 0 0 auto; padding: 0 10px; border: 0; border-radius: 8px; background: var(--green-soft); color: var(--green); font: inherit; }
@media (max-width: 760px) {
  .mono-connection { bottom: calc(var(--mobile-nav-space) + 10px); width: max-content; }
  .alert-notification-hint { bottom: calc(var(--mobile-nav-space) + 10px); }
}

/* One opaque app bar, outside the scrolling main, on every dashboard page. */
.dashboard-page .app-shell { padding-left: var(--sidebar); }
.dashboard-page body { padding-left: 0; }
.dashboard-page .main-content, .dashboard-page .trade-shell, .dashboard-page .daily-shell {
  width: 100%; max-width: 1440px; margin: 0 auto; padding-left: 24px; padding-right: 24px;
}
.app-header {
  position: sticky; top: 0; z-index: 30; flex: 0 0 auto;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--bg); border-bottom: 1px solid var(--line);
  backdrop-filter: none; -webkit-backdrop-filter: none; filter: none;
}
.app-header-inner {
  width: 100%; max-width: 1440px; height: 64px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.app-header-heading { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.app-header-title { color: var(--ink); font-size: 16px; line-height: 21px; font-weight: 700; letter-spacing: .02em; }
.app-header-sync { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; line-height: 15px; font-weight: 400; font-variant-numeric: tabular-nums; }
.app-header-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 6px; }
.app-header .app-header-button {
  position: static; display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
  width: 44px; min-width: 44px; height: 44px; min-height: 44px; margin: 0; padding: 0;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--muted);
  font: inherit; cursor: pointer; list-style: none; transform: none; box-shadow: none;
  transition: background-color .15s, color .15s; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.app-header-button::-webkit-details-marker { display: none; }
.app-header-button::marker { content: ""; }
.app-header-button:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }
.app-header .app-header-button:active, .app-header-more[open] > .app-header-button { color: var(--green); background: var(--green-soft); }
.app-header .ui-icon { width: 18px; height: 18px; }
.app-header-more { position: relative; }
.app-header-menu {
  position: absolute; top: calc(100% + 8px); right: 0; width: 232px; max-width: calc(100vw - 24px);
  padding: 6px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--ink); box-shadow: 0 12px 32px #0002;
  max-height: calc(100vh - 160px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); overflow-y: auto; overscroll-behavior: contain;
}
.app-header-menu-actions { display: grid; }
.app-header-menu-actions > button {
  position: relative; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px;
  margin: 0; padding: 10px 12px; border: 0; border-radius: 8px;
  color: var(--ink); background: transparent; font: inherit; font-size: 13px; line-height: 20px; text-align: left; cursor: pointer;
}
.app-header-menu-actions > button > [data-icon], .app-header-menu-actions > button > span:first-child { color: var(--muted); }
.app-header-menu-actions > button:active { background: var(--subtle); }
.app-header-menu-actions > button.paused { color: var(--orange); background: var(--orange-soft); }
.app-header-menu-meta { display: flex; justify-content: space-between; gap: 8px; margin: 4px 6px 0; padding: 10px 6px 5px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 16px; font-variant-numeric: tabular-nums; }
.app-header-menu .alert-notification-button > span { font-size: inherit; line-height: inherit; }
.app-header-menu .alert-notification-button > i { top: 12px; right: 12px; }
@media (hover: hover) {
  .app-header .app-header-button:hover { color: var(--ink); background: var(--subtle); }
  .app-header-menu-actions > button:hover { background: var(--subtle); }
}
@media (max-width: 760px) {
  .dashboard-page .app-shell { display: grid; grid-template-rows: auto minmax(0, 1fr); }
  .app-header { position: relative; top: auto; }
  .app-header-inner { padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px)); }
  .dashboard-page .main-content, .dashboard-page .trade-shell, .dashboard-page .daily-shell {
    padding-top: 0; padding-left: max(12px, env(safe-area-inset-left, 0px)); padding-right: max(12px, env(safe-area-inset-right, 0px));
    scroll-padding-top: 12px;
  }
}
@media (prefers-reduced-motion: reduce) { .app-header * { transition: none !important; animation: none !important; } }
