@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=Sora:wght@500;600;700;800&display=swap");

:root {
  --ink-900: #1d2630;
  --ink-700: #3a4857;
  --ink-500: #6d7a89;
  --paper: #f3f7fa;
  --white: #ffffff;
  --surface-muted: #eef4f8;
  --line: #d9e1e8;
  --line-soft: #edf1f5;
  --panel-row-border: #e6edf5;
  --panel-row-bg: #fafcff;
  --input-border: #cfd8e3;
  --input-bg: #fcfdfe;
  --fieldset-border: #d3dce6;
  --timeline-line: #cde6de;
  --code-bg: #eef3f8;
  --bg-grad-1: #d9f5ea;
  --bg-grad-2: #dbeafe;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --warn: #c68a03;
  --info: #1d4ed8;
  --danger: #b42318;
  --success: #166534;
  --shadow: 0 12px 30px rgba(15, 35, 58, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Trebuchet MS", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 10% 10%, var(--bg-grad-1) 0, transparent 30%),
    radial-gradient(circle at 90% 12%, var(--bg-grad-2) 0, transparent 34%),
    var(--paper);
  color: var(--ink-900);
  color-scheme: light;
}

body.app-body {
  min-height: 100vh;
}

body.theme-dark {
  --ink-900: #e6edf7;
  --ink-700: #c5d4e4;
  --ink-500: #9db0c4;
  --paper: #0f1724;
  --white: #121c2c;
  --surface-muted: #18253a;
  --line: #28384d;
  --line-soft: #223146;
  --panel-row-border: #2a3a4e;
  --panel-row-bg: #142033;
  --input-border: #32475f;
  --input-bg: #0f1a2a;
  --fieldset-border: #334a63;
  --timeline-line: #245049;
  --code-bg: #1a2a3f;
  --bg-grad-1: rgba(10, 91, 77, 0.35);
  --bg-grad-2: rgba(24, 62, 111, 0.32);
  --brand: #14b8a6;
  --brand-dark: #0f9488;
  --warn: #f59e0b;
  --info: #60a5fa;
  --danger: #f87171;
  --success: #4ade80;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.app-frame {
  min-height: 100vh;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  margin: 0 0 1.5rem;
  border-bottom: 1px solid rgba(187, 202, 220, 0.78);
  background: rgba(248, 251, 254, 0.9);
  box-shadow: 0 12px 28px rgba(30, 58, 95, 0.08);
  backdrop-filter: blur(16px);
}

.app-header-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

.app-topbar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "brand actions";
  align-items: center;
  gap: 1.25rem;
  min-height: 88px;
  padding: 1rem 0 0.95rem;
}

.app-brand {
  grid-area: brand;
  display: inline-flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 280px;
  text-decoration: none;
  color: var(--ink-900);
  overflow: hidden;
}

.app-brand-mark {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(74, 141, 208, 0.28);
  background:
    radial-gradient(circle at 35% 35%, rgba(110, 225, 214, 0.32), transparent 35%),
    linear-gradient(135deg, rgba(226, 241, 255, 1), rgba(206, 226, 247, 1));
  color: #2f6ebc;
  font-family: "Sora", "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.app-brand-lockup {
  display: grid;
  gap: 0.16rem;
  min-width: 0;
}

.app-brand-name {
  color: #2f6ebc;
  font-family: "Sora", "Avenir Next", "Trebuchet MS", sans-serif;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.app-brand-tag {
  color: var(--ink-500);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.app-user-menu {
  grid-area: actions;
  position: relative;
  justify-self: end;
}

.app-user-toggle {
  all: unset;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.app-user-toggle::-webkit-details-marker {
  display: none;
}

.app-user-toggle:focus-visible .app-account-pill {
  outline: 2px solid rgba(120, 165, 255, 0.85);
  outline-offset: 3px;
}

.app-account-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.2rem 0.72rem 0.2rem 0.24rem;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(236, 243, 255, 0.96), rgba(225, 235, 248, 0.94));
  border: 1px solid rgba(137, 170, 219, 0.58);
  color: var(--ink-900);
  text-decoration: none;
  box-shadow: 0 8px 18px rgba(31, 61, 100, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: background 0.18s ease, border-color 0.18s ease;
}

.app-account-pill:hover,
.app-user-menu[open] .app-account-pill {
  background: linear-gradient(180deg, rgba(228, 239, 255, 0.98), rgba(214, 229, 247, 0.96));
  border-color: rgba(110, 150, 213, 0.66);
}

.app-user-dropdown {
  position: absolute;
  top: calc(100% + 0.75rem);
  right: 0;
  z-index: 80;
  display: grid;
  gap: 0.9rem;
  width: min(420px, calc(100vw - 2rem));
  padding: 0.85rem;
  border: 1px solid rgba(194, 209, 228, 0.96);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(20, 184, 166, 0.08), transparent 32%),
    linear-gradient(165deg, rgba(255, 255, 255, 0.99), rgba(242, 247, 252, 0.99));
  box-shadow: 0 20px 40px rgba(31, 61, 100, 0.16);
}

.app-user-section {
  display: grid;
  gap: 0.6rem;
}

.app-user-section-title {
  margin: 0;
  color: var(--ink-500);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
}

.app-user-menu-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(210, 222, 236, 0.92);
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-900);
  text-decoration: none;
  font-weight: 700;
}

