:root {
  --primary-color: #a36d26;
  --primary-color-contrast: #2d2d2d;
  --text-color: #1c140a;
  --background-color: #ecce9650;
  --error-color: #ff4d4d;
  --success-color: #267f3e;
  --font-size-base: 16px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --border-radius: 0.25rem;
  --max-width: 1200px;
  --focus-outline: 2px solid var(--primary-color);
  --color-muted: #666;
}
* {
  box-sizing: border-box;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
html {
  font-size: 100%;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%; /* iOS Safari */
  -moz-text-size-adjust: 100%; /* Firefox Mobile */
  text-size-adjust: 100%; /* Modern browsers */
}
body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: var(--text-color);
  background-color: var(--background-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: var(--space-5);
}

body.theme-dark {
  background-color: #181818;
  color: #e4cfae;
}

/* Visually hidden helper for a11y */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  left: -9999px;
}

/* layout container */
.container {
  width: calc(100% - (var(--space-4) * 2));
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-4);
}

/* Header / nav small defaults */
header {
  border-bottom: 1px solid #ece5dc;
  position: sticky;
  top: 0;
  background: var(--background-color);
  backdrop-filter: blur(20px);
  z-index: 10;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  padding: var(--space-3);
}
header.container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
}

/* --- Header Flex Layout --- */
.header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.Header-text h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--primary-color-contrast);
  font-weight: 700;
}

/* --- Navigation Menu --- */
.menu-toggle {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  color: var(--primary-color-contrast);
  padding: 0;
  z-index: 10;
}
.menu-toggle span {
  width: 25px;
  height: 3px;
  margin: 3px 0;
  background-color: var(--primary-color-contrast);
  border-radius: 3px;
  transition: 0.3s;
}
.menu-toggle.open span:nth-child(1) {
  transform: rotate(-45deg) translate(-5px, 6px);
}

