:root {
  color-scheme: light;
  --brand-charcoal: #3b4246;
  --brand-charcoal-dark: #1d211d;
  --brand-gold: #d8b52f;
  --brand-ivory: #dedccd;
  --bg: #f2f0e8;
  --panel: #fffef9;
  --panel-soft: #f7f5ec;
  --line: #d8d2c0;
  --ink: #1d211d;
  --muted: #5f6666;
  --accent: #3b4246;
  --accent-2: #d8b52f;
  --warn: #a87705;
  --danger: #9f2f24;
  --closed: #9aa0a0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.sidebar-collapsed .sidebar {
  width: 76px;
}

body.sidebar-collapsed .shell {
  margin-left: 76px;
}

body.sidebar-collapsed .brand {
  justify-content: center;
}

body.sidebar-collapsed .brand-logo {
  display: none;
}

body.sidebar-collapsed .brand-favicon {
  display: block;
}

body.sidebar-collapsed .menu button {
  justify-content: center;
  padding-inline: 0;
}

body.sidebar-collapsed .menu span {
  display: none;
}

button,
input,
select {
  font: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 248px;
  background: var(--brand-charcoal-dark);
  color: #fff;
  padding: 24px 18px;
  overflow: hidden;
  transition: width 180ms ease;
}

.brand {
  display: flex;
  align-items: center;
  margin: 14px 0 30px;
}

.brand-logo {
  display: block;
  width: min(198px, 100%);
  height: auto;
}

.brand-favicon {
  display: none;
  width: 42px;
  height: 42px;
  object-fit: contain;
}

.muted,
.eyebrow,
label span,
.kpi-card span,
.kpi-card small,
.section-head small,
td small,
.detail-grid span,
.ops-grid span {
  color: var(--muted);
}

.menu {
  display: grid;
  gap: 8px;
}

.menu button,
.menu a {
  width: 100%;
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--brand-ivory);
  cursor: pointer;
  padding: 10px 12px;
  text-align: left;
  text-decoration: none;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
}

.menu svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: currentColor;
  opacity: 0.9;
}

.menu span {
  min-width: 0;
}

.menu button.active,
.menu button:hover,
.menu a:hover {
  background: rgba(216, 181, 47, 0.14);
  color: #fff;
}

.shell {
  margin-left: 248px;
  padding: 28px;
  transition: margin-left 180ms ease;
}

.topbar,
.toolbar,
.view {
  max-width: 1540px;
  margin: 0 auto;
}

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

.sidebar-toggle {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(222, 220, 205, 0.22);
  border-radius: 8px;
  background: rgba(222, 220, 205, 0.06);
  color: var(--brand-ivory);
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: rgba(216, 181, 47, 0.14);
}

.sidebar-toggle svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin: 4px 0 6px;
  font-size: 31px;
  line-height: 1.15;
}

h2 {
  font-size: 19px;
  line-height: 1.25;
}

.eyebrow {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 250px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  padding: 11px 14px;
  text-align: center;
}

.status::before {
  display: none;
  width: 8px;
  height: 8px;
  flex: 0 0 8px;
  border-radius: 999px;
  content: "";
}

.status[data-tone="loading"] {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--brand-charcoal-dark);
}

.status[data-tone="loading"]::before {
  display: block;
  background: var(--danger);
  box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.42);
  animation: status-pulse 1.1s ease-out infinite;
}

.status[data-tone="ok"] {
  border-color: rgba(42, 125, 77, 0.34);
  color: var(--brand-charcoal-dark);
}

.status[data-tone="ok"]::before {
  display: block;
  background: #2a7d4d;
}

.status[data-tone="error"] {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.status[data-tone="error"]::before {
  display: block;
  background: var(--danger);
}

@keyframes status-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(180, 35, 24, 0.42);
    transform: scale(1);
  }

  70% {
    box-shadow: 0 0 0 7px rgba(180, 35, 24, 0);
    transform: scale(1.08);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(180, 35, 24, 0);
    transform: scale(1);
  }
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 170px 210px 130px;
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  font-size: 13px;
  font-weight: 700;
}