.app-user-menu-link:hover {
  background: rgba(233, 242, 251, 0.94);
  border-color: rgba(90, 136, 208, 0.3);
}

.app-module-menu {
  position: relative;
}

.app-module-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
  min-width: 212px;
  padding: 0.62rem 0.98rem 0.62rem 1.02rem;
  border: 1px solid rgba(194, 209, 228, 0.96);
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 245, 251, 0.96)),
    rgba(255, 255, 255, 0.9);
  color: var(--ink-900);
  cursor: pointer;
  list-style: none;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 8px 20px rgba(31, 61, 100, 0.1);
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.app-module-toggle::-webkit-details-marker {
  display: none;
}

.app-module-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  margin-left: auto;
  border-right: 2px solid rgba(58, 72, 87, 0.72);
  border-bottom: 2px solid rgba(58, 72, 87, 0.72);
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.app-module-menu[open] .app-module-toggle {
  border-color: rgba(122, 161, 221, 0.82);
  background:
    linear-gradient(180deg, rgba(228, 239, 255, 0.98), rgba(218, 231, 248, 0.96)),
    rgba(255, 255, 255, 0.92);
}

.app-module-menu[open] .app-module-toggle::after {
  transform: rotate(-135deg) translateX(-1px);
}

.app-module-toggle-text {
  font-size: 0.92rem;
  font-weight: 700;
  white-space: nowrap;
}

.app-module-dropdown {
  position: static;
  display: grid;
  gap: 0.5rem;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.app-module-divider {
  height: 1px;
  margin: 0.2rem 0 0.1rem;
  background: rgba(212, 223, 237, 0.9);
}

.app-module-item {
  display: grid;
  gap: 0.35rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid rgba(210, 222, 236, 0.9);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink-900);
  text-decoration: none;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.app-module-item:hover {
  background: rgba(233, 242, 251, 0.94);
  border-color: rgba(90, 136, 208, 0.3);
  transform: translateY(-1px);
}

.app-module-item-active {
  border-color: rgba(105, 148, 214, 0.58);
  background: rgba(221, 235, 251, 0.92);
}

.app-module-item-disabled {
  opacity: 0.58;
}

.app-module-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.app-module-item-title {
  font-size: 0.92rem;
  font-weight: 700;
}

.app-module-item-meta {
  color: var(--ink-500);
  font-size: 0.82rem;
  line-height: 1.45;
}

.app-module-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  background: rgba(219, 230, 243, 0.82);
  color: var(--ink-700);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.app-module-signout-form {
  margin: 0;
}

.app-module-signout {
  width: 100%;
  min-height: 42px;
  padding: 0.58rem 0.95rem;
  border: 1px solid rgba(210, 222, 236, 0.92);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink-900);
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.app-module-signout:hover {
  background: rgba(233, 242, 251, 0.94);
  border-color: rgba(90, 136, 208, 0.3);
}

.app-utility {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0;
}

.app-account-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #7fb0ff, #3f73ff);
  color: #f8fbff;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 6px 14px rgba(47, 95, 214, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.app-account-name {
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  color: inherit;
}

.app-signout-btn {
  min-height: 38px;
  white-space: nowrap;
}

.app-subbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 1rem;
  padding: 1rem 0 1.15rem;
  border-top: 1px solid rgba(214, 225, 238, 0.92);
}

.app-subbar > * {
  min-width: 0;
}

.app-subbar-copy {
  min-width: 0;
  max-width: 78ch;
  justify-self: start;
  text-align: left;
}

.app-page-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
}

.app-page-summary {
  color: var(--ink-500);
  font-size: 1rem;
  line-height: 1.5;
}

.page-status-badge {
  align-self: center;
}

.app-page-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
  max-width: 100%;
}

.app-page-actions-shell {
  width: 100%;
  min-width: 0;
  max-width: 100%;
}

.app-page-scroll-btn {
  display: none;
}

