:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-2: #f0f4f1;
  --line: #d9dfd6;
  --text: #20251f;
  --muted: #657063;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff1ed;
  --warning: #a15c07;
  --warning-soft: #fff1d5;
  --danger: #a83434;
  --danger-soft: #fbe2df;
  --ok: #2f7d45;
  --ok-soft: #e4f4e8;
  --violet: #574b90;
  --shadow: 0 14px 35px rgba(33, 42, 31, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
  line-height: 1.45;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 72px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, #0f766e, #486a2e);
  font-weight: 700;
}

.brand strong,
.brand small {
  display: block;
}

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

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.user-status {
  max-width: 280px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-field {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.compact-field select {
  min-width: 210px;
}

.icon-button {
  min-width: 44px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface);
  font-size: 12px;
  font-weight: 700;
}

.icon-button:hover {
  border-color: var(--accent);
}

.app-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: calc(100vh - 72px);
}

.sidebar {
  padding: 18px 14px;
  border-right: 1px solid var(--line);
  background: #eef2ec;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.nav-button {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.nav-button:hover,
.nav-button.is-active {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface);
}

.nav-child {
  min-height: 36px;
  margin-left: 14px;
  padding-left: 14px;
  font-size: 13px;
}

.content {
  width: 100%;
  max-width: 1440px;
  padding: 24px;
}

body.is-login .topbar {
  position: static;
}

body.is-login .sidebar {
  display: none;
}

body.is-login .app-layout {
  display: block;
  min-height: calc(100vh - 72px);
}

body.is-login .content {
  max-width: none;
  min-height: calc(100vh - 72px);
  padding: 0;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 72px);
  place-items: center;
  padding: 28px;
}

.auth-card {
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-card p {
  margin: 6px 0 0;
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.view-header h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.15;
}

.view-header p {
  max-width: 780px;
  margin: 7px 0 0;
  color: var(--muted);
}

.grid {
  display: grid;
  gap: 16px;
}

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

.grid.two {
  grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.15fr);
  align-items: start;
}

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

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 16px;
}

.subnav .secondary-button.is-active {
  border-color: var(--accent);
  color: #ffffff;
  background: var(--accent);
}

.card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  min-height: 118px;
  padding: 16px;
}

.card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.card strong {
  display: block;
  margin-top: 12px;
  font-size: 27px;
  line-height: 1.1;
}

.card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.panel {
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.panel-header h2 {
  margin: 0;
  font-size: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.panel-body {
  padding: 16px;
}

.catalog-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.catalog-search .muted {
  padding-bottom: 10px;
  white-space: nowrap;
}

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

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

.field {
  display: grid;
  gap: 6px;
}

.check-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
}

.check-field input {
  width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
}

.role-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.field span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #ffffff;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 3px solid var(--accent-soft);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.primary-button,
.secondary-button,
.danger-button {
  min-height: 40px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 700;
}

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

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

.secondary-button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--surface);
}

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

.danger-button {
  border: 1px solid #d8a3a3;
  color: var(--danger);
  background: var(--danger-soft);
}

