/*  CSS VARIABLES */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #010409;
  --card-bg: #161b22;
  --card-hover: #1c2128;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --accent-primary: #7ee787;
  --accent-secondary: #79c0ff;
  --accent-gradient: linear-gradient(135deg, #7ee787 0%, #56d364 100%);
  --success: #3fb950;
  --success-bg: #0d3a20;
  --danger: #f85149;
  --danger-bg: #490202;
  --warning: #d29922;
  --border: rgba(48, 54, 61, 0.8);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.7);
}

/* GLOBAL STYLES */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  margin: 0;
  background: radial-gradient(
    ellipse at top,
    #1a1f3a 0%,
    var(--bg-primary) 50%
  );
  color: var(--text-primary);
  font-family: "Inter",  "Segoe UI", Roboto,
    sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

/* LAYOUT */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 24px;
  margin-top: 24px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* HEADER */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

header h1 {
  font-size: 28px;
  font-weight: 700;
  background: var(--accent-gradient);
  background-clip: text;
  letter-spacing: -0.5px;
}

/* CARDS */
.card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.card:hover {
  border-color: rgba(59, 130, 246, 0.3);
  box-shadow: var(--shadow-lg);
}

.summary-card {
  flex: 1;
  padding: 20px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    rgba(59, 130, 246, 0.1) 0%,
    rgba(139, 92, 246, 0.1) 100%
  );
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.summary-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59, 130, 246, 0.4);
}

.top-summary {
  display: flex;
  gap: 16px;
}

/* BUTTONS */
button {
  background: var(--accent-gradient);
  border: none;
  color: white;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.4);
}

button:active {
  transform: translateY(0);
}

.pill {
  padding: 6px 14px;
  border-radius: 20px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--accent-primary);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  box-shadow: none;
}

.pill:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-1px);
}

/* Danger button styling */
button.danger {
  background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

button.danger:hover {
  box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.pill.danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger);
}

.pill.danger:hover {
  background: rgba(239, 68, 68, 0.25);
  border-color: rgba(239, 68, 68, 0.5);
}

/* FORM ELEMENTS */
input,
select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  transition: all 0.3s ease;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

input::placeholder {
  color: var(--text-muted);
}

textarea {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 14px;
  min-height: 80px;
  resize: vertical;
  outline: none;
  transition: all 0.3s ease;
}

textarea:focus {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.05);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.controls {
  display: flex;
  gap: 10px;
}

.controls-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* LISTS */
.list {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.acct-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.acct-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: all 0.3s ease;
}

.acct-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(59, 130, 246, 0.3);
  transform: translateX(4px);
}

/* Transaction item styling */
.tx {
  display: flex;
  justify-content: space-between;
  padding: 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  transition: all 0.3s ease;
}

.tx:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(59, 130, 246, 0.3);
}

.tx .meta {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* TYPOGRAPHY */
.section-title {
  font-weight: 700;
  font-size: 18px;
  margin-bottom: 16px;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.muted {
  color: var(--text-secondary);
  font-size: 14px;
}

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

/* TAGS */
.tag {
  padding: 6px 12px;
  border-radius: 8px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  font-size: 13px;
  font-weight: 500;
}

select option {
  background: var(--card-bg);   /* dark background */
  color: var(--text-primary);   /* light text */
}

.success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.3);
  color: var(--success);
}

/* PROGRESS BAR */
.progress {
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

.progress > i {
  display: block;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width 0.5s ease;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

/* CHARTS */
.chart-wrap {
  height: 240px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-top: 12px;
}

/* EMPTY STATE */
.empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  background: rgba(255, 255, 255, 0.02);
  border-radius: 12px;
  border: 1px dashed var(--border);
}

/* FOOTER */
footer {
  margin-top: 40px;
  padding-top: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* RESPONSIVE DESIGN */
@media (max-width: 1024px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .app {
    padding: 16px;
  }

  .top-summary {
    flex-direction: column;
  }

  header {
    flex-direction: column;
    gap: 16px;
    text-align: center;
  }

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

  .chart-wrap {
    height: 200px;
  }

  /* Make charts section stack on tablet */
  .card > div[style*="grid-template-columns: 1fr 1fr"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 12px;
    max-width: 100%;
    overflow-x: hidden;
  }

  header {
    padding: 16px 0;
  }

  header h1 {
    font-size: 22px;
  }

  .card {
    padding: 16px;
    border-radius: 12px;
    width: 100%;
    min-width: 0;
  }

  .top-summary {
    gap: 12px;
  }

  .summary-card {
    padding: 16px;
    width: 100%;
    min-width: 0;
  }

  .summary-card > div:nth-child(2) {
    font-size: 24px !important;
  }

  .section-title {
    font-size: 16px;
    margin-bottom: 12px;
  }

  .controls-wrap {
    width: 100%;
    flex-direction: column;
  }

  .controls-wrap input,
  .controls-wrap select,
  .controls-wrap button {
    width: 100%;
  }

  .row {
    flex-wrap: wrap;
  }

  .controls {
    width: 100%;
    flex-direction: column;
  }

  .controls button {
    width: 100%;
  }

  button {
    padding: 10px 16px;
    font-size: 14px;
    width: 100%;
  }

  .pill {
    padding: 6px 12px;
    font-size: 12px;
    white-space: nowrap;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  input,
  select,
  textarea {
    width: 100%;
    font-size: 16px;
    padding: 12px;
  }

  .tx {
    flex-direction: column;
    gap: 12px;
    padding: 12px;
  }

  .tx .meta {
    width: 100%;
  }

  .tx > div:last-child {
    width: 100%;
    text-align: left !important;
  }

  .tx > div:last-child > div:last-child {
    justify-content: flex-start !important;
  }

  .acct-item {
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
    padding: 12px;
  }

  .acct-item .row {
    width: 100%;
    justify-content: flex-start;
  }

  .chart-wrap {
    height: 180px;
    padding: 12px;
  }

  .list {
    max-height: 300px;
  }

  .empty {
    padding: 24px 16px;
    font-size: 13px;
  }

  footer {
    margin-top: 24px;
    padding-top: 16px;
    font-size: 12px;
  }

  /* Fix for cards in grid on mobile */
  .stack {
    gap: 16px;
    width: 100%;
    min-width: 0;
  }

  /* Ensure proper text wrapping */
  .muted,
  .small {
    word-wrap: break-word;
    overflow-wrap: break-word;
  }

  /* Report section improvements */
  #reportOut {
    font-size: 14px;
  }

  #reportOut > div {
    flex-direction: column !important;
    gap: 12px;
  }
}