.container-detail {
  max-width: 1080px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.detail-back-row {
  display: flex;
  justify-content: flex-start;
  margin: 0.15rem 0 0.9rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 1.9rem;
  font-family: "Sora", "Avenir Next", "Trebuchet MS", sans-serif;
  letter-spacing: -0.02em;
}

h2 {
  margin: 0 0 1rem;
  font-family: "Sora", "Avenir Next", "Trebuchet MS", sans-serif;
  letter-spacing: -0.01em;
}

.page-eyebrow,
.section-kicker {
  margin: 0 0 0.4rem;
  color: #9bded8;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

p {
  margin: 0.2rem 0;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.45rem;
  width: fit-content;
  padding: 0.42rem 0.78rem;
  border-radius: 999px;
  border: 1px solid rgba(142, 178, 221, 0.5);
  background: linear-gradient(180deg, rgba(236, 243, 255, 0.96), rgba(223, 234, 247, 0.94));
  color: #2f6ebc;
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.back-link:hover {
  border-color: rgba(110, 150, 213, 0.66);
  background: linear-gradient(180deg, rgba(228, 239, 255, 0.98), rgba(214, 229, 247, 0.96));
  transform: translateX(-1px);
}

.back-link-inline {
  margin-top: 0.85rem;
  margin-bottom: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
  margin: 1.2rem 0;
}

.stat-card {
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 14px;
  padding: 1rem;
}

.clickable-card {
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.clickable-card:hover {
  transform: translateY(-2px);
  border-color: #b9d4f4;
}

.card-active {
  border-color: var(--brand);
  box-shadow: 0 8px 22px rgba(15, 118, 110, 0.18);
}

.stat-card h3 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-500);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stat-card p {
  margin: 0.45rem 0 0;
  font-size: 2rem;
  font-weight: 700;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
}

.filters a {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  text-decoration: none;
  font-weight: 600;
  color: var(--ink-700);
  background: var(--white);
}

.filters a.active {
  border-color: var(--brand);
  color: var(--brand);
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.desktop-table {
  display: block;
}

.mobile-invoice-list {
  display: none;
}

.search-panel {
  margin-bottom: 1rem;
}

.stats-grid-wide {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.mobile-stage-menu {
  display: none;
  margin: 0 0 1rem;
}

.mobile-context-menu {
  position: relative;
}

.mobile-context-toggle {
  list-style: none;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.2rem 0.75rem;
  align-items: center;
  margin-top: 0;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  color: var(--ink-900);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.mobile-context-toggle::-webkit-details-marker {
  display: none;
}

.mobile-context-toggle::after {
  content: "";
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--ink-500);
  border-bottom: 2px solid var(--ink-500);
  transform: rotate(45deg);
  transition: transform 0.18s ease;
}

.mobile-context-menu[open] .mobile-context-toggle::after {
  transform: rotate(-135deg) translate(-2px, -2px);
}

.mobile-context-label {
  color: var(--ink-500);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mobile-context-toggle strong {
  min-width: 0;
  font-size: 1rem;
}

.mobile-context-count {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--brand-dark);
  font-size: 0.84rem;
  font-weight: 700;
}

.mobile-context-panel {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.55rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  box-shadow: var(--shadow);
}

.mobile-context-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  color: var(--ink-900);
  text-decoration: none;
  font-weight: 700;
}

.mobile-context-item:hover {
  background: rgba(15, 118, 110, 0.08);
}

.mobile-context-item.is-active {
  background: rgba(15, 118, 110, 0.12);
  color: var(--brand-dark);
}

.mobile-context-item-count {
  color: var(--ink-500);
  font-size: 0.85rem;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 0.6rem;
  align-items: center;
}

.advanced-grid {
  margin-top: 0.8rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

.import-automation-panel {
  margin-bottom: 1rem;
}

.import-automation-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.import-automation-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.75rem;
}

.import-automation-metric {
  padding: 0.85rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  box-shadow: var(--shadow);
}

.metric-label {
  display: block;
  margin-bottom: 0.38rem;
  color: var(--ink-500);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.import-automation-metric strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.4;
}

.import-automation-note {
  min-height: 100%;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.28);
}

.import-automation-run-note {
  margin-top: 0.9rem;
}

.queue-sync-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.34);
}

.queue-sync-banner .badge {
  flex: 0 0 auto;
}

.app-modal {
  width: min(920px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 0;
  background: transparent;
}

.app-modal::backdrop {
  background: rgba(7, 12, 22, 0.72);
  backdrop-filter: blur(8px);
}

.app-modal-card {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at top right, rgba(20, 184, 166, 0.12), transparent 30%),
    linear-gradient(165deg, var(--white), var(--surface-muted));
  box-shadow: 0 28px 60px rgba(7, 12, 22, 0.32);
}

.app-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.app-modal-close {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--code-bg);
  color: var(--ink-900);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.app-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.3rem;
}