.menu-toggle.open span:nth-child(2) {
  opacity: 0;
}
.menu-toggle.open span:nth-child(3) {
  transform: rotate(45deg) translate(-5px, -6px);
}
.nav-menu {
  list-style: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #ecce96;
  padding: 0;
  width: 100%;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease-out;
}
.nav-menu.open {
  max-height: 300px; /* adjust as needed */
}
.nav-menu li {
  border-top: 1px solid #fde1ab;
}
.nav-menu ul {
  list-style: none;
  padding: var(--space-3) var(--space-4);
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: flex-start;
}
.nav-menu a {
  color: var(--primary-color);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.2s, color 0.2s;
  padding: var(--space-2) var(--space-3);
  display: block;
  border-radius: var(--border-radius);
}
.nav-menu a:hover {
  text-decoration: none;
  background: var(--primary-color);
  color: var(--primary-color-contrast);
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  gap: var(--space-3);
  align-items: center;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

a:focus,
button:focus {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

/* ---- Focus visibility (important for a11y) ---- */
:focus {
  outline: none;
  box-shadow: 0 0 0 3px var(--primary-color);
  border-radius: var(--border-radius);
}

/* ---- Typography ---- */
h1,
h2,
h3 {
  margin: 0 0 var(--space-3) 0;
  color: var(--text-color);
  font-weight: 600;
  line-height: 1.2;
}
h1 {
  font-size: 1.25rem;
} /* 20px */
h2 {
  font-size: 1.125rem;
} /* 18px */
h3 {
  font-size: 1rem;
} /* 16px */
p,
li {
  font-size: 0.9375rem;
} /* 15px */

section {
  max-width: 900px;
  margin: 2rem auto;
  background: var(--background-color);
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  padding: 2rem;
}
.actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
  margin-bottom: var(--space-3);
}
.btn {
  padding: 0.5rem 1.2rem;
  border-radius: var(--border-radius);
  border: none;
  cursor: pointer;
  font-weight: 500;
}
.btn-primary {
  background: #267f3e;
  color: #fff;
}
.btn-outline {
  background: #ffffff;
  color: #267f3e;
  border: 1px solid #267f3e;
}
.btn-primary:hover,
.btn-outline:hover {
  background: #267f3e;
  color: #fff;
}
.transaction-cards {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.transaction-card {
  background: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  padding: 1rem;
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.badge {
  padding: 0.2rem 0.7rem;
  border-radius: 12px;
  font-size: 0.9rem;
  color: #fff;
}
.badge.income {
  background: #267f3e;
}
.badge.expense {
  background: #a32626;
}
.card-amount.income {
  color: #267f3e;
  font-weight: bold;
}
.card-amount.expense {
  color: #a32626;
  font-weight: bold;
}
.card-description {
  margin: 0.5rem 0;
  font-size: 1.1rem;
}
.card-meta {
  font-size: 0.9rem;
  color: #888;
  display: flex;
  gap: 1rem;
}
.card-actions {
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}
.transaction-table {
  display: none;
}
.transaction-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 400px;
  margin: 1rem auto;
}
.transaction-form input,
.transaction-form select {
  padding: 0.7rem;
  border-radius: 4px;
  border: 1px solid #ccc;
}
.hidden {
  display: none !important;
}

/* dashboard */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.stat-card {
  background: var(--background-color);
  padding: var(--space-4);
  border-radius: var(--border-radius);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  text-align: center;
}
.stat-card h3 {
  color: var(--primary-color-contrast);
  margin-bottom: var(--space-2);
}

.stat-value.income {
  color: #267f3e;
}
.stat-value.expense {
  color: #a32626;
}
.stat-value.balance {
  color: #267f3e;
}

.chart-container {
  width: 95%;
  max-width: 100%;
  min-width: 0;
  height: 220px;
  margin: 0 auto 2rem auto;
  position: relative;
  overflow-x: auto;
}

canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ---- Simple responsive breakpoints (lightweight) ---- */
/* breakpoint1 */
@media (min-width: 576px) {
  h1 {
    font-size: 1.5rem;
  } /* 24px */
  h2 {
    font-size: 1.25rem;
  } /* 20px */
  h3 {
    font-size: 1.125rem;
  } /* 18px */
  p,
  li {
    font-size: 1rem;
  } /* 16px */
  .menu-toggle {
    display: none; /* hide menu button on larger screens */
  }
  .nav-menu {
    display: flex !important;
    flex-direction: row;
    position: static;
    background: none;
    width: auto;
    max-height: none;
    overflow: visible;
  }
  .nav-menu ul {
    flex-direction: row;
    gap: var(--space-4);
    padding: 0;
  }
  .nav-menu a {
    padding: var(--space-1) var(--space-2);
    background: none;
    color: var(--primary-color);
  }
  .nav-menu a:hover {
    background: var(--primary-color);
    color: var(--primary-color-contrast);
  }
  .transaction-cards {
    display: none;
  }
  .transaction-table {
    display: block;
  }
  table {
    width: 100%;
    border-collapse: collapse;
  }
  th,
  td {
    padding: 0.7rem;
    border-bottom: 1px solid #eee;
    text-align: left;
  }
  th {
    background: #f0f0f0;
  }
  .table-amount.income {
    color: #267f3e;
    font-weight: bold;
  }
  .table-amount.expense {
    color: #a32626;
    font-weight: bold;
  }
  .chart-container {
    max-width: 90%;
    width: 80%;
    height: 300px;
    overflow-x: visible;
  }
  .actions {
    flex-direction: row;
    gap: var(--space-4);
  }
}

/* breakpoint2 */
@media (min-width: 768px) {
  h1 {
    font-size: 1.75rem;
  } /* 28px */
  h2 {
    font-size: 1.5rem;
  } /* 24px */
  h3 {
    font-size: 1.25rem;
  } /* 20px */
  p,
  li {
    font-size: 1.125rem;
  } /* 18px */
  .menu-toggle {
    display: none; /* hide menu button on larger screens */
  }
  /* 3. Show the navigation in the header on desktop */
  .nav-menu {
    display: flex !important;
    flex-direction: row;
    position: static;
    background: none;
    width: auto;
    max-height: none;
    overflow: visible;
  }
  .nav-menu ul {
    flex-direction: row;
    gap: var(--space-4);
    padding: 0;
  }
  .nav-menu a {
    padding: var(--space-1) var(--space-2);
    background: none;
    color: var(--primary-color);
  }
  .nav-menu a:hover {
    background: var(--primary-color);
    color: var(--primary-color-contrast);
  }
  .transaction-cards {
    display: none;
  }
  .actions {
    flex-direction: row;
    gap: var(--space-4);
  }
}
/* breakpoint3 */
@media (min-width: 1024px) {
  h1 {
    font-size: 2rem;
  } /* 32px */
  h2 {
    font-size: 1.75rem;
  } /* 28px */
  h3 {
    font-size: 1.5rem;
  } /* 24px */
  p,
  li {
    font-size: 1.25rem;
  } /* 20px */
  .menu-toggle {
    display: none; /* hide menu button on larger screens */
  }
  .nav-menu {
    display: flex !important;
    flex-direction: row;
    position: static;
    background: none;
    width: auto;
    max-height: none;
    overflow: visible;
  }
  .nav-menu ul {
    flex-direction: row;
    gap: var(--space-4);
    padding: 0;
  }
  .nav-menu a {
    padding: var(--space-1) var(--space-2);
    background: none;
    color: var(--primary-color);
  }
  .nav-menu a:hover {
    background: var(--primary-color);
    color: var(--primary-color-contrast);
  }
  .chart-container {
    width: 60%;
    max-width: 70%;
    height: 400px;
  }
  .transaction-cards {
    display: none;
  }
  .actions {
    flex-direction: row;
    gap: var(--space-4);
  }
}
footer {
  text-align: center;
  padding: 2rem 0;
  color: #888;
}
