:root {
  color-scheme: light;
  --ink: #27203c;
  --muted: #6b6478;
  --purple: #6b46a3;
  --purple-dark: #34254d;
  --purple-pale: #f4f0fa;
  --purple-active: #eee5f8;
  --line: #dcd4e8;
  --line-light: #ece7f2;
  --surface: #fff;
  --canvas: #f7f5fa;
  --error: #a2262d;
  --success: #17633a;
  --row-height: 1.9rem;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-size: .875rem;
}

.application-version {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 4px 9px;
  border: 1px solid rgba(255,255,255,.42);
  border-radius: 999px;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  white-space: nowrap;
}

[hidden] { display: none !important; }

h1, h2, h3, p { margin-top: 0; }
h1 { margin: 0; font-size: 1.35rem; line-height: 1.2; }
h2 { margin: 0; font-size: 1.13rem; }
h3 { margin: 0; font-size: .95rem; }

.topbar {
  height: 4.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .6rem 1.15rem;
  color: #fff;
  background: var(--purple-dark);
  border-top: 4px solid #d9ad2b;
}

.brand-block { min-width: 0; }
.subtitle { margin: .08rem 0 0; color: #ded6ea; font-size: .78rem; }

.eyebrow {
  margin: 0 0 .12rem;
  color: var(--purple);
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.topbar .eyebrow { color: #d9c9ef; }
.topbar nav { display: flex; gap: .4rem; }
.topbar nav a {
  padding: .38rem .58rem;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: .35rem;
  text-decoration: none;
  white-space: nowrap;
}
.topbar nav a:hover, .topbar nav a:focus-visible { background: rgba(255, 255, 255, .1); }

.setup-shell {
  display: grid;
  grid-template-columns: 13.25rem minmax(0, 1fr);
  height: calc(100vh - 4.65rem);
  min-height: 0;
}

.setup-sidebar {
  min-height: 0;
  overflow-y: auto;
  padding: .7rem .55rem;
  background: #fbfafd;
  border-right: 1px solid var(--line);
}

.setup-sidebar-label {
  margin: 0 .45rem .4rem;
  color: var(--muted);
  font-size: .65rem;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.setup-menu { display: grid; gap: .12rem; }

.setup-menu-item,
.setup-menu-link {
  width: 100%;
  min-height: 2.15rem;
  display: flex;
  align-items: center;
  padding: .38rem .55rem;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: .35rem;
  cursor: pointer;
  text-decoration: none;
}

.setup-menu-item span,
.setup-menu-link span {
  min-width: 0;
  overflow: hidden;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.setup-menu-item small,
.setup-menu-link small { display: none; }
.setup-menu-item:hover,
.setup-menu-link:hover,
.setup-menu-link:focus-visible { background: var(--purple-pale); }
.setup-menu-link {
  margin-top: .45rem;
  border-top-color: var(--line);
  border-radius: 0 0 .35rem .35rem;
}
.setup-menu-item[aria-selected="true"] {
  color: var(--purple-dark);
  background: var(--purple-active);
  border-color: #cdbce2;
  box-shadow: inset 3px 0 0 var(--purple);
}

.setup-workspace {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: .65rem;
}

.setup-panel {
  position: relative;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: .75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: .45rem;
  box-shadow: 0 2px 9px rgba(48, 34, 73, .04);
}

.panel-heading {
  min-height: 2.35rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding-bottom: .45rem;
}

.subtabs {
  display: flex;
  gap: .12rem;
  padding: 0 .15rem;
  border-bottom: 1px solid var(--line);
}

.subtab {
  min-height: 2rem;
  padding: .35rem .75rem;
  color: var(--muted);
  font-weight: 700;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
}

.subtab[aria-selected="true"] { color: var(--purple); border-bottom-color: var(--purple); }
.subtab-panel { min-height: 0; overflow: auto; padding-top: .55rem; }

label { color: var(--muted); font-size: .72rem; font-weight: 650; white-space: nowrap; }

input, select, button {
  min-height: 2rem;
  border: 1px solid #c8bed8;
  border-radius: .35rem;
  font: inherit;
}

input, select {
  width: 100%;
  padding: .32rem .5rem;
  color: var(--ink);
  background: #fff;
}

button {
  padding: .32rem .68rem;
  color: #fff;
  font-weight: 700;
  background: var(--purple);
  border-color: var(--purple);
  cursor: pointer;
  white-space: nowrap;
}

button.secondary { color: var(--purple); background: #fff; }
button:disabled { opacity: .55; cursor: wait; }

.toolbar-form {
  display: grid;
  grid-template-columns: auto minmax(12rem, 28rem) auto;
  align-items: center;
  gap: .4rem;
  min-height: 2.45rem;
  padding: .3rem .4rem;
  background: #fbfafd;
  border: 1px solid var(--line-light);
  border-radius: .35rem;
}

.site-form { max-width: 38rem; }
.input-action, .policy-actions { display: flex; align-items: center; gap: .45rem; }
.input-action input { flex: 1 1 auto; }
.input-action button { flex: 0 0 auto; }

.message {
  min-height: 1.35rem;
  margin: .28rem 0;
  color: var(--muted);
  font-size: .75rem;
  line-height: 1.35rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.message.error {
  min-height: 1.35rem;
  overflow: visible;
  color: var(--error);
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}
.message.success { color: var(--success); }

.status-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  overflow: hidden;
  background: var(--line-light);
  border: 1px solid var(--line-light);
  border-radius: .35rem;
}

.status-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.status-grid div {
  min-width: 0;
  min-height: 2.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .3rem .45rem;
  background: #fff;
}
.status-grid dt { color: var(--muted); font-size: .66rem; text-transform: uppercase; white-space: nowrap; }
.status-grid dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-size: .78rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-wrap { min-width: 0; overflow: auto; border: 1px solid var(--line-light); border-radius: .3rem; }
.panel-table { flex: 1 1 auto; min-height: 7rem; }
table { width: 100%; border-collapse: collapse; font-size: .78rem; }
th, td {
  height: var(--row-height);
  max-width: 22rem;
  padding: .24rem .42rem;
  overflow: hidden;
  border-bottom: 1px solid var(--line-light);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}
th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f8f6fb;
  font-size: .65rem;
  letter-spacing: .02em;
  text-transform: uppercase;
}
tbody tr { background: #fff; }
tbody tr:nth-child(even) { background: #fcfbfd; }
tbody tr[role="button"] { cursor: pointer; }
tbody tr[role="button"]:hover, tbody tr[role="button"]:focus {
  outline: none;
  background: var(--purple-pale);
}
tbody tr[role="button"][aria-selected="true"] {
  background: var(--purple-active);
  box-shadow: inset 3px 0 0 var(--purple);
}
.details-column { width: 5.4rem; text-align: center; }
.row-detail-button,
.value-disclosure-button {
  min-height: 1.45rem;
  padding: .12rem .38rem;
  color: var(--purple);
  background: #fff;
  border-color: #c8bed8;
  font-size: .7rem;
}
.row-detail-button { width: 100%; }
.row-detail-button[aria-expanded="true"],
.value-disclosure-button[aria-expanded="true"] { background: var(--purple-active); }
.value-disclosure-button {
  display: block;
  width: 100%;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: .78rem;
  font-weight: 700;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.compact-table { max-width: 36rem; }
.wide-table { min-width: 72rem; }


.row-detail-drawer {
  position: absolute;
  z-index: 3;
  top: 3.55rem;
  right: .75rem;
  bottom: .75rem;
  width: min(31rem, calc(100% - 1.5rem));
  overflow: auto;
  padding: .65rem;
  background: #fff;
  border: 1px solid #bba7d6;
  border-radius: .4rem;
  box-shadow: 0 8px 24px rgba(48, 34, 73, .2);
}
.row-detail-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .55rem;
  padding-bottom: .45rem;
  border-bottom: 1px solid var(--line-light);
}
.row-detail-drawer .status-grid { grid-template-columns: 1fr; }
.row-detail-drawer .status-grid div { align-items: flex-start; }
.row-detail-drawer .status-grid dd {
  overflow: visible;
  text-align: right;
  overflow-wrap: anywhere;
  white-space: normal;
}
.row-detail-drawer .value-disclosure-button {
  overflow: visible;
  padding: 0;
  border: 0;
  white-space: normal;
}
.authority-detail-drawer { top: .75rem; }

.authority-detail-drawer.vendor-defaults-open {
  width: min(64rem, calc(100% - 1.5rem));
}
.authority-detail-drawer.vendor-defaults-open .status-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.vendor-accounting-default-detail {
  margin-top: .7rem;
}
.vendor-accounting-default-detail .section-note {
  margin: 0 0 .35rem;
}
.vendor-accounting-default-table-wrap {
  max-height: calc(100vh - 20rem);
}
.vendor-accounting-default-table {
  min-width: 72rem;
}
.vendor-accounting-default-table td:nth-child(2),
.vendor-accounting-default-table td:nth-child(4),
.vendor-accounting-default-table td:nth-child(6) {
  min-width: 16rem;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: .72rem;
}
.vendor-accounting-default-table td:nth-child(3),
.vendor-accounting-default-table td:nth-child(5),
.vendor-accounting-default-table td:nth-child(7) {
  min-width: 9rem;
}
.vendor-accounting-default-invalid td:last-child {
  color: var(--error);
  font-weight: 750;
}

.sync-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: .65rem;
  align-items: start;
  width: min(100%, 70rem);
  padding: .75rem;
  background: var(--purple-pale);
  border: 1px solid var(--line);
  border-radius: .4rem;
}
.sync-panel p { margin: .25rem 0 0; color: var(--muted); font-size: .78rem; }
.sync-form { display: grid; gap: .55rem; }
.sync-mode {
  display: grid;
  gap: .35rem;
  margin: 0;
  padding: 0;
  border: 0;
}
.sync-mode legend {
  margin-bottom: .2rem;
  color: var(--ink);
  font-size: .76rem;
  font-weight: 800;
}
.sync-mode .segmented-control {
  display: inline-flex;
  width: fit-content;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: #fff;
}
.sync-mode .segmented-control label { cursor: pointer; }
.sync-mode .segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.sync-mode .segmented-control span {
  display: block;
  min-width: 7rem;
  padding: .45rem .75rem;
  color: var(--muted);
  text-align: center;
  font-size: .74rem;
  font-weight: 750;
}
.sync-mode .segmented-control label + label span { border-left: 1px solid var(--line); }
.sync-mode .segmented-control input:checked + span {
  color: #fff;
  background: var(--purple);
}
.sync-mode .segmented-control input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}
.sync-mode .field-help { margin: 0; }
.sync-integrations {
  position: relative;
  margin: 0;
  padding: .65rem;
  border: 1px solid var(--line);
  border-radius: .35rem;
  background: #fff;
}
.sync-integrations legend {
  padding: 0 .25rem;
  color: var(--ink);
  font-size: .76rem;
  font-weight: 800;
}
.sync-selection-actions {
  display: flex;
  justify-content: flex-end;
  gap: .35rem;
  margin: -.2rem 0 .45rem;
}
.sync-selection-actions button {
  min-height: 1.8rem;
  padding: .2rem .55rem;
  font-size: .7rem;
}
.sync-integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .3rem .55rem;
}
.sync-integration-grid label {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  min-height: 3rem;
  padding: .45rem .5rem;
  background: #fbfafd;
  border: 1px solid var(--line-light);
  border-radius: .3rem;
  cursor: pointer;
}
.sync-integration-grid label:hover { background: var(--purple-pale); }
.sync-integration-grid input[type="checkbox"] {
  flex: 0 0 1rem;
  width: 1rem;
  min-height: 1rem;
  height: 1rem;
  margin: 0;
  padding: 0;
  accent-color: var(--purple);
}
.sync-integration-grid span { display: grid; min-width: 0; gap: .08rem; }
.sync-integration-grid strong { font-size: .74rem; }
.sync-integration-grid small { color: var(--muted); font-size: .66rem; line-height: 1.25; }
.sync-progress {
  width: min(100%, 70rem);
  margin-top: .65rem;
  padding: .7rem .8rem;
  border: 1px solid var(--line);
  border-left: .22rem solid var(--purple);
  border-radius: .35rem;
  background: #fff;
}
.sync-progress.complete { border-left-color: var(--success); }
.sync-progress.failed { border-left-color: var(--error); }
.sync-progress.failed progress { accent-color: var(--error); }
.sync-progress-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .45rem;
}
.sync-progress-heading strong { color: var(--ink); font-size: .86rem; }
.sync-progress-heading span { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .72rem; }
.sync-progress progress { width: 100%; height: .4rem; accent-color: var(--purple); }
.sync-progress-grid {
  display: grid;
  grid-template-columns: 6rem minmax(12rem, 1fr) 6rem 8rem;
  gap: .45rem;
  margin: .55rem 0 0;
}
.sync-progress-grid div { min-width: 0; }
.sync-progress-grid dt { color: var(--muted); font-size: .64rem; font-weight: 800; text-transform: uppercase; }
.sync-progress-grid dd { overflow: hidden; margin: .1rem 0 0; font-size: .76rem; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.sync-progress-detail, .sync-progress-selection { margin: .45rem 0 0; font-size: .72rem; }
.sync-progress-detail { color: var(--ink); }
.sync-progress-selection { color: var(--muted); }

.charge-default-grid {
  display: grid;
  gap: 1px;
  overflow: hidden;
  background: var(--line-light);
  border: 1px solid var(--line-light);
  border-radius: .35rem;
}
.charge-default-grid article {
  min-height: var(--row-height);
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr) 5rem;
  align-items: center;
  gap: .6rem;
  padding: .27rem .45rem;
  background: #fff;
}
.charge-default-grid h3 { font-size: .76rem; }
.charge-default-grid p { margin: 0; overflow: hidden; font-size: .76rem; text-overflow: ellipsis; white-space: nowrap; }

.chart-layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(18rem, .85fr) minmax(25rem, 1.15fr);
  gap: .55rem;
}
.chart-account-list { min-height: 0; }
.chart-detail {
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto auto minmax(4rem, 1fr);
  gap: .35rem;
  overflow: hidden;
  padding: .5rem;
  background: #fbfafe;
  border: 1px solid var(--line);
  border-radius: .35rem;
}
.chart-detail .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.unit-rule-list { max-height: 8rem; }
.unit-value-list { min-height: 0; }
.unit-value-form { grid-template-columns: auto 5.5rem minmax(8rem, 1fr) auto; }

.section-copy { margin: 0 0 .45rem; color: var(--muted); font-size: .78rem; }
.policy-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(8rem, 1fr));
  gap: .5rem;
  overflow: auto;
  padding-top: .55rem;
  border-top: 1px solid var(--line);
}
.policy-grid label { display: grid; gap: .18rem; }
.version-banner, .confirmation, .policy-actions { grid-column: 1 / -1; }
.version-banner { margin: 0; padding: .42rem .55rem; background: var(--purple-pale); border-radius: .3rem; }
.confirmation { display: flex !important; align-items: center; gap: .4rem; }
.confirmation input { width: auto; min-height: auto; }