.app-modal-section {
  display: grid;
  gap: 0.85rem;
  padding-top: 0.25rem;
  border-top: 1px solid var(--line-soft);
}

.vendor-directory-list {
  max-height: 320px;
  overflow: auto;
  padding-right: 0.2rem;
}

.vendor-directory-search {
  display: grid;
  gap: 0.3rem;
}

.vendor-directory-search-field {
  max-width: 420px;
}

.vendor-directory-search-note {
  margin: 0;
}

.vendor-directory-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.vendor-directory-main {
  display: grid;
  gap: 0.25rem;
}

.vendor-directory-meta {
  display: grid;
  gap: 0.35rem;
  justify-items: end;
  text-align: right;
}

.btn-sm {
  padding: 0.38rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8rem;
}

.rule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.75rem;
}

details summary {
  margin-top: 0.2rem;
  cursor: pointer;
  color: var(--brand-dark);
  font-weight: 700;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.8rem 0.75rem;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
}

th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-500);
}

.empty-cell {
  text-align: center;
  color: var(--ink-500);
  padding: 2rem 1rem;
}

.muted {
  color: var(--ink-500);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 0.28rem 0.62rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid transparent;
}

.badge-warning {
  color: #725100;
  background: #fff5d2;
  border-color: #f4dfa0;
}

.badge-info {
  color: #18428f;
  background: #e5eeff;
  border-color: #c7d9ff;
}

.badge-success {
  color: #14502f;
  background: #e4f8ea;
  border-color: #b9e8c8;
}

.badge-danger {
  color: #841e2f;
  background: #ffe8ec;
  border-color: #ffc7d1;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 0.56rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.btn-primary {
  background: linear-gradient(140deg, var(--brand), #0d9488);
  color: var(--white);
}

.btn-primary:hover {
  background: linear-gradient(140deg, var(--brand-dark), var(--brand));
}

.btn-light {
  background: var(--code-bg);
  color: var(--ink-900);
}

.inline-form {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.inline-form input,
.inline-form select {
  width: auto;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 600;
}

.running-note {
  color: var(--ink-500);
  font-size: 0.9rem;
  font-weight: 600;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.9rem;
}

.queue-nav {
  margin-bottom: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

button[disabled] {
  opacity: 0.7;
  cursor: not-allowed;
}

.alert {
  border-radius: 10px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid transparent;
}

.alert-success {
  background: #ecfdf3;
  color: #135d35;
  border-color: #b4e8c7;
}

.alert-danger {
  background: #fff1f3;
  color: #8e1f2f;
  border-color: #fec7d1;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.module-overview-grid {
  align-items: stretch;
}

.module-overview-panel,
.roadmap-panel {
  height: 100%;
}

.module-overview-copy {
  margin-bottom: 1rem;
  max-width: 64ch;
}

.capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.capability-card {
  display: grid;
  gap: 0.4rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  color: var(--ink-900);
}

.capability-card span {
  color: var(--ink-500);
  font-size: 0.9rem;
  line-height: 1.4;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.workflow-strip-compact {
  margin-bottom: 1rem;
}

.workflow-step {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  min-height: 84px;
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  text-align: center;
  overflow: hidden;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
}

.workflow-step strong {
  position: relative;
  z-index: 1;
  font-size: 0.92rem;
  line-height: 1.35;
}

.workflow-step.is-current {
  border-color: rgba(20, 184, 166, 0.5);
  background:
    radial-gradient(circle at top, rgba(20, 184, 166, 0.32), transparent 58%),
    linear-gradient(165deg, rgba(243, 255, 252, 0.98), rgba(213, 247, 243, 0.98));
  box-shadow:
    0 14px 30px rgba(15, 118, 110, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.workflow-step.is-current::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.18), transparent 62%);
  pointer-events: none;
}

.workflow-step.is-current strong {
  color: var(--brand-dark);
}

.workflow-step.is-complete {
  border-color: rgba(22, 101, 52, 0.18);
  background: linear-gradient(165deg, rgba(228, 248, 234, 0.9), var(--white));
}

.workflow-step.is-upcoming {
  opacity: 0.72;
}

body.theme-dark .workflow-step.is-current {
  border-color: rgba(45, 212, 191, 0.55);
  background:
    radial-gradient(circle at top, rgba(45, 212, 191, 0.26), transparent 58%),
    linear-gradient(165deg, rgba(22, 43, 47, 0.98), rgba(16, 30, 41, 0.98));
  box-shadow:
    0 16px 34px rgba(7, 20, 26, 0.42),
    0 0 0 1px rgba(45, 212, 191, 0.16);
}

body.theme-dark .workflow-step.is-current strong {
  color: #d9fffa;
}

body.theme-dark .app-modal-card {
  border-color: rgba(61, 81, 108, 0.92);
  background:
    radial-gradient(circle at top right, rgba(45, 212, 191, 0.12), transparent 32%),
    linear-gradient(165deg, rgba(18, 28, 44, 0.98), rgba(15, 23, 36, 0.98));
}

body.theme-dark .app-modal-close {
  border-color: rgba(61, 81, 108, 0.92);
  background: rgba(20, 31, 47, 0.92);
  color: var(--ink-900);
}

body.theme-dark .location-checkbox-list,
body.theme-dark .copy-target-list,
body.theme-dark .location-checkbox-pill,
body.theme-dark .copy-target-item {
  border-color: rgba(61, 81, 108, 0.92);
}

body.theme-dark .user-actions-toggle {
  border-color: rgba(61, 81, 108, 0.92);
  background: rgba(20, 31, 47, 0.92);
}

body.theme-dark .user-actions-panel {
  border-color: rgba(61, 81, 108, 0.92);
  background:
    radial-gradient(circle at top right, rgba(45, 212, 191, 0.08), transparent 32%),
    linear-gradient(165deg, rgba(18, 28, 44, 0.98), rgba(15, 23, 36, 0.98));
}

.simple-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.simple-list li {
  border: 1px solid var(--panel-row-border);
  border-radius: 10px;
  padding: 0.55rem 0.65rem;
  background: var(--panel-row-bg);
}

.mobile-invoice-card {
  display: grid;
  gap: 0.8rem;
}

.mobile-invoice-select {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.mobile-invoice-select input {
  width: auto;
}

.mobile-invoice-meta {
  display: grid;
  gap: 0.35rem;
  color: var(--ink-500);
}

.user-permissions-list {
  display: grid;
  gap: 0.65rem;
}

.dynamic-location-assignment,
.user-location-assignments {
  display: grid;
  gap: 0.45rem;
}

.user-location-launcher {
  align-content: end;
  width: 100%;
  max-width: 190px;
}

.user-location-modal-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding: 0.72rem 0.9rem;
}

.location-checkbox-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.45rem;
  max-height: 11.5rem;
  padding: 0.55rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-row-bg);
}

.location-checkbox-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 38px;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.25;
}

