:root {
  color-scheme: light;
  --bg: #edf2f5;
  --panel: #ffffff;
  --text: #202a33;
  --muted: #60717e;
  --line: #cbd6de;
  --accent: #49627d;
  --accent-dark: #31475f;
  --warn: #9f4f16;
}

* {
  box-sizing: border-box;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 92px;
  padding: 10px clamp(16px, 4vw, 48px);
  background: #e4ebf0;
  border-bottom: 1px solid #b8c7d2;
  box-shadow: 0 2px 8px rgba(38, 54, 68, 0.08);
}

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

.brandLogo {
  display: block;
  width: 158px;
  height: 72px;
  object-fit: contain;
}

.brandTitle {
  padding-left: 12px;
  border-left: 1px solid #aebdc9;
}

.brandTitle span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  color: #293c50;
  font-size: 24px;
}

h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.tabs {
  display: flex;
  gap: 8px;
}

.tab,
button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.tab:hover,
button:hover {
  border-color: #8ea2b3;
  background: #f7fafb;
}

.tab.active,
button[type="submit"] {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}


.tab.active:hover,
button[type="submit"]:hover {
  background: var(--accent-dark);
}

main {
  padding: 24px clamp(16px, 4vw, 48px) 48px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 5px 18px rgba(40, 58, 72, 0.06);
}

.panelHeader {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.panelHeader p,
.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.filters {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
}

input:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(73, 98, 125, 0.14);
}

select {
  height: 40px;
  min-width: 240px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 0 10px;
  font: inherit;
}

.workspace {
  display: block;
}

.loginForm {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  align-items: end;
  gap: 12px;
}

.metrics {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.sectionHeading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 10px;
}

.sectionHeading h3 {
  margin: 0;
  font-size: 16px;
}

.sectionHeading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.reconciliationLine {
  margin: -4px 0 22px;
  padding: 10px 12px;
  border-left: 3px solid #7c93a8;
  background: #f1f5f7;
  color: #455968;
  font-size: 13px;
}

.metric {
  display: inline-grid;
  gap: 2px;
  min-width: 160px;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f7;
}

.metric span {
  color: var(--muted);
  font-size: 13px;
}

.metric strong {
  font-size: 28px;
}