input,
select,
.toolbar button {
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

input,
select {
  width: 100%;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

.toolbar button {
  align-self: end;
  background: var(--brand-charcoal);
  border-color: var(--brand-charcoal);
  color: var(--brand-ivory);
  cursor: pointer;
  font-weight: 800;
}

.toolbar button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.kpi-card,
.panel,
.table-wrap,
.details {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.kpi-card.strong {
  border-color: rgba(216, 181, 47, 0.48);
  background: #fbf6dc;
}

.kpi-card.attention {
  border-color: rgba(181, 71, 8, 0.3);
  background: #fff8ef;
}

.kpi-card span,
.kpi-card small {
  display: block;
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  display: block;
  margin: 10px 0 7px;
  font-size: 27px;
  line-height: 1;
}

.visual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

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

.panel {
  min-height: 260px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.section-head small {
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.donut-wrap {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 20px;
  align-items: center;
  min-height: 184px;
}

.donut {
  display: grid;
  width: 172px;
  height: 172px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(var(--brand-charcoal) 0 var(--active-rate), var(--brand-gold) var(--active-rate) 100%);
  position: relative;
  cursor: help;
  transition: transform 160ms ease, filter 160ms ease;
}

.donut:hover {
  filter: drop-shadow(0 10px 18px rgba(59, 66, 70, 0.18));
  transform: scale(1.03);
}

.donut::after {
  content: "";
  position: absolute;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--panel);
}

.donut span {
  position: relative;
  z-index: 1;
  font-size: 25px;
  font-weight: 800;
}

.legend {
  display: grid;
  gap: 12px;
}

.legend-row {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  gap: 8px;
  align-items: center;
  border: 0;
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  padding: 7px 8px;
  text-align: left;
}

.legend-row:hover {
  background: #fbf6dc;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
}

.dot.active {
  background: var(--brand-charcoal);
}

.dot.closed {
  background: var(--brand-gold);
}

.columns {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  min-height: 190px;
  align-items: end;
}

.column {
  display: grid;
  grid-template-rows: auto 150px auto;
  gap: 7px;
  text-align: center;
}

.column span,
.column small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.column i {
  display: block;
  align-self: end;
  border-radius: 8px 8px 3px 3px;
  background: linear-gradient(180deg, var(--brand-gold), var(--brand-charcoal));
  transition: filter 160ms ease, transform 160ms ease;
}

.column {
  cursor: help;
}

.column:hover i {
  filter: brightness(1.08);
  transform: translateY(-4px);
}

.flow-chart {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  min-height: 190px;
  align-items: end;
}

.flow-month {
  display: grid;
  grid-template-rows: auto 142px auto;
  gap: 7px;
  text-align: center;
  cursor: help;
}

.flow-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.flow-values span,
.flow-month small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.flow-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  align-items: end;
}

.flow-bars i {
  display: block;
  border-radius: 8px 8px 3px 3px;
  transition: filter 160ms ease, transform 160ms ease;
}

.flow-month:hover .flow-bars i {
  filter: brightness(1.08);
  transform: translateY(-4px);
}

.flow-bars .entry {
  background: linear-gradient(180deg, var(--brand-gold), var(--brand-charcoal));
}

.flow-bars .closed {
  background: linear-gradient(180deg, var(--brand-ivory), var(--closed));
}

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

.range-card {
  min-height: 84px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 13px;
  cursor: help;
  transition: border-color 160ms ease, transform 160ms ease;
}

.range-card:hover {
  border-color: rgba(181, 71, 8, 0.38);
  transform: translateY(-2px);
}

.range-card span,
.range-card strong {
  display: block;
}

.range-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.range-card strong {
  margin: 8px 0 10px;
  font-size: 24px;
}

.range-card i {
  display: block;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e7edf3;
}

.range-card b {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warn), var(--danger));
}

.bars {
  display: grid;
  gap: 13px;
}

.bar-row {
  display: grid;
  gap: 7px;
  width: 100%;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.bar-row:hover .bar-track i {
  filter: brightness(1.08);
}

.bar-row:hover strong {
  color: var(--brand-charcoal);
}

.bar-row div:first-child {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: start;
}

.bar-row strong,
.bar-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-row strong {
  font-size: 13px;
}

.bar-row span {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

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

.bar-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-charcoal), var(--brand-gold));
}

