:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #657185;
  --line: #dce2ea;
  --paper: #ffffff;
  --bg: #f4f6f8;
  --brand: #b42318;
  --accent: #136f63;
  --gold: #d89d2a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 2;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
}

h2 {
  font-size: 17px;
}

.topbar p {
  color: var(--muted);
  margin-top: 4px;
}

nav,
.filters,
.section-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

main {
  padding: 22px 28px 36px;
}

.button,
button,
select,
input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.75;
}

button[type="submit"],
.button {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.ghost,
.icon-button,
.mode-button {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.mode-button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.month-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.month-head h2 {
  font-size: 26px;
  text-transform: capitalize;
}

.month-head p {
  color: var(--muted);
  margin-top: 4px;
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpis article,
.insight-grid article,
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.kpis article {
  padding: 16px;
}

.kpis span,
.insight-grid span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.kpis strong,
.insight-grid strong {
  font-size: 24px;
}

.insight-grid strong small {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 700;
}

.delta-up {
  color: var(--accent);
}

.delta-down {
  color: var(--brand);
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel {
  padding: 16px;
  margin-bottom: 18px;
}

.ledger-panel {
  padding: 0;
  overflow: hidden;
}

.ledger-wrap {
  border: 0;
  border-radius: 8px 8px 0 0;
}

.ledger-table {
  min-width: 1320px;
}

.ledger-table th,
.ledger-table td {
  padding: 7px 8px;
}

.ledger-table th:first-child,
.ledger-table td:first-child,
.ledger-table th:nth-child(2),
.ledger-table td:nth-child(2) {
  text-align: left;
}

.ledger-table input {
  min-height: 30px;
  width: 78px;
  padding: 0 7px;
  text-align: right;
  border-color: #cfd8e3;
}

.ledger-table .calculated-input {
  background: #f6f8fb;
  font-weight: 700;
}

.ledger-table .input-warning {
  border-color: #b42318;
  background: #fff0ee;
  color: #8f1d14;
}

.weather-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #cfd8e3;
  background: #f7f9fb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.weather-good {
  border-color: #f0c766;
  background: #fff6d8;
  color: #765000;
}

.weather-mid {
  border-color: #b9c9d8;
  background: #edf4f8;
  color: #3e5870;
}

.weather-rain {
  border-color: #8fb4dd;
  background: #e8f1fb;
  color: #204b78;
}

.weather-empty {
  color: #8b96a6;
}

.ledger-table .closed-day {
  background: #f3f5f7;
  color: #7b8794;
}

.ledger-table .closed-day input {
  background: #eef1f4;
}

.save-row {
  min-height: 30px;
  padding: 0 10px;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.wide {
  min-width: 0;
}

.section-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

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

label:first-child,
label:nth-child(2),
form button,
#saveStatus {
  grid-column: 1 / -1;
}

input,
select {
  width: 100%;
  padding: 0 10px;
}

#saveStatus {
  min-height: 18px;
  color: var(--accent);
  font-size: 13px;
  padding: 10px 14px 14px;
}

.analytics-shell {
  margin: 24px 0 18px;
  padding: 18px;
  background: #17202b;
  color: #fff;
  border-radius: 8px;
}

.forecast-shell {
  background: #202632;
}

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

.analytics-head p {
  margin-top: 5px;
  color: #bfccd9;
}

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

.analytics-controls label {
  color: #dce6ef;
}

.analytics-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.8fr);
  gap: 14px;
}

.analysis-card {
  min-width: 0;
  padding: 14px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
}

.analysis-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.card-note {
  margin: -4px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

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

.tab {
  min-height: 34px;
  padding: 0 12px;
  background: #243243;
  color: #eef5fa;
  border-color: #40546c;
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.insight-grid article {
  padding: 14px;
  background: #ffffff;
  color: var(--ink);
}

.line-chart {
  min-height: 260px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.compact {
  max-height: 452px;
}

.line-chart svg {
  width: 100%;
  height: 230px;
  display: block;
}

.line-chart polyline {
  fill: none;
  stroke: var(--brand);
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.line-chart circle {
  fill: var(--gold);
  stroke: var(--brand);
  stroke-width: 0.6;
  vector-effect: non-scaling-stroke;
}

.line-chart text {
  fill: var(--muted);
  font-size: 3px;
  text-anchor: middle;
}

.multi-chart {
  min-height: 420px;
  margin-bottom: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.multi-chart svg {
  width: 100%;
  height: 420px;
  display: block;
}

.multi-chart polyline {
  fill: none;
  stroke-width: 1.8;
  vector-effect: non-scaling-stroke;
}

.multi-chart text {
  fill: var(--muted);
  font-size: 14px;
  text-anchor: middle;
}

.multi-chart .axis-y {
  text-anchor: end;
}

.multi-chart line {
  stroke: #dbe3ec;
  stroke-width: 1;
  vector-effect: non-scaling-stroke;
}

.multi-chart circle {
  stroke: #fff;
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}


.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
}

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

.chart-legend i {
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.empty {
  color: var(--muted);
  padding: 60px 0;
  text-align: center;
}

.chart {
  display: grid;
  grid-template-columns: repeat(12, minmax(34px, 1fr));
  gap: 8px;
  align-items: end;
  height: 220px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.bar {
  display: grid;
  align-items: end;
  gap: 8px;
  min-width: 0;
  height: 100%;
}

.bar span {
  display: block;
  min-height: 8px;
  border-radius: 5px 5px 0 0;
  background: linear-gradient(180deg, var(--accent), #0f4f47);
}

.bar small {
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  overflow: hidden;
  white-space: nowrap;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.daily {
  max-height: 520px;
}

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

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  position: sticky;
  top: 0;
  background: #eef2f5;
  color: #394557;
  font-size: 12px;
  text-transform: uppercase;
}

@media (max-width: 900px) {
  .topbar,
  .workspace,
  .section-head,
  .month-head {
    display: grid;
  }

  .workspace,
  .kpis,
  .insight-grid,
  .analytics-controls,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .analytics-head {
    display: grid;
  }

  main {
    padding: 16px;
  }
}

@media print {
  .topbar nav,
  form,
  #searchInput {
    display: none;
  }

  body {
    background: #fff;
  }
}