.location-checkbox-list-modal {
  max-height: min(420px, calc(100vh - 16rem));
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.location-checkbox-pill input {
  width: auto;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.location-checkbox-pill span {
  min-width: 0;
  word-break: break-word;
}

.user-permissions-item {
  display: grid;
  gap: 0.65rem;
  padding: 0.95rem 1rem;
}

.user-permissions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.user-permissions-identity {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
}

.user-permissions-identity strong {
  font-size: 0.98rem;
  line-height: 1.2;
}

.user-permissions-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.45rem;
}

.user-permissions-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.32rem;
}

.user-permissions-badges .badge {
  padding: 0.28rem 0.55rem;
  font-size: 0.72rem;
}

.user-permissions-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  font-size: 0.82rem;
}

.user-permissions-form {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(150px, 190px) auto;
  gap: 0.6rem;
  align-items: end;
}

.user-permissions-field {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.user-permissions-field-label {
  color: var(--ink-500);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-permissions-field select {
  min-width: 0;
  margin: 0;
  padding: 0.72rem 0.9rem;
  min-height: 44px;
}

.user-permissions-inline-note {
  margin: 0;
  font-size: 0.78rem;
}

.user-permissions-submit {
  justify-self: end;
}

.user-permissions-submit .btn {
  min-height: 44px;
  padding: 0.72rem 1rem;
}

.copy-target-list {
  display: grid;
  gap: 0.45rem;
  max-height: min(360px, calc(100vh - 18rem));
  padding: 0.55rem;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-row-bg);
}

.copy-target-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.copy-target-item input {
  width: auto;
  margin: 0.1rem 0 0;
  padding: 0;
  flex: 0 0 auto;
}

.copy-target-item span {
  display: grid;
  gap: 0.18rem;
  min-width: 0;
}

.copy-target-item small {
  color: var(--ink-500);
  font-size: 0.78rem;
}

.user-actions-menu {
  position: relative;
}

.user-actions-toggle {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-height: 36px;
  padding: 0.38rem 0.72rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--ink-900);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.user-actions-toggle::-webkit-details-marker {
  display: none;
}

.user-actions-toggle::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translateY(-1px);
  transition: transform 0.18s ease;
}

