:root {
  --bg-color: #0c0e15;
  --panel-bg: rgba(255, 255, 255, 0.03);
  --panel-border: rgba(255, 255, 255, 0.08);
  --primary-color: #4f46e5;
  --primary-hover: #4338ca;
  --income-color: #10b981;
  --income-bg: rgba(16, 185, 129, 0.1);
  --expense-color: #ef4444;
  --expense-bg: rgba(239, 68, 68, 0.1);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --font-family: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-family);
  background: var(--bg-color);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background-image:
    radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.15) 0%, transparent 50%),
    radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
  background-attachment: fixed;
}

.app-container {
  width: 100%;
  max-width: 1000px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

header {
  text-align: center;
  margin-bottom: 1rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--text-muted);
  font-weight: 300;
  margin-top: 0.5rem;
  font-size: 1.1rem;
}

/* Dashboard Summary */
.dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.balance-card::before {
  background: linear-gradient(90deg, #4f46e5, #8b5cf6);
}

.income-card::before {
  background: var(--income-color);
}

.expense-card::before {
  background: var(--expense-color);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.card h3 {
  color: var(--text-muted);
  font-size: 1rem;
  font-weight: 500;
}

.card h2 {
  font-size: 2.2rem;
  font-weight: 600;
}

/* Main Content Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  gap: 2rem;
}

@media (max-width: 768px) {
  .main-content {
    grid-template-columns: 1fr;
  }
}

.glass-panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.glass-panel h3 {
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  font-weight: 600;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.8rem;
}

/* Form Styles */
.form-group {
  margin-bottom: 1.2rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
select {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  color: white;
  font-family: var(--font-family);
  font-size: 1rem;
  transition: var(--transition);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

/* Custom Select styling for dark mode */
select option {
  background: var(--bg-color);
  color: white;
}

/* Type Toggle */
.type-toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  padding: 0.3rem;
  border-radius: 12px;
}

.type-toggle input[type="radio"] {
  display: none;
}

.type-toggle label {
  flex: 1;
  text-align: center;
  padding: 0.6rem;
  margin: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  color: var(--text-muted);
}

#type-income:checked+label {
  background: var(--income-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#type-expense:checked+label {
  background: var(--expense-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

.primary-btn {
  width: 100%;
  padding: 1rem;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
}

.primary-btn:hover {
  background: var(--primary-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
}

.primary-btn:active {
  transform: translateY(0);
}

.btn-icon {
  font-size: 1.3rem;
}

/* History List */
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 0.8rem;
  margin-bottom: 1.5rem;
}

.history-header h3 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  transition: var(--transition);
}

.text-btn:hover {
  color: white;
  text-decoration: underline;
}

.transaction-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 500px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

/* Scrollbar styles */
.transaction-list::-webkit-scrollbar {
  width: 6px;
}

.transaction-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.transaction-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.transaction-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  transition: var(--transition);
  border-left: 4px solid transparent;
  animation: slideIn 0.3s ease forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-10px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.transaction-item:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(4px);
}

.transaction-item.income {
  border-left-color: var(--income-color);
}

.transaction-item.expense {
  border-left-color: var(--expense-color);
}

.tx-info {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.tx-category {
  font-weight: 500;
  color: white;
}

.tx-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tx-date {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.4);
}

.tx-amount-section {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tx-amount {
  font-weight: 600;
  font-size: 1.1rem;
}

.transaction-item.income .tx-amount {
  color: var(--income-color);
}

.transaction-item.expense .tx-amount {
  color: var(--expense-color);
}

.delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: var(--transition);
  opacity: 0.5;
  padding: 0.5rem;
  border-radius: 50%;
}

.transaction-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  color: var(--expense-color);
  background: var(--expense-bg);
}

.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-style: italic;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal.show .modal-content {
  animation: modalIn 0.3s ease forwards;
}

.modal-content {
  width: 90%;
  max-width: 450px;
  position: relative;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 1rem;
}

.modal-header h3 {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  transition: var(--transition);
}

.close-btn:hover {
  color: white;
}

.modal-toggle {
  margin-bottom: 1rem;
}

.add-category-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.small-btn {
  padding: 0.8rem 1.5rem;
  width: auto;
  margin-top: 0;
  border-radius: 8px;
}

.category-list {
  list-style: none;
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-right: 0.5rem;
}

.category-list::-webkit-scrollbar {
  width: 6px;
}

.category-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.1);
  border-radius: 4px;
}

.category-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
}

.category-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.8rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  transition: var(--transition);
}

.category-item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.category-actions {
  display: flex;
  gap: 0.3rem;
}

.action-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 6px;
  transition: var(--transition);
}

.action-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}

.action-btn.del:hover {
  background: var(--expense-bg);
  color: var(--expense-color);
}

/* Report Table Web Styles */
.report-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.report-table th,
.report-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--panel-border);
}

.report-table th {
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-muted);
  font-weight: 500;
  position: sticky;
  top: 0;
}

.transaction-row.income .tx-amount {
  color: var(--income-color);
  font-weight: 600;
}

.transaction-row.expense .tx-amount {
  color: var(--expense-color);
  font-weight: 600;
}

/* Print Styles */
@media print {
  body {
    background: white;
    color: black;
    display: block;
    margin: 0;
    padding: 0;
  }

  /* Hide everything by default */
  body * {
    visibility: hidden;
  }

  /* Show only the report results */
  #reportModal,
  #reportModal * {
    visibility: visible;
  }

  #reportModal {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    background: transparent !important;
  }

  /* Hide print buttons and controls */
  #printReportBtn,
  .close-btn,
  .report-controls {
    display: none !important;
  }

  .modal,
  .modal-content {
    align-items: flex-start;
    justify-content: flex-start;
    border: none;
    box-shadow: none;
    background: transparent !important;
    max-width: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  /* Dashboard summary on paper */
  .dashboard {
    display: flex !important;
    justify-content: flex-start !important;
    gap: 1rem !important;
    margin-bottom: 0.5rem !important;
  }

  .dashboard .card {
    background: transparent;
    border: 1px solid #000;
    box-shadow: none;
    padding: 0.5rem 1rem !important;
    flex: 0 1 auto;
  }

  .dashboard .card h2 {
    color: black;
    font-size: 1.2rem !important;
    margin: 0;
  }

  .dashboard .card h3 {
    color: black;
    font-size: 0.9rem !important;
    margin-bottom: 0.2rem !important;
  }

  /* The actual Data Grid! */
  .table-container {
    max-height: none !important;
    overflow: visible !important;
  }

  .report-table {
    border: 1px solid #000;
    margin-top: 0.5rem;
    width: 100%;
  }

  .report-table th,
  .report-table td {
    border: 1px solid #000 !important;
    color: #000;
    padding: 4px 6px !important;
  }

  .report-table th {
    background: #e5e5e5 !important;
    color: #000;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    font-weight: bold;
    padding: 6px 8px !important;
  }

  .income-card h2,
  .transaction-row.income .tx-amount {
    color: #000 !important;
  }

  .expense-card h2,
  .transaction-row.expense .tx-amount {
    color: #000 !important;
  }

  #reportResults::before {
    content: "Income and Expense Report - " attr(data-period);
    display: block;
    font-size: 1.4rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #000;
  }

  h4 {
    margin-bottom: 0.5rem !important;
    color: #000 !important;
  }
}