.inlineSection {
  margin: 0 0 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.inlineSectionHeader {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.inlineSection h3 {
  margin: 0;
  font-size: 16px;
}

.inlineForm {
  display: flex;
  align-items: end;
  gap: 8px;
  flex-wrap: wrap;
}

.inlineForm input {
  width: 140px;
}

.inlineForm input:first-child {
  width: 240px;
}

.tableWrap {
  overflow-x: auto;
}

.compactTable table {
  min-width: 640px;
}

.compactTable td {
  padding: 7px 8px;
}

.compactTable input {
  width: 100%;
  min-width: 80px;
}

.rowActions {
  white-space: nowrap;
}

.rowActions button {
  min-height: 34px;
  padding: 0 10px;
}

.chartWrap {
  position: relative;
  width: 100%;
  margin: 4px 0 18px;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

#revenueChart,
#expensesChart,
#cashflowChart {
  display: block;
  width: 100%;
  min-height: 280px;
}

.chartGrid {
  stroke: #e6ecef;
  stroke-width: 1;
}

.chartArea {
  fill: rgba(15, 118, 110, 0.12);
}

.chartLine {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3;
}

.chartLineRevenue {
  stroke: #0f766e;
}

.chartLineExpense {
  stroke: #c2410c;
}

.chartLineNet {
  stroke: #2563eb;
}

.chartZeroLine {
  stroke: #9aa7af;
  stroke-dasharray: 5 5;
  stroke-width: 1.5;
}

.chartDot {
  fill: #ffffff;
  stroke: var(--accent-dark);
  stroke-width: 2;
  cursor: pointer;
}

.chartDotCheck {
  fill: #b7d8d0;
  stroke: var(--accent-dark);
}

.chartDotFixedExpense {
  fill: #fed7aa;
  stroke: #c2410c;
}

.chartDotQuotation {
  fill: #fde68a;
  stroke: #b45309;
}

.chartDotPurchaseRfq {
  fill: #ddd6fe;
  stroke: #6d28d9;
}

.chartDotRevenue {
  fill: #e7f4f1;
  stroke: #0f766e;
}

.chartDotExpense {
  fill: #fff0df;
  stroke: #c2410c;
}

.chartDotNet {
  fill: #dbeafe;
  stroke: #2563eb;
}

.chartLegend {
  display: flex;
  gap: 16px;
  align-items: center;
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.chartLegend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chartControls label {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.chartControls input {
  width: 14px;
  height: 14px;
  padding: 0;
}

.legendSwatch {
  display: inline-block;
  width: 22px;
  height: 3px;
  border-radius: 999px;
}

.legendRevenue {
  background: #0f766e;
}

.legendExpenses {
  background: #c2410c;
}

.legendNet {
  background: #2563eb;
}

.legendQuotation {
  width: 10px;
  height: 10px;
  border: 2px solid #b45309;
  border-radius: 50%;
  background: #fde68a;
}

.legendPurchaseRfq {
  width: 10px;
  height: 10px;
  border: 2px solid #6d28d9;
  border-radius: 50%;
  background: #ddd6fe;
}

.projectionRowInvoice td {
  background: #eef8fc;
}

.projectionRowCheck td {
  background: #edf8f1;
}

.projectionRowSaleOrder td {
  background: #f1f2fa;
}

.projectionRowQuotation td {
  background: #fff7df;
}

.projectionRowVendorBill td {
  background: #f7eff1;
}

.projectionRowPurchaseOrder td {
  background: #eef4fb;
}

.projectionRowPurchaseRfq td {
  background: #f3effa;
}

.projectionRowOwnCheck td {
  background: #fff8e5;
}

.projectionRowFixedExpense td {
  background: #fff0e3;
}

.chartLabel,
.chartEmpty {
  fill: var(--muted);
  font-size: 12px;
}

.chartTooltip {
  position: absolute;
  z-index: 2;
  max-width: min(360px, calc(100% - 24px));
  transform: translate(-50%, calc(-100% - 12px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 12px 28px rgba(29, 37, 43, 0.18);
  padding: 10px 12px;
  pointer-events: none;
}

.chartTooltip.alignLeft {
  transform: translate(8px, calc(-100% - 12px));
}

.chartTooltip.alignRight {
  transform: translate(calc(-100% - 8px), calc(-100% - 12px));
}

.chartTooltip.below {
  transform: translate(-50%, 12px);
}

.chartTooltip.below.alignLeft {
  transform: translate(8px, 12px);
}

.chartTooltip.below.alignRight {
  transform: translate(calc(-100% - 8px), 12px);
}

.tooltipTitle {
  margin-bottom: 8px;
  color: var(--text);
  font-size: 13px;
  font-weight: 750;
}

.tooltipRow {
  display: grid;
  gap: 2px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 12px;
}

.tooltipRow strong {
  color: var(--text);
}

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

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

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

th {
  color: var(--muted);
  font-size: 13px;
}

.simpleBreakdownTable table {
  min-width: 760px;
}

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

.simpleBreakdownTable tfoot th {
  background: #e4ebf0;
  color: var(--text);
  font-weight: 750;
}

.accountCode {
  color: #3d5368;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px;
  white-space: nowrap;
}

.exerciseResult {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 24px;
  padding: 18px 0 4px;
  border-top: 2px solid #9eb0bf;
}

.exerciseResult span {
  color: var(--text);
  font-size: 16px;
  font-weight: 750;
}

.exerciseResult p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.exerciseResult strong {
  color: #237451;
  font-size: 28px;
  text-align: right;
  white-space: nowrap;
}

.exerciseResult strong.resultNegative {
  color: #a33f3f;
}

td:last-child,
th:last-child {
  text-align: right;
}

.hidden {
  display: none;
}

.error {
  color: var(--warn);
}

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

  .tabs {
    width: 100%;
    flex-wrap: wrap;
  }

  .tabs .tab {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 0;
  }
}

@media (max-width: 760px) {
  .topbar,
  .panelHeader {
    align-items: stretch;
    flex-direction: column;
  }

  .tabs,
  .filters {
    width: 100%;
  }

  .tabs {
    flex-wrap: wrap;
  }

  .filters label,
  .filters button,
  .loginForm label,
  .loginForm button {
    flex: 1;
  }

  .tabs .tab {
    flex: 1 1 calc(33.333% - 8px);
    min-width: 0;
    padding: 0 8px;
  }

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

  .brandLogo {
    width: 132px;
    height: 60px;
  }

  .brandTitle {
    display: none;
  }

  .exerciseResult {
    align-items: flex-start;
    flex-direction: column;
  }

  .exerciseResult strong {
    font-size: 24px;
    text-align: left;
  }
}