.user-actions-menu[open] .user-actions-toggle::after {
  transform: rotate(-135deg) translateX(-1px);
}

.user-actions-panel {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 5;
  display: grid;
  gap: 0.45rem;
  min-width: 210px;
  padding: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(165deg, var(--white), var(--surface-muted));
  box-shadow: var(--shadow);
}

.user-actions-btn {
  width: 100%;
}

.panel-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.8rem;
}

.pdf-frame {
  width: 100%;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-row-bg);
}

.ocr-preview {
  margin: 0;
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-row-bg);
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.86rem;
}

.kv-list {
  margin: 0;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem 0.8rem;
}

.kv-list dt {
  color: var(--ink-500);
  font-weight: 600;
}

.kv-list dd {
  margin: 0;
}

.stack-form {
  display: grid;
  gap: 0.75rem;
}

label {
  display: grid;
  gap: 0.4rem;
  font-weight: 600;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 9px;
  padding: 0.55rem 0.65rem;
  font: inherit;
  color: var(--ink-900);
  background: var(--input-bg);
}

textarea {
  resize: vertical;
}

fieldset {
  border: 1px solid var(--fieldset-border);
  border-radius: 10px;
  margin: 0;
  padding: 0.7rem 0.8rem;
}

.decision-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-right: 1rem;
  font-weight: 500;
}

.hidden {
  display: none;
}

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
}

.timeline li {
  border-left: 3px solid var(--timeline-line);
  padding: 0.2rem 0 0.6rem 0.75rem;
  margin-left: 0.35rem;
  margin-bottom: 0.6rem;
}

.inline-link {
  color: var(--brand-dark);
  font-weight: 700;
}

.auth-container {
  max-width: 640px;
}

.auth-panel {
  margin-top: 2.5rem;
}

.settings-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 1.2rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(165deg, var(--surface-muted), var(--white));
}

.settings-tab {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0.5rem 0.95rem;
  border-radius: 10px;
  color: var(--ink-700);
  font-weight: 700;
  text-decoration: none;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
}

.settings-tab:hover {
  background: rgba(15, 118, 110, 0.08);
  color: var(--brand-dark);
}

.settings-tab.is-active {
  background: linear-gradient(140deg, var(--brand), #0d9488);
  color: var(--white);
  box-shadow: 0 10px 20px rgba(15, 118, 110, 0.18);
}

.settings-tab-panel {
  display: grid;
  gap: 1.2rem;
}

.settings-info-panel {
  margin-bottom: 0.1rem;
}

.auth-note {
  margin-top: 0.9rem;
}

.theme-toggle-fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 999;
  box-shadow: var(--shadow);
}

body.theme-dark .badge-warning {
  color: #fcd34d;
  background: #3a2f06;
  border-color: #735b0a;
}

body.theme-dark .badge-info {
  color: #93c5fd;
  background: #172d4c;
  border-color: #2f4f78;
}

body.theme-dark .badge-success {
  color: #86efac;
  background: #123823;
  border-color: #1f5c36;
}

body.theme-dark .badge-danger {
  color: #fca5a5;
  background: #4c1d2a;
  border-color: #7a2f3f;
}

body.theme-dark .alert-success {
  background: #123823;
  color: #86efac;
  border-color: #1f5c36;
}

body.theme-dark .alert-danger {
  background: #4c1d2a;
  color: #fda4af;
  border-color: #7a2f3f;
}

body.theme-dark .queue-sync-banner {
  background: rgba(20, 32, 51, 0.78);
  border-color: rgba(70, 92, 122, 0.42);
}

body.theme-dark .mobile-context-toggle,
body.theme-dark .mobile-context-panel {
  border-color: rgba(70, 92, 122, 0.42);
}

body.theme-dark .mobile-context-count {
  background: rgba(20, 184, 166, 0.18);
  color: #b7fff7;
}

body.theme-dark .mobile-context-item.is-active {
  background: rgba(20, 184, 166, 0.18);
  color: #d7fffb;
}

body.theme-dark .app-header-top,
body.theme-dark .app-header {
  border-color: rgba(70, 92, 122, 0.42);
}

