/* ============================================================
     Responsive Styles
     ============================================================ */

/* 1024px - Smaller desktops / Large tablets */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr 300px;
    gap: 24px;
    padding: 24px 20px 60px;
  }
  .board {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 20px;
  }
}

/* 940px - Tablets */
@media (max-width: 940px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .history {
    position: static;
    max-height: 420px;
    margin-top: 24px;
  }
  .board {
    max-height: none;
    padding-right: 0;
  }
}

/* 768px - Small Tablets / Large Phones */
@media (max-width: 768px) {
  /* 2-row header: Top row has Brand, Add Btns, Theme. Bottom row has Search. */
  .topbar-inner {
    padding: 16px 20px;
    gap: 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
  }
  .brand {
    order: 1;
    margin-right: auto;
  }
  #addCategoryBtn {
    order: 2;
  }
  #addExpenseBtn {
    order: 3;
  }
  .theme-toggle {
    order: 4;
  }
  .search {
    order: 5;
    flex: 1 1 100%;
    max-width: 100%;
    margin-top: 4px;
  }

  .hero-top {
    flex-wrap: wrap;
    gap: 16px;
  }
  .hero-stats {
    width: 100%;
    justify-content: space-around;
  }
  .modal {
    padding: 28px;
    margin: 16px;
  }
}

/* 560px - Mobile Phones */
@media (max-width: 560px) {
  /* 3-row header for tiny screens to prevent cramping */
  .topbar-inner {
    padding: 14px 16px;
    gap: 12px;
  }
  .brand p {
    display: none;
  }
  .brand-logo {
    width: 48px;
    height: 48px;
  }
  .brand h1 {
    font-size: 20px;
  }
  
  .brand {
    order: 1;
    margin-right: auto;
  }
  .theme-toggle {
    order: 2;
  }
  #addCategoryBtn {
    order: 3;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }
  #addExpenseBtn {
    order: 4;
    flex: 1 1 calc(50% - 6px);
    justify-content: center;
  }
  .search {
    order: 5;
    margin-top: 0;
  }

  .hero-wrap {
    padding: 24px 16px 0;
  }
  .hero-card {
    padding: 22px 20px;
  }
  .hero-amt {
    font-size: 26px;
  }
  .layout {
    padding: 20px 16px 50px;
  }
  .card {
    padding: 20px;
    border-radius: 20px;
  }
  .board {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .btn {
    padding: 10px 16px;
    font-size: 14px;
  }
  .theme-toggle {
    width: 40px;
    height: 40px;
  }
  .history-list {
    max-height: 300px;
  }
  .section-label h2 {
    font-size: 16px;
  }
  .section-label .hint {
    font-size: 12px;
  }
}

/* 400px - Small Mobile Phones */
@media (max-width: 400px) {
  .brand-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
  }
  .brand h1 {
    font-size: 18px;
  }
  .modal {
    padding: 20px;
    margin: 12px;
  }
  .quick-amts {
    grid-template-columns: repeat(2, 1fr);
  }
  .hero-top {
    flex-direction: column;
    text-align: center;
  }
  .hero-info {
    margin-right: 0;
    align-items: center;
  }
  .card-delete {
    top: 16px;
    right: 16px;
    width: 28px;
    height: 28px;
  }
  #addCategoryBtn,
  #addExpenseBtn {
    padding: 8px;
    font-size: 13px;
  }
  .theme-toggle {
    width: 36px;
    height: 36px;
  }
  .card-top {
    gap: 10px;
  }
  .avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }
  .card-name {
    font-size: 15px;
  }
  .balance-amt {
    font-size: 18px;
  }
}
