:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #fbfcfd;
  --surface-muted: #f3f4f6;
  --ink: #1f2937;
  --muted: #6b7280;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-strong: #d1d5db;
  --green: #15803d;
  --red: #b42318;
  --blue: #2563eb;
  --gold: #b7791f;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --warning-soft: #fffbeb;
  --danger-soft: #fef2f2;
  --success-soft: #f0fdf4;
  --shadow: none;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.4;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button, a, input, select { transition: background .14s ease, color .14s ease, border-color .14s ease; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 188px minmax(0, 1fr); }
.side {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
}
.brand strong { display: block; font-size: 14px; line-height: 1.1; }
.brand small { display: block; color: var(--muted); font-size: 12px; margin-top: 1px; }
.nav { display: grid; gap: 3px; }
.nav-section {
  margin: 14px 10px 4px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.nav a, .nav summary, .filters a, .soft-button, .primary-link {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 650;
}
.nav a, .nav summary { justify-content: flex-start; }
.nav summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.nav summary::-webkit-details-marker { display: none; }
.nav summary::after {
  content: "";
  width: 7px;
  height: 7px;
  margin-left: auto;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform .14s ease;
}
.nav-group {
  display: grid;
  gap: 3px;
}
.nav-group[open] summary::after {
  transform: rotate(45deg);
}
.nav-sub {
  display: grid;
  gap: 3px;
  padding-left: 8px;
}
.nav-sub a {
  min-height: 29px;
  font-size: 12px;
}
.nav a:hover, .nav a.active, .nav summary:hover, .nav summary.active, .filters a.active, .filters a:hover {
  background: var(--accent-soft);
  color: var(--accent);
}
.logout {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  display: grid;
  gap: 6px;
  color: var(--muted);
}
.logout button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 0 9px;
}

