:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --graphite: #332e2e;
  --graphite-2: #211d1d;
  --text: #191615;
  --muted: #6f7377;
  --line: #e2e5e7;
  --orange: #ff7108;
  --orange-2: #f05f00;
  --silver: #d8dbdd;
  --green: #178f62;
  --red: #c84a3d;
  --blue: #3067a8;
  --shadow: 0 20px 55px rgba(30, 27, 27, .10);
  --radius: 8px;
  --font: "Aptos", "Segoe UI", Arial, sans-serif;
  --display: "Bahnschrift", "Aptos", "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scrollbar-gutter: stable; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 72% 0%, rgba(255, 113, 8, .12), transparent 30rem),
    linear-gradient(135deg, #f6f7f8 0%, #eceff1 46%, #f8f8f8 100%);
  color: var(--text);
  font: 14px/1.45 var(--font);
}

a { color: inherit; }
button { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  overflow: auto;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 113, 8, .14), transparent 28%),
    linear-gradient(180deg, var(--graphite), var(--graphite-2));
  border-right: 1px solid rgba(255, 255, 255, .08);
}

.brand {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 72px;
  padding: 10px;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .07);
}

.brand img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(255,255,255,.92);
  box-shadow: 0 10px 22px rgba(0,0,0,.16);
}

.brand strong {
  display: block;
  font: 800 18px/1.05 var(--display);
  letter-spacing: 0;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,.65);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.nav-stack {
  display: grid;
  gap: 7px;
}

.nav-link {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 8px 10px;
  color: rgba(255,255,255,.78);
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease;
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.10);
  transform: translateX(3px);
}

.nav-link.active {
  box-shadow: inset 3px 0 0 var(--orange);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.08);
  color: var(--orange);
  font-size: 11px;
  font-weight: 900;
}

.sidebar-panel {
  margin-top: auto;
  display: grid;
  grid-template-columns: 14px minmax(0,1fr);
  gap: 10px;
  align-items: start;
  padding: 14px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
}

.sidebar-panel strong,
.sidebar-panel small { display: block; }
.sidebar-panel small { margin-top: 3px; color: rgba(255,255,255,.62); }
.pulse-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 999px;
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(255,113,8,.55);
  animation: pulse 1.9s ease infinite;
}

.main-content {
  min-width: 0;
  width: min(1680px, 100%);
  margin: 0 auto;
  padding: 20px;
}

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

.topbar h1 {
  margin: 3px 0 0;
  font: 850 28px/1.05 var(--display);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: var(--orange-2);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.icon-button,
.refresh-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,255,255,.86);
  color: var(--text);
  box-shadow: 0 10px 24px rgba(35, 31, 31, .07);
  cursor: pointer;
}

.icon-button {
  width: 42px;
  display: grid;
  place-items: center;
  font-weight: 900;
}

.refresh-button {
  padding: 0 14px;
  background: linear-gradient(180deg, var(--orange), var(--orange-2));
  color: #fff;
  border-color: rgba(255,113,8,.2);
  font-weight: 850;
}

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

.kpi-card,
.panel {
  border: 1px solid rgba(255,255,255,.74);
  border-radius: var(--radius);
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow);
}

.kpi-card {
  position: relative;
  min-height: 136px;
  padding: 18px;
  overflow: hidden;
}

.kpi-card:before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--orange);
}

.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}

.kpi-card strong {
  display: block;
  margin-top: 14px;
  font: 850 31px/1 var(--display);
}

.kpi-card small {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-weight: 750;
}

.kpi-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.kpi-meta small {
  min-width: 0;
  margin-top: 0;
  padding: 8px 9px;
  border-radius: var(--radius);
  background: #f6f8f9;
  line-height: 1.15;
}

.accent-green:before { background: var(--green); }
.accent-graphite:before { background: var(--graphite); }
.accent-silver:before { background: #aeb4b8; }
.accent-blue:before { background: var(--blue); }

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, .75fr);
  gap: 12px;
  margin-bottom: 12px;
}