.attachment-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.attachment-list.compact {
  display: inline-flex;
  margin-top: 6px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.attachment-link {
  border: 0;
  padding: 0;
  color: var(--accent);
  background: transparent;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.primary-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

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

th {
  color: var(--muted);
  background: #fbfcfa;
  font-size: 12px;
  text-transform: uppercase;
}

td.actions {
  width: 1%;
  white-space: nowrap;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.status.ok {
  color: var(--ok);
  background: var(--ok-soft);
}

.status.warn {
  color: var(--warning);
  background: var(--warning-soft);
}

.status.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.status.info {
  color: var(--violet);
  background: #ebe8fb;
}

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

.empty {
  padding: 18px;
  color: var(--muted);
}

.month-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.transaction-filters {
  margin-top: 16px;
}

.transaction-filter-grid {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.accountability-report {
  margin-bottom: 16px;
}

.report-cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: 16px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.report-cover h3 {
  margin: 6px 0;
  font-size: 22px;
}

.report-cover p {
  margin: 0;
  color: var(--muted);
}

.report-cover-kpis {
  display: grid;
  gap: 8px;
}

.report-section {
  margin-top: 18px;
}

.report-section h3 {
  margin: 0;
  padding: 12px 0 8px;
  font-size: 17px;
}

.report-notes {
  margin: 0;
  padding-left: 20px;
}

.report-notes li {
  margin: 8px 0;
}

.dre-table {
  min-width: 860px;
  border-collapse: collapse;
}

.dre-table th,
.dre-table td {
  border: 2px solid #111111;
  padding: 6px 8px;
}

.dre-table th {
  color: #000000;
  background: #ffffff;
  font-size: 20px;
  text-align: center;
  text-transform: none;
}

.dre-table thead tr + tr th {
  font-size: 14px;
  font-weight: 500;
}

.dre-table td {
  color: #000000;
  background: #ffffff;
  font-size: 16px;
  text-align: right;
}

.dre-table td:first-child {
  min-width: 250px;
  text-align: left;
}

.dre-table .dre-bold td:first-child,
.dre-table .dre-section-row td:first-child {
  font-weight: 800;
}

.dre-table .dre-indent {
  padding-left: 34px;
}

.dre-table .dre-expense-row td {
  color: #ffffff;
  background: #ff0000;
  font-weight: 800;
}

.dre-table .dre-expense-row td:first-child {
  color: #000000;
  background: #ffffff;
}

.dre-table .dre-result-row td {
  color: #ff0000;
  background: #f5d7cf;
}

.dre-table .dre-result-row td:first-child {
  color: #000000;
  background: #ffffff;
  font-weight: 800;
}

.dre-table .dre-spacer td {
  height: 20px;
  background: #ffffff;
}

.month-groups {
  display: grid;
}

.month-group + .month-group {
  border-top: 1px solid var(--line);
}

.month-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfa;
}

.month-group-header span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.summary-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-line:last-child {
  border-bottom: 0;
}

.inline-link-fields {
  display: grid;
  gap: 6px;
  min-width: 190px;
}

.inline-link-fields input,
.inline-link-fields select {
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.import-attachment-field {
  display: grid;
  gap: 6px;
}

.import-attachment-field input[type="file"] {
  min-width: 220px;
}

.inline-recurring-options {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 88px;
  gap: 6px;
  align-items: end;
}

.inline-check-field,
.inline-recurring-field {
  color: var(--muted);
  font-size: 12px;
}

.inline-check-field {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
}

.inline-link-fields .inline-check-field input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
}

.inline-recurring-field {
  display: grid;
  gap: 3px;
}

.inline-recurring-field span {
  line-height: 1;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px minmax(100px, 1fr) 110px;
  align-items: center;
  gap: 10px;
}

.bar-track {
  height: 11px;
  border-radius: 999px;
  background: #e3e7df;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  border-left: 3px solid var(--accent);
  padding: 2px 0 2px 10px;
}

.audit-item strong {
  display: block;
}

.notice {
  margin-bottom: 16px;
  border: 1px solid var(--warning);
  border-radius: 8px;
  padding: 12px 14px;
  color: #4c3304;
  background: var(--warning-soft);
}

.hide {
  display: none;
}

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

  .sidebar {
    position: sticky;
    top: 72px;
    z-index: 9;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    display: flex;
    min-width: max-content;
  }

  .nav-button {
    text-align: center;
  }

  .grid.kpis,
  .grid.two,
  .grid.three {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .topbar {
    position: static;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .user-status {
    max-width: 100%;
  }

  .compact-field {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .compact-field select {
    min-width: 0;
  }

  .content {
    padding: 18px 14px;
  }

  .view-header {
    flex-direction: column;
  }

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

  .role-checks {
    grid-template-columns: 1fr;
  }

  .catalog-search {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .catalog-search .muted {
    padding-bottom: 0;
  }

  .bar-row {
    grid-template-columns: 1fr;
  }

  .report-cover {
    grid-template-columns: 1fr;
  }

  .month-group-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .month-group-header span {
    text-align: left;
  }
}