.general-parameters-form {
  width: min(100%, 46rem);
  display: grid;
  gap: .85rem;
  align-self: flex-start;
  padding: 1rem;
  background: #fbfafe;
  border: 1px solid var(--line);
  border-radius: .45rem;
}
.general-parameters-intro h3 { margin-bottom: .2rem; }
.general-parameters-intro p {
  max-width: 42rem;
  margin: 0;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.45;
}
.general-parameters-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(10rem, 1fr));
  gap: .75rem;
}
.general-parameters-fields label { display: grid; align-content: start; gap: .22rem; }
.general-parameters-actor { grid-column: 1 / -1; }
.field-help { color: var(--muted); font-size: .68rem; font-weight: 500; }
.parameter-input {
  min-height: 2rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  overflow: hidden;
  color: var(--muted);
  background: #fff;
  border: 1px solid #c8bed8;
  border-radius: .35rem;
}
.parameter-input:focus-within { outline: 2px solid rgba(107, 70, 163, .22); border-color: var(--purple); }
.parameter-input > span { padding: 0 .5rem; font-weight: 700; }
.parameter-input > input {
  min-height: 1.9rem;
  padding-left: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
}
.parameter-input:has(input:first-child) { grid-template-columns: minmax(0, 1fr) auto; }
.parameter-input:has(input:first-child) > input { padding-left: .5rem; }
.general-parameters-version {
  margin: 0;
  color: var(--muted);
  font-size: .72rem;
}
.general-parameters-actions { display: flex; align-items: center; gap: .45rem; }

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

