:root {
  --bg: #f6f3ed;
  --surface: #fffdf8;
  --ink: #202124;
  --muted: #70757a;
  --line: #ded8cd;
  --green: #4f8a5b;
  --teal: #2b8a8f;
  --red: #c94b4b;
  --amber: #c4802c;
  --blue: #4d74a8;
  --shadow: 0 20px 60px rgba(32, 33, 36, 0.08);
}

* {
  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;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px 22px;
  background: #fbfaf6;
  border-right: 1px solid var(--line);
}

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

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

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 28px;
}

h3 {
  margin-bottom: 0;
  font-size: 18px;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.sheet-settings {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.sheet-summary strong,
.sheet-summary span {
  display: block;
}

.sheet-summary strong {
  font-size: 14px;
}

.sheet-summary span {
  max-width: 160px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-settings.is-saved {
  border-color: rgba(79, 138, 91, 0.35);
  background: #f7fbf7;
}

.sheet-form {
  display: grid;
  gap: 10px;
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions {
  display: grid;
  gap: 10px;
}

button {
  height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  color: white;
  background: var(--green);
}

.secondary-button {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}

.status-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.status-dot {
  flex: 0 0 auto;
  width: 10px;
  height: 10px;
  background: var(--amber);
  border-radius: 999px;
}

.status-dot.connected {
  background: var(--green);
}

.dashboard {
  padding: 28px;
}

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

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

.kpi-grid,
.content-grid {
  display: grid;
  gap: 16px;
}

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

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

.bottom-grid {
  margin-top: 16px;
}

.metric-card,
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric-card {
  display: grid;
  gap: 8px;
  min-height: 130px;
  padding: 18px;
}

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

.metric-card strong {
  font-size: 30px;
  line-height: 1;
}

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

.top-category-list {
  display: grid;
  gap: 7px;
}

.top-category-item {
  display: grid;
  gap: 2px;
}

.top-category-item strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-category-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.alert-card.over {
  border-color: rgba(201, 75, 75, 0.4);
  background: #fff8f7;
}

.panel {
  padding: 18px;
}

.wide {
  grid-row: span 2;
}

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

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  color: var(--green);
  background: #eaf3ec;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.budget-bars {
  display: grid;
  gap: 12px;
}

.budget-row {
  display: grid;
  gap: 7px;
}

.budget-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.budget-meta span:last-child {
  color: var(--muted);
  text-align: right;
}

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

.bar-fill {
  height: 100%;
  width: 0;
  background: var(--green);
  border-radius: inherit;
}

.bar-fill.warn {
  background: var(--amber);
}

.bar-fill.over {
  background: var(--red);
}

.quarter-row {
  padding-bottom: 6px;
}

.quarter-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.chart-wrap {
  width: 100%;
  min-height: 260px;
}

canvas {
  display: block;
  width: 100%;
  height: 260px;
}

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

.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 46px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.summary-item:last-child {
  border-bottom: 0;
}

.summary-item strong {
  font-size: 14px;
}

.summary-item span {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .wide {
    grid-column: 1 / -1;
    grid-row: auto;
  }
}

@media (max-width: 720px) {
  .dashboard,
  .sidebar {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

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

  .metric-card strong {
    font-size: 26px;
  }
}