.main {
  width: 100%;
  max-width: 1240px;
  padding: 16px 18px 28px;
  margin: 0 auto;
}
.main-login { max-width: none; display: grid; place-items: center; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.eyebrow {
  margin: 0 0 3px;
  color: var(--faint);
  font-size: 12px;
  font-weight: 700;
}
h1 { margin: 0; font-size: 22px; line-height: 1.2; letter-spacing: 0; }
h2 { margin: 0; font-size: 14px; line-height: 1.2; letter-spacing: 0; }
.page-subtitle { max-width: 760px; margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.4; }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 12px;
}
.metric, .panel, .attention, .login-card, .review-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: none;
}
.summary-grid .metric {
  border: 0;
  border-right: 1px solid var(--line);
  border-radius: 0;
}
.summary-grid .metric:last-child { border-right: 0; }
.metric {
  min-height: 74px;
  display: grid;
  align-content: center;
  gap: 3px;
  padding: 10px 12px;
}
.metric-link:hover {
  background: var(--accent-soft);
}
.metric-link:hover span,
.metric-link:hover small {
  color: var(--accent);
}
.metric span { color: var(--muted); font-weight: 500; }
.metric strong {
  font-size: 22px;
  line-height: 1.08;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.metric small { color: var(--faint); }
.metric-total { background: var(--surface-soft); }
.positive { color: var(--green); }
.negative { color: var(--red); }
.neutral { color: var(--gold); }

.attention {
  margin: 0 0 12px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  border-color: var(--line);
  background: var(--warning-soft);
}
.attention.calm { background: var(--surface); }
.attention.warning { background: var(--warning-soft); }
.attention.danger { background: var(--danger-soft); }
.attention p { margin: 3px 0 0; color: var(--muted); }
.primary-link, .soft-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  white-space: nowrap;
}
.primary-link {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.soft-button:hover, .primary-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.primary-link:hover { background: #1d4ed8; color: #fff; }

.export-menu { position: relative; justify-self: end; }
.export-menu summary {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-weight: 650;
  list-style: none;
}
.export-menu summary::-webkit-details-marker { display: none; }
.export-menu[open] summary, .export-menu summary:hover { border-color: var(--accent); color: var(--accent); }
.export-menu div {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 20;
  min-width: 178px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.export-menu a {
  min-height: 30px;
  display: flex;
  align-items: center;
  border-radius: 5px;
  padding: 0 8px;
  color: var(--ink);
  font-weight: 650;
}
.export-menu a:hover { background: var(--accent-soft); color: var(--accent); }

.panel {
  margin-top: 12px;
  padding: 12px;
}
.dense-panel { padding: 8px; }
.list-panel { padding: 12px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 12px; }
.panel.narrow { max-width: 760px; }
.panel.wide { max-width: 980px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-head a { color: var(--accent); font-weight: 650; }

.tx-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.tx-row {
  display: grid;
  grid-template-columns: 92px minmax(180px, 1.3fr) minmax(120px, .7fr) 86px 110px 88px;
  gap: 10px;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.tx-row:nth-child(even) { background: var(--surface-soft); }
.tx-row:last-child { border-bottom: 0; }
.tx-row-draft { cursor: pointer; }
.tx-row-draft:hover, .tx-row-draft.is-open { background: var(--accent-soft); }
.tx-row-draft:focus-visible { outline: 2px solid rgba(37,99,235,.2); outline-offset: -2px; }
.tx-head {
  min-height: 34px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.tx-date { color: var(--muted); font-size: 12px; }
.tx-main { min-width: 0; }
.tx-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-main p { margin: 1px 0 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-side { text-align: right; display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.tx-amount, .tx-side strong { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.tx-action { text-align: right; }
.status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--faint);
}
.status-needs_review::before { background: var(--gold); }
.status-confirmed::before, .status-reconciled::before { background: var(--green); }
.status-draft::before { background: var(--faint); }
.status-rejected::before { background: var(--red); }
.tiny-link { color: var(--accent); font-size: 12px; font-weight: 700; }
.draft-toggle-button {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
.draft-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.draft-inline[hidden] { display: none; }
.draft-inline h2 { margin: 0 0 5px; }
.draft-inline p {
  margin: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.draft-inline dl {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin: 10px 0 0;
}
.draft-inline dl div { display: flex; gap: 4px; color: var(--muted); }
.draft-inline dt { font-weight: 700; }
.draft-inline dd { margin: 0; color: var(--ink); }
.draft-inline-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  white-space: nowrap;
}
.draft-inline-actions form { margin: 0; }
.danger-button { color: var(--red); }
.danger-button:hover {
  border-color: var(--red);
  background: var(--danger-soft);
  color: var(--red);
}

.filters { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.status-tabs {
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  width: fit-content;
  max-width: 100%;
}
.status-tabs a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.status-tabs a.active {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}
.filter-panel, .period-panel {
  margin-top: 0;
  margin-bottom: 12px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.filter-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
.period-panel { display: grid; gap: 8px; }
.period-switch { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 7px; background: var(--surface-soft); width: fit-content; }
.period-switch a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 700;
}
.period-switch a:hover, .period-switch a.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}

.form { display: grid; gap: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 10px; }
.form-grid .full-span { grid-column: 1 / -1; }
.manual-form { gap: 10px; }
.form-section {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.form-section h2 { font-size: 14px; }
.manual-submit { justify-self: start; min-width: 180px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; font-weight: 650; }
.hidden-field { display: none; }
.hidden-field.is-visible { display: grid; }
input, select {
  width: 100%;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 0 9px;
  color: var(--ink);
}
select {
  appearance: none;
  padding-right: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}
select option {
  min-height: 32px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}
input:focus, select:focus { outline: 2px solid rgba(37,99,235,.12); border-color: var(--accent); }
.taxonomy-field {
  gap: 5px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}
.taxonomy-field:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.taxonomy-select {
  min-height: 40px;
  border-color: var(--line-strong);
  border-radius: 7px;
  background-color: #fff;
  font-size: 14px;
  font-weight: 750;
}
.taxonomy-select:hover { border-color: var(--accent); }
.taxonomy-select-subcategory { font-weight: 680; }
.taxonomy-select.is-empty-choice {
  color: var(--muted);
  font-weight: 650;
  background-color: #fafafa;
}
.taxonomy-select.is-new-value {
  border-color: var(--gold);
  background-color: var(--warning-soft);
}
.taxonomy-helper {
  color: var(--faint);
  font-size: 11px;
  line-height: 1.25;
  font-weight: 500;
}
.taxonomy-field.is-new-value .taxonomy-helper { color: var(--gold); }
.taxonomy-field.is-empty-choice .taxonomy-helper { color: var(--muted); }
input[type="file"] { min-height: 42px; padding: 7px; background: var(--surface-soft); }
input[type="file"]::file-selector-button {
  min-height: 28px;
  margin-right: 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--ink);
  padding: 0 9px;
  font-weight: 700;
  cursor: pointer;
}
.file-picker {
  position: relative;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line-strong);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 750;
}
.file-picker:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.check input { width: 16px; min-height: 16px; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.primary {
  min-height: 32px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 750;
}
.primary:hover { background: #1d4ed8; }
.error { color: var(--red); margin: 0; font-weight: 700; }
.success {
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid #bbf7d0;
  border-radius: 7px;
  background: var(--success-soft);
  color: var(--green);
}
.success p { margin: 3px 0 0; color: var(--green); }
.hint, .empty { color: var(--muted); }
.empty { padding: 10px; }
.login-card { width: min(420px, calc(100vw - 32px)); padding: 18px; }
.brand-login { margin-bottom: 18px; }

.review-list { display: grid; gap: 10px; }
.review-card { padding: 12px; display: grid; gap: 10px; }
.review-main {
  display: grid;
  grid-template-columns: 100px minmax(120px, auto) 1fr;
  gap: 12px;
  align-items: center;
}
.review-main strong { font-size: 20px; font-variant-numeric: tabular-nums; }
.review-main p { color: var(--muted); margin: 0; }
.review-fields { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }

.directory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.inline-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.employee-create-form { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.compact-directory-form { grid-template-columns: minmax(220px, .5fr) auto; justify-content: start; }
.split-forms {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.directory-section {
  padding: 0;
  overflow: hidden;
}
.directory-section > summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 12px;
  cursor: pointer;
  list-style: none;
}
.directory-section > summary::-webkit-details-marker { display: none; }
.directory-section > summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform .14s ease;
}
.directory-section[open] > summary::after { transform: rotate(45deg); }
.directory-section > summary:hover { background: var(--surface-soft); }
.directory-section > summary h2 { margin: 0; }
.directory-section > summary .hint { margin: 3px 0 0; }
.directory-section > summary > span {
  min-width: 26px;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  text-align: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.directory-section > form,
.directory-section > .split-forms,
.directory-section > .category-tree,
.directory-section > .directory-list,
.directory-section > .employee-table,
.directory-section > .nested-directory-section {
  margin-left: 12px;
  margin-right: 12px;
}
.directory-section > :last-child { margin-bottom: 12px; }
.category-tree { display: grid; gap: 6px; margin-top: 12px; }
.category-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.category-card summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 9px 10px;
}
.category-card:not([open]) summary:hover { background: var(--surface-soft); }
.category-card summary::-webkit-details-marker { display: none; }
.category-card summary strong { font-size: 13px; }
.category-card summary span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.category-card summary form { margin: 0; }
.category-card button, .subcategory-row button, .directory-row button, .employee-row button, .compact-form button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
  color: var(--accent);
  cursor: pointer;
  font-weight: 700;
  padding: 0 8px;
}
.subcategory-list { display: grid; gap: 0; padding: 0 10px 10px; }
.category-empty { padding: 0 10px 10px; margin: 0; }
.subcategory-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  color: var(--ink);
}
.rule-form { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.user-form { grid-template-columns: 1.5fr 1fr 1fr 1fr auto; }
.directory-wide { grid-column: 1 / -1; }
.directory-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.directory-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.directory-row:nth-child(even) { background: var(--surface-soft); }
.directory-row:last-child { border-bottom: 0; }
.directory-row span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.employee-table {
  display: grid;
  gap: 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}
.employee-row {
  min-width: 1180px;
  display: grid;
  grid-template-columns: 1.35fr .9fr .8fr 1.1fr 1.1fr .8fr .75fr .75fr 1.2fr .7fr 1fr;
  gap: 6px;
  align-items: center;
  padding: 7px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.employee-row:last-child { border-bottom: 0; }
.employee-row:nth-child(even):not(.employee-head) { background: var(--surface-soft); }
.employee-head {
  min-height: 34px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  background: var(--surface-soft);
}
.employee-row input,
.employee-row select {
  width: 100%;
  min-height: 30px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #fff;
}
.employee-row select { color: var(--ink); }
.employee-row > span {
  color: var(--muted);
  font-size: 12px;
}
.row-actions {
  display: flex;
  gap: 5px;
  justify-content: flex-end;
}
.compact-form { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.muted-row { opacity: .55; }
.nested-directory-section {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  overflow: hidden;
}
.nested-directory-section > summary {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  background: var(--surface-soft);
}
.nested-directory-section > summary::-webkit-details-marker { display: none; }
.nested-directory-section > summary span { font-weight: 800; }
.nested-directory-section > summary em {
  min-width: 24px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-style: normal;
  font-weight: 800;
  text-align: center;
}
.nested-directory-section > .employee-table {
  margin: 10px;
}
.nested-empty { padding: 10px; margin: 0; }

.correction-note {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  margin-bottom: 10px;
  background: var(--warning-soft);
}
.correction-note p { margin: 3px 0 0; color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.document-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.document-actions p { margin: 4px 0 0; }
.document-actions form { margin: 0; }
.detail-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin: 10px 0 0;
}
.detail-list div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); }
.detail-list dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-weight: 650; }
.audit-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin-top: 10px;
}
.audit-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}
.audit-row:last-child { border-bottom: 0; }
.audit-row span { color: var(--muted); font-size: 12px; }
.audit-row p { margin: 2px 0 0; color: var(--muted); }
.audit-row-wide { align-items: flex-start; }

.bar-list { display: grid; gap: 8px; margin-top: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px 8px; align-items: center; }
.bar-row span { color: var(--muted); }
.bar-row strong, .cash-row strong, .roi-numbers strong, .reconcile-amounts strong {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.bar-track { grid-column: 1 / -1; height: 6px; background: #eef2ff; border-radius: 999px; overflow: hidden; }
.bar-track i { display: block; height: 100%; background: #93c5fd; border-radius: inherit; }
.bar-track.income i { background: #86efac; }
.bar-track.investment i { background: #fbbf24; }
.roi-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, .85fr);
  gap: 12px;
  align-items: end;
}
.roi-numbers { display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); gap: 8px; }
.roi-numbers div {
  min-width: 150px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.roi-numbers span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; margin-bottom: 3px; }
.roi-numbers strong { font-size: 15px; }
.roi-track {
  grid-column: 1 / -1;
  height: 8px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
}
.roi-track i { display: block; height: 100%; max-width: 100%; background: var(--accent); border-radius: inherit; }
.quick-panel {
  display: grid;
  grid-template-columns: 1.35fr repeat(5, minmax(128px, 1fr));
  gap: 8px;
  margin: -2px 0 12px;
}
.quick-action {
  min-height: 54px;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.quick-action:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.quick-action strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  line-height: 1.15;
  font-weight: 780;
}
.quick-action strong em {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  line-height: 1.25;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.quick-action span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}
.quick-action:hover strong,
.quick-action:hover span {
  color: var(--accent);
}
.quick-action.primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
.quick-action.primary-action span { color: rgba(255,255,255,.82); }
.quick-action.primary-action:hover { background: #1d4ed8; color: #fff; }
.quick-action.primary-action:hover strong,
.quick-action.primary-action:hover span {
  color: #fff;
}
.quick-action.needs-attention {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, .2);
}
.quick-action.needs-attention strong,
.quick-action.needs-attention:hover strong {
  color: #92400e;
}
.quick-action.needs-attention span,
.quick-action.needs-attention:hover span {
  color: #a16207;
}
.quick-action.needs-attention strong em {
  background: #f59e0b;
  color: #fff;
}
.quick-action.needs-attention:hover {
  border-color: #d97706;
  background: #fef3c7;
}
.sync-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.sync-status {
  min-height: 86px;
  margin: 0;
}
.sync-status form { margin: 0; }
.sync-status button.primary-link {
  font: inherit;
  cursor: pointer;
}
.sync-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}
.quick-actions { display: grid; gap: 6px; margin-top: 10px; }
.quick-actions a {
  min-height: 40px;
  display: grid;
  gap: 2px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  font-weight: 700;
}
.quick-actions a:hover { border-color: var(--accent); background: var(--accent-soft); }
.action-grid a span { color: var(--muted); font-size: 12px; font-weight: 500; }

.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  align-items: stretch;
}
.import-card { display: grid; align-content: start; gap: 12px; margin-top: 0; min-height: 250px; }
.import-card form { margin-top: 0; }
.bank-agent-card { background: var(--surface-soft); }
.agent-status {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.agent-status span, .agent-status small { color: var(--muted); }
.agent-status strong { font-size: 20px; line-height: 1.1; }
.agent-stats { display: flex; flex-wrap: wrap; gap: 6px; }
.agent-stats span {
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}
.cash-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
  margin-top: 10px;
}
.cash-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.cash-row:nth-child(even) { background: var(--surface-soft); }
.cash-row:last-child { border-bottom: 0; }
.cash-row span { color: var(--muted); }
.cash-item {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.cash-item:nth-child(even) { background: var(--surface-soft); }
.cash-item:last-child { border-bottom: 0; }
.cash-item .cash-row {
  padding: 0;
  border: 0;
  background: transparent;
}
.cash-item .hint {
  margin: 0;
  font-size: 12px;
}
.notice.compact {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}
.notice.compact strong { color: var(--ink); font-size: 13px; }

.analytics-head { align-items: flex-start; }
.analytics-scope {
  display: grid;
  gap: 2px;
  min-width: 210px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: right;
}
.analytics-scope strong { color: var(--ink); font-size: 15px; }
.analytics-filter-panel { gap: 10px; }
.analytics-filter-form {
  grid-template-columns: repeat(3, minmax(150px, 1fr)) auto;
}
.metric-switch {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  width: fit-content;
}
.metric-switch a {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border-radius: 5px;
  color: var(--muted);
  font-weight: 750;
}
.metric-switch a:hover,
.metric-switch a.active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line);
}
.analytics-kpis { margin-bottom: 12px; }
.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .75fr);
  gap: 12px;
}
.analytics-card { overflow: hidden; }
.analytics-card-main { min-width: 0; }
.analytics-panel-head { align-items: flex-start; margin-bottom: 12px; }
.analytics-panel-head p { margin: 3px 0 0; }
.chip {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.positive-chip {
  border-color: #bbf7d0;
  background: var(--success-soft);
  color: var(--green);
}
.analytics-bars { display: grid; gap: 8px; }
.analytics-bar-row {
  display: grid;
  grid-template-columns: minmax(160px, .9fr) minmax(180px, 1.4fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.analytics-bar-row:last-child { border-bottom: 0; }
.analytics-bar-label { min-width: 0; display: grid; gap: 2px; }
.analytics-bar-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.analytics-bar-label span { color: var(--muted); font-size: 12px; }
.analytics-bar-track {
  height: 11px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
.analytics-bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #059669);
}
.analytics-bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.repair-list { display: grid; gap: 8px; }
.repair-list div {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}
.repair-list span { color: var(--muted); }
.line-chart-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fff, var(--surface-soft));
  padding: 12px 12px 8px;
}
.line-chart-shell {
  display: grid;
  grid-template-columns: minmax(68px, auto) minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}
.line-scale {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 260px;
  padding: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.line-chart {
  width: 100%;
  height: 260px;
  display: block;
}
.line-chart line {
  stroke: var(--line);
  stroke-width: .35;
  vector-effect: non-scaling-stroke;
}
.line-chart polyline {
  fill: none;
  stroke: var(--line-color);
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}
.line-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  overflow-x: auto;
}
.line-axis span { white-space: nowrap; }
.analytics-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 10px;
  color: var(--muted);
}
.analytics-legend span { display: inline-flex; align-items: center; gap: 6px; }
.analytics-legend em {
  color: var(--ink);
  font-style: normal;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.analytics-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}
.heatmap-wrap {
  overflow-x: auto;
  padding-bottom: 2px;
}
.heatmap {
  min-width: 760px;
  display: grid;
  grid-template-columns: 38px repeat(var(--heatmap-hours, 16), minmax(34px, 1fr));
  gap: 4px;
}
.heatmap-head,
.heatmap-hour,
.heatmap-day,
.heat-cell {
  min-height: 28px;
  display: grid;
  place-items: center;
  border-radius: 5px;
}
.heatmap-hour {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}
.heatmap-day {
  justify-content: start;
  color: var(--muted);
  font-weight: 850;
}
.heat-cell {
  border: 1px solid var(--line);
  background: #fff;
  color: #0f172a;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.heat-cell span { line-height: 1; }
.weekday-list { display: grid; gap: 9px; }
.weekday-row {
  display: grid;
  grid-template-columns: 30px minmax(100px, 1fr) minmax(86px, auto);
  gap: 8px;
  align-items: center;
}
.weekday-row span { color: var(--muted); font-weight: 850; }
.weekday-row strong {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.weekday-row small {
  grid-column: 2 / -1;
  margin-top: -5px;
  color: var(--muted);
}
.weekday-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}
.weekday-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d97706, #059669);
}
.analytics-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.analytics-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
  background: #fff;
}
.analytics-table th,
.analytics-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.analytics-table th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.analytics-table th:first-child,
.analytics-table td:first-child {
  text-align: left;
}
.analytics-table tr:last-child td { border-bottom: 0; }
.reconcile-list {
  display: grid;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}
.reconcile-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, auto);
  gap: 12px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.reconcile-row:last-child { border-bottom: 0; }
