.pwa-shell { max-width: 1080px; margin: 0 auto; padding-bottom: 5.5rem; }
.pwa-hero { color: #fff; background: radial-gradient(circle at top right, #374151, #111827 62%); border-radius: 1.5rem; padding: clamp(1.4rem, 4vw, 2.5rem); }
.pwa-hero .btn { min-height: 46px; }
.pwa-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.pwa-action { display: flex; flex-direction: column; gap: .55rem; min-height: 150px; padding: 1.25rem; color: inherit; text-decoration: none; background: #fff; border: 1px solid #e5e7eb; border-radius: 1.2rem; box-shadow: 0 8px 28px rgb(17 24 39 / 7%); }
.pwa-action:hover { color: inherit; border-color: #9ca3af; transform: translateY(-1px); }
.pwa-action i { font-size: 1.75rem; }
.pwa-action strong { font-size: 1.08rem; }
.pwa-stat { background: rgb(255 255 255 / 12%); border: 1px solid rgb(255 255 255 / 15%); border-radius: 1rem; padding: .85rem 1rem; }
.pwa-dashboard-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pwa-dashboard-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.pwa-metric-card { position: relative; display: flex; flex-direction: column; gap: .35rem; min-height: 148px; padding: 1.2rem; overflow: hidden; color: #111827; text-decoration: none; background: #fff; border: 1px solid #e5e7eb; border-radius: 1.2rem; box-shadow: 0 8px 28px rgb(17 24 39 / 7%); }
.pwa-metric-card::before { position: absolute; inset: 0 auto 0 0; width: .35rem; content: ''; background: #64748b; }
.pwa-metric-card:hover { color: #111827; border-color: #9ca3af; transform: translateY(-1px); }
.pwa-metric-card strong { font-size: clamp(1.55rem, 4vw, 2.15rem); line-height: 1.15; }
.pwa-metric-card > span:last-child { color: #6b7280; }
.pwa-metric-label { display: flex; align-items: center; gap: .5rem; color: #4b5563; font-weight: 600; }
.pwa-metric-label i { font-size: 1.2rem; }
.pwa-metric-primary::before { background: #2563eb; }
.pwa-metric-danger::before { background: #dc2626; }
.pwa-metric-warning::before { background: #f59e0b; }
.pwa-metric-good::before { background: #16a34a; }
.pwa-currency-totals { display: flex; flex-wrap: wrap; gap: .35rem .75rem; }
.pwa-currency-totals span { white-space: nowrap; }
.pwa-glance-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.pwa-glance-grid > a { display: flex; align-items: center; gap: 1rem; min-height: 92px; padding: 1rem; color: inherit; text-decoration: none; background: #fff; border: 1px solid #e5e7eb; border-radius: 1rem; }
.pwa-glance-grid > a:hover { border-color: #9ca3af; }
.pwa-glance-grid i { flex: 0 0 auto; display: grid; place-items: center; width: 46px; height: 46px; color: #fff; font-size: 1.3rem; background: #111827; border-radius: .8rem; }
.pwa-glance-grid strong { font-size: 1.35rem; }
.pwa-glance-grid small { display: block; color: #6b7280; }
.pwa-install-guide { display: flex; align-items: center; gap: .85rem; padding: 1rem; color: #111827; background: #fff7ed; border: 1px solid #fdba74; border-radius: 1rem; box-shadow: 0 8px 28px rgb(17 24 39 / 7%); }
.pwa-install-guide[hidden] { display: none !important; }
.pwa-install-guide-icon { flex: 0 0 auto; display: grid; place-items: center; width: 46px; height: 46px; color: #fff; font-size: 1.35rem; background: #ea580c; border-radius: .8rem; }
.pwa-install-guide .btn-close { flex: 0 0 auto; min-height: 44px; min-width: 44px; }
.pwa-swipe-hint { display: none; }
.pwa-global-nav { display: none; }
.pwa-topbar-brand, .pwa-user-menu { display: none; }
.is-offline [data-requires-online] { opacity: .55; pointer-events: none; }

html.pwa-mode { -webkit-tap-highlight-color: rgb(249 115 22 / 22%); scroll-behavior: smooth; }
html.pwa-mode body { overscroll-behavior-y: none; }
html.pwa-mode .app-shell { display: block; }
html.pwa-mode .app-sidebar { display: none !important; }
html.pwa-mode .app-sidebar-toggle { display: none !important; }
html.pwa-mode .app-main { padding-bottom: calc(5.25rem + env(safe-area-inset-bottom)); }
html.pwa-mode .app-footer { display: none; }
html.pwa-mode .btn,
html.pwa-mode button,
html.pwa-mode [role="button"] { min-height: 48px; touch-action: manipulation; }
html.pwa-mode .btn-sm { min-height: 44px; padding: .55rem .8rem; font-size: .9rem; }
html.pwa-mode .form-control,
html.pwa-mode .form-select { min-height: 48px; padding-top: .65rem; padding-bottom: .65rem; font-size: 16px; }
html.pwa-mode textarea.form-control { min-height: 96px; }
html.pwa-mode .form-check-input { width: 1.5rem; height: 1.5rem; margin-right: .4rem; }
html.pwa-mode .form-check-label { min-height: 36px; display: inline-flex; align-items: center; }
html.pwa-mode .dropdown-item,
html.pwa-mode .list-group-item { min-height: 48px; padding-top: .75rem; padding-bottom: .75rem; }
html.pwa-mode .table-responsive { overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
html.pwa-mode .table-responsive > table { min-width: 780px; }
html.pwa-mode .document-lines-table,
html.pwa-mode table:has(.invoice-line-row) { min-width: 1040px; }
html.pwa-mode .invoice-line-row td,
html.pwa-mode .quote-line-row td,
html.pwa-mode .credit-note-line-row td { padding: .65rem .35rem; }
html.pwa-mode .remove-line { min-width: 48px; font-size: 1rem; }
html.pwa-mode .card { border-radius: 1rem; }
html.pwa-mode .modal-dialog { margin: .5rem; }
html.pwa-mode .modal-footer { gap: .5rem; }
html.pwa-mode .modal-footer .btn { flex: 1 1 auto; }
html.pwa-mode .pwa-global-nav { position: fixed; z-index: 1050; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; left: 0; right: 0; bottom: 0; padding: .4rem max(.3rem, env(safe-area-inset-right)) calc(.4rem + env(safe-area-inset-bottom)) max(.3rem, env(safe-area-inset-left)); background: rgb(17 24 39 / 97%); box-shadow: 0 -8px 24px rgb(0 0 0 / 18%); backdrop-filter: blur(14px); }
html.pwa-mode .pwa-global-nav a { min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .12rem; padding: .25rem .1rem; border-radius: .7rem; color: #d1d5db; text-decoration: none; text-align: center; font-size: clamp(.62rem, 2.6vw, .75rem); touch-action: manipulation; }
html.pwa-mode .pwa-global-nav a i { color: #fff; font-size: 1.25rem; line-height: 1; }
html.pwa-mode .pwa-global-nav a.active { color: #fff; background: rgb(255 255 255 / 13%); }
html.pwa-mode .pwa-global-nav a.active i { color: #fb923c; }
@media (max-width: 767.98px) {
  .pwa-shell { padding-inline: .25rem; }
  .pwa-actions { grid-template-columns: 1fr; }
  .pwa-dashboard-grid, .pwa-dashboard-grid-2, .pwa-glance-grid { grid-template-columns: 1fr; }
  .pwa-metric-card { min-height: 126px; }
  .pwa-action { min-height: 108px; }
  html.pwa-mode .app-topbar-left,
  html.pwa-mode .app-topbar-center,
  html.pwa-mode .app-quick-action-toggle,
  html.pwa-mode .app-chat-button,
  html.pwa-mode .app-user-desktop { display: none !important; }
  html.pwa-mode .app-topbar { display: flex; justify-content: space-between; gap: .75rem; min-height: 64px; padding: .55rem .75rem; }
  html.pwa-mode .pwa-topbar-brand { display: inline-flex; align-items: center; gap: .55rem; color: #fff; font-size: 1.05rem; font-weight: 700; text-decoration: none; }
  html.pwa-mode .pwa-topbar-brand img { width: 38px; height: 38px; object-fit: contain; }
  html.pwa-mode .app-topbar-actions { flex-wrap: nowrap; gap: .4rem; }
  html.pwa-mode .app-topbar-actions > .dropdown { flex: 0 0 auto; }
  html.pwa-mode .app-topbar-actions .navbar-nav { flex-direction: row; gap: .4rem; }
  html.pwa-mode .pwa-user-menu { display: block; }
  html.pwa-mode .pwa-user-menu-toggle { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border-radius: 999px; }
  html.pwa-mode .pwa-user-menu-toggle i { font-size: 1.35rem; }
  html.pwa-mode .pwa-user-menu-panel { width: min(20rem, calc(100vw - 1.5rem)); }
  html.pwa-mode .app-notification-menu { position: fixed !important; inset: 4.25rem .75rem auto .75rem !important; width: auto; transform: none !important; }
  html.pwa-mode .pwa-card-table { min-width: 0; background: transparent; }
  html.pwa-mode .pwa-card-table thead { display: none; }
  html.pwa-mode .pwa-card-table tbody,
  html.pwa-mode .pwa-card-table tr,
  html.pwa-mode .pwa-card-table td { display: block; width: 100%; }
  html.pwa-mode .pwa-card-table tbody { padding: .15rem; }
  html.pwa-mode .pwa-card-table tbody tr { margin-bottom: .85rem; padding: .75rem .9rem; overflow: hidden; background: #fff; border: 1px solid #e5e7eb; border-radius: 1rem; box-shadow: 0 5px 18px rgb(17 24 39 / 6%); }
  html.pwa-mode .pwa-card-table tbody tr:last-child { margin-bottom: 0; }
  html.pwa-mode .pwa-card-table tbody td { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; min-height: 42px; padding: .55rem 0; text-align: right; border-color: #eef0f2; white-space: normal; }
  html.pwa-mode .pwa-card-table tbody td::before { flex: 0 0 38%; content: attr(data-label); color: #6b7280; font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-align: left; text-transform: uppercase; }
  html.pwa-mode .pwa-card-table tbody td[colspan] { display: block; text-align: left; }
  html.pwa-mode .pwa-card-table tbody td[colspan]::before,
  html.pwa-mode .pwa-card-table tbody td:not([data-label])::before { display: none; }
  html.pwa-mode .pwa-card-table tbody td .d-flex { justify-content: flex-end !important; flex-wrap: wrap; }
  html.pwa-mode .pwa-card-table tbody td form { display: inline-flex; }
  html.pwa-mode .pwa-card-table tbody td:first-child { padding-top: .2rem; font-size: 1.05rem; }
  html.pwa-mode .pwa-card-table tbody td:last-child { padding-bottom: .2rem; border-bottom: 0; }
  html.pwa-mode .document-lines-section { overflow: visible; padding-bottom: .35rem; }
  html.pwa-mode .document-lines-section > table { display: block; min-width: 0; margin: 0; }
  html.pwa-mode .document-lines-section > table thead { display: none; }
  html.pwa-mode .document-lines-section > table tbody { display: block; }
  html.pwa-mode .document-lines-section > table tbody tr { position: relative; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-bottom: 1rem; padding: 3rem 1rem 1rem; background: #fff; border: 1px solid #dfe3e8; border-radius: 1rem; box-shadow: 0 7px 22px rgb(17 24 39 / 7%); }
  html.pwa-mode .document-lines-section > table tbody tr::before { position: absolute; top: 0; right: 0; left: 0; padding: .6rem 1rem; content: attr(data-line-number); color: #374151; font-size: .82rem; font-weight: 800; background: #f3f4f6; border-bottom: 1px solid #e5e7eb; border-radius: 1rem 1rem 0 0; }
  html.pwa-mode .document-lines-section > table tbody td { display: block; width: auto; min-width: 0; padding: 0; border: 0; }
  html.pwa-mode .document-lines-section > table tbody td::before { display: block; margin-bottom: .3rem; content: attr(data-label); color: #6b7280; font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
  html.pwa-mode .document-lines-section > table tbody td:nth-child(1),
  html.pwa-mode .document-lines-section > table tbody td:nth-child(2),
  html.pwa-mode .document-lines-section > table tbody td:nth-child(3),
  html.pwa-mode .document-lines-section > table tbody td:nth-child(4),
  html.pwa-mode .document-lines-section > table tbody td:last-child { grid-column: 1 / -1; }
  html.pwa-mode .document-lines-section > table tbody td:last-child { display: flex; justify-content: flex-end; align-items: center; }
  html.pwa-mode .document-lines-section > table tbody td:last-child::before { margin: 0 auto 0 0; }
  html.pwa-mode .document-lines-section .form-control,
  html.pwa-mode .document-lines-section .form-select,
  html.pwa-mode .document-lines-section .searchable-select { width: 100%; max-width: none; }
  html.pwa-mode .document-lines-section .remove-line { min-width: 92px; }
  html.pwa-mode .app-content > section > .d-flex:first-child { align-items: stretch !important; }
  html.pwa-mode .app-content > section > .d-flex:first-child > div:last-child { flex-wrap: wrap; }
  html.pwa-mode .app-topbar { padding-inline: .65rem; }
  html.pwa-mode .app-content { padding-inline: .65rem; }
  html.pwa-mode section.py-4 { padding-top: 1rem !important; }
  html.pwa-mode h1.display-6 { font-size: 1.75rem; }
  html.pwa-mode .d-flex.gap-2 > .btn,
  html.pwa-mode .d-flex.flex-wrap.gap-2 > .btn { flex: 1 1 auto; }
}

@media (hover: none) and (pointer: coarse) {
  html.pwa-mode .pwa-action:hover { transform: none; }
  html.pwa-mode a, html.pwa-mode button, html.pwa-mode input, html.pwa-mode select, html.pwa-mode textarea { touch-action: manipulation; }
}
