:root {
  --ink: #12161c;
  --ink-soft: #334155;
  --paper: #ffffff;
  --panel: #ffffff;
  --panel-border: #e2e8f0;
  --line: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --accent: #9a7340;
  --accent-strong: #7a5928;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --info: #0369a1;
  --radius: 14px;
  --font-display: "Manrope", sans-serif;
  --font-body: "Manrope", sans-serif;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 16px rgba(15, 23, 42, 0.04);
  --surface: #f8fafc;
  --surface-hover: #f1f5f9;
  --sidebar-bg: linear-gradient(180deg, #1a2332 0%, #141c28 100%);
  --sidebar-border: rgba(232, 237, 242, 0.1);
  --sidebar-text: #e8edf2;
  --sidebar-muted: #93a0b0;
  --sidebar-line: rgba(232, 237, 242, 0.1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--paper);
  line-height: 1.45;
  overflow-x: hidden;
}

body.drawer-open {
  overflow: hidden;
}

body.drawer-open .shell-main,
body.drawer-open .sidebar {
  pointer-events: none;
  user-select: none;
}

body.drawer-open .drawer,
body.drawer-open .drawer-backdrop {
  pointer-events: auto;
}

.shell {
  display: grid;
  grid-template-columns: minmax(220px, 260px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 1.5rem 1rem 1.25rem;
  border-right: 1px solid var(--sidebar-border);
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: rise 0.55s ease both;
}

.sidebar-brand .brand {
  margin: 0;
  color: #e0bf84;
}

.sidebar-tag {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--sidebar-muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  color: var(--sidebar-muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  color: var(--sidebar-text);
  background: rgba(232, 237, 242, 0.06);
}

.nav-link.active {
  color: #e0bf84;
  background: rgba(196, 165, 116, 0.12);
  font-weight: 600;
}

.nav-icon {
  width: 1.1rem;
  text-align: center;
  opacity: 0.85;
}

.sidebar-foot {
  border-top: 1px solid var(--sidebar-line);
  padding-top: 0.85rem;
}

.sidebar-foot .user-line {
  color: var(--sidebar-text);
}

.sidebar-foot .role-line {
  color: var(--sidebar-muted);
}

.sidebar .ghost {
  color: var(--sidebar-muted);
  border-color: var(--sidebar-line);
}

.sidebar .ghost:hover {
  color: var(--sidebar-text);
  border-color: rgba(232, 237, 242, 0.25);
}

.user-line {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.role-line {
  margin: 0.15rem 0 0.65rem;
  font-size: 0.75rem;
  color: var(--muted);
  text-transform: capitalize;
}

.logout-form {
  margin: 0;
}

.shell-main {
  min-width: 0;
}

.page-top {
  padding-top: 1.5rem;
}

.page-top h1 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 3.2vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.shell-main main {
  padding: 0 clamp(1.25rem, 4vw, 3rem) 2rem;
  animation: rise 0.65s ease both;
}

.shell-main .foot {
  padding: 0.75rem clamp(1.25rem, 4vw, 3rem) 1.5rem;
}

.placeholder-note {
  margin-top: 1rem;
}

button.small,
.ghost.small {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-shell {
  width: min(420px, calc(100vw - 2rem));
}

.login-card {
  padding: 2rem;
}

.login-card h1 {
  margin: 0.35rem 0;
  font-family: var(--font-display);
  font-size: 1.75rem;
}

.login-form {
  display: grid;
  gap: 0.85rem;
  margin-top: 1.25rem;
}

.login-form label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.login-form input {
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--text);
  font: inherit;
}

button.full {
  width: 100%;
  margin-top: 0.35rem;
}

.login-error {
  margin-top: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  border: 1px solid rgba(185, 28, 28, 0.25);
  background: rgba(185, 28, 28, 0.06);
  color: var(--bad);
  font-size: 0.88rem;
}

.login-foot {
  margin-top: 1rem;
  font-size: 0.88rem;
  text-align: center;
}

.login-foot a {
  color: var(--accent-strong);
}

.login-info {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.88rem;
  color: var(--muted);
}

.login-info p {
  margin: 0 0 0.65rem;
}

.login-info p:last-child {
  margin-bottom: 0;
}

a.login-link-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  padding: 0.65rem 1rem;
  border-radius: 10px;
}

.user-admin-form {
  max-width: 420px;
}

.ok-text {
  color: var(--ok);
  font-size: 0.88rem;
}

.atmosphere {
  display: none;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: end;
  padding: 2rem clamp(1.25rem, 4vw, 3rem) 1rem;
  animation: rise 0.6s ease both;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--accent-strong);
}

.top h1 {
  margin: 0.2rem 0 0.35rem;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 3.5vw, 2.25rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.lede {
  margin: 0;
  color: var(--muted);
  max-width: 36rem;
}

.top-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  justify-content: flex-end;
}

.mailbox {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  max-width: min(280px, 70vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pill {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--line);
}

.pill.ok {
  background: rgba(21, 128, 61, 0.08);
  color: var(--ok);
  border-color: rgba(21, 128, 61, 0.2);
}

.pill.bad {
  background: rgba(185, 28, 28, 0.08);
  color: var(--bad);
  border-color: rgba(185, 28, 28, 0.2);
}

.pipeline-scheduler-hint {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
  line-height: 1.45;
}

.treatment-retry-hint {
  margin: 0 0 0.75rem;
  font-size: 0.86rem;
  line-height: 1.45;
}

.detail-last-done {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
}

main {
  padding: 0 clamp(1.25rem, 4vw, 3rem) 3rem;
  display: grid;
  gap: 1.25rem;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.85rem;
  animation: rise 0.7s ease 0.05s both;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.kpi:hover {
  transform: translateY(-2px);
  border-color: rgba(154, 115, 64, 0.35);
}

.kpi .label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi .value {
  margin: 0.35rem 0 0;
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.kpi .hint {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: calc(var(--radius) + 2px);
  padding: 1.15rem 1.2rem 1.25rem;
  box-shadow: var(--shadow);
  animation: rise 0.75s ease 0.1s both;
  min-width: 0;
}

.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
}

.panel-head p {
  margin: 0.25rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.panel-head-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-head-row > .primary {
  align-self: center;
  text-decoration: none;
  white-space: nowrap;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-top: 1rem;
}

.panel-head-row .action-row-head {
  margin-top: 0;
  justify-content: flex-end;
  flex: 0 1 auto;
  max-width: min(100%, 820px);
  gap: 0.5rem;
}

.action-row-head .field-inline-compact input {
  width: 4.25rem;
}

.action-row-head button.small {
  min-height: 36px;
}

.action-row-head .check,
.action-row-head .field-inline {
  font-size: 0.78rem;
}

.action-row-head .field-inline input {
  min-height: 32px;
  padding: 0.3rem 0.5rem;
}

button,
.ghost,
.primary,
.secondary {
  font-family: var(--font-body);
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 44px;
}

.primary {
  background: var(--accent);
  color: var(--ink);
}

.primary:hover {
  background: var(--accent-strong);
}

.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

.secondary:hover {
  border-color: var(--accent);
  color: var(--accent-strong);
  background: var(--surface);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.ghost:hover {
  color: var(--text);
}

.check,
.field-inline {
  display: inline-flex;
  gap: 0.4rem;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.field-inline input,
.filters input,
.filters select {
  background: var(--paper);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 10px;
  padding: 0.5rem 0.7rem;
  font: inherit;
  min-height: 44px;
  max-width: 100%;
}

.field-inline input {
  width: 5rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.25rem;
  min-width: 0;
}

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

.filters input[type="search"] {
  flex: 1 1 220px;
  min-width: 0;
}

.filters select {
  flex: 1 1 140px;
}

.filters-row {
  align-items: flex-end;
}

.search-field {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.search-field input[type="search"] {
  flex: 0 0 auto;
  width: 100%;
}

.filters-compact {
  margin-top: 0.75rem;
}

.filters-compact input[type="search"] {
  flex: 0 1 320px;
  min-height: 36px;
  padding: 0.4rem 0.65rem;
  font-size: 0.88rem;
}

.table-pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}

.pagination-summary {
  margin: 0;
  font-size: 0.86rem;
}

.pagination-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.pagination-size {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.pagination-size select {
  min-height: 36px;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper);
  font: inherit;
}

.status-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0 0.75rem;
}

.status-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  min-height: 36px;
}

.status-tab:hover {
  color: var(--text);
  border-color: #cbd5e1;
  background: var(--surface-hover);
}

.status-tab.active {
  color: var(--text);
  border-color: rgba(154, 115, 64, 0.45);
  background: rgba(154, 115, 64, 0.08);
}

.status-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  padding: 0.05rem 0.35rem;
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.status-tab.active .tab-count {
  background: rgba(154, 115, 64, 0.15);
}

.tab-hint {
  margin: -0.35rem 0 0.75rem;
  font-size: 0.82rem;
}

.table-sub {
  font-size: 0.78rem;
  margin-top: 0.15rem;
}

.pipeline-mini {
  display: flex;
  gap: 0.25rem;
  list-style: none;
  margin: 0;
  padding: 0;
  align-items: center;
}

.pipeline-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--line);
  flex-shrink: 0;
}

.pipeline-dot.done {
  background: var(--ok);
}

.pipeline-dot.failed {
  background: var(--bad);
}

.pipeline-dot.current {
  background: var(--info);
  box-shadow: 0 0 0 2px rgba(3, 105, 161, 0.2);
}

.pipeline-dot.pending,
.pipeline-dot.skipped {
  background: #cbd5e1;
}

.pipeline-stepper {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0.25rem 0 0.5rem;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pipeline-step {
  flex: 1 1 0;
  min-width: 6.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  position: relative;
  padding: 0 0.35rem 0.5rem;
}

.pipeline-step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 0.55rem;
  left: calc(50% + 0.6rem);
  right: calc(-50% + 0.6rem);
  height: 2px;
  background: var(--line);
  z-index: 0;
}

.pipeline-step.done:not(:last-child)::before {
  background: rgba(21, 128, 61, 0.4);
}

.pipeline-step.failed:not(:last-child)::before {
  background: rgba(185, 28, 28, 0.25);
}

.pipeline-step.current:not(:last-child)::before {
  background: rgba(3, 105, 161, 0.35);
}

.pipeline-step-marker {
  width: 1.1rem;
  height: 1.1rem;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
  z-index: 1;
  position: relative;
}

.pipeline-step.done .pipeline-step-marker {
  border-color: var(--ok);
  background: rgba(21, 128, 61, 0.12);
}

.pipeline-step.failed .pipeline-step-marker {
  border-color: var(--bad);
  background: rgba(185, 28, 28, 0.08);
}

.pipeline-step.current .pipeline-step-marker {
  border-color: var(--info);
  background: rgba(3, 105, 161, 0.1);
  box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.12);
}

.pipeline-step.pending .pipeline-step-marker,
.pipeline-step.skipped .pipeline-step-marker {
  border-color: #cbd5e1;
  background: var(--surface);
}

.pipeline-step-body {
  margin-top: 0.65rem;
  width: 100%;
  min-width: 0;
}

.pipeline-step-head {
  display: block;
}

.pipeline-step-head strong {
  display: block;
  font-size: 0.82rem;
  line-height: 1.25;
}

.pipeline-step-detail {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.35;
  word-break: break-word;
}

.pipeline-step-when {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.68rem;
}

@media (max-width: 720px) {
  .pipeline-step {
    min-width: 6.5rem;
  }

  .pipeline-step-head strong {
    font-size: 0.76rem;
  }
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(3, 105, 161, 0.08);
  color: var(--info);
  border: 1px solid rgba(3, 105, 161, 0.15);
}

.table-wrap {
  overflow: auto;
  max-height: min(420px, 55vh);
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

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

th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  z-index: 1;
}

tr:hover td {
  background: var(--surface-hover);
}

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

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge.invoice {
  background: rgba(21, 128, 61, 0.1);
  color: var(--ok);
}

.badge.credit {
  background: rgba(3, 105, 161, 0.1);
  color: var(--info);
}

.badge.other {
  background: var(--surface);
  color: var(--muted);
}

.badge.ok {
  background: rgba(21, 128, 61, 0.1);
  color: var(--ok);
}

.badge.warn {
  background: rgba(180, 83, 9, 0.1);
  color: var(--warn);
}

.badge.info {
  background: rgba(3, 105, 161, 0.1);
  color: var(--info);
}

.drawer.mail-drawer {
  width: min(760px, 96vw);
}

.mail-meta-grid {
  display: grid;
  gap: 0.55rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.mail-meta-row {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  font-size: 0.88rem;
}

.mail-meta-row .label {
  color: var(--muted);
}

.mail-meta-row .value {
  word-break: break-word;
}

.mail-collect-box {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(232, 237, 242, 0.04);
}

.mail-collect-box .muted {
  flex: 1 1 100%;
  margin: 0.25rem 0 0;
  font-size: 0.82rem;
}

.mail-attachments {
  margin-bottom: 1rem;
}

.mail-attachments ul {
  margin: 0.35rem 0 0;
  padding-left: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.85rem;
}

.mail-attachment-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}

.mail-attachment-item:last-child {
  border-bottom: 0;
}

.mail-attachment-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
}

.mail-attachment-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.mail-attachment-link:hover {
  text-decoration: underline;
}

.filter-detail {
  margin-top: 0.85rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.filter-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.filter-detail-head h3 {
  margin: 0.15rem 0 0;
  font-size: 0.98rem;
}

.filter-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.filter-summary {
  margin: 0.65rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.filter-score-main {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.35rem 0 0.55rem;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--paper);
}

.score-pill.ok {
  color: var(--ok);
  border-color: rgba(21, 128, 61, 0.25);
  background: rgba(21, 128, 61, 0.06);
}

.score-pill.warn {
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.25);
  background: rgba(180, 83, 9, 0.06);
}

.score-pill.muted {
  color: var(--muted);
}

.filter-lines {
  list-style: none;
  margin: 0.35rem 0 0;
  padding: 0;
}

.filter-lines li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.65rem;
  align-items: start;
  padding: 0.45rem 0;
  border-top: 1px solid var(--line);
  font-size: 0.84rem;
}

