:root {
  --bg: #f4f7fa;
  --surface: #ffffff;
  --ink: #203040;
  --muted: #667085;
  --line: #dce6ee;
  --navy: #19324c;
  --teal: #1f7a8c;
  --green: #2a9d8f;
  --coral: #e76f51;
  --amber: #f4a261;
  --blue: #2f80ed;
  --shadow: 0 18px 45px rgba(25, 50, 76, 0.12);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  background: var(--navy);
  color: #fff;
  padding: 28px 22px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 32px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--teal);
  font-weight: 800;
}

.brand small,
.screen-label,
.panel-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.brand small {
  color: #b7c8d8;
  display: block;
  margin-top: 2px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-button {
  border: 0;
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  color: #d7e4ee;
  background: transparent;
}

.nav-button:hover,
.nav-button.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.content {
  padding: 28px;
  min-width: 0;
}

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

.topbar h1,
.hero-panel h2,
.panel h2 {
  margin: 0;
}

.screen-label {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0;
  font-weight: 700;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

input,
select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
}

input[type="file"] {
  padding: 9px 12px;
}

.primary-button,
.install-button,
.quick-grid button,
.month-grid button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  color: #fff;
  background: var(--teal);
  font-weight: 800;
}

.install-button {
  color: var(--teal);
  background: #e5f3f5;
}

.connection-pill {
  display: inline-grid;
  min-height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--green);
  background: var(--surface);
  font-size: 0.84rem;
  font-weight: 800;
}

.connection-pill.offline {
  color: var(--coral);
  background: #fff3ef;
}

.checkbox-row {
  align-items: center;
  grid-template-columns: auto 1fr;
  min-height: 42px;
  color: var(--ink);
}

.checkbox-row input {
  width: 18px;
  min-height: 18px;
}

.form-note {
  margin: -4px 0 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

[hidden] {
  display: none !important;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 24px;
  align-items: center;
  border-radius: 8px;
  padding: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.hero-panel h2 {
  max-width: 680px;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1;
}

.hero-panel p {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.05rem;
}

.quick-grid,
.month-grid,
.kpi-grid,
.dashboard-grid,
.month-detail-grid {
  display: grid;
  gap: 16px;
}

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

.month-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  margin-top: 20px;
}

.kpi-grid {
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  margin-bottom: 18px;
}

.kpi-card,
.panel,
.month-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 10px 30px rgba(25, 50, 76, 0.07);
}

.kpi-card {
  padding: 18px;
}

.kpi-card small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 10px;
}

.kpi-card strong {
  display: block;
  font-size: 1.35rem;
}

.dashboard-grid {
  grid-template-columns: 1.5fr 1fr;
}

.span-2 {
  min-height: 380px;
}

.panel {
  padding: 18px;
}

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

.chart-box {
  min-height: 300px;
}

.chart-box svg {
  width: 100%;
  height: 310px;
}

.axis {
  stroke: #cbd8e4;
  stroke-width: 1;
}

.line-income {
  fill: none;
  stroke: var(--green);
  stroke-width: 3;
}

.line-expense {
  fill: none;
  stroke: var(--coral);
  stroke-width: 3;
}

.stack-list {
  display: grid;
  gap: 12px;
}

.stack-row {
  display: grid;
  gap: 6px;
}

.stack-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.88rem;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef4;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1160px;
  border-collapse: collapse;
  font-size: 0.92rem;
}

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

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

.month-detail-grid {
  grid-template-columns: repeat(4, minmax(210px, 1fr));
}

.month-card {
  padding: 18px;
}

.month-card h3 {
  margin: 0 0 12px;
}

.month-card dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.month-card div {
  display: flex;
  justify-content: space-between;
}

.positive {
  color: var(--green);
}

.negative {
  color: var(--coral);
}

.attachment-link {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.attachment-link:hover {
  text-decoration: underline;
}

.actions-cell {
  white-space: nowrap;
}

.actions-cell {
  display: flex;
  gap: 8px;
  align-items: center;
}

.secondary-button,
.danger-button {
  min-height: 34px;
  border: 1px solid #ffd7cc;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 800;
}

.secondary-button {
  border-color: #b8dce3;
  color: var(--teal);
  background: #edf8fa;
}

.secondary-button:hover {
  border-color: var(--teal);
}

.danger-button {
  color: var(--coral);
  background: #fff3ef;
}

.danger-button:hover {
  border-color: var(--coral);
}

dialog {
  width: min(680px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(16, 35, 52, 0.42);
}

dialog header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
}

dialog h2 {
  margin: 0;
}

#closeDialogBtn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.file-field {
  grid-column: 1 / -1;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }

  .brand {
    margin-bottom: 12px;
  }

  .nav-list {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .nav-button {
    flex: 0 0 auto;
    min-width: 98px;
    text-align: center;
    padding: 10px 8px;
  }

  .topbar,
  .hero-panel {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar,
  .form-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  .month-grid,
  .kpi-grid,
  .dashboard-grid,
  .month-detail-grid {
    grid-template-columns: 1fr;
  }
}
