:root { --mobile-nav-height: 72px; }
.app-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.app-nav a { display: flex; align-items: center; gap: .45rem; padding: .6rem .9rem; border-radius: .7rem; color: #fff; text-decoration: none; font-weight: 600; }
.app-nav a:hover { background: #ffffff24; }
.app-nav a.active { background: #fff; color: #1d4ed8; }
.app-nav a:focus-visible, summary:focus-visible { outline: 3px solid #60a5fa; outline-offset: 3px; }
.app-eyebrow { font-size: .68rem; font-weight: 700; letter-spacing: .13em; margin: 0 0 .5rem; opacity: .85; }
.settings-disclosure { border: 1px solid #e2e8f0; border-radius: .8rem; margin-top: .8rem; background: #fff; }
.settings-disclosure > summary { padding: .85rem; cursor: pointer; color: #334155; font-size: .9rem; font-weight: 600; }
.settings-disclosure > summary span { display: block; font-size: .77rem; font-weight: 400; color: #64748b; margin: .25rem 0 0 1rem; }
.settings-disclosure > .disclosure-body { padding: 0 .85rem .85rem; }
.settings-disclosure[open] > summary { color: #1d4ed8; }
.table-scroll-hint { display: none; }
.sticky-actions { position: static; }
.history-more > summary { cursor: pointer; color: #475569; font-size: .85rem; padding: .6rem 0; }
.list-tools > summary { cursor: pointer; color: #475569; font-size: .8rem; font-weight: 500; min-height: 44px; padding: .65rem 0; }
.form-control, .form-select { scroll-margin-top: 1rem; scroll-margin-bottom: 6rem; }

@media screen and (max-width: 767.98px) {
    html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: calc(var(--mobile-nav-height) + 24px); }
    body { background: #f4f6fb; font-size: 15px; line-height: 1.5; }
    .page-wrap { padding: 1.25rem 1rem calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 1.5rem); }
    .page-wrap > .hero, body.has-result .page-wrap > .hero { background: none; color: #172344; box-shadow: none; border-radius: 0; padding: 0 0 .25rem; margin-bottom: 1rem !important; }
    .hero > .d-flex { gap: .4rem !important; }
    .hero .text-end { display: none; }
    .hero .app-eyebrow { color: #4f46e5; }
    .hero h1, body.has-result .hero h1 { font-size: 1.5rem !important; line-height: 1.25; letter-spacing: -.035em; font-weight: 750; margin-bottom: .4rem !important; }
    .hero small, body.has-result .hero small { display: block; color: #64748b; font-size: .86rem; line-height: 1.5; }
    .app-nav { position: fixed; inset: auto 0 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .25rem; margin: 0; min-height: var(--mobile-nav-height); padding: .4rem max(.65rem, env(safe-area-inset-right, 0px)) calc(.4rem + env(safe-area-inset-bottom, 0px)) max(.65rem, env(safe-area-inset-left, 0px)); background: #fff; border-top: 1px solid #e2e8f0; box-shadow: 0 -4px 20px #18264408; z-index: 1030; }
    .app-nav a { flex-direction: column; justify-content: center; gap: .25rem; min-height: 56px; padding: .4rem .2rem; color: #64748b; font-size: .72rem; border-radius: .75rem; }
    .app-nav a.active { background: #eef2ff; color: #4338ca; }
    .app-nav a:hover { background: #f1f5f9; color: #4338ca; }
    .card-soft { border: 1px solid #e5eaf3; border-radius: 1rem; box-shadow: 0 3px 14px #18264404; min-width: 0; }
    .card-soft.mb-3 { margin-bottom: 1rem !important; }
    .card-soft .card-header { padding: 1rem; font-size: .95rem; font-weight: 700; }
    .card-soft .card-body { padding: 1rem; }
    .card-header.d-flex { flex-wrap: wrap; gap: .65rem !important; }
    .row.g-2 { --bs-gutter-y: .85rem; --bs-gutter-x: .75rem; }
    .row.g-3 { --bs-gutter-y: 1rem; }
    .row > *, .d-flex > *, .input-group > *, .result-quick > * { min-width: 0; }
    .form-label { font-size: .82rem; margin-bottom: .4rem; line-height: 1.4; }
    .form-control, .form-control-sm, .form-select { font-size: 16px !important; min-height: 46px; border-radius: .65rem; padding: .65rem .7rem; border-color: #d9e0ed; max-width: 100%; }
    input[type="date"] { appearance: none; -webkit-appearance: none; min-width: 0; width: 100%; }
    input[type="date"]::-webkit-date-and-time-value { text-align: left; min-width: 0; }
    .btn, .btn-sm, .profile-chip .p-actions .btn, .history-actions .btn { min-height: 44px; padding: .6rem .8rem; font-size: .85rem; border-radius: .65rem; white-space: normal; line-height: 1.35; }
    .btn-primary { background: #4f46e5; border-color: #4f46e5; }
    .btn-primary:hover, .btn-primary:focus { background: #4338ca; border-color: #4338ca; }
    .btn-lg { min-height: 50px; font-size: 1rem; }
    .btn-close { min-width: 44px; min-height: 44px; box-sizing: border-box; background-size: 12px; }
    .form-check { min-height: 44px; padding-top: .4rem; padding-bottom: .4rem; }
    .form-check-label { font-size: .88rem; }
    .hint { font-size: .8rem; line-height: 1.5; }
    .paste-toolbar { display: flex !important; flex-wrap: wrap; gap: .4rem !important; width: 100%; margin-bottom: .85rem; }
    .paste-toolbar .btn { flex: 1 1 0; min-height: 44px; padding: .55rem .35rem; font-size: .8rem; width: auto; }
    textarea.paste-box { min-height: 200px; font-size: 16px; line-height: 1.65; padding: .85rem; }
    .format-details > summary { min-height: 44px; padding: .65rem 0; font-size: .8rem; }
    .settings-disclosure { margin-top: .75rem; }
    .settings-disclosure > summary { min-height: 50px; }
    #paramProfilesBox { padding: 0 !important; margin-bottom: .85rem !important; background: #f8fafc; }
    #paramProfilesBox .profile-list { max-height: 280px; }
    .profile-chip { padding: .8rem; }
    .profile-chip .p-name { font-size: .95rem; }
    .profile-chip .p-meta { line-height: 1.5; overflow-wrap: anywhere; }
    .param-accordion .accordion-button { min-height: 48px; font-size: .85rem; padding: .8rem; flex-wrap: wrap; }
    .param-accordion .accordion-button .acc-hint { display: none; }
    .param-accordion .accordion-body { padding: .85rem; }
    .sticky-actions { position: static; background: transparent; border: 0; box-shadow: none; backdrop-filter: none; padding: 0; margin: 1rem 0; }
    .sticky-actions .btn-lg { width: 100%; }
    #historyCard { display: none; }
    .result-hero .card-body { padding: 1rem; }
    .result-hero .card-body > .d-flex { flex-direction: column; gap: .7rem; }
    .result-hero-net { text-align: left !important; }
    .result-hero-name { white-space: normal; overflow-wrap: anywhere; }
    .result-hero-amount { font-size: 1.8rem; letter-spacing: -.04em; }
    .result-quick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .result-quick .btn { font-size: .85rem; min-height: 44px; padding: .65rem .45rem; }
    .result-quick #btnShareBriefTop { grid-column: auto; }
    .result-quick #btnClearResult { grid-column: 1 / -1; }
    .result-tabs .nav-link, .nav-pills .nav-link { min-height: 44px; padding: .7rem .35rem; font-size: .85rem; }
    .day-list-all, #pane-slip .table-responsive { max-height: none; }
    .day-row { padding: .8rem; }
    .copy-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem !important; }
    .copy-toolbar .btn { min-height: 44px; font-size: .8rem; }
    .history-item { padding: .85rem; }
    .history-item > .d-flex, .history-group-head { flex-wrap: wrap; }
    .history-item .net { font-size: 1rem; }
    .history-item .meta, .history-group-head .g-name { overflow-wrap: anywhere; }
    .history-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; margin-top: .85rem; }
    .history-actions .btn { width: 100%; }
    .history-more { margin-top: .5rem; }
    .history-more > summary { min-height: 44px; padding: .65rem 0; font-size: .8rem; color: #475569; cursor: pointer; }
    .history-group-body { padding: .65rem; }
    .history-list { max-height: none; overflow: visible; }
    .history-toolbar .btn { min-height: 44px; }
    .stat { padding: .85rem; }
    .stat .value { font-size: clamp(.95rem, 4vw, 1.25rem); overflow-wrap: anywhere; }
    .table-responsive { max-width: 100%; overscroll-behavior-x: contain; }
    .table-scroll-hint { display: block; color: #64748b; font-size: .75rem; padding: .65rem 1rem; margin: 0; background: #f8fafc; }
    .chart-wrap { max-width: 100%; }
    .chart-wrap canvas { max-width: 100%; }
    .modal-dialog { margin: .75rem; }
    .modal-content { border-radius: 1rem; }
    .modal-footer { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
    .modal-footer > * { margin: 0; width: 100%; }
    .modal-footer > :last-child { grid-column: 1 / -1; }
    .toast-save { left: 1rem; right: 1rem; bottom: calc(var(--mobile-nav-height) + env(safe-area-inset-bottom, 0px) + .75rem); text-align: center; }
    .data-warn-banner { flex-wrap: wrap; gap: .65rem; }
    .data-warn-banner .btn { min-height: 44px; }
    #yearDetectionMessage { font-size: .85rem; line-height: 1.6; }
    .mobile-help { display: none; }
}
@media screen and (max-width: 359.98px) {
    .page-wrap { padding-left: .75rem; padding-right: .75rem; }
    .card-soft .card-body, .card-soft .card-header { padding: .85rem; }
    .date-settings .col-6 { width: 100%; }
    .form-label { font-size: .78rem; }
    .modal-body .col-4 { width: 100%; }
}
@media print {
    .app-nav, .app-eyebrow { display: none !important; }
    .page-wrap { padding-bottom: 0 !important; }
}