.filter-line-label {
  color: var(--text);
}

.filter-points {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.filter-points.pos {
  color: #15803d;
}

.filter-points.neg {
  color: #b91c1c;
}

.filter-points.zero {
  color: var(--muted);
}

.filter-lines li.filter-line-info {
  background: rgba(15, 23, 42, 0.03);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-top: 0.35rem;
  border-top: none;
}

.filter-lines li.filter-line-neutral .filter-line-label {
  color: var(--muted);
}

.filter-legend {
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
  line-height: 1.45;
}

.filter-plain-reason {
  margin: 0.65rem 0 0;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  background: rgba(180, 83, 9, 0.08);
  border: 1px solid rgba(180, 83, 9, 0.18);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.55;
}

.filter-lines li.filter-line-plain {
  color: var(--text);
  line-height: 1.5;
}

.filter-value {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.82rem;
}

.mail-collect-box .filter-detail {
  margin-top: 0.65rem;
}

.mail-body-shell {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  min-height: 280px;
}

.mail-body-frame {
  width: 100%;
  min-height: 420px;
  border: 0;
  background: #fff;
}

.mail-body-text {
  margin: 0;
  padding: 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: #1f2937;
  font: 0.88rem/1.5 var(--font-body);
  max-height: 60vh;
  overflow: auto;
}

.jobs-layout {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr;
  gap: 0.85rem;
  margin-top: 1rem;
  min-width: 0;
}

.job-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  -webkit-overflow-scrolling: touch;
}

