/* Shared screen styles for the operations shell and the external ledgers. */
@media screen {
  :is(#appShell, #app .shell) {
    --work-rail-gap: 4px;
    --work-section-gap: 16px;
    --work-radius: 8px;
    --work-line: var(--ui-line, var(--line, #d9e1e8));
    --work-subtle: var(--ui-panel-soft, #f4f7f9);
    --work-muted: var(--ui-muted, var(--muted, #52647a));
    --work-focus: var(--ui-brand, var(--blue, #245ce3));
  }

  /* The site moves focus to main on navigation. Keep the landmark boundary quiet. */
  html body :is(#appShell #mainContent, #app #workspace-main):focus {
    outline: 0 !important;
  }
  html body :is(#appShell #mainContent, #app #workspace-main) :is(input,select,textarea):focus-visible:not([type=checkbox],[type=radio],[type=range],[type=file]) {
    outline: 1px solid var(--work-focus) !important;
    outline-offset: 0 !important;
    box-shadow: none !important;
  }

  html body.ui-spacious #appShell > .sidebar,
  #app .shell > .sidebar {
    --sidebar-row-gap: var(--work-rail-gap);
    --sidebar-section-gap: var(--work-section-gap);
  }
  html body.ui-spacious #appShell .sidebar :is(.nav-link,.nav-group-toggle),
  #app .shell .sidebar #workspace-nav button {
    min-height: 44px !important;
    padding-block: 10px !important;
    line-height: 22px !important;
    border-radius: var(--work-radius) !important;
  }

  html body.ui-spacious #appShell #mainContent > .topbar,
  #app .shell .content .page-heading {
    gap: 12px;
    margin-bottom: var(--work-section-gap) !important;
  }
  html body.ui-spacious #appShell #mainContent > .topbar h1,
  #app .shell .page-heading h1 {
    font-size: clamp(21px, 1.65vw, 26px) !important;
    font-weight: 650;
    line-height: 1.3;
  }

  html body.ui-spacious #appShell #view-dashboard .dashboard-kpis {
    gap: 8px !important;
  }
  html body.ui-spacious #appShell #view-dashboard .dashboard-kpis .kpi {
    min-height: 82px !important;
    padding: 12px 14px !important;
    gap: 4px;
    border-radius: var(--work-radius) !important;
  }
  html body.ui-spacious #appShell #view-dashboard .dashboard-kpis .kpi strong {
    font-size: clamp(18px, 1.45vw, 25px) !important;
    font-variant-numeric: tabular-nums;
  }
  html body.ui-spacious #appShell #mainContent #financeWorkspaceContext {
    margin-block-end: 10px !important;
    padding-block-end: 8px !important;
  }
  html body.ui-spacious #appShell #view-tax :is(.tax-tabs,.tax-filters) {
    margin-block: 0 10px !important;
  }

  html body :is(#appShell #mainContent, #app .content) .fl-list {
    --fl-gap: 10px;
    --fl-row-padding: 9px;
    --fl-control-height: 36px;
  }
  html body :is(#appShell #mainContent, #app .content) :is(.fl-table,.data-table,.table-scroll table) thead th {
    color: var(--work-muted);
    background-color: var(--work-subtle);
    font-size: 13px;
    font-weight: 600;
    vertical-align: middle;
    padding-block: 9px !important;
  }
  html body :is(#appShell #mainContent, #app .content) :is(.fl-table,.data-table,.table-scroll table) tbody td {
    padding-block: 9px !important;
    font-variant-numeric: tabular-nums;
  }
  html body :is(#appShell #mainContent, #app .content) :is(.fl-table,.data-table,.table-scroll table) tbody tr:focus-within {
    outline: 1px solid var(--work-line);
    outline-offset: -1px;
  }
  #app .shell > .main > .topbar {
    min-height: 60px;
    padding-block: 8px;
  }
  #app .shell .content .panel > .panel-head {
    padding-block: 12px;
  }
}
@media screen and (min-width: 1200px) {
  html body.ui-spacious #appShell #view-dashboard .dashboard-kpis {
    grid-template-columns: repeat(auto-fit, minmax(142px, 1fr)) !important;
  }
}
@media screen and (max-width: 720px) {
  #app .shell .content .page-heading,
  html body.ui-spacious #appShell #mainContent > .topbar {
    gap: 8px;
    margin-bottom: 12px !important;
  }
  html body :is(#appShell #mainContent, #app .content) .fl-list {
    --fl-control-height: 42px;
  }
}
@media screen and (min-width: 721px) {
  /* Row actions set the height of even a one-line record; compact both together. */
  html body :is(#appShell #mainContent .view, #app #workspace-main .content) :is(.table-wrap,.table-scroll,.fl-table) tbody td,
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-table tbody td {
    padding-block: 5px !important;
    line-height: 1.4 !important;
  }
  html body :is(#appShell #mainContent .view, #app #workspace-main .content) :is(.table-wrap,.table-scroll,.fl-table) tbody td :is(.btn,button):not([role=switch]),
  html body.ui-spacious #appShell #mainContent #view-inventory .inventory-table td .btn {
    height: auto !important;
    min-height: 28px !important;
    padding-block: 3px !important;
    line-height: 20px !important;
  }
}
@media screen {
  /* Single-line text rules must not flatten the interactive bank matching form. */
  html body #appShell #mainContent .fl-list .bank-table td .bank-match-tools,
  html body #appShell #mainContent .fl-list .bank-table td .bank-match-primary,
  html body #appShell #mainContent .fl-list .bank-table td .bank-operation-panel {
    display: grid !important;
    min-width: 0;
    gap: 4px;
  }
  html body #appShell #mainContent .fl-list .bank-table td .bank-action-buttons {
    display: flex !important;
    align-items: center;
  }
  html body #appShell #mainContent .fl-list .bank-table td .bank-match-tools :is(.hidden,[hidden]) {
    display: none !important;
  }
}
@media screen and (min-width: 721px) {
  html body.ui-spacious #appShell #mainContent .bank-table .bank-match-tools :is(select,input) {
    height: 30px !important;
    min-height: 30px !important;
    padding-block: 3px !important;
  }
}

