:root {
  color-scheme: light;
  --ink: var(--polo-text, #17211b);
  --muted: var(--polo-muted, #666666);
  --paper: var(--polo-bg, #f7f7f7);
  --panel: var(--polo-surface, #ffffff);
  --panel-strong: var(--polo-surface-2, #f0f0f0);
  --line: var(--polo-line, #d8d8d8);
  --green: var(--polo-success, #2f7d5c);
  --green-soft: #dff1e8;
  --amber: var(--polo-warning, #a86616);
  --amber-soft: #f7e5c6;
  --red: var(--polo-danger, #aa3f2e);
  --red-soft: #f6d8d1;
  --blue: var(--polo-accent, #345f8f);
  --shadow: var(--polo-shadow-md, 0 24px 80px rgba(37, 44, 31, 0.14));
  --radius: var(--polo-card-radius, var(--polo-radius-md, 8px));
  font-family: var(--polo-font-ui, Avenir Next, Optima, Candara, Segoe UI, sans-serif);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
}

body::before {
  display: none;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 0;
  background: var(--paper);
  backdrop-filter: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: var(--polo-radius-md, 8px);
  background: var(--polo-primary, #18241d);
  color: var(--polo-control-text, #ffffff);
  font-weight: 900;
  letter-spacing: -0.08em;
  box-shadow: 0 16px 40px rgba(24, 36, 29, 0.22);
}

nav {
  display: grid;
  gap: 12px;
  margin-top: 36px;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  padding: 14px 18px;
  border-radius: 999px;
}

nav a.active,
nav a:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
}

main {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 34px clamp(18px, 4vw, 56px) 64px;
}

.accounting-hero h1 {
  max-width: 980px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1, h2 { margin: 0; line-height: 0.95; }
h1 { font-size: clamp(44px, 8vw, 112px); letter-spacing: -0.075em; max-width: 900px; }
h2 { font-size: clamp(24px, 3vw, 38px); letter-spacing: -0.045em; }

.hero-copy {
  max-width: 640px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

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

.hero-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px;
  border-radius: var(--radius);
}

.pulse {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 8px rgba(168, 102, 22, 0.14);
}

.pulse.ok { background: var(--green); box-shadow: 0 0 0 8px rgba(47, 125, 92, 0.16); }
.pulse.bad { background: var(--red); box-shadow: 0 0 0 8px rgba(170, 63, 46, 0.16); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 22px;
  margin: 28px 0;
}

button {
  min-height: var(--polo-control-height, 36px);
  border: 1px solid var(--line);
  border-radius: var(--polo-control-radius, 8px);
  padding: 0 var(--polo-control-padding-x, 14px);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  font-weight: 900;
  cursor: pointer;
}

button.primary {
  color: var(--polo-control-text, #ffffff);
  background: var(--polo-control-bg, #18241d);
}

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

.switch { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-weight: 800; }
.switch input { accent-color: var(--green); }
.muted { color: var(--muted); font-size: 13px; }

.locale-switch {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(23, 33, 27, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.42);
}

.locale-button {
  min-width: 42px;
  padding: 7px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
}

.locale-button.active {
  color: #fff8e8;
  background: var(--green);
}

.grid.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.system-metrics {
  margin-top: 16px;
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 20px;
  border-radius: var(--radius);
}

.metric::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -38px;
  bottom: -46px;
  border-radius: 999px;
  background: rgba(47, 125, 92, 0.13);
}

.metric span, .metric small { display: block; color: var(--muted); font-weight: 800; }
.metric strong { display: block; margin: 10px 0; font-size: 42px; letter-spacing: -0.06em; }

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 16px;
  margin-top: 16px;
}

.wide-left {
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
}

.panel {
  padding: 22px;
  border-radius: var(--radius);
  min-width: 0;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.pending { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.ghost { margin-top: 12px; background: rgba(24, 36, 29, 0.08); color: var(--muted); }

.ledger-workbench {
  align-items: stretch;
}

.action-panel {
  background:
    linear-gradient(145deg, rgba(255, 252, 244, 0.94), rgba(238, 246, 234, 0.86)),
    var(--panel);
}

.operator-panel {
  background:
    radial-gradient(circle at 88% 10%, rgba(47, 125, 92, 0.16), transparent 15rem),
    var(--panel);
}

.workflow-steps {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.workflow-steps li {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px;
  border: 1px solid rgba(23, 33, 27, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
}

.workflow-steps strong,
.summary-grid strong {
  display: block;
}

.workflow-steps small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  line-height: 1.35;
}

.step-index {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  color: #fff8e8;
  background: #18241d;
  font-weight: 900;
}

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

.summary-grid div {
  min-height: 92px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.48);
  border: 1px solid rgba(23, 33, 27, 0.1);
}

.summary-grid div:first-child {
  grid-column: 1 / -1;
  background: #18241d;
  color: #fff8e8;
}

.summary-grid small {
  display: block;
  color: inherit;
  opacity: 0.68;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.summary-grid strong {
  margin-top: 8px;
  font-size: clamp(24px, 4vw, 42px);
  letter-spacing: -0.06em;
}

.source-coordination {
  align-items: stretch;
}

.source-grid {
  display: grid;
  gap: 12px;
}

.source-card {
  display: grid;
  gap: 8px;
  padding: 16px;
  border: 1px solid rgba(23, 33, 27, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.source-card.online {
  background:
    linear-gradient(135deg, rgba(222, 242, 232, 0.8), rgba(255, 255, 255, 0.5)),
    rgba(255, 255, 255, 0.5);
}

.source-card.attention {
  background:
    linear-gradient(135deg, rgba(255, 239, 199, 0.62), rgba(255, 255, 255, 0.5)),
    rgba(255, 255, 255, 0.5);
}

.source-card header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.source-card p {
  margin: 0;
  font-weight: 900;
}

.status-dot {
  width: 11px;
  height: 11px;
  border-radius: 999px;
  background: var(--amber);
  box-shadow: 0 0 0 6px rgba(168, 102, 22, 0.12);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(47, 125, 92, 0.13);
}

.source-contract code {
  max-width: 150px;
  white-space: normal;
  text-align: right;
}

.check-list {
  display: grid;
  gap: 10px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.check-list li, .item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
}

.ledger-line code {
  color: var(--green);
}

.check-list b { color: var(--green); }
.check-list b.warn { color: var(--amber); }
.check-list b.bad { color: var(--red); }

.storage-readiness {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.storage-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(225, 239, 251, 0.72), rgba(255, 255, 255, 0.46));
}

.storage-planes {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.35fr);
  gap: 10px;
}

.storage-plane {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.36);
}

.storage-plane.ok {
  box-shadow: inset 0 0 0 1px rgba(43, 109, 74, 0.14);
}

.storage-plane.pending {
  box-shadow: inset 0 0 0 1px rgba(161, 106, 37, 0.16);
}

.storage-plane.blocked {
  box-shadow: inset 0 0 0 1px rgba(176, 66, 54, 0.18);
}

.storage-plane-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.storage-head small,
.storage-plane-head small,
.storage-card small {
  display: block;
  margin-top: 4px;
}

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

.storage-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.46);
}

.storage-card.ok {
  background: rgba(223, 241, 232, 0.72);
}

.storage-card.pending {
  background: rgba(255, 241, 207, 0.72);
}

.storage-card.blocked {
  background: rgba(249, 223, 220, 0.72);
}

.storage-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.rules-readiness {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.rules-readiness.ok {
  background: linear-gradient(135deg, rgba(223, 241, 232, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-readiness.pending {
  background: linear-gradient(135deg, rgba(247, 229, 198, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-readiness.blocked {
  background: linear-gradient(135deg, rgba(246, 216, 209, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-governance {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(225, 239, 251, 0.64), rgba(255, 255, 255, 0.48));
}

.rules-governance.ok {
  background: linear-gradient(135deg, rgba(223, 241, 232, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-governance.pending,
.rules-governance.planned {
  background: linear-gradient(135deg, rgba(247, 229, 198, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-governance.blocked {
  background: linear-gradient(135deg, rgba(246, 216, 209, 0.82), rgba(255, 255, 255, 0.48));
}

.rules-readiness-head,
.rule-card,
.rule-diagnostic {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.rules-readiness-head {
  align-items: start;
}

.rules-kpis,
.rules-checks {
  display: grid;
  gap: 8px;
}

.rules-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.rules-kpis span,
.rule-check {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.rules-kpis small,
.rule-check small {
  display: block;
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.rules-kpis strong,
.rule-check strong {
  display: block;
  margin-top: 5px;
}

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

.governance-grid {
  display: grid;
  gap: 8px;
}

.governance-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.governance-card.ok {
  background: rgba(223, 241, 232, 0.72);
}

.governance-card.pending,
.governance-card.planned {
  background: rgba(255, 241, 207, 0.72);
}

.governance-card.blocked {
  background: rgba(249, 223, 220, 0.72);
}

.governance-card strong,
.governance-card small,
.governance-card em {
  display: block;
  line-height: 1.35;
}

.governance-card em,
.rules-governance-note {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.governance-icon {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 30px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.governance-icon.ok {
  background: var(--green-soft);
  color: var(--green);
}

.governance-icon.pending,
.governance-icon.planned {
  background: var(--amber-soft);
  color: var(--amber);
}

.governance-icon.blocked {
  background: var(--red-soft);
  color: var(--red);
}

.rule-check.ok {
  background: rgba(223, 241, 232, 0.72);
}

.rule-check.pending {
  background: rgba(255, 241, 207, 0.72);
}

.rule-check.blocked {
  background: rgba(249, 223, 220, 0.72);
}

.rule-check em {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  line-height: 1.35;
}

.rule-card,
.rule-diagnostic {
  position: relative;
  align-items: center;
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.42);
}

.rule-card.ok {
  border-color: rgba(47, 125, 92, 0.22);
}

.rule-card.pending {
  border-color: rgba(168, 102, 22, 0.24);
}

.rule-card.blocked,
.rule-diagnostic {
  border-color: rgba(170, 63, 46, 0.24);
}

.rule-card small {
  display: block;
  margin-top: 4px;
  line-height: 1.35;
}

.rule-card-status {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.close-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.close-summary span {
  padding: 12px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.46);
}

.close-summary small,
.close-check small {
  display: block;
  line-height: 1.35;
}

.close-summary small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.close-summary strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
}

.close-check {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(23, 33, 27, 0.09);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.close-check.ok {
  background: linear-gradient(135deg, rgba(223, 241, 232, 0.82), rgba(255, 255, 255, 0.48));
}

.close-check.attention {
  background: linear-gradient(135deg, rgba(247, 229, 198, 0.82), rgba(255, 255, 255, 0.48));
}

.close-check.blocked {
  background: linear-gradient(135deg, rgba(246, 216, 209, 0.82), rgba(255, 255, 255, 0.48));
}

.close-check code {
  color: var(--blue);
  font-weight: 900;
}

.close-action {
  padding: 9px 12px;
  font-size: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(24, 36, 29, 0.08);
  color: #2c3a31;
  font-size: 12px;
  font-weight: 900;
}

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 8px; border-bottom: 1px solid rgba(23, 33, 27, 0.1); text-align: left; font-size: 13px; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; font-size: 11px; }
td.money { font-family: Palatino, Georgia, serif; font-weight: 900; }

.stack { display: grid; gap: 10px; }
.stack.compact { max-height: 330px; overflow: auto; padding: 2px; }
.item code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--blue); }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  padding: 14px 16px;
  border-radius: 18px;
  background: #18241d;
  color: #fff8e8;
  box-shadow: var(--shadow);
  transform: translateY(24px);
  opacity: 0;
  transition: 180ms ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: relative; height: auto; display: flex; align-items: center; gap: 16px; padding: 14px; }
  .brand-mark { width: 50px; height: 50px; }
  nav { display: flex; margin: 0; overflow-x: auto; }
  nav a { writing-mode: initial; transform: none; padding: 10px 12px; }
  .hero, .split, .wide-left, .grid.metrics, .summary-grid { grid-template-columns: 1fr; }
  .workflow-steps li { grid-template-columns: 34px minmax(0, 1fr); }
  .workflow-steps button { grid-column: 1 / -1; }
  .summary-grid div:first-child { grid-column: auto; }
  .storage-planes { grid-template-columns: 1fr; }
  .storage-grid { grid-template-columns: 1fr; }
  main { padding-top: 22px; }
}

/* Polo operations skin: shared visual grammar with Fatturazione and Magazzino. */
:root {
  --bg: var(--polo-bg, #f7f7f7);
  --nav: var(--bg);
  --nav-2: var(--polo-surface-2, #f0f0f0);
  --surface: var(--polo-surface, #ffffff);
  --surface-2: var(--polo-surface-2, #f0f0f0);
  --text: var(--polo-text, #171717);
  --muted: var(--polo-muted, #666666);
  --line: var(--polo-line, #d8d8d8);
  --accent: var(--polo-primary, #126a72);
  --accent-2: var(--polo-accent, #1c5d99);
  --green: var(--polo-success, #137047);
  --green-bg: color-mix(in srgb, var(--polo-success, #137047) 14%, var(--surface));
  --amber: var(--polo-warning, #8a5d00);
  --amber-bg: color-mix(in srgb, var(--polo-warning, #8a5d00) 16%, var(--surface));
  --red: var(--polo-danger, #aa3528);
  --red-bg: color-mix(in srgb, var(--polo-danger, #aa3528) 14%, var(--surface));
  --blue: var(--polo-accent, #1c5d99);
  --blue-bg: color-mix(in srgb, var(--polo-accent, #1c5d99) 14%, var(--surface));
  --ink: var(--text);
  --paper: var(--bg);
  --panel: var(--surface);
  --panel-strong: var(--surface);
  --green-soft: var(--green-bg);
  --amber-soft: var(--amber-bg);
  --red-soft: var(--red-bg);
  --shadow: var(--polo-shadow-sm, 0 1px 2px rgba(18, 26, 32, 0.06));
  --radius: var(--polo-radius-md, 8px);
  --container-pad: var(--polo-space-lg, 20px);
  --panel-pad: var(--polo-space-md, 14px);
  --cell-pad-y: 10px;
  --cell-pad-x: 12px;
  font-family: var(--polo-font-ui, Inter, Avenir Next, Segoe UI, sans-serif);
}

body {
  color: var(--text);
  background: var(--bg);
  font-family: var(--polo-font-ui, Inter, Avenir Next, Segoe UI, sans-serif);
}

body::before { display: none; }

.shell {
  grid-template-columns: 268px minmax(0, 1fr);
  background: var(--bg);
}

body.shellEmbedded .shell {
  min-height: 100vh;
  grid-template-columns: minmax(0, 1fr);
}

body.shellEmbedded .rail {
  display: none;
}

body.shellEmbedded main {
  padding: var(--polo-space-sm, 8px);
}

.rail {
  padding: 18px 14px;
  border-right: 0;
  background: var(--bg);
  color: var(--text);
  backdrop-filter: none;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #f2c14e;
  color: var(--nav);
  box-shadow: none;
  letter-spacing: -0.04em;
}

nav {
  gap: 4px;
  margin-top: 22px;
}

nav a {
  display: flex;
  align-items: center;
  min-height: 36px;
  padding: 10px 12px;
  border-radius: 6px;
  color: #c6d0d6;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
  writing-mode: horizontal-tb;
  transform: none;
}

nav a.active,
nav a:hover {
  color: #ffffff;
  background: var(--nav-2);
}

main {
  width: 100%;
  margin: 0;
  padding: 22px;
}

.hero {
  grid-template-columns: minmax(0, 1fr) 270px;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

h1,
h2 {
  line-height: 1.1;
  letter-spacing: -0.02em;
}

h1 {
  max-width: none;
  font-size: 30px;
}

h2 {
  font-size: 16px;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.12em;
}

.hero-copy {
  max-width: 860px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.hero-card,
.panel,
.metric,
.toolbar,
.source-card,
.item,
.summary-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: none;
}

.hero-card {
  min-height: 84px;
  padding: 14px;
  align-items: center;
}

.pulse {
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(19, 112, 71, 0.12);
}

.toolbar {
  margin: 0 0 14px;
  padding: 12px;
  gap: 8px;
  align-items: center;
}

.appearance-controls {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.appearance-segment {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.appearance-button {
  min-height: 32px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.appearance-button:last-child {
  border-right: 0;
}

.appearance-button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  color: var(--accent);
}

.appearance-density {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 750;
}

button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

button:hover {
  border-color: rgba(18, 106, 114, 0.45);
  transform: none;
}

.switch,
.locale-switch {
  min-height: 36px;
  border-radius: 6px;
  background: var(--surface-2);
}

.locale-button {
  min-height: 28px;
  padding: 5px 9px;
}

.locale-button.active {
  background: var(--nav);
  color: #ffffff;
}

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

.metric {
  min-height: 118px;
  padding: 14px;
}

.metric::after { display: none; }

.metric span,
.metric small {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  margin: 8px 0;
  color: var(--text);
  font-size: 28px;
  letter-spacing: -0.04em;
}

.split {
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 14px;
  margin-bottom: 14px;
}

.wide-left {
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
}

.panel {
  padding: var(--panel-pad);
}

.panel-head {
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 11px;
  letter-spacing: 0.05em;
}

.badge.pending {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.bad {
  background: var(--red-bg);
  color: var(--red);
}

.workflow-steps {
  gap: 8px;
}

.workflow-steps li {
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.workflow-steps strong,
.source-card p {
  color: var(--text);
  font-weight: 760;
}

.workflow-steps small {
  color: var(--muted);
  font-weight: 500;
  line-height: 1.35;
}

.step-index {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--nav);
  color: #ffffff;
  font-size: 12px;
  box-shadow: none;
}

.summary-grid {
  gap: 10px;
}

.summary-grid div {
  min-height: 86px;
  padding: 14px;
}

.summary-grid div:first-child {
  background: var(--nav);
  color: #ffffff;
}

.summary-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  letter-spacing: -0.04em;
}

.source-coordination {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.source-grid {
  gap: 10px;
}

.source-card {
  gap: 7px;
  padding: 12px;
}

.source-card.online {
  background: var(--green-bg);
  border-color: rgba(19, 112, 71, 0.2);
}

.source-card.attention {
  background: var(--amber-bg);
  border-color: rgba(138, 93, 0, 0.22);
}

.status-dot {
  width: 9px;
  height: 9px;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(138, 93, 0, 0.12);
}

.status-dot.ok {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(19, 112, 71, 0.13);
}

.compatibility-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.compatibility-head strong {
  font-size: 14px;
}

.compatibility-list {
  margin-top: 10px;
}

.compatibility-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.compatibility-row.ok {
  border-color: rgba(19, 112, 71, 0.2);
}

.compatibility-row.attention {
  border-color: rgba(138, 93, 0, 0.24);
}

.compatibility-row code {
  color: var(--accent-2);
}

.ledger-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-bottom: 12px;
}

.ledger-filter label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.ledger-filter select {
  min-height: 36px;
  min-width: 210px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  text-transform: none;
  letter-spacing: 0;
}

.source-coordination .stack.compact {
  max-height: none;
  overflow: visible;
}

.reference-node {
  position: relative;
  outline: none;
  cursor: help;
  isolation: isolate;
}

.reference-node:focus-visible {
  outline: 2px solid rgba(18, 106, 114, 0.48);
  outline-offset: 3px;
}

.reference-node:hover,
.reference-node:focus,
.reference-node:focus-within {
  z-index: 60;
}

.reference-widget {
  position: absolute;
  left: 12px;
  top: calc(100% + 8px);
  z-index: 40;
  display: grid;
  gap: 8px;
  min-width: min(360px, calc(100vw - 48px));
  max-width: 420px;
  padding: 12px;
  border: 1px solid rgba(18, 26, 32, 0.12);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 18px 50px rgba(18, 26, 32, 0.18);
  opacity: 0;
  transform: translateY(-4px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
}

.source-contract .reference-widget,
.compatibility-row .reference-widget {
  right: 10px;
  left: auto;
  transform-origin: top right;
}

.reference-node:hover .reference-widget,
.reference-node:focus .reference-widget,
.reference-node:focus-within .reference-widget {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.reference-widget strong {
  font-size: 13px;
  letter-spacing: -0.01em;
}

.reference-widget span {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
}

.reference-widget small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.reference-widget code {
  min-width: 0;
  color: var(--accent-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: left;
}

.check-list li,
.item {
  padding: var(--cell-pad-y) var(--cell-pad-x);
  border-color: var(--line);
}

.rules-readiness,
.rules-governance,
.rule-card,
.rule-diagnostic {
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.rules-readiness.ok {
  background: var(--green-bg);
  border-color: rgba(19, 112, 71, 0.2);
}

.rules-readiness.pending {
  background: var(--amber-bg);
  border-color: rgba(138, 93, 0, 0.22);
}

.rules-readiness.blocked {
  background: var(--red-bg);
  border-color: rgba(170, 53, 40, 0.22);
}

.rules-governance.ok {
  background: var(--green-bg);
  border-color: rgba(19, 112, 71, 0.2);
}

.rules-governance.pending,
.rules-governance.planned {
  background: var(--amber-bg);
  border-color: rgba(138, 93, 0, 0.22);
}

.rules-governance.blocked {
  background: var(--red-bg);
  border-color: rgba(170, 53, 40, 0.22);
}

.rules-kpis span,
.rule-check,
.governance-card {
  border-color: var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.governance-card.ok {
  background: var(--green-bg);
}

.governance-card.pending,
.governance-card.planned {
  background: var(--amber-bg);
}

.governance-card.blocked {
  background: var(--red-bg);
}

.rule-card.ok {
  background: var(--green-bg);
  border-color: rgba(19, 112, 71, 0.2);
}

.rule-card.pending {
  background: var(--amber-bg);
  border-color: rgba(138, 93, 0, 0.22);
}

.rule-card.blocked,
.rule-diagnostic {
  background: var(--red-bg);
  border-color: rgba(170, 53, 40, 0.22);
}

.chip {
  border-radius: 999px;
  background: var(--blue-bg);
  color: var(--blue);
}

.table-wrap {
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  padding: var(--panel-pad);
  background: transparent;
}

table {
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

th,
td {
  padding: var(--cell-pad-y) var(--cell-pad-x);
  border-bottom: 1px solid var(--line);
}

tr:last-child td {
  border-bottom: 0;
}

th {
  color: var(--muted);
  font-size: 11px;
}

td.money {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 750;
}

.toast {
  border-radius: var(--radius);
  background: var(--nav);
  box-shadow: 0 8px 30px rgba(18, 26, 32, 0.18);
}

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

  .rail {
    position: relative;
    height: auto;
    align-items: center;
    overflow: hidden;
  }

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

  nav {
    display: flex;
    margin: 0;
    overflow-x: auto;
  }

  nav a {
    white-space: nowrap;
  }

  main {
    padding: 16px;
  }

  .hero,
  .split,
  .wide-left,
  .grid.metrics,
  .source-coordination,
  .summary-grid,
  .close-summary {
    grid-template-columns: 1fr;
  }

  .close-check {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .rules-kpis,
  .rules-checks,
  .governance-card,
  .rule-card,
  .rule-diagnostic {
    grid-template-columns: 1fr;
  }

  .rule-card,
  .rule-diagnostic {
    display: grid;
  }

  .rule-card-status {
    justify-items: start;
  }

  .close-check code,
  .close-action {
    grid-column: 1 / -1;
  }

  .workflow-steps li {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .workflow-steps button {
    grid-column: 1 / -1;
  }
}

/* Accounting workspace pass: make the journal book the product center, not the telemetry. */
main {
  display: flex;
  flex-direction: column;
}

.accounting-hero { order: 0; }
.toolbar { order: 1; }
.primary-ledger { order: 2; }
.workflow-row { order: 3; }
.accounts-rules-row { order: 4; }
.sources-row { order: 5; }
.close-row { order: 6; }
.system-metrics { order: 7; }
.controls-row { order: 8; }

.accounting-hero {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) + 4px);
  padding: 18px;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface-2) 72%, transparent)),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--text) 5%, transparent) 0 1px, transparent 1px 34px);
}

.accounting-hero::after {
  content: "";
  position: absolute;
  inset: 12px auto 12px 48%;
  width: 1px;
  background: rgba(18, 106, 114, 0.18);
}

.accounting-hero h1 {
  font-size: clamp(32px, 5vw, 68px);
  letter-spacing: -0.045em;
}

.primary-ledger {
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.55fr);
  align-items: start;
}

.primary-ledger .panel {
  border-color: rgba(18, 106, 114, 0.22);
}

.primary-ledger #ledger {
  background:
    linear-gradient(90deg, transparent 0 116px, color-mix(in srgb, var(--accent) 10%, transparent) 116px 117px, transparent 117px),
    repeating-linear-gradient(0deg, color-mix(in srgb, var(--text) 4%, transparent) 0 1px, transparent 1px 38px),
    var(--surface);
}

.journal-register {
  border-collapse: separate;
  border-spacing: 0 8px;
}

.journal-register thead th {
  border-bottom: 1px solid var(--line);
  color: var(--accent);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.journal-register .entry-main td {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 86%, transparent);
}

.journal-register .entry-main td:first-child {
  border-left: 1px solid var(--line);
  border-radius: 8px 0 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 850;
}

.journal-register .entry-main td:last-child {
  border-right: 1px solid var(--line);
  border-radius: 0 8px 8px 0;
}

.entry-lines-row td {
  padding: 0 0 8px;
  border: 0;
}

.journal-lines {
  display: grid;
  gap: 6px;
  margin: -6px 0 4px 26px;
  padding: 10px;
  border-left: 3px solid rgba(18, 106, 114, 0.28);
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
}

.journal-causale {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line);
}

.journal-causale small,
.dossier-grid dt {
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.journal-line {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 82px 128px;
  gap: 10px;
  align-items: center;
  min-height: 32px;
}

.journal-line code {
  color: var(--accent-2);
  font-weight: 850;
}

.journal-line strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.journal-line em {
  color: var(--muted);
  font-style: normal;
  text-transform: uppercase;
}

.journal-line b {
  justify-self: end;
  color: var(--text);
}

.journal-line.debit {
  border-left: 3px solid var(--green);
  padding-left: 8px;
}

.journal-line.credit {
  border-left: 3px solid var(--accent-2);
  padding-left: 8px;
}

.document-dossier {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(18, 106, 114, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--blue-bg) 80%, transparent), color-mix(in srgb, var(--surface) 90%, transparent)),
    var(--surface);
}

.dossier-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.dossier-head small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.dossier-head strong {
  font-size: 18px;
}

.dossier-grid {
  display: grid;
  gap: 8px;
  margin: 0;
}

.dossier-grid div {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.dossier-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 760;
}

.dossier-empty {
  color: var(--muted);
  line-height: 1.45;
}

.system-metrics {
  opacity: 0.78;
}

.system-metrics::before {
  content: none;
}

.metrics-label {
  grid-column: 1 / -1;
  margin: 0 0 -2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.system-metrics .metric {
  min-height: 84px;
}

.system-metrics .metric strong {
  font-size: 22px;
}

@media (max-width: 920px) {
  .accounting-hero::after { display: none; }

  .primary-ledger,
  .workflow-row,
  .accounts-rules-row,
  .sources-row,
  .close-row,
  .controls-row {
    grid-template-columns: 1fr;
  }

  .journal-line {
    grid-template-columns: 66px minmax(0, 1fr);
  }

  .journal-line em,
  .journal-line b {
    justify-self: start;
  }

  .dossier-grid div {
    grid-template-columns: 1fr;
  }
}

/* Enterprise accounting workstation pass: the UI should read like accounting software, not a dev dashboard. */
:root {
  --accounting-bg: var(--polo-bg, #f4f3ef);
  --accounting-surface: var(--polo-surface, #fffefa);
  --accounting-surface-raised: color-mix(in srgb, var(--polo-surface, #ffffff) 88%, #eef2ec);
  --accounting-ink: var(--polo-text, #151917);
  --accounting-muted: var(--polo-muted, #60645f);
  --accounting-line: color-mix(in srgb, var(--polo-line, #d8d8d8) 82%, #8d988f);
  --accounting-accent: var(--polo-primary, #0f6c6e);
  --accounting-accent-2: var(--polo-accent, #275f86);
  --accounting-gold: #b6892b;
  --accounting-ledger: #25342c;
  --accounting-shadow: 0 18px 52px rgba(30, 38, 34, 0.10);
  --accounting-tight-shadow: 0 1px 0 rgba(21, 25, 23, 0.08);
  --radius: var(--polo-radius-md, 10px);
  font-family: var(--polo-font-ui, "Aptos", "Avenir Next", "Segoe UI", sans-serif);
}

body {
  color: var(--accounting-ink);
  background:
    linear-gradient(90deg, rgba(15, 108, 110, 0.035) 0 1px, transparent 1px 28px),
    linear-gradient(0deg, rgba(21, 25, 23, 0.035) 0 1px, transparent 1px 28px),
    radial-gradient(circle at 12% 0%, rgba(182, 137, 43, 0.12), transparent 34rem),
    var(--accounting-bg);
}

.shell {
  grid-template-columns: 284px minmax(0, 1fr);
}

.rail {
  padding: 20px 16px;
  border-right: 1px solid var(--accounting-line);
  background:
    linear-gradient(180deg, rgba(255, 254, 250, 0.92), rgba(238, 239, 234, 0.82)),
    var(--accounting-bg);
}

.brand-mark {
  width: 46px;
  height: 46px;
  background: var(--accounting-ledger);
  color: #fffdf4;
  border: 1px solid rgba(21, 25, 23, 0.18);
}

.rail-title {
  display: grid;
  gap: 2px;
  margin-top: 12px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--accounting-line);
}

.rail-title strong {
  font-size: 15px;
  letter-spacing: -0.02em;
}

.rail-title span {
  color: var(--accounting-muted);
  font-size: 12px;
  font-weight: 760;
}

nav a {
  color: var(--accounting-muted);
  background: transparent;
}

nav a.active,
nav a:hover {
  color: var(--accounting-ink);
  background: var(--accounting-surface);
  box-shadow: var(--accounting-tight-shadow);
}

body.shellEmbedded .shell {
  grid-template-columns: minmax(0, 1fr);
}

body.shellEmbedded main {
  padding: clamp(12px, 2vw, 22px);
}

main {
  max-width: 1680px;
  gap: 14px;
}

.accounting-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 18px;
  margin: 0;
  padding: 22px;
  border: 1px solid var(--accounting-line);
  border-left: 6px solid var(--accounting-accent);
  border-radius: 16px;
  background:
    linear-gradient(120deg, rgba(255, 254, 250, 0.96), rgba(242, 244, 239, 0.86)),
    var(--accounting-surface);
  box-shadow: var(--accounting-shadow);
}

.accounting-hero::after {
  display: none;
}

.accounting-hero .eyebrow {
  color: var(--accounting-gold);
}

.accounting-hero h1 {
  max-width: 760px;
  font-size: clamp(30px, 4.5vw, 58px);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.hero-copy {
  max-width: 780px;
  font-size: 15px;
}

.hero-card {
  min-height: 100%;
  border-radius: 14px;
  background: var(--accounting-ledger);
  color: #fffdf4;
  border-color: rgba(21, 25, 23, 0.18);
}

.hero-card small {
  color: rgba(255, 253, 244, 0.72);
}

.enterprise-context {
  order: 1;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr 1fr 1.1fr;
  gap: 10px;
}

.enterprise-context article {
  display: grid;
  gap: 5px;
  min-height: 96px;
  padding: 14px 16px;
  border: 1px solid var(--accounting-line);
  border-radius: 14px;
  background: var(--accounting-surface);
  box-shadow: var(--accounting-tight-shadow);
}

.enterprise-context span,
.ledger-commandbar small,
.toolbar-title small {
  color: var(--accounting-muted);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.enterprise-context strong {
  font-size: clamp(20px, 2.4vw, 30px);
  letter-spacing: -0.05em;
}

.enterprise-context small {
  color: var(--accounting-muted);
  overflow-wrap: anywhere;
}

.toolbar {
  order: 2;
  display: flex;
  gap: 10px;
  margin: 0;
  border-radius: 14px;
  background: rgba(255, 254, 250, 0.92);
  box-shadow: var(--accounting-tight-shadow);
}

.toolbar-title {
  display: grid;
  gap: 2px;
  min-width: 210px;
  padding-right: 12px;
  border-right: 1px solid var(--accounting-line);
}

.toolbar-title strong {
  font-size: 16px;
  letter-spacing: -0.02em;
}

button.primary {
  border-color: var(--accounting-ledger);
  background: var(--accounting-ledger);
}

.primary-ledger {
  order: 3;
  grid-template-columns: minmax(0, 1.42fr) minmax(360px, 0.58fr);
}

.workflow-row { order: 4; }
.accounts-rules-row { order: 5; }
.close-row { order: 6; }
.sources-row { order: 7; }
.system-metrics { order: 8; }
.controls-row { order: 9; }

.panel,
.metric,
.source-card,
.item,
.summary-grid div,
.workflow-steps li {
  border-color: var(--accounting-line);
  background: var(--accounting-surface);
  box-shadow: var(--accounting-tight-shadow);
}

.panel {
  border-radius: 14px;
}

.panel-head h2 {
  font-size: 18px;
  letter-spacing: -0.03em;
}

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

.ledger-commandbar span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--accounting-line);
  border-radius: 10px;
  background: var(--accounting-surface-raised);
}

.ledger-commandbar strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.primary-ledger #ledger {
  background:
    linear-gradient(90deg, transparent 0 118px, rgba(15, 108, 110, 0.16) 118px 119px, transparent 119px),
    repeating-linear-gradient(0deg, rgba(21, 25, 23, 0.035) 0 1px, transparent 1px 38px),
    var(--accounting-surface);
}

.journal-register .entry-main td {
  background: rgba(255, 254, 250, 0.94);
}

.journal-lines,
.document-dossier {
  background: var(--accounting-surface-raised);
}

.document-dossier {
  border-color: color-mix(in srgb, var(--accounting-accent) 28%, var(--accounting-line));
}

.action-panel,
.operator-panel {
  background: var(--accounting-surface);
}

.workflow-steps li {
  grid-template-columns: 30px minmax(0, 1fr) auto;
  border-radius: 12px;
}

.step-index {
  width: 26px;
  height: 26px;
  background: var(--accounting-accent);
}

.summary-grid div:first-child {
  background: var(--accounting-ledger);
}

.system-metrics,
.controls-row {
  opacity: 0.68;
}

.system-metrics:hover,
.controls-row:hover,
.system-metrics:focus-within,
.controls-row:focus-within {
  opacity: 1;
}

.metrics-label {
  color: var(--accounting-muted);
}

.badge {
  background: color-mix(in srgb, var(--green) 13%, var(--accounting-surface));
}

.badge.pending {
  background: color-mix(in srgb, var(--amber) 13%, var(--accounting-surface));
}

.badge.bad {
  background: color-mix(in srgb, var(--red) 13%, var(--accounting-surface));
}

@media (max-width: 1100px) {
  .enterprise-context,
  .ledger-commandbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .primary-ledger {
    grid-template-columns: 1fr;
  }
}

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

  .rail-title {
    display: none;
  }

  .accounting-hero,
  .enterprise-context,
  .ledger-commandbar,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .toolbar-title {
    min-width: 0;
    width: 100%;
    padding: 0 0 10px;
    border-right: 0;
    border-bottom: 1px solid var(--accounting-line);
  }

  .enterprise-context article {
    min-height: auto;
  }
}

/* Enterprise workstation density pass: compact fiscal context before the books. */
.accounting-hero {
  align-items: center;
  padding: 16px 18px;
}

.accounting-hero h1 {
  font-size: clamp(28px, 3.6vw, 46px);
}

.hero-copy {
  max-width: 920px;
  margin-bottom: 0;
}

.hero-card {
  min-height: 64px;
  align-self: stretch;
}

.enterprise-context {
  grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.enterprise-context article {
  min-height: 72px;
  padding: 11px 13px;
}

.enterprise-context strong {
  font-size: clamp(16px, 1.5vw, 22px);
}

.toolbar {
  align-items: center;
  padding: 10px;
}

.toolbar button,
.toolbar .switch,
.locale-switch {
  min-height: 36px;
}

.primary-ledger .panel {
  min-height: 360px;
}

.ledger-commandbar {
  grid-template-columns: repeat(4, minmax(128px, 1fr));
  margin-bottom: 10px;
}

.ledger-commandbar span {
  min-height: 54px;
  padding: 9px 12px;
}

body.shellEmbedded main {
  gap: 10px;
}

body.shellEmbedded .accounting-hero {
  grid-template-columns: minmax(0, 1fr) minmax(210px, 280px);
}

body.shellEmbedded .enterprise-context,
body.shellEmbedded .ledger-commandbar {
  grid-template-columns: repeat(4, minmax(142px, 1fr));
}

@media (max-width: 760px) {
  .accounting-hero,
  body.shellEmbedded .accounting-hero {
    grid-template-columns: 1fr;
  }

  .enterprise-context,
  body.shellEmbedded .enterprise-context,
  .ledger-commandbar,
  body.shellEmbedded .ledger-commandbar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    scroll-snap-type: x proximity;
  }

  .enterprise-context article,
  .ledger-commandbar span {
    flex: 0 0 176px;
    scroll-snap-align: start;
  }

  .toolbar {
    align-items: stretch;
  }

  .toolbar-title {
    width: 100%;
  }
}

/* Modern app shell pass: sidebar navigation with dedicated accounting pages. */
[hidden] {
  display: none !important;
}

.accounting-shell {
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100vh;
  overflow: auto;
}

body.shellEmbedded .shell {
  grid-template-columns: minmax(238px, 276px) minmax(0, 1fr);
}

body.shellEmbedded .rail {
  display: flex;
}

.rail nav {
  display: grid;
  gap: 8px;
  margin-top: 6px;
}

.rail nav a {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 8px 10px;
  align-items: center;
  min-height: 58px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--accounting-muted);
  text-decoration: none;
  writing-mode: horizontal-tb;
  transform: none;
}

.rail nav a span:not(.nav-icon) {
  color: inherit;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.rail nav a small {
  grid-column: 2;
  color: color-mix(in srgb, var(--accounting-muted) 84%, transparent);
  font-size: 11px;
  font-weight: 720;
}

.rail nav a.active,
.rail nav a:hover,
.rail nav a:focus-visible {
  border-color: color-mix(in srgb, var(--accounting-accent) 24%, var(--accounting-line));
  color: var(--accounting-ink);
  background: linear-gradient(135deg, rgba(255, 254, 250, 0.98), rgba(238, 244, 240, 0.92));
  box-shadow: 0 12px 32px rgba(21, 25, 23, 0.08);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: color-mix(in srgb, var(--accounting-accent) 12%, var(--accounting-surface));
  color: var(--accounting-accent);
  font-size: 11px;
  font-weight: 950;
  letter-spacing: -0.03em;
}

.rail nav a.active .nav-icon,
.rail nav a:hover .nav-icon {
  background: var(--accounting-ledger);
  color: #fffdf4;
}

.app-pagebar {
  order: -2;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 18px 20px;
  border: 1px solid var(--accounting-line);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 254, 250, 0.98), rgba(239, 242, 236, 0.86)),
    var(--accounting-surface);
  box-shadow: var(--accounting-tight-shadow);
}

.app-pagebar .eyebrow {
  color: var(--accounting-gold);
}

.app-pagebar h1 {
  margin: 0;
  font-size: clamp(28px, 3.2vw, 44px);
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.app-pagebar p:last-child {
  max-width: 820px;
  margin: 8px 0 0;
  color: var(--accounting-muted);
  font-size: 14px;
}

.pagebar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

[data-page].is-active-page {
  animation: accounting-page-enter 180ms ease-out;
}

@keyframes accounting-page-enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.appPaged .enterprise-context,
body.appPaged .toolbar {
  position: sticky;
  z-index: 4;
}

body.appPaged .enterprise-context {
  top: 10px;
}

body.appPaged .toolbar {
  top: 98px;
}

body.appPaged .system-metrics,
body.appPaged .controls-row {
  opacity: 1;
}

@media (max-width: 980px) {
  body.shellEmbedded .shell,
  .shell {
    grid-template-columns: 1fr;
  }

  .rail,
  body.shellEmbedded .rail {
    position: sticky;
    top: 0;
    z-index: 12;
    height: auto;
    max-height: none;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--accounting-line);
    background: color-mix(in srgb, var(--accounting-bg) 92%, white);
  }

  .brand-mark,
  .rail-title {
    display: none;
  }

  .rail nav {
    display: flex;
    gap: 8px;
    margin: 0;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .rail nav a {
    flex: 0 0 156px;
  }

  .app-pagebar {
    grid-template-columns: 1fr;
  }

  .pagebar-actions {
    justify-content: flex-start;
  }

  body.appPaged .enterprise-context,
  body.appPaged .toolbar {
    position: static;
  }
}
