:root {
  color: #172237;
  background: #f6f8fb;
  font:
    15px/1.5 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  --ink: #172237;
  --muted: #57677d;
  --soft: #f1f4f9;
  --line: #dfe5ee;
  --blue: #244bd4;
  --blue-soft: #eaf0ff;
  --white: #fff;
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
  color: inherit;
}
button,
summary {
  cursor: pointer;
}
a {
  color: var(--blue);
  text-decoration: none;
}
:focus-visible {
  outline: 3px solid #6683ff;
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}
.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
}
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 21px;
  background: #edf2f8;
  padding: 26px 18px 17px;
  border-right: 1px solid #dce4ee;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 7px;
  font-size: 19px;
  font-weight: 750;
  letter-spacing: -0.6px;
}
.brand-mark,
.paper-logo {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #496ff4, #2448cf);
  color: white;
  font-weight: 740;
  box-shadow: 0 3px 7px #15377826;
}
.company-picker {
  position: relative;
}
.company-picker summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  background: #fff;
  border: 1px solid #dce4ee;
  border-radius: 12px;
  list-style: none;
  box-shadow: 0 2px 5px #15326008;
}
.company-picker summary::-webkit-details-marker {
  display: none;
}
.company-avatar,
.profile-avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-weight: 720;
  color: #2444a6;
  background: #e4ebfa;
}
.company-avatar[data-variant="sk"],
.paper-logo[data-variant="sk"] {
  background: #dcf0e9;
  color: #226650;
}
.company-label,
.profile > span:last-child {
  min-width: 0;
  display: grid;
  gap: 0;
  line-height: 1.35;
}
.company-label strong,
.profile strong {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-label small,
.profile small {
  color: var(--muted);
  font-size: 11px;
}
.switch-mark {
  color: var(--muted);
  text-align: center;
  margin-left: auto;
  line-height: 7px;
  font-weight: 700;
  padding: 2px;
}
.company-menu {
  position: absolute;
  z-index: 3;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  box-shadow: 0 9px 28px #14264b20;
  padding: 5px;
}
.company-menu button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 5px;
  width: 100%;
  padding: 8px;
  border: 0;
  border-radius: 7px;
  background: white;
  font-size: 12px;
}
.company-menu button:hover,
.company-menu button[aria-pressed="true"] {
  background: var(--blue-soft);
}
.company-menu small {
  color: var(--muted);
}
.nav {
  display: grid;
  align-content: start;
  gap: 4px;
}
.nav a {
  color: #33445e;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 570;
  min-height: 35px;
}
.nav a [data-nav-icon] {
  width: 19px;
  flex: 0 0 19px;
  display: inline-block;
  text-align: center;
  font-size: 17px;
  line-height: 1;
  color: #61728c;
}
.nav a [data-nav-label] {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.nav a:hover {
  background: #e3eaf5;
}
.nav a[aria-current="page"] {
  background: #dce7fb;
  color: #2348ad;
  font-weight: 700;
}
.nav a[aria-current="page"] span {
  color: #2348ad;
}
.nav-label {
  padding: 9px 10px 0;
  color: #536780;
  font-size: 11px;
  font-weight: 680;
}
.profile {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: auto;
  padding: 12px 5px 2px;
  border-top: 1px solid #dce4ee;
}
.profile-avatar {
  border-radius: 50%;
  width: 31px;
  height: 31px;
  font-size: 11px;
  background: #e1e9f5;
}
.main {
  min-width: 0;
}
.topbar {
  min-height: 67px;
  display: flex;
  gap: 15px;
  justify-content: space-between;
  align-items: center;
  padding: 9px clamp(18px, 3.2vw, 50px);
  border-bottom: 1px solid var(--line);
  background: #fcfdff;
}
.breadcrumb,
.header-actions {
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 13px;
}
.header-actions {
  gap: 16px;
}
.breadcrumb span,
.demo-tag {
  color: var(--muted);
}
.breadcrumb strong {
  font-weight: 650;
}
.demo-tag {
  white-space: nowrap;
  font-size: 11px;
  font-weight: 590;
}
.button {
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 38px;
  padding: 7px 13px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 680;
}
.button span {
  font-size: 16px;
  line-height: 1;
}
.primary {
  color: white;
  background: var(--blue);
  box-shadow: 0 2px 4px #2339a024;
}
.primary:hover {
  background: #1b3fbe;
}
.secondary {
  color: #34445b;
  border-color: var(--line);
  background: white;
}
.secondary:hover {
  background: #f1f5fb;
}
.screen {
  padding: 29px clamp(18px, 3.2vw, 50px) 32px;
  max-width: 1460px;
  margin: 0 auto;
}
.intro {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 21px;
}
.intro h1 {
  margin: 0;
  font-size: clamp(28px, 3.45vw, 41px);
  line-height: 1.14;
  letter-spacing: -0.045em;
  font-weight: 735;
}
.intro p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}
.intro p strong {
  color: var(--ink);
  font-weight: 630;
}
.intro > .button {
  margin-bottom: 1px;
}
.card,
.metric {
  background: white;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 1px 3px #172c5406;
}
.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 13px;
  margin-bottom: 17px;
}
.metric {
  padding: 12px 15px;
}
.metric small,
.metric p {
  color: var(--muted);
  font-size: 12px;
}
.metric strong {
  margin: 1px 0 0;
  display: block;
  font-size: clamp(17px, 2.2vw, 26px);
  letter-spacing: -0.035em;
  font-weight: 715;
  font-variant-numeric: tabular-nums;
}
.metric p {
  margin: 2px 0 0;
}
.metric.is-late strong {
  color: #9c3835;
}
.documents-card {
  overflow: hidden;
}
.toolbar {
  min-height: 60px;
  padding: 11px 14px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
}
.filter-group {
  border: 1px solid #e4eaf4;
  background: #f0f3f8;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  padding: 3px;
  gap: 2px;
}
.filter-group button {
  white-space: nowrap;
  border: 0;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 650;
  padding: 6px 8px;
  color: #4f6079;
  background: transparent;
  min-height: 29px;
}
.filter-group button:hover {
  color: var(--blue);
}
.filter-group button[aria-pressed="true"] {
  background: white;
  color: var(--blue);
  box-shadow: 0 1px 3px #1b386426;
}
.search {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #5f728e;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 0 9px;
  width: min(100%, 229px);
  font-size: 18px;
  line-height: 1;
}
.search input {
  padding: 8px 0;
  width: 100%;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 12px;
}
.search:focus-within {
  outline: 2px solid #6683ff;
  outline-offset: 2px;
}
.search input:focus {
  outline: 0;
}
.search input::placeholder {
  color: #606f85;
}
.table-scroll {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
th {
  background: #f5f7fa;
  color: #53647b;
  text-align: left;
  font-size: 11px;
  font-weight: 680;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
th,
td {
  padding: 10px 11px;
}
td {
  border-bottom: 1px solid #edf0f5;
}
th:first-child,
td:first-child {
  padding-left: 15px;
}
th:last-child,
td:last-child {
  padding-right: 15px;
}
tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fafcff;
}
.amount,
.table-date {
  font-variant-numeric: tabular-nums;
}
td.amount {
  font-weight: 680;
}
.amount {
  text-align: right;
}
.number-link {
  padding: 1px 0;
  border: 0;
  background: transparent;
  color: #2446b2;
  font-weight: 690;
  font-variant-numeric: tabular-nums;
}
.number-link:hover {
  text-decoration: underline;
}
.table-date,
.cell-caption {
  color: #57677d;
}
.cell-caption {
  display: block;
  font-size: 11px;
  font-weight: 450;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 20px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.45;
  font-weight: 670;
  vertical-align: middle;
  white-space: nowrap;
}
.badge.status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge.blue {
  color: #2846a5;
  background: #e9eeff;
}
.badge.green {
  color: #206249;
  background: #e5f5ed;
}
.badge.red {
  color: #8d3634;
  background: #fae9e8;
}
.badge.amber {
  color: #795017;
  background: #f9f0dd;
}
.badge.gray {
  color: #4c5e77;
  background: #eef1f6;
}
.table-footer {
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 15px;
  color: var(--muted);
  font-size: 11px;
}
.row-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.row-action button {
  min-height: 28px;
  padding: 2px 5px;
  font-size: 12px;
  font-weight: 660;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #2446b2;
}
.row-action button:hover {
  background: var(--blue-soft);
}
.empty {
  color: var(--muted);
  text-align: center;
  padding: 26px;
}
.overview-card {
  padding-bottom: 19px;
}
.card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 19px;
}
.card-heading h2,
.access-card h2,
.field-card h2 {
  font-size: 17px;
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.02em;
}
.card-heading p,
.access-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}
.chart {
  height: 234px;
  display: flex;
  justify-content: space-evenly;
  margin: 14px 20px 0;
  background: repeating-linear-gradient(to top, #e9eef6 0 1px, #fff 1px 25%);
  border-bottom: 1px solid var(--line);
  padding: 0 5%;
  gap: 7px;
}
.chart div {
  display: flex;
  gap: 3px;
  align-items: end;
  justify-content: center;
  width: 60px;
  height: 100%;
  position: relative;
}
.chart i,
.chart b {
  display: block;
  width: 21px;
  border-radius: 5px 5px 0 0;
}
.chart i {
  height: var(--h);
  background: #a4b8fa;
}
.chart b {
  height: var(--p);
  background: #3459d4;
}
.chart div span {
  position: absolute;
  bottom: -24px;
  color: var(--muted);
  font-size: 11px;
}
.legend {
  display: flex;
  gap: 17px;
  justify-content: center;
  margin-top: 36px;
  color: var(--muted);
  font-size: 12px;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.legend i {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  background: #a4b8fa;
}
.legend span + span i {
  background: #3459d4;
}
.back {
  display: inline-flex;
  margin: 0 0 9px;
  font-size: 12px;
  font-weight: 660;
}
.dot-separator {
  margin: 0 2px;
}
.editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 1fr);
  align-items: start;
  gap: 15px;
}
.editor-fields {
  display: grid;
  gap: 12px;
}
.field-card {
  padding: 15px;
}
.field-card h2 {
  margin: 0 0 12px;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.fields .span {
  grid-column: 1 / -1;
}
.fields label {
  display: grid;
  min-width: 0;
  gap: 4px;
}
.fields label span {
  color: #435570;
  font-size: 12px;
  font-weight: 650;
}
.fields input,
.fields select {
  min-width: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 8px;
  background: #fcfdff;
  font-size: 13px;
  height: 38px;
}
.tax-panel {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  margin-top: 11px;
  padding: 9px 10px;
  border-radius: 8px;
  background: #eef3ff;
  color: #254794;
}
.tax-panel[data-review="true"] {
  background: #faf2e4;
  color: #765015;
}
.tax-icon {
  background: #e0e9ff;
  min-width: 24px;
  height: 24px;
  border-radius: 6px;
  text-align: center;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 750;
}
.tax-panel[data-review="true"] .tax-icon {
  background: #f2e5ce;
}
.tax-panel strong {
  font-size: 13px;
}
.tax-panel p {
  margin: 1px 0 0;
  font-size: 11px;
  line-height: 1.35;
}
.item-fields {
  grid-template-columns: minmax(78px, 1fr) minmax(49px, 0.31fr) minmax(
      72px,
      0.45fr
    );
}
.item-footer {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  padding-top: 9px;
  border-top: 1px solid #edf0f5;
  font-size: 12px;
  color: var(--muted);
}
.item-footer strong {
  color: var(--ink);
}
.preview-card {
  overflow: hidden;
}
.preview-header {
  padding: 12px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.preview-header a {
  font-size: 11px;
  font-weight: 650;
}
.paper-wrap {
  background: #eef2f8;
  padding: 13px;
}
.paper {
  min-height: 377px;
  background: white;
  padding: 15px;
  border: 1px solid #e4e9f0;
  border-radius: 4px;
  box-shadow: 0 3px 7px #2534490a;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.paper-heading,
.paper-parties,
.paper-dates {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.paper-heading {
  align-items: flex-start;
  padding-bottom: 13px;
  border-bottom: 1px solid #e6ecf4;
}
.paper-heading div {
  display: grid;
  text-align: right;
}
.paper-heading strong {
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.04em;
}
.paper small,
.paper-parties span {
  color: #5b6b81;
}
.paper-heading small {
  font-size: 11px;
}
.paper-parties,
.paper-dates {
  margin: 12px 0;
}
.paper-parties > div,
.paper-dates > div {
  width: 50%;
  display: grid;
}
.paper-parties small,
.paper-dates small {
  font-size: 10px;
}
.paper-line {
  display: flex;
  justify-content: space-between;
  gap: 11px;
  padding: 5px 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.paper-line.value {
  color: var(--ink);
  padding-block: 8px;
}
.paper-line span:last-child {
  flex-shrink: 0;
}
.paper-total {
  margin: 10px 0 0 auto;
  display: grid;
  gap: 3px;
}
.paper-total > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 9px;
  padding: 4px 7px;
}
.paper-total > div:last-child {
  background: #eef3ff;
  border-radius: 5px;
  color: #2446ad;
}
.paper-total > div:last-child strong {
  font-size: 16px;
}
.paper-note {
  font-size: 10px;
  color: #4b5e76;
  margin: 9px 0 0;
}
.access-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 17px;
}
.access-card {
  padding: 17px 19px;
  position: relative;
}
.access-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: #eaf0ff;
  color: #2649bf;
  margin-bottom: 12px;
  font-weight: 700;
}
.access-card code {
  display: table;
  color: #395178;
  background: #eff3fa;
  padding: 3px 6px;
  border-radius: 5px;
  margin-top: 10px;
  font-size: 12px;
}
.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--blue);
  margin-top: 10px;
  font-size: 12px;
  font-weight: 680;
}
.link-button:hover {
  text-decoration: underline;
}
.access-table {
  overflow: hidden;
}
.scope-list {
  display: flex;
  gap: 5px;
}
.access-table td {
  padding-block: 12px;
}
dialog {
  width: min(460px, calc(100% - 28px));
  border: 1px solid var(--line);
  border-radius: 15px;
  padding: 0;
  box-shadow: 0 16px 50px #10234438;
}
dialog::backdrop {
  background: #1e31554e;
  backdrop-filter: blur(2px);
}
.dialog-content {
  padding: 21px;
}
.dialog-content h2 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.03em;
}
.dialog-content p {
  margin: 7px 0 15px;
  color: var(--muted);
}
.dialog-content form {
  display: flex;
  justify-content: flex-end;
  margin-top: 13px;
}
.dialog-content pre {
  background: #eff3fa;
  border-radius: 8px;
  padding: 11px;
  overflow: auto;
  font-size: 12px;
}
@media (max-width: 1020px) {
  .shell {
    grid-template-columns: 204px minmax(0, 1fr);
  }
  .sidebar {
    padding-inline: 12px;
  }
  th,
  td {
    padding-inline: 8px;
  }
  .row-action button {
    min-width: 32px;
  }
}
@media (max-width: 820px) {
  .shell {
    display: block;
  }
  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 13px 17px 9px;
    display: grid;
    grid-template-columns: auto minmax(145px, 194px);
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    overflow: visible;
  }
  .sidebar .brand {
    padding: 0;
  }
  .nav {
    display: flex;
    grid-column: 1 / -1;
    overflow: auto;
    gap: 4px;
    scrollbar-width: thin;
  }
  .nav a {
    white-space: nowrap;
  }
  .nav-label,
  .profile {
    display: none;
  }
  .editor-grid {
    grid-template-columns: minmax(0, 1fr) minmax(235px, 0.9fr);
  }
}
@media (max-width: 560px) {
  .topbar {
    min-height: 55px;
    padding-inline: 13px;
  }
  .breadcrumb {
    gap: 5px;
    font-size: 11px;
  }
  .demo-tag {
    display: none;
  }
  .screen {
    padding: 20px 13px;
  }
  .intro {
    align-items: flex-start;
    gap: 8px;
  }
  .intro h1 {
    font-size: 27px;
  }
  .intro p {
    font-size: 12px;
  }
  .metrics {
    gap: 6px;
  }
  .metric {
    padding: 8px;
  }
  .metric small,
  .metric p {
    font-size: 10px;
  }
  .metric strong {
    font-size: 14px;
  }
  .toolbar {
    flex-direction: column-reverse;
    align-items: stretch;
    padding: 8px;
  }
  .filter-group {
    align-self: flex-start;
    max-width: 100%;
    overflow-x: auto;
  }
  .filter-group button {
    font-size: 10px;
    padding-inline: 6px;
  }
  .search {
    width: 100%;
  }
  .editor-grid,
  .access-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
#notice {
  position: fixed;
  bottom: 24px;
  right: 24px;
  max-width: 520px;
  background: #172638;
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  z-index: 20;
  display: none;
}
#notice.error {
  background: #9d263c;
}
.login {
  max-width: 440px;
  margin: 10vh auto;
  padding: 36px;
}
.login h1 {
  margin-bottom: 25px;
}
label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
}
input,
select,
textarea {
  font: inherit;
  border: 1px solid #dce1e8;
  border-radius: 8px;
  padding: 10px;
  background: white;
  min-width: 0;
  width: 100%;
}
textarea {
  min-height: 80px;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.form-grid .wide {
  grid-column: 1/-1;
}
.stack {
  display: grid;
  gap: 18px;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0;
}
.card.pad {
  padding: 24px;
  margin-bottom: 20px;
}
.muted {
  color: #75808f;
}
.empty {
  padding: 48px;
  text-align: center;
  color: #738092;
}
.item-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
  align-items: end;
}
.paper {
  width: 100%;
  min-height: 480px;
}
.paper table {
  font-size: 12px;
}
.paper h2 {
  font-size: 24px;
}
.danger {
  color: #aa2845;
}
.inline {
  display: flex;
  gap: 10px;
  align-items: center;
}
.inline input[type="checkbox"] {
  width: auto;
}
.company-picker select {
  border: 0;
  background: transparent;
  font-weight: 600;
}
.nav button {
  background: none;
  border: 0;
  text-align: left;
  font: inherit;
  padding: 12px;
  color: inherit;
}
.nav a.active {
  background: #eaf0ff;
  color: #275bcb;
}
.profile {
  gap: 10px;
}
.profile button {
  font-size: 11px;
}
.toolbar form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.toolbar input {
  max-width: 180px;
}
dialog {
  max-width: 760px;
  width: calc(100% - 32px);
  border: 0;
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 90px #17263840;
}
dialog::backdrop {
  background: #17263860;
}
.preview-card {
  padding: 24px;
  align-self: start;
  position: sticky;
  top: 24px;
}
.badge {
  white-space: nowrap;
}
pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
a {
  cursor: pointer;
}
.full {
  width: 100%;
}
@media (max-width: 900px) {
  .editor-grid {
    display: block;
  }
  .preview-card {
    position: static;
  }
  .item-row {
    grid-template-columns: 2fr 1fr;
  }
  .sidebar {
    position: static;
    width: 100%;
  }
  .shell {
    display: block;
  }
  .main {
    margin-left: 0;
  }
  .nav {
    display: flex;
    flex-wrap: wrap;
  }
  .nav-label,
  .profile {
    display: none;
  }
  .topbar {
    padding: 18px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid .wide {
    grid-column: auto;
  }
}

/* Compact list controls, with deliberate wrapping only on narrow screens. */
.toolbar {
  padding: 18px 22px;
}
.toolbar form {
  display: grid;
  grid-template-columns: minmax(190px, 1fr) 160px 146px 146px auto;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.toolbar form input,
.toolbar form select {
  width: 100%;
  max-width: none;
  height: 40px;
  font-size: 13px;
}
.toolbar form .button {
  height: 40px;
  white-space: nowrap;
  padding: 8px 15px;
}
.table-scroll td .link-button {
  text-align: left;
  font-weight: 600;
}
.badge.neutral {
  background: #edf0f4;
  color: #647184;
}
#content details summary {
  cursor: pointer;
  font-weight: 600;
  color: #385779;
  padding: 8px 0;
}
#content details[open] summary {
  margin-bottom: 16px;
}
#document-relations {
  display: grid;
  gap: 16px;
}
#document-relations select[multiple] {
  min-height: 128px;
}
@media (max-width: 1200px) {
  .toolbar form {
    grid-template-columns: minmax(190px, 1fr) 155px auto;
  }
  .toolbar form input[type="date"] {
    grid-row: 2;
  }
  .toolbar form button {
    grid-column: 3;
    grid-row: 1/3;
  }
}
@media (max-width: 650px) {
  .toolbar form {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar form input[type="search"],
  .toolbar form input[name="q"] {
    grid-column: 1/-1;
  }
  .toolbar form input[type="date"] {
    grid-row: auto;
  }
  .toolbar form button {
    grid-column: auto;
    grid-row: auto;
  }
  .toolbar {
    padding: 14px;
  }
  .topbar .header-actions {
    gap: 8px;
  }
  .topbar .breadcrumb {
    max-width: 35%;
    overflow-wrap: anywhere;
  }
}

/* Shared application surfaces; the document preview keeps its own paper palette. */
:root {
  color-scheme: light;
  --canvas: #f6f8fb;
  --surface: #fff;
  --surface-raised: #fcfdff;
  --sidebar: #edf2f8;
  --hover: #e3eaf5;
  --ink: #172237;
  --muted: #57677d;
  --soft: #f1f4f9;
  --line: #dfe5ee;
  --blue: #244bd4;
  --blue-soft: #eaf0ff;
  --focus: #4569ea;
  background: var(--canvas);
  color: var(--ink);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #141923;
  --surface: #1d2532;
  --surface-raised: #222d3c;
  --sidebar: #19212d;
  --hover: #2c394d;
  --ink: #edf2fa;
  --muted: #b3c0d3;
  --soft: #263245;
  --line: #42516a;
  --blue: #a4bbff;
  --blue-soft: #2c3f65;
  --focus: #adc3ff;
}
body { background: var(--canvas); color: var(--ink); }
:focus-visible { outline-color: var(--focus); }
input, select, textarea { color: var(--ink); background: var(--surface); border-color: var(--line); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
.sidebar { background: var(--sidebar); border-color: var(--line); }
.topbar { background: var(--surface-raised); }
.card, .metric, .company-picker summary, .company-menu, .company-menu button,
.search, .secondary, dialog { background: var(--surface); color: var(--ink); }
.company-picker summary, .profile { border-color: var(--line); }
.nav a, .nav a span, .nav-label, .fields label span, .table-date, .cell-caption,
.muted, .empty, .search, #content details summary { color: var(--muted); }
.nav a:hover, .secondary:hover { background: var(--hover); }
.nav a.active, .nav a[aria-current="page"] { color: var(--blue); background: var(--blue-soft); }
.nav a[aria-current="page"] span, .number-link, .row-action button { color: var(--blue); }
.filter-group { background: var(--soft); border-color: var(--line); }
.filter-group button { color: var(--muted); }
.filter-group button[aria-pressed="true"] { background: var(--surface); }
.fields input, .fields select { background: var(--surface-raised); }
th { background: var(--soft); color: var(--muted); }
td, .item-footer { border-color: var(--line); }
tbody tr:hover { background: var(--surface-raised); }
.dialog-content pre, .access-card code { background: var(--soft); color: var(--ink); }
.paper-wrap { background: var(--soft); }
.chart { background: repeating-linear-gradient(to top, var(--line) 0 1px, var(--surface) 1px 25%); }
.theme-toggle { min-width: 44px; min-height: 40px; flex-shrink: 0; }
.login > .theme-toggle { float: right; margin: 0 0 12px 12px; }
.primary { color: #fff; background: #244bd4; }
.primary:hover { background: #1b3fbe; }
:root[data-theme="dark"] .primary { background: #a4bbff; color: #142442; }
:root[data-theme="dark"] .primary:hover { background: #bed0ff; }
:root[data-theme="dark"] .metric.is-late strong,
:root[data-theme="dark"] .danger { color: #ffacb6; }
:root[data-theme="dark"] .badge.blue { color: #bed0ff; background: #304269; }
:root[data-theme="dark"] .badge.green { color: #a4e4c4; background: #23483c; }
:root[data-theme="dark"] .badge.red { color: #ffc0bc; background: #573337; }
:root[data-theme="dark"] .badge.amber { color: #f5d69e; background: #51432c; }
:root[data-theme="dark"] .badge.gray,
:root[data-theme="dark"] .badge.neutral { color: #c5d0e2; background: #344156; }
:root[data-theme="dark"] .tax-panel { color: #c7d7ff; background: #2c3f65; }
:root[data-theme="dark"] .tax-icon { background: #3b517c; }
:root[data-theme="dark"] .tax-panel[data-review="true"] { color: #f5d69e; background: #51432c; }
:root[data-theme="dark"] .tax-panel[data-review="true"] .tax-icon { background: #665437; }
:root[data-theme="dark"] .access-icon { color: #bed0ff; background: #304269; }

/* An invoice remains white and readable in either application theme. */
.paper {
  color-scheme: light;
  --ink: #172237;
  --muted: #57677d;
  --line: #dfe5ee;
  color: #172237;
  background: #fff;
  min-width: 0;
}
.paper table { white-space: normal; table-layout: fixed; }
.paper th { background: #f1f4f9; color: #53647b; }
.paper td { color: #172237; border-color: #dfe5ee; overflow-wrap: anywhere; }
.paper tbody tr:hover { background: #fafcff; }
.paper h2 { margin: 0; }
.paper-heading > strong { overflow-wrap: anywhere; text-align: right; }
.paper th:first-child, .paper td:first-child { width: 48%; }

/* Keep long values and scrollable tables contained in the main column. */
.sidebar, .topbar, .header-actions, .screen, .editor-fields, .preview-card,
.card, .toolbar, .toolbar form, .form-grid, .item-row, .table-scroll { min-width: 0; }
.table-scroll { max-width: 100%; overscroll-behavior-inline: contain; }
.help-highlight { outline: 3px solid var(--accent); outline-offset: 3px; }
.company-picker select { max-width: 100%; text-overflow: ellipsis; }
.breadcrumb { min-width: 0; overflow-wrap: anywhere; }
.header-actions { flex-wrap: wrap; justify-content: flex-end; }
.header-actions > label { flex-shrink: 0; }
.card-heading, .intro, .item-footer { flex-wrap: wrap; }
.card.pad p, .card.pad code, .access-card code { overflow-wrap: anywhere; }
.item-row { grid-template-columns: minmax(120px, 2fr) repeat(4, minmax(60px, 1fr)) auto; }
.item-row > label { min-width: 0; }
dialog {
  color: var(--ink);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
}
#notice { max-width: min(520px, calc(100vw - 32px)); overflow-wrap: anywhere; }

@media (max-width: 1200px) {
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-card { position: static; margin-top: 16px; }
}
@media (max-width: 900px) {
  .sidebar {
    display: grid;
    height: auto;
    grid-template-columns: minmax(0, 1fr) minmax(170px, 1fr);
    gap: 14px;
    padding: 16px 18px 10px;
    overflow: visible;
  }
  .nav { grid-column: 1 / -1; gap: 4px; flex-wrap: wrap; }
  .nav a, .nav button { min-height: 44px; }
  .nav .nav-label { display: none; }
  .sidebar .profile {
    display: flex;
    grid-column: 1 / -1;
    justify-content: space-between;
    margin-top: 0;
    padding-top: 10px;
  }
  .profile > span { overflow-wrap: anywhere; min-width: 0; }
  .profile button { min-height: 40px; }
  .toolbar form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .toolbar form input[type="search"], .toolbar form input[name="q"] { grid-column: 1 / -1; }
  .toolbar form input[type="date"], .toolbar form button { grid-column: auto; grid-row: auto; }
  .item-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .item-row > label:first-child { grid-column: 1 / -1; }
  input, select, textarea, .fields input, .fields select { font-size: 16px; min-height: 44px; }
  .button { min-height: 44px; }
}
@media (max-width: 560px) {
  .sidebar { grid-template-columns: minmax(0, 1fr); gap: 12px; padding-inline: 14px; }
  .company-picker { grid-column: 1; }
  .nav { flex-wrap: nowrap; overflow-x: auto; padding: 3px; margin-inline: -3px; }
  .nav a, .nav button { flex: 0 0 auto; }
  .topbar { flex-wrap: wrap; padding: 12px 14px; gap: 10px; }
  .topbar .breadcrumb { max-width: none; flex-basis: 100%; font-size: 13px; }
  .header-actions { width: 100%; gap: 8px; justify-content: flex-start; align-items: flex-end; }
  .header-actions > label { margin-right: auto; }
  .header-actions .button { padding-inline: 10px; }
  .card.pad, .preview-card { padding: 16px; }
  .intro > .button { width: 100%; }
  .metrics { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .metric { padding: 12px 14px; }
  .metric small, .metric p { font-size: 12px; }
  .metric strong { font-size: 24px; overflow-wrap: anywhere; }
  .paper { padding: 12px; }
  .paper-heading { flex-wrap: wrap; }
  .paper-heading > strong { font-size: 18px; }
  .paper th, .paper td { padding: 8px 4px; }
  .paper th:first-child, .paper td:first-child { padding-left: 4px; }
  .paper th:last-child, .paper td:last-child { padding-right: 4px; }
  .paper-total > div { padding-inline: 0; flex-wrap: wrap; }
  .actions > .button { flex: 1 1 auto; white-space: normal; }
  .table-footer { flex-wrap: wrap; }
  dialog { padding: 18px; }
  .login { width: calc(100% - 28px); margin: 24px auto; padding: 24px; }
  #notice { bottom: 16px; right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; }
}
input[type="checkbox"], input[type="radio"] {
  min-height: 0;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: #244bd4;
}
label.inline { flex-direction: row; min-height: 44px; }
fieldset { min-width: 0; border-color: var(--line); border-radius: 8px; }
@media (max-width: 560px) {
  .table-footer > .inline { flex-wrap: wrap; }
}

/* Company PDF layouts use fixed print colors, independent of the app theme. */
.paper[data-pdf-design="minimal"] .paper-heading {
  border-bottom: 1px solid #cbd2dc;
  padding-bottom: 18px;
}
.paper[data-pdf-design="minimal"] .paper-heading h2 {
  font-weight: 500;
  letter-spacing: -0.025em;
}
.paper[data-pdf-design="minimal"] th {
  background: #fff;
  color: #172237;
  border-top: 0;
  border-bottom: 1px solid #9aa6b6;
}
.paper[data-pdf-design="minimal"] .paper-total > div:last-child {
  background: #fff;
  color: #172237;
  border-top: 1px solid #9aa6b6;
  border-radius: 0;
  padding-top: 9px;
}
.paper[data-pdf-design="accent"] .paper-heading {
  border-bottom: 3px solid #2446ad;
  padding-bottom: 16px;
}
.paper[data-pdf-design="accent"] .paper-heading h2,
.paper[data-pdf-design="accent"] .paper-heading > strong {
  color: #2446ad;
}
.paper[data-pdf-design="accent"] th {
  background: #eaf0ff;
  color: #2446ad;
  border-color: #d6e0fc;
}
.paper[data-pdf-design="accent"] .paper-total > div:last-child {
  background: #2446ad;
  color: #fff;
  padding: 8px;
}

/* Navigation drawer complements the persistent desktop sidebar. */
img.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
  object-fit: contain;
}
.mobile-menu-toggle { display: none; }
.mobile-menu-close {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 44px;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-raised);
  color: var(--ink);
  font-size: 22px;
}
dialog.mobile-menu {
  width: min(360px, calc(100vw - 28px));
  max-width: 360px;
  height: 100dvh;
  max-height: 100dvh;
  inset: 0 auto 0 0;
  margin: 0;
  padding: 20px;
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0 18px 18px 0;
  background: var(--sidebar);
  box-shadow: 12px 0 60px #07101d40;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.mobile-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.mobile-menu-header .brand { margin: 0; }
.mobile-menu .brand { padding: 0; }
.nav-group { display: grid; gap: 5px; margin: 0; }
.nav-group-label {
  display: block;
  margin: 8px 0 0;
  padding: 4px 12px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.mobile-menu .company-picker { margin-bottom: 18px; }
.mobile-menu .company-picker select { background: var(--surface); border: 1px solid var(--line); }
.mobile-menu .nav { display: grid; gap: 5px; overflow: visible; margin: 0; padding: 0; }
.mobile-menu .nav a, .mobile-menu .nav button { min-height: 44px; padding: 11px 12px; white-space: normal; }
.mobile-menu .nav-label { display: block; padding: 14px 12px 3px; }
.mobile-menu .profile {
  display: flex;
  flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 18px;
  align-items: center;
}
.mobile-menu .profile button { min-height: 44px; }
.mobile-menu > label, .mobile-menu > .theme-toggle { margin-top: 16px; }
.mobile-menu select { min-height: 44px; }
.company-chooser { max-width: 720px; margin-inline: auto; }
.company-choice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  width: 100%;
  min-height: 72px;
  margin-top: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: var(--surface);
  text-align: left;
  font-weight: 650;
  overflow-wrap: anywhere;
}
.company-choice:hover { border-color: var(--blue); background: var(--blue-soft); }
.company-choice small { color: var(--muted); font-weight: 450; }
.company-choice[aria-pressed="true"], .company-choice.active { border-color: var(--blue); background: var(--blue-soft); }
.profile button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: var(--surface);
  color: var(--ink);
}

.boot-state {
  min-height: 100svh;
  display: grid;
  grid-template-columns: auto auto;
  align-content: center;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: var(--muted);
}
.boot-state img { grid-column: 1 / -1; justify-self: center; margin-bottom: 8px; }
.busy-indicator, .button[aria-busy="true"]::before {
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
}
.button[aria-busy="true"]::before { content: ""; display: inline-block; margin-inline-end: 0.45em; vertical-align: -0.13em; }
.screen-loading { display: grid; gap: 13px; max-width: 720px; color: var(--muted); padding: 10px 0; }
.skeleton-line { display: block; min-height: 14px; width: min(100%, 460px); border-radius: 8px; background: var(--line); }
.skeleton-line:nth-of-type(2) { width: min(78%, 360px); }
.skeleton-line:nth-of-type(3) { width: min(91%, 420px); }
.form-status { margin: 0; color: var(--muted); font-size: 13px; }
.form-status:empty { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .button, .nav a, .company-choice { transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease; }
  dialog[open] { animation: surface-enter 160ms ease-out both; }
  dialog.mobile-menu[open] { animation: drawer-enter 200ms cubic-bezier(0.2, 0.75, 0.25, 1) both; }
  dialog[open]::backdrop { animation: backdrop-enter 160ms ease-out both; }
  .busy-indicator, .button[aria-busy="true"]::before { animation: busy-spin 800ms linear infinite; }
  .screen-loading .skeleton-line { animation: waiting-pulse 1.15s ease-in-out infinite alternate; }
}
@keyframes surface-enter { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes drawer-enter { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes backdrop-enter { from { opacity: 0; } to { opacity: 1; } }
@keyframes busy-spin { to { transform: rotate(1turn); } }
@keyframes waiting-pulse { from { opacity: 0.58; } to { opacity: 1; } }
@media (max-width: 900px) {
  .shell > .sidebar { display: none; }
  .mobile-menu-toggle {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--ink);
    padding: 0;
    font-size: 23px;
  }
  .topbar {
    display: flex;
    flex-wrap: nowrap;
    min-height: 72px;
    padding: 12px 18px;
    gap: 12px;
  }
  .topbar .breadcrumb {
    flex: 1 1 auto;
    display: block;
    max-width: none;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 14px;
    font-weight: 650;
  }
  .topbar .header-actions { flex: 0 0 auto; width: auto; gap: 0; }
  .topbar .header-actions > :not(.primary) { display: none; }
  .topbar .header-actions .primary { min-height: 44px; padding: 10px 16px; }
  .screen { padding-top: 22px; }
  .intro { margin-bottom: 18px; }
  .mobile-menu .nav-label { display: block; }
}
@media (max-width: 560px) {
  .topbar { min-height: 68px; padding: 12px 14px; gap: 9px; }
  .topbar .breadcrumb { flex-basis: auto; font-size: 13px; }
  .topbar .header-actions .primary { padding: 10px 12px; }
  .screen { padding-top: 20px; }
  .company-choice { padding: 14px; }
  dialog.mobile-menu { padding: 16px; }
}
.desktop-controls, .mobile-menu-header, .mobile-menu-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}
.mobile-menu-header { margin-bottom: 24px; }
.mobile-menu-header .brand { margin: 0; }
.mobile-menu-header .mobile-menu-close { flex: 0 0 44px; }
.mobile-menu-footer { flex-wrap: wrap; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.mobile-menu-footer > label { flex: 1 1 100%; }
.mobile-menu-footer .profile { width: 100%; margin: 0; }
.company-choice > strong { flex: 1 1 180px; }
.company-choice > span { color: var(--muted); font-size: 13px; font-weight: 450; }
.invoice-settings { padding: 16px; margin: 20px 0; }
.invoice-settings legend { padding-inline: 7px; font-weight: 650; }
.activity-list td { vertical-align: top; }
.activity-list td:last-child { white-space: normal; min-width: 200px; max-width: 440px; overflow-wrap: anywhere; }
