:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1d252c;
  --muted: #66717d;
  --line: #d9dee4;
  --accent: #086ccf;
  --accent-dark: #0556a7;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(24, 34, 45, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 42px;
  padding: 0 18px;
}

button:hover {
  background: var(--accent-dark);
}

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

button.secondary {
  background: #e9edf2;
  color: var(--text);
}

button.secondary:hover {
  background: #dce3ea;
}

button.danger {
  background: #b42318;
}

button.danger:hover {
  background: #8f1d14;
}

button.small {
  font-size: 12px;
  min-height: 34px;
  padding: 0 10px;
  white-space: nowrap;
}

button.tab {
  background: transparent;
  color: var(--muted);
  border-radius: 0;
  border-bottom: 3px solid transparent;
  min-height: 40px;
  padding: 0 12px;
}

button.tab:hover,
button.tab.active {
  background: transparent;
  border-bottom-color: var(--accent);
  color: var(--text);
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  padding: 28px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

h1 {
  font-size: 26px;
  line-height: 1.2;
  margin: 0;
}

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

input {
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--text);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(8, 108, 207, 0.16);
}

.error {
  color: var(--danger);
  font-size: 14px;
  min-height: 20px;
  margin: 0;
}

.app-view {
  display: grid;
  gap: 18px;
  padding: 24px;
}

.topbar {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.status-row {
  align-items: center;
  color: var(--muted);
  display: flex;
  font-size: 14px;
  justify-content: space-between;
  gap: 16px;
}

.status-row p {
  margin: 0;
}

.tabs {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
}

.filters {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(180px, 240px)) repeat(2, auto);
  justify-content: start;
}

.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(24, 34, 45, 0.08);
  height: calc(100vh - 260px);
  max-height: 720px;
  min-height: 360px;
  overflow: auto;
}

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

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

th {
  background: #f0f3f7;
  color: #48535f;
  font-size: 12px;
  letter-spacing: 0;
  position: sticky;
  text-transform: uppercase;
  top: 0;
  z-index: 1;
}

td {
  color: var(--text);
  font-size: 14px;
  line-height: 1.35;
}

.amount {
  font-weight: 800;
  white-space: nowrap;
}

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

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

.metrics-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  margin-bottom: 16px;
}

.metric,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(24, 34, 45, 0.08);
}

.metric {
  display: grid;
  gap: 8px;
  padding: 16px;
}

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

.metric strong {
  font-size: 25px;
  line-height: 1.15;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
  margin-bottom: 16px;
}

.dashboard-grid-wide {
  grid-template-columns: minmax(0, 3fr) minmax(220px, 0.8fr);
}

.panel-wide {
  min-width: 0;
}

.panel {
  padding: 16px;
}

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

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

.legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 12px;
}

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

.income-dot,
.expense-dot,
.balance-dot {
  border-radius: 99px;
  display: inline-block;
  height: 10px;
  width: 10px;
}

.income-dot,
.bar.income {
  background: #16835f;
}

.expense-dot,
.bar.expense {
  background: #cc4b2c;
}

.balance-dot {
  background: #4b5fd7;
}

.chart {
  align-items: end;
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(7, minmax(76px, 1fr));
  min-height: 280px;
  overflow-x: auto;
  padding-top: 10px;
}

.bar-group {
  display: grid;
  gap: 8px;
  min-width: 76px;
  text-align: center;
}

.bars {
  align-items: end;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 5px;
  height: 190px;
  justify-content: center;
}

.bar {
  border-radius: 5px 5px 0 0;
  display: inline-block;
  min-height: 3px;
  width: 22px;
}

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

.bar-group small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

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

.comparison div {
  display: grid;
  gap: 6px;
}

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

.variation {
  border-radius: 7px;
  font-weight: 700;
  margin: 0;
  padding: 12px;
}

.variation.neutral {
  background: #eef2f6;
  color: var(--muted);
}

.variation.good {
  background: #e8f5ef;
  color: #11684b;
}

.variation.bad {
  background: #fff0eb;
  color: #a23a20;
}

.insights-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

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

.rank-item {
  display: grid;
  gap: 6px;
}

.rank-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
}

.rank-name {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
}

.rank-track {
  background: #eef2f6;
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.rank-fill {
  background: var(--accent);
  border-radius: inherit;
  display: block;
  height: 100%;
  min-width: 3px;
}

.line-chart {
  min-height: 310px;
  overflow-x: auto;
}

.line-chart svg {
  display: block;
  min-width: 680px;
  width: 100%;
}

.chart-empty {
  color: var(--muted);
  display: grid;
  min-height: 160px;
  place-items: center;
}

@media (max-width: 720px) {
  .app-view {
    padding: 16px;
  }

  .topbar,
  .status-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions,
  .actions button {
    width: 100%;
  }

  .filters,
  .metrics-grid,
  .dashboard-grid,
  .dashboard-grid-wide,
  .insights-grid {
    grid-template-columns: 1fr;
  }

  .filters button {
    width: 100%;
  }
}
