:root {
  --bg: #edf3ed;
  --bg-warm: #f6f1e7;
  --paper: rgba(255, 255, 252, 0.88);
  --paper-strong: #fffdfa;
  --ink: #1d2a25;
  --muted: #61756c;
  --line: rgba(110, 145, 129, 0.22);
  --accent: #2e7d68;
  --accent-strong: #174d41;
  --accent-soft: #d8eee5;
  --accent-soft-2: #edf8f2;
  --warn: #a4672d;
  --warn-soft: #f5e7d7;
  --danger: #8f4b4b;
  --danger-soft: #f6e2e2;
  --info: #4f6876;
  --info-soft: #dfe9ef;
  --sidebar-bg: rgba(255, 255, 250, 0.72);
  --sidebar-paper: #f4fbf6;
  --sidebar-ink: #1d2a25;
  --shadow: 0 22px 50px rgba(31, 49, 42, 0.1);
  --shadow-soft: 0 10px 24px rgba(31, 49, 42, 0.06);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(114, 203, 176, 0.18), transparent 22%),
    radial-gradient(circle at top right, rgba(244, 220, 175, 0.28), transparent 28%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  color: var(--ink);
  min-height: 100vh;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card {
  width: min(460px, calc(100vw - 32px));
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 252, 0.94);
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  text-align: center;
}

.auth-brand {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.auth-brand-icon {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #202828 0%, #141919 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-wordmark {
  display: block;
  width: 228px;
  max-width: 100%;
  height: auto;
}

.auth-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-byline {
  margin: -2px 0 0;
  color: #5f7269;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.auth-copy {
  display: grid;
  gap: 8px;
}

.auth-copy h1,
.auth-copy p {
  margin: 0;
}

.auth-copy p {
  color: var(--muted);
}

.auth-field {
  display: grid;
  gap: 8px;
}

.auth-field input {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  text-align: left;
}

.auth-login-button {
  width: 100%;
  justify-content: center;
}

.auth-error {
  margin: -4px 0 0;
  color: #8f3e3e;
  font-size: 14px;
  min-height: 20px;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1680px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 0 0 28px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
}

.main-column {
  display: grid;
  gap: 14px;
  align-content: start;
  min-width: 0;
  min-height: calc(100vh - 112px);
}

.topbar,
.panel,
.stat-card,
.toolbar {
  background: var(--paper);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  border-radius: 0;
  padding: 12px 24px;
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 252, 0.95) 0%, rgba(242, 250, 245, 0.92) 100%);
  color: var(--sidebar-ink);
  border-color: rgba(118, 163, 145, 0.2);
  border-top: none;
  border-left: none;
  border-right: none;
  box-shadow: 0 2px 12px rgba(29, 42, 37, 0.06);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1,
.topbar .eyebrow,
.topbar .subcopy {
  color: var(--sidebar-ink);
}

.brand-lockup {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
  min-width: 0;
  align-self: center;
  padding-top: 0;
}

.brand-mark {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #202828 0%, #141919 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.brand-mark-svg {
  overflow: hidden;
}

.salma-icon {
  display: block;
  width: 84px;
  height: 84px;
}

.salma-face {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.salma-face-active {
  opacity: 1;
}

.brand-wordmark {
  display: block;
  width: 274px;
  height: 84px;
  max-width: none;
  object-fit: cover;
  object-position: left 50%;
  transform: translateY(10px);
}

.topbar-title {
  justify-self: center;
  align-self: center;
  font-size: 25px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #2e7d68;
  white-space: nowrap;
}

.topbar-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.header-language-toggle,
.auth-topbar-controls {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(118, 163, 145, 0.24);
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.72);
}