.dashboard-grid-main {
  grid-template-columns: minmax(520px, 1.08fr) minmax(460px, .92fr);
  align-items: start;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px 13px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2 {
  margin: 3px 0 0;
  font: 850 20px/1.08 var(--display);
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff4e9;
  color: #9a4200;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.chip.dark {
  color: #fff;
  background: var(--graphite);
}

.cash-chart {
  display: grid;
  grid-template-columns: repeat(10, minmax(42px, 1fr));
  align-items: end;
  gap: 12px;
  min-height: 300px;
  padding: 22px 20px 14px;
}

.cash-day {
  display: grid;
  grid-template-rows: 1fr auto;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 5px;
  height: 240px;
}

.cash-day small {
  grid-column: span 2;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
  font-weight: 800;
}

.bar-in,
.bar-out {
  display: block;
  min-height: 18px;
  border-radius: 7px 7px 2px 2px;
  transform-origin: bottom;
  animation: rise .85s ease both;
}

.bar-in {
  height: var(--in);
  background: linear-gradient(180deg, var(--orange), var(--orange-2));
}

.bar-out {
  height: var(--out);
  background: linear-gradient(180deg, #3d3838, #161313);
}

.legend {
  display: flex;
  gap: 16px;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

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

.legend-in { background: var(--orange); }
.legend-out { background: var(--graphite); }

.bank-list,
.inventory-list {
  display: grid;
  padding: 8px;
}

.drill-list {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.drill-row {
  border: 1px solid #e7ebee;
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}

.drill-row[open] {
  border-color: rgba(255,113,8,.30);
  box-shadow: 0 12px 28px rgba(40,35,35,.08);
}

.drill-row summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  min-height: 68px;
  padding: 13px 14px;
  cursor: pointer;
  list-style: none;
}

.drill-row summary::-webkit-details-marker {
  display: none;
}

.drill-row summary:before {
  content: "+";
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #fff3e8;
  color: var(--orange-2);
  font-weight: 900;
}

.drill-row[open] summary:before {
  content: "–";
}

.summary-main {
  min-width: 0;
  padding-left: 34px;
}

.summary-main strong,
.summary-main small,
.summary-value strong,
.summary-value small {
  display: block;
}

.summary-main strong {
  font-weight: 900;
}

.summary-main small,
.summary-value small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.summary-value {
  text-align: right;
  white-space: nowrap;
}

.summary-value strong {
  font: 850 18px/1 var(--display);
}

.drill-body {
  padding: 0 10px 10px;
}

.detail-table {
  min-width: 0;
  border: 1px solid #edf0f2;
  border-radius: var(--radius);
  overflow: hidden;
}

.detail-table th,
.detail-table td {
  padding: 9px 10px;
  font-size: 12px;
}

.detail-table th {
  position: static;
}

.bank-row,
.inventory-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 10px;
  border-bottom: 1px solid #edf0f2;
}

.bank-row:last-child,
.inventory-row:last-child { border-bottom: 0; }

.bank-row strong,
.inventory-row strong {
  display: block;
  font-weight: 900;
}

.bank-row small,
.inventory-row small,
td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.bank-value {
  text-align: right;
}

.positive { color: var(--green) !important; }
.negative { color: var(--red) !important; }

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid #edf0f2;
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafb;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.money {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.type-pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.type-pill.receivable {
  background: #e9f7f1;
  color: var(--green);
}

.type-pill.payable {
  background: #fff0eb;
  color: var(--orange-2);
}

.status-pill {
  color: #45494d;
  background: #eef1f3;
  text-transform: capitalize;
}

.coverage {
  width: 150px;
  display: grid;
  gap: 5px;
}

.coverage span {
  display: block;
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8ecef;
}

.coverage span:before {
  content: "";
  display: block;
  width: var(--coverage);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--orange), var(--graphite));
}

.coverage small {
  text-align: right;
}

.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .55s ease, transform .55s ease;
}

.reveal.visible {
  opacity: 1;
  transform: none;
}

body.compact .kpi-card { min-height: 112px; padding: 14px; }
body.compact .kpi-card strong { font-size: 26px; }
body.compact th,
body.compact td { padding: 8px 11px; }
body.compact .bank-row,
body.compact .inventory-row { padding: 8px 10px; }

@keyframes pulse {
  70% { box-shadow: 0 0 0 10px rgba(255,113,8,0); }
  100% { box-shadow: 0 0 0 0 rgba(255,113,8,0); }
}

@keyframes rise {
  from { transform: scaleY(.22); opacity: .4; }
  to { transform: scaleY(1); opacity: 1; }
}

@media (max-width: 1160px) {
  .app-shell { grid-template-columns: 92px minmax(0, 1fr); }
  .brand { grid-template-columns: 1fr; place-items: center; }
  .brand span,
  .nav-link span:last-child,
  .sidebar-panel div { display: none; }
  .nav-link { grid-template-columns: 1fr; place-items: center; }
  .dashboard-grid,
  .dashboard-grid-main { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    height: auto;
    padding: 12px;
  }
  .nav-stack {
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    overflow-x: auto;
  }
  .nav-link {
    min-height: 48px;
    padding: 5px;
  }
  .main-content { padding: 12px; }
  .topbar { display: grid; }
  .kpi-grid { grid-template-columns: 1fr; }
  .dashboard-grid,
  .dashboard-grid-main { grid-template-columns: 1fr; }
  .drill-row summary { grid-template-columns: 1fr; }
  .summary-value { text-align: left; padding-left: 34px; }
  .cash-chart {
    overflow-x: auto;
    grid-template-columns: repeat(10, 54px);
  }
}