@media (max-width: 900px) {
  .setup-shell {
    grid-template-columns: 10rem minmax(0, 1fr);
    height: calc(100vh - 4.65rem);
    min-height: 0;
  }
  .setup-sidebar {
    overflow-x: hidden;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    border-bottom: 0;
  }
  .setup-menu { display: grid; width: auto; }
  .setup-menu-item, .setup-menu-link { width: 100%; min-width: 0; }
  .setup-workspace { min-height: 0; padding: .45rem; }
  .setup-panel { min-height: 0; padding: .6rem; }
  .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .chart-layout {
    grid-template-columns: minmax(13rem, .8fr) minmax(20rem, 1.2fr);
    overflow: auto;
  }
  .policy-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .topbar { height: 3.25rem; min-height: 3.25rem; padding: .35rem .55rem; }
  .topbar .eyebrow, .subtitle { display: none; }
  .topbar h1 { font-size: 1.05rem; }
  .topbar nav { flex-direction: row; }
  .topbar nav a { padding: .28rem .38rem; font-size: .68rem; }
  .setup-shell {
    grid-template-columns: 7.75rem minmax(0, 1fr);
    height: calc(100vh - 3.25rem);
    min-height: 0;
  }
  .setup-sidebar { padding: .35rem .25rem; }
  .setup-sidebar-label { display: none; }
  .setup-menu-item, .setup-menu-link { min-height: 2rem; padding: .28rem .4rem; font-size: .75rem; }
  .setup-workspace { padding: .3rem; }
  .setup-panel { padding: .45rem; }
  .panel-heading { min-height: 2rem; padding-bottom: .3rem; }
  .panel-heading .eyebrow { display: none; }
  .toolbar-form { grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
  .toolbar-form > label:not(.visually-hidden) {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .sync-panel, .status-grid, .status-grid.compact { grid-template-columns: 1fr; }
  .sync-integration-grid { grid-template-columns: 1fr; }
  .sync-progress-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .status-grid div { min-height: 2.35rem; }
  .unit-value-form { grid-template-columns: 4.5rem minmax(0, 1fr) auto; }
  .policy-grid {
    grid-template-columns: repeat(2, minmax(7rem, 1fr));
    min-width: 15rem;
  }
  .general-parameters-form { padding: .75rem; }
  .general-parameters-fields { grid-template-columns: 1fr; }
  .general-parameters-actor { grid-column: auto; }
}

.integration-checkpoints { margin-top: 1rem; }
.compact-heading { margin-bottom: .45rem; }
.compact-heading p { margin: .2rem 0 0; }
.checkpoint-form {
  display: grid;
  grid-template-columns: minmax(8rem, 1fr) minmax(6rem, 1fr) auto;
  gap: .35rem;
  min-width: 21rem;
}
.checkpoint-form input,
.checkpoint-form button { min-height: 2rem; }