.lang-toggle-button {
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  min-width: 42px;
  height: 31px;
  padding: 0 12px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.lang-toggle-button + .lang-toggle-button {
  border-left: 1px solid rgba(118, 163, 145, 0.2);
}

.lang-toggle-button.active {
  background: var(--accent-strong);
  color: white;
}

.topbar-logout-link {
  border: none;
  background: transparent;
  padding: 0 0 0 14px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  border-left: 1px solid rgba(118, 163, 145, 0.22);
  cursor: pointer;
}

.topbar-logout-link:hover {
  color: var(--ink);
  text-decoration: underline;
}

.settings-button {
  opacity: 0.7;
  font-size: 13px;
}

.test-mode-panel {
  border-radius: 28px;
  margin-bottom: 0;
}

.test-mode-grid {
  padding: 14px 18px 18px;
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  gap: 12px;
}

.auth-shell {
  position: relative;
}

.auth-topbar-controls {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 1;
}

.test-card {
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 22px;
  background: rgba(255, 255, 251, 0.9);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.test-card label {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.test-card label span {
  color: var(--muted);
  font-size: 13px;
}

.test-card input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.selected-files {
  margin-top: 8px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  padding: 10px;
  min-height: 58px;
  color: var(--muted);
  background: #f5faf7;
  white-space: pre-wrap;
}

.workspace-state {
  margin-bottom: 12px;
}

.button-wide {
  width: 100%;
  justify-content: center;
}

.folder-picker-supported,
.folder-picker-unsupported,
.folder-picker-confirm {
  display: grid;
  gap: 12px;
}

.folder-picker-hint {
  margin: 0;
}

.folder-selected-name {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
}

.settings-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.mini-stats div,
.path-list div {
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 14px;
  padding: 10px;
  background: #f5faf7;
}

.mini-stats span,
.path-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.mini-stats strong {
  font-size: 20px;
}

.path-list {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.compact-path-list {
  margin-top: 8px;
}

.folder-path {
  margin: 0 0 10px;
  font-family: "IBM Plex Mono", monospace;
  color: #2d544b;
  font-size: 13px;
  word-break: break-word;
}

.folder-path-secondary {
  color: var(--muted);
  margin-top: -4px;
}

.workspace-paths-toggle {
  margin: 0 0 10px;
}

.workspace-paths-toggle code {
  display: block;
  margin-top: 4px;
  word-break: break-word;
}

.folder-tree {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 18px;
  background: #f5faf7;
  padding: 12px;
  margin-top: 10px;
}

.folder-level {
  display: grid;
  gap: 8px;
}

.folder-indent {
  padding-left: 0;
}

.folder-node {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  border-radius: 999px;
  background: #fffdfa;
  border: 1px solid rgba(110, 145, 129, 0.16);
  padding: 6px 10px;
  font-size: 13px;
}

.folder-main {
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(23, 98, 79, 0.2);
}

.folder-children {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.folder-child {
  background: #fff;
}

.text-link-button {
  margin-top: 10px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  text-align: left;
}

.text-link-button:hover {
  text-decoration: underline;
}

.detail-file-status {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.4;
}

.detail-file-status.success {
  color: var(--accent);
}

.detail-file-status.error {
  color: #b42318;
}

.detail-retry-filing {
  margin-top: 0;
  margin-left: 8px;
  font-size: 12px;
}

.folder-empty {
  color: var(--muted);
}

code {
  display: block;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "IBM Plex Mono", monospace;
  color: #2d544b;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
h4,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1;
  letter-spacing: -0.04em;
}

.subcopy {
  margin-bottom: 0;
  color: var(--muted);
  max-width: 20ch;
  line-height: 1.35;
  font-size: 14px;
}

.stats-compact {
  display: flex;
  gap: 14px;
  align-items: center;
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
}

.stats-compact strong {
  color: var(--ink);
  font-size: 15px;
  margin-right: 3px;
}

.stats-compact .stat-warn strong {
  color: var(--warn);
}

.stats-grid-invoices {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 0;
  position: sticky;
  top: 128px;
  z-index: 7;
}

.toolbar[data-workspace-panel="invoices"] {
  position: sticky;
  top: 84px;
  z-index: 8;
}

.stats-grid-invoices .stat-card {
  background: rgba(255, 255, 252, 0.94);
  border: 1px solid rgba(110, 145, 129, 0.14);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.stats-grid-invoices .stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(31, 49, 42, 0.08);
}

.stats-grid-invoices .stat-card.active {
  border-color: rgba(46, 125, 104, 0.28);
  background: linear-gradient(180deg, #fffdfa 0%, #eef8f3 100%);
}

.stat-card-confirmed strong {
  color: var(--accent-strong);
}

.stat-card-review strong {
  color: var(--warn);
}

.stat-card-errors strong {
  color: var(--danger);
}

.topbar .button.primary {
  background: linear-gradient(135deg, #9de0c7 0%, #73caab 100%);
  color: #17342d;
  box-shadow: 0 10px 24px rgba(58, 143, 118, 0.22);
}

.topbar .button.secondary {
  background: rgba(255, 255, 255, 0.72);
  color: var(--sidebar-ink);
  border: 1px solid rgba(110, 145, 129, 0.16);
}

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 11px 15px;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease, box-shadow 120ms ease, background 120ms ease;
  font-weight: 600;
}

.button:hover {
  transform: translateY(-1px);
}

.button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.button.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #4baa8c 100%);
  color: white;
  box-shadow: 0 10px 24px rgba(46, 125, 104, 0.18);
}

.button.secondary {
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  border-color: rgba(110, 145, 129, 0.18);
}

.button.danger-outline {
  background: rgba(255, 255, 255, 0.9);
  color: var(--danger);
  border-color: rgba(143, 75, 75, 0.3);
}

.button.danger-outline:hover {
  background: var(--danger-soft);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 0;
}

.queue-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 0;
}

.stat-card {
  border-radius: 22px;
  padding: 10px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 72px;
}

.queue-card {
  border-radius: 22px;
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.queue-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(31, 49, 42, 0.08);
}

.queue-card-static {
  cursor: default;
}

.queue-card-static:hover {
  transform: none;
  box-shadow: var(--shadow);
}

.queue-card.active {
  border-color: rgba(46, 125, 104, 0.3);
  background: linear-gradient(180deg, #fffdfa 0%, #eef8f3 100%);
}

.stat-card span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.stat-card strong {
  font-size: 30px;
  line-height: 1;
  letter-spacing: -0.06em;
}

.queue-label {
  display: block;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 700;
}

.queue-card strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  margin: 8px 0 6px;
  letter-spacing: -0.05em;
}

.queue-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

.queue-card-subtle {
  margin-top: 6px;
}

.queue-link-button {
  margin-top: 8px;
}

.email-settings-card {
  min-height: 0;
}

.settings-cost-centers-card {
  grid-column: 1 / -1;
}

.settings-accountant-card {
  min-height: 0;
}

.cost-center-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.cost-center-card {
  width: 100%;
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 18px;
  background: #fff;
  padding: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.cost-center-card:hover {
  transform: translateY(-1px);
  border-color: rgba(46, 125, 104, 0.24);
}

.cost-center-card.active {
  border-color: rgba(46, 125, 104, 0.32);
  background: #eef8f3;
}

.cost-center-card.is-inactive {
  opacity: 0.72;
}

.cost-center-card-head,
.cost-center-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.cost-center-card-head p,
.cost-center-card-meta {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.cost-center-card-meta {
  margin-top: 10px;
  flex-wrap: wrap;
}

.cost-center-editor-panel {
  margin-top: 14px;
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 20px;
  background: #fffdfa;
  padding: 16px;
}

.cost-center-drive-box,
.accountant-export-panel {
  margin-top: 14px;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: #f3f6f4;
}

.cost-center-drive-box h4 {
  margin-bottom: 12px;
}

.cost-center-drive-fields,
.accountant-export-panel {
  display: grid;
  gap: 12px;
}

.drive-field-picker {
  display: grid;
  gap: 10px;
}

.drive-field-copy {
  display: grid;
  gap: 4px;
}

.drive-field-copy > span {
  font-weight: 600;
}

.drive-field-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 14px;
  background: #fffdfa;
  padding: 12px;
}

.drive-field-status strong {
  color: var(--muted);
}

.drive-field-status.has-value strong {
  color: var(--ink);
}

.drive-field-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.drive-field-links .text-link-button {
  margin-top: 0;
}

.drive-path-confirm {
  display: grid;
  gap: 6px;
}

.drive-path-confirm span {
  font-size: 12px;
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.cost-center-auto-box {
  margin-top: 14px;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 18px;
  padding: 14px;
  background: #f5f5f5;
}

.cost-center-auto-box h4 {
  margin-bottom: 12px;
}

.cost-center-auto-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.cost-center-auto-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.cost-center-auto-list p {
  margin: 0;
  font-size: 14px;
}

.cost-center-rule-box {
  margin-top: 14px;
  border: 1px dashed rgba(110, 145, 129, 0.26);
  border-radius: 18px;
  padding: 14px;
  background: #f9fcfa;
}

.compact-stats .stat-card span {
  font-size: 12px;
}

.toolbar {
  border-radius: 24px;
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 0;
  flex-wrap: wrap;
}

.view-switch {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.workspace-switch {
  display: flex;
  gap: 6px;
  align-items: center;
}

.tab-button {
  border: 1px solid rgba(110, 145, 129, 0.18);
  background: rgba(255, 255, 255, 0.76);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.tab-button.active {
  background: linear-gradient(135deg, #dff4eb 0%, #c9e9dc 100%);
  border-color: rgba(23, 98, 79, 0.2);
  color: var(--accent-strong);
  font-weight: 700;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

.filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.filters label,
.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filters span,
.form-grid span {
  color: var(--muted);
  font-size: 13px;
}

select,
input,
textarea {
  min-width: 180px;
  border: 1px solid rgba(110, 145, 129, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 12px;
}

textarea {
  resize: vertical;
  min-height: 78px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(0, 1.2fr);
  gap: 14px;
  align-items: start;
  min-height: calc(100vh - 270px);
}

.list-panel,
.detail-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.detail-panel {
  position: sticky;
  top: 214px;
}

.panel {
  border-radius: 28px;
  overflow: hidden;
}

.rules-panel {
  margin-top: 0;
}

.rules-assistant-shell {
  padding: 10px 16px 0;
}

.rules-insights {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 10px 0 0;
  flex: 1 1 auto;
}

.rules-overview-bar {
  display: flex;
  gap: 16px;
  align-items: start;
  padding: 0 16px;
}

.rules-overview-actions {
  flex: 0 0 280px;
  padding-top: 10px;
}

.rules-overview-actions p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.rules-insight-card {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 252, 0.92);
  padding: 16px;
}

.rules-insight-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.rules-insight-card strong {
  display: block;
  font-size: 28px;
  line-height: 1;
  margin-bottom: 8px;
}

.rules-insight-card p {
  margin: 0;
  color: #50665e;
}

.rules-assistant-toggle {
  margin: 10px 16px 0;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 22px;
  background: rgba(255, 255, 252, 0.86);
  overflow: hidden;
}

.rules-assistant-toggle summary {
  cursor: pointer;
  font-weight: 700;
  padding: 16px 18px;
  list-style: none;
}

.rules-assistant-toggle summary::-webkit-details-marker {
  display: none;
}

.rules-assistant-toggle summary::before {
  content: "+";
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #edf7f1;
  color: var(--accent-strong);
  font-weight: 700;
  margin-right: 8px;
}

.rules-assistant-toggle[open] summary::before {
  content: "-";
}

.rules-assistant-card {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(246, 252, 248, 0.98) 0%, rgba(255, 255, 255, 0.96) 100%);
  padding: 18px;
  box-shadow: var(--shadow-soft);
}

.rules-assistant-head h3 {
  margin-bottom: 6px;
}

.rules-assistant-head p,
.assistant-copy {
  color: var(--muted);
}

.rules-assistant-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.rule-assistant-result {
  margin-top: 14px;
  border: 1px solid rgba(110, 145, 129, 0.12);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.92);
  padding: 16px;
}

.rules-group-row td {
  padding-top: 18px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: rgba(245, 250, 247, 0.9);
}

.rules-group-row span {
  margin-left: 8px;
  font-weight: 700;
  color: #35584d;
}

.assistant-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 18px;
}

.assistant-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 4px;
}

.assistant-warning {
  margin-top: 14px;
  border-radius: 16px;
  background: rgba(255, 244, 221, 0.9);
  color: #805b16;
  padding: 12px 14px;
}

.panel-header {
  padding: 18px 20px 0;
  flex: 0 0 auto;
}

.panel-header p {
  color: var(--muted);
  margin-bottom: 0;
}

.table-wrap {
  overflow: auto;
  padding: 10px 16px 18px;
}

.invoice-list {
  display: grid;
  gap: 8px;
  padding: 6px 14px 16px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.invoice-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 252, 0.92);
  padding: 12px 14px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease, background 120ms ease;
}

.invoice-list-item:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(31, 49, 42, 0.08);
}

.invoice-list-item.selected {
  border-color: rgba(46, 125, 104, 0.34);
  background: linear-gradient(180deg, #fffdfa 0%, #f0faf4 100%);
  box-shadow: inset 4px 0 0 var(--accent), 0 14px 28px rgba(46, 125, 104, 0.1);
}

.invoice-list-item:focus-visible,
.workspace-switch .tab-button:focus-visible,
.queue-card:focus-visible,
.button:focus-visible {
  outline: 2px solid rgba(46, 125, 104, 0.4);
  outline-offset: 2px;
}

.invoice-list-top,
.invoice-list-bottom {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.invoice-list-middle {
  margin: 8px 0 10px;
}

.invoice-list-vendor {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.15;
  user-select: text;
  -webkit-user-select: text;
}

.invoice-list-date {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  user-select: text;
  -webkit-user-select: text;
}

.invoice-list-amount {
  font-size: 16px;
  font-weight: 700;
  white-space: nowrap;
  user-select: text;
  -webkit-user-select: text;
}

.invoice-list-cost-center {
  color: #35584d;
  font-weight: 600;
  line-height: 1.3;
  font-size: 13px;
  user-select: text;
  -webkit-user-select: text;
}

.invoice-list-status {
  flex: 0 0 auto;
}

.invoice-list-meta {
  min-width: 0;
  text-align: right;
  font-size: 12px;
}

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

th,
td {
  text-align: left;
  border-bottom: 1px solid rgba(110, 145, 129, 0.14);
  padding: 12px 8px;
  vertical-align: top;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

tbody tr:hover {
  background: rgba(223, 244, 235, 0.5);
}

.table-wrap th:last-child,
.table-wrap td:last-child {
  position: sticky;
  right: 0;
  background: rgba(255, 255, 250, 0.98);
}

.mini-button {
  border: 1px solid rgba(110, 145, 129, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  padding: 8px 12px;
  cursor: pointer;
}

.compact-button {
  padding: 7px 10px;
}

.mini-button.danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.empty-row,
.empty-detail {
  color: var(--muted);
  padding: 24px 12px;
}

.detail-content {
  padding: 20px 22px 24px;
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}

.detail-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-card {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 22px;
  padding: 14px;
  background: rgba(255, 255, 252, 0.92);
}

.detail-details summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.summary-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.learn-dialog-shell {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 24px;
}

.learn-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 28, 24, 0.36);
  backdrop-filter: blur(4px);
}

.learn-dialog-card {
  position: relative;
  width: min(100%, 560px);
  border-radius: 28px;
  padding: 28px;
  background: linear-gradient(180deg, #fffefa 0%, #f3fbf7 100%);
  border: 1px solid rgba(110, 145, 129, 0.16);
  box-shadow: 0 28px 80px rgba(24, 37, 31, 0.2);
}

.learn-dialog-lead {
  margin: 0 0 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.learn-dialog-copy,
.learn-dialog-question {
  margin: 0 0 12px;
}

.learn-dialog-question {
  font-weight: 600;
}

.learn-dialog-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 20px;
}

.detail-card-hero {
  display: grid;
  gap: 14px;
}

.detail-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.detail-hero-copy,
.detail-hero-amount-block {
  display: grid;
  gap: 6px;
}

.detail-hero-primary {
  display: block;
  font-size: clamp(28px, 3vw, 38px);
  line-height: 1;
  letter-spacing: -0.05em;
  user-select: text;
  -webkit-user-select: text;
}

.detail-hero-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-hero-secondary {
  display: block;
  color: var(--muted);
  font-size: 16px;
  user-select: text;
  -webkit-user-select: text;
}

.detail-hero-cost-center {
  font-size: clamp(22px, 2.4vw, 30px);
}

.detail-hero-cost-center.missing {
  color: var(--warn);
}

.detail-hero-primary-amount,
.detail-hero-secondary-date {
  text-align: right;
}

.detail-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.detail-status-item {
  display: inline-flex;
  align-items: center;
  user-select: text;
  -webkit-user-select: text;
}

.detail-status-item:not(:first-child)::before {
  content: "·";
  margin-right: 10px;
  color: rgba(80, 102, 94, 0.72);
}

.detail-status-link a {
  font-weight: 600;
}

.detail-source-hint,
.detail-inline-hint {
  margin: 0;
}

.detail-inline-hint {
  color: #9f6b15;
  font-size: 12px;
}

.summary-actions-inline {
  display: flex;
  align-items: start;
}

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

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quick-action-bar {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(110, 145, 129, 0.14);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.primary-action-bar {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.quick-vendor-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 12px;
  align-items: end;
}

.detail-more-options {
  margin-top: 12px;
}

.detail-more-options-grid {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.quick-action-secondary-row {
  display: flex;
  justify-content: flex-start;
}

.action-tip {
  margin-top: 12px;
  margin-bottom: 0;
}

.quick-action-field {
  display: grid;
  gap: 6px;
}

.quick-action-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.quick-action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.quick-action-choice {
  display: flex;
  flex-direction: column;
  gap: 4px;
  justify-content: flex-end;
  align-items: stretch;
}

.quick-action-hint {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.excluded-mail-info {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.excluded-mail-details {
  margin-top: 8px;
}

.excluded-mail-list {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.excluded-mail-row {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 14px;
  background: rgba(255, 255, 251, 0.84);
}

.detail-divider {
  border-top: 1px solid rgba(110, 145, 129, 0.18);
  margin: -2px 0 0;
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.detail-grid strong {
  display: block;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.modal-open {
  overflow: hidden;
}

.tag-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  background: #edf7f1;
}

.example-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.example-chip {
  display: inline-flex;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 11px;
  background: #f0f7f3;
  color: #50665e;
}

.decision-mode-explainer {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0 12px;
}

.decision-mode-explainer div {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 16px;
  background: #f5faf7;
  padding: 12px;
}

.decision-mode-explainer span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.compact-explainer {
  margin-top: 12px;
}

.freitext-label {
  display: block;
}

.suggestion-card {
  margin-top: 12px;
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 22px;
  background: linear-gradient(180deg, #fffdfa 0%, #f4fbf7 100%);
  padding: 14px;
}

.empty-suggestion {
  color: var(--muted);
}

.suggestion-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.suggestion-head h4,
.suggestion-copy p {
  margin-bottom: 0;
}

.suggestion-head p {
  margin-bottom: 0;
  color: var(--muted);
}

.suggestion-input-box {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 16px;
  background: #fffdfa;
  padding: 12px;
  margin-bottom: 12px;
}

.suggestion-input-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.suggestion-input-box p {
  margin: 0;
}

.suggestion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.suggestion-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.suggestion-copy {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 16px;
  background: #fffdfa;
  padding: 12px;
}

.suggestion-warning {
  margin-top: 10px;
  border-radius: 12px;
  background: var(--warn-soft);
  color: #704113;
  padding: 10px 12px;
}

.address-box,
.json-block {
  margin-top: 14px;
}

.info-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.info-list div,
.action-help,
.action-result {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 16px;
  background: #f5faf7;
  padding: 12px;
}

.info-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.action-help p {
  margin: 0 0 8px;
  color: #433d38;
}

.action-help p:last-child {
  margin-bottom: 0;
}

pre {
  margin: 8px 0 0;
  background: #f2f8f4;
  border-radius: 16px;
  padding: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  color: #244239;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-grid .wide {
  grid-column: 1 / -1;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: 18px;
  height: 18px;
  min-width: auto;
}

.inline-action {
  display: grid;
  gap: 8px;
  align-content: end;
}

.rule-actions-cell {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-editor-panel {
  border-bottom: 1px solid rgba(110, 145, 129, 0.14);
  padding: 16px 18px 18px;
  background: rgba(255, 255, 252, 0.88);
}

.list-meta {
  color: #433d38;
  line-height: 1.3;
}

.list-meta.subtle {
  color: var(--muted);
  font-size: 12px;
  margin-top: 0;
  user-select: text;
  -webkit-user-select: text;
}

.list-panel-header .eyebrow {
  margin-bottom: 2px;
}

.compact-editor-head {
  padding: 0 0 12px;
}

.inline-action span,
.subtle-note {
  color: var(--muted);
}

.detail-toggle {
  margin-top: 12px;
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 16px;
  background: #f5faf7;
  padding: 12px;
}

.detail-details summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.detail-details summary::-webkit-details-marker {
  display: none;
}

.detail-details summary::before {
  content: "+";
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  background: #edf7f1;
  color: var(--accent-strong);
  font-weight: 700;
  font-size: 13px;
}

.detail-details[open] summary::before {
  content: "-";
}

.technical-details-collapse {
  background: #f5f5f5;
  border-color: rgba(0, 0, 0, 0.08);
  margin-top: 12px;
}

.technical-details-collapse summary {
  font-size: 14px;
  font-weight: 700;
  color: #4c5450;
}

.technical-details-collapse summary::before {
  content: "\25B6";
  width: auto;
  height: auto;
  border-radius: 0;
  background: transparent;
  color: #606864;
  font-size: 12px;
}

.technical-details-collapse[open] summary::before {
  content: "\25BC";
}

.technical-details-stack {
  display: grid;
  gap: 12px;
  font-size: 13px;
  color: #4f5653;
  margin-top: 10px;
}

.technical-suggestion-block {
  margin-top: 0;
}

.technical-details-collapse .detail-grid,
.technical-details-collapse .info-list,
.technical-details-collapse .action-help,
.technical-details-collapse .form-grid,
.technical-details-collapse .json-block,
.technical-details-collapse .detail-toggle,
.technical-details-collapse pre,
.technical-details-collapse label span {
  font-size: 13px;
}

.technical-details-collapse .detail-toggle {
  background: rgba(255, 255, 255, 0.6);
}

#quickVendorSelect,
#detailVendorSelect {
  min-width: 300px;
  max-width: 100%;
}

.vendor-management-panel {
  display: grid;
  gap: 12px;
}

.vendor-row-card {
  border: 1px solid rgba(110, 145, 129, 0.14);
  border-radius: 18px;
  background: #fffdfa;
  padding: 14px;
}

.vendor-row {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
}

.vendor-row-copy {
  display: grid;
  gap: 4px;
}

.vendor-row-name {
  user-select: text;
  -webkit-user-select: text;
}

.vendor-row-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.vendor-inline-editor,
.vendor-delete-panel {
  margin-top: 12px;
  display: grid;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid rgba(110, 145, 129, 0.14);
}

.vendor-delete-link {
  color: var(--danger);
}

.vendor-delete-panel p {
  margin-bottom: 0;
}

.detail-grid span,
.info-list span,
.info-list strong,
.json-block pre,
.address-box pre,
[data-field="vendor"],
[data-field="costCenter"],
[data-field="amount"],
[data-field="date"] {
  user-select: text;
  -webkit-user-select: text;
}

.compact-toggle {
  margin-top: 10px;
}

.divider {
  height: 1px;
  background: rgba(110, 145, 129, 0.16);
  margin: 14px 0;
}

.compact-status-card {
  align-content: start;
}

.settings-advanced {
  grid-column: 1 / -1;
}

.settings-advanced-stack {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.settings-advanced .compact-status-card {
  border: none;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.settings-advanced summary {
  cursor: pointer;
  font-weight: 700;
  color: #4c5450;
  list-style: none;
}

.settings-advanced summary::-webkit-details-marker {
  display: none;
}

.settings-advanced summary::before {
  content: "\25B6";
  margin-right: 8px;
  color: #606864;
  font-size: 12px;
}

.settings-advanced[open] summary::before {
  content: "\25BC";
}

.mail-account-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.mail-account-header strong {
  display: block;
  font-size: 18px;
  margin-top: 4px;
}

.mail-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.mail-stats-grid div,
.mail-inline-notice,
.checkbox-card {
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 14px;
  background: #f5faf7;
}

.mail-stats-grid div {
  padding: 10px;
}

.mail-stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.mail-stats-grid strong {
  font-size: 16px;
}

.mail-inline-notice {
  margin-bottom: 12px;
  padding: 10px 12px;
  color: #4f5653;
}

.mail-inline-notice.is-error {
  background: #f8e9e9;
  border-color: rgba(143, 75, 75, 0.22);
  color: #7a3d3d;
}

.mail-inline-notice.is-warning {
  background: #fbf1e2;
  border-color: rgba(164, 103, 45, 0.22);
  color: #8a5927;
}

.mail-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.checkbox-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px;
}

.checkbox-card input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.checkbox-card span {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.mail-settings-grid label:not(.checkbox-card) {
  display: grid;
  gap: 6px;
}

.mail-settings-grid label:not(.checkbox-card) span {
  color: var(--muted);
  font-size: 13px;
}

.mail-settings-grid label:not(.checkbox-card) input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
}

.mail-candidate-section {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(110, 145, 129, 0.16);
}

.mail-candidate-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.mail-candidate-card {
  border: 1px solid rgba(110, 145, 129, 0.16);
  border-radius: 16px;
  background: #f9fcfa;
  padding: 12px;
}

.mail-candidate-head,
.mail-candidate-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.mail-candidate-head p,
.mail-candidate-footer .subtle-note {
  margin: 4px 0 0;
}

.mail-candidate-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.mail-candidate-reasons,
.mail-candidate-signals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.tag-muted {
  background: #eef4f0;
  color: #5c6862;
}

.detail-toggle summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--info);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.state-confirmed {
  background: var(--accent-soft);
  color: var(--accent);
}

.state-manual_applied,
.state-confirmed_by_user,
.state-rule_saved {
  background: var(--accent-soft);
  color: var(--accent);
}

.state-note_saved {
  background: var(--warn-soft);
  color: var(--warn);
}

.state-needs_review {
  background: var(--warn-soft);
  color: var(--warn);
}

.state-excluded,
.state-duplicate {
  background: var(--danger-soft);
  color: var(--danger);
}

.state-other {
  background: var(--info-soft);
  color: var(--info);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  min-width: 240px;
  max-width: 380px;
  background: #1d2a25;
  color: white;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22);
  z-index: 20;
}

@media (max-width: 1100px) {
  .topbar {
    flex-wrap: wrap;
  }

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

  .toolbar[data-workspace-panel="invoices"] {
    position: static;
  }

  .detail-hero {
    flex-direction: column;
  }

  .detail-hero-primary-amount,
  .detail-hero-secondary-date {
    text-align: left;
  }

  .rules-overview-bar {
    flex-direction: column;
  }

  .rules-overview-actions {
    flex-basis: auto;
    width: 100%;
    padding-top: 0;
  }

  .queue-grid,
  .rules-insights,
  .content-grid {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .detail-panel {
    position: static;
  }

  .invoice-list,
  .detail-content {
    max-height: none;
    overflow: visible;
  }

  .quick-action-bar {
    grid-template-columns: 1fr;
  }

  .quick-vendor-bar {
    grid-template-columns: 1fr;
  }

  .quick-action-buttons {
    justify-content: stretch;
  }

  .stats-compact {
    flex-wrap: wrap;
    gap: 8px;
  }

  .test-mode-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .stats-grid-invoices {
    grid-template-columns: 1fr;
  }

  .learn-dialog-card {
    padding: 22px;
  }

  .learn-dialog-actions {
    flex-direction: column;
  }

  .learn-dialog-actions .button {
    width: 100%;
  }

  .page-shell {
    width: 100%;
    padding: 0 0 16px;
  }

  .topbar {
    padding: 10px 12px;
    gap: 10px;
    grid-template-columns: auto 1fr;
  }

  .topbar .workspace-switch {
    order: 3;
    grid-column: 1 / -1;
    width: 100%;
    overflow-x: auto;
  }

  .topbar-controls {
    order: 4;
    grid-column: 1 / -1;
    justify-content: flex-start;
    padding-top: 4px;
  }

  .topbar-title {
    justify-self: end;
    font-size: 16px;
    letter-spacing: 0.06em;
  }

  .topbar-logout-link {
    padding-left: 10px;
  }

  .brand-wordmark {
    width: 184px;
    height: 58px;
  }

  .brand-mark {
    width: 64px;
    height: 64px;
  }

  .salma-icon {
    width: 64px;
    height: 64px;
  }

  .auth-topbar-controls {
    top: 14px;
    right: 14px;
  }

  .toolbar {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
  }

  .stats-compact {
    justify-content: space-between;
  }

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

  .filters,
  .form-grid,
  .detail-grid,
  .suggestion-grid,
  .assistant-grid,
  .decision-mode-explainer,
  .mini-stats,
  .info-list {
    grid-template-columns: 1fr;
  }

  .invoice-list-top,
  .invoice-list-bottom {
    flex-direction: column;
  }

  .invoice-list-meta {
    text-align: left;
  }

  .filters label,
  .form-grid label,
  select,
  input,
  textarea {
    width: 100%;
    min-width: 0;
  }

  .table-wrap {
    padding: 12px;
  }
}