body.theme-dark .app-header {
  background: rgba(24, 29, 36, 0.94);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

body.theme-dark .app-brand {
  color: var(--white);
}

body.theme-dark .app-brand-mark {
  border-color: rgba(109, 185, 255, 0.38);
  background:
    radial-gradient(circle at 35% 35%, rgba(110, 225, 214, 0.45), transparent 35%),
    linear-gradient(135deg, rgba(39, 62, 92, 1), rgba(20, 27, 40, 1));
  color: #8ec5ff;
}

body.theme-dark .app-brand-name {
  color: #7db5ff;
}

body.theme-dark .app-brand-tag {
  color: rgba(226, 234, 248, 0.66);
}

body.theme-dark .app-account-pill {
  background: linear-gradient(180deg, rgba(90, 132, 231, 0.24), rgba(43, 62, 106, 0.2));
  border-color: rgba(126, 165, 255, 0.34);
  color: var(--ink-900);
  box-shadow: 0 8px 18px rgba(8, 14, 24, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

body.theme-dark .app-account-pill:hover,
body.theme-dark .app-user-menu[open] .app-account-pill {
  background: linear-gradient(180deg, rgba(102, 145, 255, 0.3), rgba(54, 76, 126, 0.24));
  border-color: rgba(140, 181, 255, 0.46);
}

body.theme-dark .app-account-name {
  color: var(--ink-900);
}

body.theme-dark .app-user-dropdown {
  border-color: rgba(120, 144, 185, 0.18);
  background: rgba(19, 26, 39, 0.98);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.36);
}

body.theme-dark .app-user-section-title {
  color: rgba(226, 234, 248, 0.48);
}

body.theme-dark .app-user-menu-link {
  border-color: rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.025);
  color: rgba(232, 240, 250, 0.92);
}

body.theme-dark .app-user-menu-link:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(106, 145, 255, 0.18);
}

body.theme-dark .app-module-toggle {
  border-color: rgba(106, 145, 255, 0.2);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.02);
  color: rgba(239, 245, 252, 0.96);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 8px 20px rgba(0, 0, 0, 0.12);
}

body.theme-dark .app-module-toggle::after {
  border-right-color: rgba(234, 240, 250, 0.75);
  border-bottom-color: rgba(234, 240, 250, 0.75);
}

body.theme-dark .app-module-menu[open] .app-module-toggle {
  border-color: rgba(106, 145, 255, 0.38);
  background:
    linear-gradient(180deg, rgba(90, 124, 208, 0.28), rgba(65, 93, 166, 0.22)),
    rgba(255, 255, 255, 0.02);
}

body.theme-dark .app-module-divider {
  background: rgba(255, 255, 255, 0.08);
}

body.theme-dark .app-module-item {
  border-color: rgba(255, 255, 255, 0.04);
  background: rgba(255, 255, 255, 0.025);
  color: rgba(232, 240, 250, 0.9);
}

body.theme-dark .app-module-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(106, 145, 255, 0.18);
}

body.theme-dark .app-module-item-active {
  border-color: rgba(106, 145, 255, 0.28);
  background: rgba(82, 114, 199, 0.17);
}

body.theme-dark .app-module-item-meta {
  color: rgba(202, 216, 234, 0.72);
}

body.theme-dark .app-module-status {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(232, 240, 250, 0.84);
}

body.theme-dark .app-module-signout {
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.03);
  color: #f0f5fc;
}

body.theme-dark .app-module-signout:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(106, 145, 255, 0.16);
}

body.theme-dark .app-subbar {
  border-top-color: rgba(255, 255, 255, 0.06);
}

body.theme-dark .app-page-summary {
  color: #c6d4e5;
}

body.theme-dark .back-link {
  border-color: rgba(125, 181, 255, 0.28);
  background: linear-gradient(180deg, rgba(77, 116, 204, 0.16), rgba(58, 84, 145, 0.12));
  color: #d8e7ff;
}

body.theme-dark .back-link:hover {
  border-color: rgba(137, 191, 255, 0.44);
  background: linear-gradient(180deg, rgba(94, 136, 235, 0.24), rgba(66, 96, 165, 0.18));
}

@media (max-width: 960px) {
  .app-topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions";
    align-items: stretch;
  }

  .app-brand {
    min-width: 0;
  }

  .app-user-menu {
    justify-self: start;
  }

  .app-page-actions-shell,
  .app-page-actions {
    justify-content: flex-start;
  }

  .app-page-actions {
    flex-wrap: wrap;
  }

  .app-user-dropdown .app-module-dropdown {
    width: 100%;
  }

  .app-user-dropdown {
    right: auto;
    left: 0;
    width: min(420px, calc(100vw - 2rem));
  }

  .app-subbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .app-subbar-copy,
  .app-page-actions-shell,
  .app-page-actions {
    justify-self: start;
    text-align: left;
  }

  .queue-sync-banner {
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .import-automation-grid {
    grid-template-columns: 1fr;
  }

  .app-modal {
    width: min(920px, calc(100vw - 1rem));
  }

  .workflow-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kv-list {
    grid-template-columns: 1fr;
  }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .queue-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.6rem;
  }

  .advanced-grid {
    grid-template-columns: 1fr 1fr;
  }

  .user-permissions-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-permissions-submit {
    justify-self: start;
  }
}