.nsk-mobile-shell { display: none; }

@media screen and (max-width: 720px) {
  body[data-book-key="nsk"] #app .shell > .sidebar,
  body[data-book-key="nsk"] #app .main > .company-workspaces,
  body[data-book-key="nsk"] #app .main > .topbar > :is(.company, .workspace-account-actions) {
    display: none;
  }
  body[data-book-key="nsk"] .nsk-mobile-shell {
    position: sticky;
    top: 0;
    z-index: 4;
    display: block;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }
  body[data-book-key="nsk"] #app .main > .topbar {
    min-height: 0;
    padding: 4px 12px;
  }
  body[data-book-key="nsk"] #app .main .content { padding-top: 10px; }
  body[data-book-key="nsk"] #app .main #period:disabled { display: none; }
  .nsk-mobile-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: max(4px, env(safe-area-inset-top)) 12px 0;
  }
  .nsk-mobile-heading strong { font-size: 18px; }
  .nsk-mobile-actions { display: flex; gap: 4px; }
  .nsk-mobile-actions button { padding-inline: 8px; white-space: nowrap; }
  body[data-book-key="nsk"] #finance-assistant-launch { display: none !important; }
  .nsk-mobile-quick {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    padding: 4px 12px 6px;
  }
  .nsk-mobile-heading button,
  .nsk-mobile-quick button,
  #nsk-mobile-modules :is(button,a) {
    min-height: 44px;
  }
  .nsk-mobile-quick button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px;
    border-color: transparent;
  }
  .nsk-mobile-quick svg { width: 16px; height: 16px; flex: none; }
  .nsk-mobile-quick [aria-current="page"],
  #nsk-mobile-modules [aria-current="page"] {
    border-color: #c7d8fc;
    color: #1749c0;
    background: #eef4ff;
  }
  #nsk-mobile-modules {
    width: min(440px, calc(100% - 24px));
    max-height: min(720px, calc(100dvh - 24px));
    padding: 12px;
    overscroll-behavior: contain;
  }
  #nsk-mobile-modules header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
  }
  #nsk-mobile-modules h2 { margin: 0; font-size: 18px; }
  #nsk-mobile-modules nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
  #nsk-mobile-modules :is(nav,footer) :is(button,a) { padding: 6px; }
  #nsk-mobile-modules footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
  }
  #nsk-mobile-modules footer a { display: inline-flex; align-items: center; }
}