.compact-select {
  width: min(260px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 10px;
}

.sentence-pie {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 16px;
  align-items: center;
  min-height: 246px;
}

.pie-visual {
  width: min(100%, 240px);
  aspect-ratio: 1;
}

.pie-visual svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.pie-visual path,
.pie-visual circle {
  cursor: help;
  stroke: var(--panel);
  stroke-width: 2;
  transition: filter 160ms ease, transform 160ms ease;
  transform-box: fill-box;
  transform-origin: center;
}

.pie-visual path:hover,
.pie-visual circle:hover {
  filter: drop-shadow(0 7px 12px rgba(29, 33, 29, 0.2));
  transform: scale(1.025);
}

.pie-visual text {
  fill: #fff;
  font-size: 23px;
  font-weight: 800;
  pointer-events: none;
}

.pie-legend {
  display: grid;
  gap: 9px;
}

.pie-legend div {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.pie-legend i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.pie-legend span,
.pie-legend strong {
  font-size: 12px;
  font-weight: 800;
}

.pie-legend span {
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pie-legend strong {
  color: var(--ink);
}

.content {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 16px;
  align-items: start;
}

.table-wrap,
.details {
  min-height: 560px;
  overflow: hidden;
}

.table-title {
  padding: 16px 16px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th:nth-child(1),
td:nth-child(1) {
  width: 24%;
}

th:nth-child(2),
td:nth-child(2) {
  width: 16%;
}

th:nth-child(3),
td:nth-child(3) {
  width: 14%;
}

th:nth-child(4),
td:nth-child(4) {
  width: 16%;
}

th:nth-child(5),
td:nth-child(5) {
  width: 20%;
}

th:nth-child(6),
td:nth-child(6) {
  width: 10%;
}

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

th {
  background: var(--brand-ivory);
  color: var(--brand-charcoal);
  font-size: 12px;
  text-transform: uppercase;
}

td {
  font-size: 14px;
}

td strong,
td small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.active {
  background: #fbf6dc;
}

.empty {
  height: 180px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: #fbf1c7;
  color: #6f5400;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 800;
}

.details {
  padding: 18px;
}

.details h2 {
  margin: 8px 0 14px;
}

.detail-grid {
  display: grid;
  gap: 10px;
}

.detail-grid div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.detail-grid span,
.detail-grid strong {
  display: block;
}

.detail-grid span {
  margin-bottom: 3px;
  font-size: 12px;
}

.detail-grid strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
}

details {
  margin-top: 16px;
}

summary {
  color: var(--brand-charcoal);
  cursor: pointer;
  font-weight: 800;
}

pre {
  max-height: 260px;
  overflow: auto;
  border-radius: 8px;
  background: var(--brand-charcoal-dark);
  color: var(--brand-ivory);
  padding: 12px;
  font-size: 12px;
}

.finance-hero {
  display: grid;
  align-content: center;
  gap: 10px;
  background: #fbf6dc;
}

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

.finance-hero strong {
  font-size: 36px;
  line-height: 1;
}

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

.ops-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 14px;
}

.ops-grid span,
.ops-grid strong {
  display: block;
}

.ops-grid span {
  font-size: 12px;
  font-weight: 800;
}

.ops-grid strong {
  margin-top: 8px;
  font-size: 23px;
}

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

.recent-list,
.critical-list {
  display: grid;
  gap: 10px;
}

.recent-item,
.critical-item {
  min-height: 58px;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  padding: 11px 12px;
  text-align: left;
}

.recent-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(150px, 240px);
  width: 100%;
  overflow: hidden;
}

.critical-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  width: 100%;
}

.recent-item:hover,
.critical-item:hover {
  background: #fbf6dc;
}

.recent-item strong,
.recent-item span,
.recent-item small,
.critical-item strong,
.critical-item span,
.critical-item small {
  display: block;
}

.recent-item div,
.critical-item div {
  min-width: 0;
}

.recent-item span,
.critical-item span {
  max-width: 100%;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recent-item small,
.critical-item small {
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  min-width: 118px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chart-tooltip {
  position: fixed;
  z-index: 30;
  max-width: 340px;
  pointer-events: none;
  border: 1px solid rgba(21, 34, 50, 0.14);
  border-radius: 8px;
  background: var(--brand-charcoal-dark);
  color: var(--brand-ivory);
  box-shadow: 0 14px 34px rgba(29, 33, 29, 0.26);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
  opacity: 0;
  padding: 9px 10px;
  transform: translateY(3px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
}

.modal.open {
  display: block;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(29, 33, 29, 0.58);
}

.modal-panel {
  position: absolute;
  inset: 36px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  max-width: 980px;
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(29, 33, 29, 0.28);
  padding: 18px;
}

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

.modal-head small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
  font-weight: 700;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

.modal-close:hover {
  background: #fbf6dc;
}

.auth-submit {
  width: 160px;
  height: 43px;
  border: 1px solid var(--brand-charcoal);
  border-radius: 8px;
  background: var(--brand-charcoal);
  color: var(--brand-ivory);
  cursor: pointer;
  font-weight: 800;
}

.auth-submit:hover {
  filter: brightness(1.05);
}

.modal-search {
  margin-bottom: 14px;
}

.hidden {
  display: none !important;
}

.modal-search small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-weight: 800;
}

.modal-bars {
  align-content: start;
  overflow: auto;
  padding-right: 6px;
}

@media (max-width: 1180px) {
  .kpi-grid,
  .visual-grid,
  .visual-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

@media (max-width: 840px) {
  .sidebar {
    position: static;
    width: auto;
    transform: none;
  }

  .shell {
    margin-left: 0;
    padding: 18px;
  }

  body.sidebar-collapsed .sidebar {
    width: auto;
  }

  body.sidebar-collapsed .shell {
    margin-left: 0;
  }

  .topbar {
    flex-direction: column;
  }

  .toolbar,
  .kpi-grid,
  .visual-grid,
  .visual-grid.two,
  .donut-wrap,
  .ops-grid {
    grid-template-columns: 1fr;
  }

  .status {
    width: 100%;
    text-align: left;
  }

  .recent-item,
  .critical-item {
    align-items: flex-start;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .critical-item small {
    min-width: 0;
    text-align: left;
  }

  .flow-chart,
  .range-grid,
  .sentence-pie {
    grid-template-columns: 1fr;
  }

  .compact-select {
    width: 100%;
  }
}
