[hidden] { display: none !important; }
.app-shell { display: none; }
body.authenticated .app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); max-width: 1510px; margin: 0 auto; align-items: start; }
.app-shell main { margin: 0; max-width: none; min-width: 0; padding: 28px 32px 44px; }
/* Let nested grids and long account names shrink to the available width. */
.app-shell, .app-shell [data-page], .panel, .report-grid, .report-grid > *,
.panel-head > *, .section-title > *, .form-grid > *, .access-grid > *,
.metric, .month, .heirs-fieldset, .heir-row, .heir-row > * { min-width: 0; }
.app-shell [data-page], .panel, .table-scroll { max-width: 100%; }
.table-scroll { width: 100%; overflow-x: auto; overscroll-behavior-x: contain; }
.app-shell p, .app-shell h2, .app-shell h3, .detail-meta, .device-list,
#accessList, #auditList, .toast { overflow-wrap: anywhere; }
input, select, textarea { max-width: 100%; }
.app-sidebar { position: sticky; top: 24px; margin: 24px 0 24px 20px; padding: 22px 14px; background: #133d35; color: #fff; border-radius: 16px; min-height: calc(100vh - 140px); max-height: calc(100vh - 48px); overflow-y: auto; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 0 10px; }
.sidebar-caption { font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .13em; color: #b8d2c7; }
.sidebar-role { margin: 10px 10px 24px; font: 500 21px Georgia, serif; color: #f4d38b; }
.app-sidebar nav { display: grid; gap: 6px; }
.app-sidebar a { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 11px 12px; border: 1px solid transparent; border-radius: 10px; color: #dbe8e1; font-size: 13px; font-weight: 600; line-height: 1.4; text-decoration: none; }
.app-sidebar a:hover { background: #205346; color: #fff; }
.app-sidebar a[aria-current="page"] { background: #e6c67e; color: #173a31; border-color: #f1d899; }
.app-sidebar svg,.nav-toggle svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-group-label { margin: 19px 12px 6px; color: #b8d2c7; font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .11em; }
.sidebar-foot { margin: 32px 10px 4px; padding-top: 16px; border-top: 1px solid #416558; color: #b8d2c7; font-size: 11px; line-height: 1.6; }
.workspace-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding-bottom: 18px; margin-bottom: 22px; border-bottom: 1px solid #dce7dc; }
.workspace-toolbar>strong { font-size: 13px; color: #557266; }
.workspace-toolbar .yearpicker label { font-size: 12px; }
.workspace-toolbar .yearpicker select { padding: 7px 10px; }
.app-shell .notice { margin: 20px 0; overflow-wrap: anywhere; }
.app-shell [data-page] { margin-bottom: 26px; }
.app-shell [data-page]>h2 { font: 500 28px Georgia, serif; margin: 0 0 12px; }
.app-shell .backup-box,.app-shell .audit-box { border-top: 0; margin-top: 0; padding-top: 0; }
.app-shell .backup-box h2,.app-shell .audit-box h2 { font: 500 28px Georgia, serif; margin: 0; }
.app-shell .member-panel { margin: 0; max-width: none; }
.app-shell .metrics { grid-template-columns: repeat(2,minmax(0,1fr)); }
.nav-toggle,#navClose,.nav-backdrop { display: none; }
body:not(.authenticated) .nav-toggle,body:not(.authenticated) .nav-backdrop { display: none !important; }
@media (max-width: 1100px) { .app-shell main { padding: 26px 22px 40px; } .report-grid { grid-template-columns: 1fr; } .month-grid { grid-template-columns: repeat(4,minmax(0,1fr)); } }
@media (max-width: 900px) {
  body.authenticated .app-shell { grid-template-columns: minmax(0,1fr); }
  .app-shell main { padding: 22px 18px 38px; }
  .top { padding: 14px 18px; gap: 12px; }
  .top .brand { flex: 1; min-width: 0; }
  .top .brand small { display: none; }
  .top .brand .mark { width: 32px; height: 32px; flex-shrink: 0; }
  .top .brand strong { font-size: 17px; }
  .top-right { gap: 8px; }
  .top-right .private,.top-right .avatar { display: none; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; padding: 9px; border-color: #5d8b77; background: transparent; color: #fff; }
  .nav-toggle span { display: none; }
  .nav-toggle:hover { background: #255a4c; }
  .app-sidebar { position: fixed; inset: 0 auto 0 0; z-index: 30; width: min(290px,calc(100vw - 48px)); margin: 0; padding-top: 24px; border-radius: 0 16px 16px 0; min-height: 100dvh; max-height: 100dvh; transform: translateX(-110%); transition: transform .2s ease; }
  body.navigation-open { overflow: hidden; }
  body.navigation-open .app-sidebar { transform: translateX(0); }
  #navClose { display: block; min-width: 42px; min-height: 42px; padding: 0; font-size: 26px; background: transparent; border-color: #5d8b77; }
  .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 25; width: 100%; height: 100dvh; border: 0; border-radius: 0; background: #102c24aa; }
  .nav-backdrop:hover { background: #102c24aa; }
}
@media (max-width: 680px) {
  .app-shell button, dialog button { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
  .section-title, .panel-head, .detail h3 { flex-wrap: wrap; }
  .section-title > *, .panel-head > *, .inline-actions { max-width: 100%; }
  .inline-actions { width: 100%; }
  .inline-actions > button { flex: 1 1 140px; min-width: 0; }
  .detail h3 { gap: 8px; }
  .detail-meta { gap: 10px 16px; }
  .detail-meta > span { min-width: 0; max-width: 100%; }
  .line, .revenue-lines div { flex-wrap: wrap; gap: 6px 12px; }
  .line strong, .revenue-lines strong, .month span { white-space: normal; overflow-wrap: anywhere; }
  .app-shell .month-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .app-shell .member-panel { padding: 18px 14px; }
  .member-panel input, .member-panel select, .access-grid input, .access-grid select,
  #reportAccount, #historyAccount { width: 100%; min-width: 0; }
  .form-grid, .access-grid, .auth-form, .heir-row { grid-template-columns: minmax(0, 1fr); }
  .dialog-body { padding: 18px 14px; }
  .dialog-head > div { min-width: 0; overflow-wrap: anywhere; }
  .dialog-head .close { flex-shrink: 0; }
  .auth-gate { padding: 0 14px; }
  .auth-card { padding: 24px 18px; overflow-wrap: anywhere; }
}
@media (max-width: 420px) {
  .top { padding: 12px; gap: 8px; }
  .top .brand strong { font-size: 15px; }
  .top .brand .mark { display: none; }
  .top-right #logoutBtn { max-width: 112px; padding: 8px; font-size: 11px; white-space: normal; line-height: 1.3; }
  .app-shell main { padding: 20px 12px 32px; }
  .app-shell .metrics { gap: 8px; }
  .workspace-toolbar { margin-bottom: 18px; }
}
/* Each register keeps its own two-axis scroll area and visible column headings. */
.register-scroll { max-height: 420px; max-height: min(420px, 55dvh); overflow: auto; scrollbar-gutter: stable; }
.register-scroll thead th { position: sticky; top: 0; z-index: 1; background: #f3f7f2; box-shadow: 0 1px 0 #dce7dc; }
.register-scroll:focus-visible { outline: 3px solid #e2ae58; outline-offset: 2px; }
@media screen and (max-width: 900px) {
  :root { --frame-top: max(8px, env(safe-area-inset-top, 0px)); --frame-bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
  html { height: 100%; }
  body { height: 100vh; height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr); overflow: hidden;
    padding: var(--frame-top) env(safe-area-inset-right, 0px) var(--frame-bottom) env(safe-area-inset-left, 0px); }
  body.authenticated .app-shell { width: 100%; height: 100%; min-height: 0; grid-template-rows: minmax(0, 1fr); overflow: hidden; }
  .app-shell main { height: 100%; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; scroll-padding-block: 18px; }
  .auth-gate { min-height: 0; width: 100%; overflow-y: auto; margin: 0 auto; padding-top: 24px; padding-bottom: 24px; }
  .app-sidebar { top: var(--frame-top); bottom: var(--frame-bottom); height: auto; min-height: 0; max-height: none; overscroll-behavior-y: contain; }
  .nav-backdrop { top: var(--frame-top); bottom: var(--frame-bottom); height: auto; }
  .register-scroll { max-height: 320px; max-height: min(320px, 45dvh); }
  dialog { max-height: calc(100dvh - var(--frame-top) - var(--frame-bottom) - 24px); overflow-y: auto; }
}
@media screen and (max-width: 900px) and (display-mode: standalone), screen and (max-width: 900px) and (display-mode: fullscreen) {
  :root { --frame-top: max(32px, env(safe-area-inset-top, 0px)); --frame-bottom: max(28px, env(safe-area-inset-bottom, 0px)); }
}
@media (prefers-reduced-motion: reduce) { .app-sidebar { transition: none; } html { scroll-behavior: auto; } }
@media print { body.authenticated .app-shell { display: block; } .app-sidebar,.nav-toggle,.nav-backdrop,.workspace-toolbar { display: none !important; } .app-shell main { padding: 0; margin: 0; } }