@media screen {
  body[data-book-key="nsk"] #app #workspace-main {
    --nsk-section-gap: 10px;
    --nsk-list-gap: 6px;
  }

  body[data-book-key="nsk"] #app #workspace-main > .content {
    padding-block-start: 12px;
  }
  body[data-book-key="nsk"] #app #workspace-main > .company-workspaces {
    margin-block-end: 0;
  }
  body[data-book-key="nsk"] #app #workspace-main > .topbar {
    min-height: 56px;
    padding-block: 6px;
  }
  body[data-book-key="nsk"] #app #workspace-main .page-heading {
    margin-block-end: var(--nsk-section-gap) !important;
  }
  body[data-book-key="nsk"] #app #workspace-main .page-heading h1 {
    margin-block-end: 2px;
  }

  /* A list grid already provides the space below its heading. */
  body[data-book-key="nsk"] #app #workspace-main .fl-list {
    --fl-gap: var(--nsk-list-gap);
  }
  body[data-book-key="nsk"] #app #workspace-main .fl-list.fl-stack > .page-heading {
    margin-block-end: 0 !important;
  }
  body[data-book-key="nsk"] #app #workspace-main :is(.content, .fl-stack) > :is(.banner, .invoice-review-progress) {
    margin-block-end: var(--nsk-section-gap);
    padding-block: 8px;
  }
  body[data-book-key="nsk"] #app #workspace-main .fl-stack > .invoice-review-progress {
    margin-block-end: 0;
  }
  body[data-book-key="nsk"] #app #workspace-main .invoice-review-progress progress {
    margin-block: 6px;
  }
  body[data-book-key="nsk"] #app #workspace-main .content > :is(.toolbar, .tabs, .metrics) {
    margin-block-end: var(--nsk-section-gap);
  }
  body[data-book-key="nsk"] #app #workspace-main :is(.metrics, .bank-summary) {
    padding-block: 10px;
    row-gap: 8px;
  }
  body[data-book-key="nsk"] #app #workspace-main .bank-summary > div {
    gap: 2px;
  }
  body[data-book-key="nsk"] #app #workspace-main .bank-source {
    padding-block: 6px;
  }
  body[data-book-key="nsk"] #app #workspace-main #bank-auto-status:not(:empty) {
    padding-block: 3px;
  }
  body[data-book-key="nsk"] #app #workspace-main .monthly-workspace :is(.monthly-toolbar, .monthly-links) {
    margin-block-end: var(--nsk-section-gap);
  }
  body[data-book-key="nsk"] #app #workspace-main .monthly-workspace .monthly-panel {
    margin-block: var(--nsk-section-gap);
    padding-block: 10px;
  }
  body[data-book-key="nsk"] #app #workspace-main .monthly-workspace .monthly-metrics button {
    padding-block: 10px;
  }
}

@media screen and (max-width: 720px) {
  body[data-book-key="nsk"] #app #workspace-main > .content {
    padding-block-start: 6px;
  }
  body[data-book-key="nsk"] #app #workspace-main > .topbar {
    min-height: 0;
    padding-block: 4px;
  }
  body[data-book-key="nsk"] #app #workspace-main .bank-source:has(> details) {
    padding-block: 0;
  }
  body[data-book-key="nsk"] #app #workspace-main .bank-source summary {
    min-height: 44px;
    padding-block: 8px;
  }
}

@media screen and (min-width: 375px) and (max-width: 720px) {
  body[data-book-key="nsk"] #app #workspace-main .bank-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 8px;
    padding-inline: 10px;
  }
  body[data-book-key="nsk"] #app #workspace-main .bank-summary strong {
    font-size: 18px;
  }
}

.nsk-nav-group {display:grid;gap:2px;}
.nsk-nav-group + .nsk-nav-group {margin-top:8px;}
.nsk-nav-caption {padding:4px 10px;color:var(--muted);font-size:12px;font-weight:600;}
#nsk-mobile-modules nav .nsk-nav-group {grid-column:1/-1;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;}
#nsk-mobile-modules .nsk-nav-caption {grid-column:1/-1;padding:2px 0;}