.reconcile-row p { margin: 3px 0 0; color: var(--muted); }
.reconcile-amounts { display: grid; gap: 4px; text-align: right; color: var(--muted); }
.reconcile-amounts strong { display: inline-block; min-width: 92px; color: var(--ink); }
.reconcile-amounts .positive { color: var(--green); }
.reconcile-amounts .negative { color: var(--red); }
.reconcile-amounts .neutral { color: var(--gold); }
.bank-rows { display: grid; gap: 6px; margin-top: 10px; }
.bank-row { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; background: #fff; }
.bank-row summary { cursor: pointer; display: grid; grid-template-columns: 110px 130px 1fr; gap: 10px; align-items: center; }
.bank-row em { color: var(--muted); font-style: normal; }
.bank-row pre { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-soft); padding: 8px; border-radius: 6px; color: var(--muted); }

.bottom-nav { display: none; }

@media (max-width: 1080px) {
  .review-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-filter-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .analytics-grid { grid-template-columns: 1fr; }
  .import-grid { grid-template-columns: 1fr; }
  .quick-panel { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 860px) {
  .shell { display: block; }
  .side {
    position: static;
    height: auto;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .brand { flex: 0 0 auto; margin-bottom: 0; }
  .brand div { display: none; }
  .nav { display: flex; gap: 3px; overflow-x: auto; }
  .nav-section { display: none; }
  .nav a { white-space: nowrap; }
  .logout { position: static; display: none; }
  .main { padding: 12px 10px 22px; }
  .page-head { display: grid; }
  .analytics-scope { min-width: 0; text-align: left; }
  .head-actions { justify-content: stretch; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-menu { justify-self: start; }
  .export-menu div { left: 0; right: auto; }
  h1 { font-size: 22px; }
  .summary-grid { grid-template-columns: 1fr; }
  .summary-grid .metric { border-right: 0; border-bottom: 1px solid var(--line); }
  .summary-grid .metric:last-child { border-bottom: 0; }
  .metric strong { font-size: 20px; }
  .quick-panel, .sync-status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid, .split-forms, .roi-panel, .roi-numbers, .directory-grid, .detail-grid { grid-template-columns: 1fr; }
  .review-main { grid-template-columns: 1fr; }
  .review-fields, .form-grid, .filter-form, .analytics-filter-form, .inline-form, .rule-form, .user-form { grid-template-columns: 1fr; }
  .form-grid .full-span { grid-column: auto; }
  .manual-submit, .form-actions .primary, .form-actions .soft-button, .document-actions .primary-link, .document-actions .soft-button { width: 100%; }
  .document-actions { display: grid; }
  .period-switch { display: flex; overflow-x: auto; width: 100%; }
  .status-tabs { width: 100%; overflow-x: auto; }
  .category-card summary { grid-template-columns: 1fr; }
  .tx-list { overflow-x: auto; }
  .tx-row { min-width: 760px; }
  .draft-inline { min-width: 760px; grid-template-columns: 1fr; }
  .draft-inline-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); white-space: normal; }
  .draft-inline-actions .primary-link, .draft-inline-actions .soft-button { width: 100%; }
  .tx-side { text-align: left; grid-template-columns: auto auto 1fr; justify-items: start; }
  .attention { display: grid; }
  .sync-status-grid { grid-template-columns: 1fr; }
  .detail-list div { grid-template-columns: 1fr; gap: 3px; }
  .bank-row summary { grid-template-columns: 1fr; }
  .reconcile-row { grid-template-columns: 1fr; }
  .reconcile-amounts { text-align: left; }
  .analytics-filter-panel .period-switch,
  .metric-switch { width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .metric-switch a { white-space: nowrap; }
  .analytics-bar-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }
  .analytics-bar-value { text-align: left; }
  .line-chart-shell {
    grid-template-columns: 1fr;
    gap: 4px;
  }
  .line-scale {
    min-height: 0;
    flex-direction: row-reverse;
    padding: 0;
    text-align: left;
  }
  .line-chart { height: 210px; }
  .weekday-row { grid-template-columns: 30px minmax(90px, 1fr) minmax(82px, auto); }
  .bottom-nav { display: none; }
}

@media (max-width: 520px) {
  .quick-panel { grid-template-columns: 1fr; }
}