@media (max-width: 640px) {
  .app-header {
    margin-bottom: 0.85rem;
  }

  .app-header-shell {
    padding: 0 0.85rem;
  }

  .container {
    padding-top: 1rem;
  }

  .app-topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "brand"
      "actions";
    align-items: stretch;
    gap: 0.85rem;
  }

  .app-user-menu {
    justify-self: end;
  }

  .app-user-dropdown {
    left: auto;
    right: 0;
    width: min(420px, calc(100vw - 1.7rem));
    max-width: calc(100vw - 1.7rem);
  }

  .app-module-nav,
  .app-module-menu,
  .app-module-toggle {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .queue-stage-grid {
    display: none;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  th,
  td {
    font-size: 0.92rem;
  }

  .search-row {
    grid-template-columns: 1fr;
  }

  .import-automation-summary {
    grid-template-columns: 1fr;
  }

  .app-modal-card {
    padding: 1rem;
  }

  .app-modal-head {
    align-items: center;
  }

  .vendor-directory-item {
    flex-direction: column;
  }

  .vendor-directory-meta {
    justify-items: start;
    text-align: left;
  }

  .user-permissions-header,
  .user-permissions-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .user-permissions-badges {
    justify-content: flex-start;
  }

  .user-permissions-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .user-permissions-form {
    grid-template-columns: 1fr;
  }

  .location-checkbox-list {
    grid-template-columns: 1fr;
    max-height: 13rem;
  }

  .location-checkbox-list-modal,
  .copy-target-list {
    max-height: calc(100vh - 15rem);
  }

  .user-permissions-field,
  .user-permissions-submit {
    width: 100%;
  }

  .user-permissions-submit .btn {
    width: 100%;
  }

  .user-actions-panel {
    position: static;
    min-width: 0;
  }

  .advanced-grid {
    grid-template-columns: 1fr;
  }

  .rule-grid {
    grid-template-columns: 1fr;
  }

  .desktop-table {
    display: none;
  }

  .mobile-invoice-list {
    display: grid;
    gap: 0.85rem;
  }

  .mobile-stage-menu {
    display: block;
  }

  .queue-sync-banner {
    display: none;
  }

  .app-brand-name {
    font-size: 1.35rem;
  }

  .app-topbar {
    padding-top: 0.9rem;
  }

  .app-brand {
    min-width: 0;
  }

  .app-page-actions-shell {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-inline: 2.15rem;
    overflow: hidden;
  }

  .app-page-scroll-btn {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    width: 1.8rem;
    height: 2.15rem;
    align-items: center;
    justify-content: center;
    transform: translateY(-50%);
    border: 1px solid rgba(116, 148, 194, 0.28);
    border-radius: 999px;
    background: rgba(11, 19, 31, 0.92);
    color: rgba(228, 238, 249, 0.94);
    font-size: 0.95rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.22);
    padding: 0;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  }

  .app-page-scroll-btn:hover {
    border-color: rgba(146, 184, 238, 0.46);
    background: rgba(20, 33, 52, 0.97);
  }

  .app-page-scroll-btn-left {
    left: 0;
  }

  .app-page-scroll-btn-right {
    right: 0;
  }

  .app-page-actions-shell[data-show-left="true"] .app-page-scroll-btn-left,
  .app-page-actions-shell[data-show-right="true"] .app-page-scroll-btn-right {
    opacity: 1;
    pointer-events: auto;
  }

  .app-page-actions,
  .settings-tabs {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    -ms-overflow-style: none;
    scrollbar-width: none;
  }

  .app-page-actions::-webkit-scrollbar,
  .settings-tabs::-webkit-scrollbar {
    display: none;
  }

  .app-page-actions > *,
  .settings-tabs > * {
    flex: 0 0 auto;
  }

  .app-page-actions {
    justify-content: flex-start;
  }

  .app-page-actions .inline-form {
    flex: 0 0 auto;
    min-width: fit-content;
  }

  .settings-tab,
  .app-page-actions .btn,
  .app-page-actions .inline-form {
    white-space: nowrap;
  }

  .app-account-pill {
    width: auto;
    min-width: 0;
    justify-content: flex-start;
    padding-right: 0.6rem;
  }

  .app-account-name {
    max-width: 112px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