.job-list li {
  padding: 0.7rem 0.8rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  min-height: 44px;
}

.job-list li:hover,
.job-list li.active {
  background: var(--surface-hover);
}

.job-list .meta {
  color: var(--muted);
  font-size: 0.75rem;
}

.log {
  margin: 0;
  min-height: 200px;
  max-height: min(320px, 40vh);
  overflow: auto;
  padding: 0.9rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.75rem;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-overflow-scrolling: touch;
}

.foot {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 clamp(1.25rem, 4vw, 3rem) calc(2rem + env(safe-area-inset-bottom, 0px));
  color: var(--muted);
  font-size: 0.78rem;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

tr.clickable {
  cursor: pointer;
}

tr.clickable.active td {
  background: rgba(154, 115, 64, 0.08);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  cursor: pointer;
  border: none;
  padding: 0;
  margin: 0;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(460px, 100vw);
  height: 100vh;
  height: 100dvh;
  z-index: 50;
  display: none;
  flex-direction: column;
  background: var(--paper);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

body.drawer-open .drawer-backdrop {
  display: block;
  animation: fade-in 0.2s ease;
}

body.drawer-open .drawer {
  display: flex;
  animation: slide-in 0.28s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slide-in {
  from {
    transform: translateX(24px);
    opacity: 0.4;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.25rem 1.35rem;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.drawer-kicker {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.drawer-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1rem, 3.5vw, 1.15rem);
  line-height: 1.25;
  word-break: break-word;
}

.drawer-body {
  overflow: auto;
  padding: 1.1rem 1.35rem 2rem;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.detail-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-bottom: 1.1rem;
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.detail-actions .small {
  padding: 0.45rem 0.85rem;
  font-size: 0.82rem;
  text-decoration: none;
}

.detail-section {
  margin-bottom: 1.25rem;
}

.detail-section h3 {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 700;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.85rem;
}

.detail-grid .full {
  grid-column: 1 / -1;
}

.detail-back {
  margin-bottom: 1rem;
}

.detail-back a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.detail-back a:hover {
  text-decoration: underline;
}

.detail-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail-page-head {
  margin-bottom: 0.25rem;
}

.detail-page-kicker {
  margin: 0;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.detail-page-title {
  margin: 0.25rem 0 0.65rem;
  font-family: var(--font-display);
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  line-height: 1.2;
}

.detail-page-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
}

.detail-page-actions {
  margin: 0;
}

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

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

.detail-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
}

.detail-panel-wide {
  grid-column: 1 / -1;
}

.detail-collapsible summary {
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}

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

.detail-grid-spaced {
  margin: 0.85rem 0;
}

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

@media (max-width: 960px) {
  .detail-page-grid,
  .detail-page-grid-3 {
    grid-template-columns: 1fr;
  }
}

.detail-field {
  min-width: 0;
}

.detail-field .label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}

.detail-field .value {
  display: block;
  font-size: 0.9rem;
  word-break: break-word;
}

.detail-field .value.mono {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.rejection-box {
  margin-top: 0.35rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(185, 28, 28, 0.2);
  background: rgba(185, 28, 28, 0.05);
  color: var(--bad);
  font-size: 0.85rem;
}

.payload-pre {
  margin: 0;
  padding: 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 0.72rem;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.pill.warn {
  background: rgba(180, 83, 9, 0.08);
  color: var(--warn);
  border-color: rgba(180, 83, 9, 0.2);
}

/* —— Responsive —— */

@media (max-width: 900px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    min-height: auto;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .nav-link {
    flex: 1 1 calc(50% - 0.25rem);
  }
}

@media (max-width: 1100px) {
  .col-lg {
    display: none;
  }
}

@media (max-width: 980px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .top {
    flex-direction: column;
    align-items: flex-start;
    padding-top: 1.5rem;
  }

  .top-meta {
    justify-content: flex-start;
    width: 100%;
  }

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

@media (max-width: 720px) {
  .top {
    padding: 1.25rem 1rem 0.75rem;
  }

  main {
    padding: 0 1rem 2rem;
    gap: 1rem;
  }

  .panel {
    padding: 1rem;
    border-radius: 12px;
  }

  .kpi .value {
    font-size: 1.45rem;
  }

  .panel-head-row .action-row-head {
    max-width: 100%;
    justify-content: flex-start;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row > button,
  .action-row > .primary,
  .action-row > .secondary {
    width: 100%;
  }

  .action-row .check,
  .action-row .field-inline {
    width: 100%;
    justify-content: space-between;
  }

  .filters {
    flex-direction: column;
  }

  .filters input[type="search"],
  .filters select {
    flex: 1 1 auto;
    width: 100%;
  }

  .jobs-layout {
    grid-template-columns: 1fr;
  }

  .job-list {
    max-height: 160px;
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border: none;
    gap: 0.5rem;
  }

  .job-list li {
    flex: 0 0 auto;
    min-width: 140px;
    border: 1px solid var(--line);
    border-radius: 10px;
    border-bottom: 1px solid var(--line);
  }

  .log {
    min-height: 160px;
  }

  .foot {
    flex-direction: column;
    align-items: flex-start;
    padding-left: 1rem;
    padding-right: 1rem;
    gap: 0.35rem;
  }

  .col-md {
    display: none;
  }

  /* Tables → cards */
  .table-cards {
    max-height: none;
    border: none;
    overflow: visible;
  }

  .table-cards table,
  .table-cards thead,
  .table-cards tbody,
  .table-cards th,
  .table-cards td,
  .table-cards tr {
    display: block;
    width: 100%;
  }

  .table-cards thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .table-cards tbody {
    display: grid;
    gap: 0.65rem;
  }

  .table-cards tr {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--paper);
    padding: 0.55rem 0.65rem;
  }

  .table-cards tr:hover td,
  .table-cards tr.clickable.active td {
    background: transparent;
  }

  .table-cards tr.clickable.active {
    border-color: rgba(154, 115, 64, 0.45);
    background: rgba(154, 115, 64, 0.06);
  }

  .table-cards td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    border: none;
    padding: 0.35rem 0.15rem;
    text-align: right;
  }

  .table-cards td.col-md,
  .table-cards td.col-lg {
    display: none;
  }

  .table-cards td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    text-align: left;
    flex: 0 0 38%;
  }

  .table-cards td[data-label=""] {
    display: block;
    text-align: left;
  }

  .table-cards td[data-label=""]::before {
    content: none;
  }

  .drawer {
    width: 100vw;
    border-left: none;
  }

  body.drawer-open .drawer {
    animation: slide-up 0.28s ease;
  }

  @keyframes slide-up {
    from {
      transform: translateY(18px);
      opacity: 0.4;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .drawer-head,
  .drawer-body {
    padding-left: max(1rem, env(safe-area-inset-left, 0px));
    padding-right: max(1rem, env(safe-area-inset-right, 0px));
  }

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

@media (max-width: 420px) {
  .kpis {
    grid-template-columns: 1fr 1fr;
    gap: 0.55rem;
  }

  .kpi {
    padding: 0.75rem 0.8rem;
  }

  .kpi .label {
    font-size: 0.68rem;
  }

  .kpi .value {
    font-size: 1.25rem;
  }

  .kpi .hint {
    font-size: 0.68rem;
  }

  .lede {
    font-size: 0.9rem;
  }
}

.reason-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.85rem;
}

.duplicate-groups {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.duplicate-group.inset {
  padding: 0.75rem 1rem;
}

.duplicate-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.duplicate-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  align-items: baseline;
  font-size: 0.88rem;
}

.validation-corrections {
  margin-top: 0.5rem;
  font-size: 0.82rem;
}

.validation-corrections summary {
  cursor: pointer;
  color: var(--accent, #3d7aee);
}

.correction-form {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.5rem;
  max-width: 22rem;
}

.correction-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.correction-form input {
  font: inherit;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border, #2a3344);
  background: var(--surface-2, #121820);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
