:root {
  /* Modern Palette */
  --primary: #6366f1;       /* Indigo */
  --primary-dark: #4f46e5;
  --secondary: #f1f5f9;     /* Slate 100 */
  --text-main: #1e293b;     /* Slate 800 */
  --text-muted: #64748b;    /* Slate 500 */
  --bg-body: #f8fafc;       /* Slate 50 */
  --bg-card: #ffffff;
  --danger: #ef4444;
  --success: #10b981;

  /* Spacing & Radius */
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --container-padding: 20px;
}

/* --- Resets & Base --- */
* { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  margin: 0;
  line-height: 1.5;
  padding-bottom: 80px; /* Space for footer */
}

a { text-decoration: none; color: inherit; }

h1, h2, h3 { margin-top: 0; color: var(--text-main); }
h1 { font-size: 1.5rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 1rem; }
h3 { font-size: 1.1rem; font-weight: 600; }

/* --- Layout --- */
.container {
  max-width: 600px; /* Mobile constrained on desktop */
  margin: 0 auto;
  padding: var(--container-padding);
}

header {
  background: var(--bg-card);
  padding: 15px var(--container-padding);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

header h1 { font-size: 1.2rem; margin: 0; color: var(--primary); }

nav a { color: var(--text-muted); font-size: 0.9rem; margin-left: 10px; }

/* --- Cards (Groups & Operations) --- */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: transform 0.1s ease;
  border: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card:active { transform: scale(0.98); background-color: var(--secondary); }

.card h3 { margin: 0; font-size: 1rem; }
.card p { margin: 4px 0 0; font-size: 0.85rem; color: var(--text-muted); }
.card .amount { font-weight: bold; color: var(--text-main); font-size: 1.1rem; }

/* --- Forms --- */
form { display: flex; flex-direction: column; gap: 15px; }

label {
  display: block;
  font-weight: 600;
  margin-bottom: 5px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius);
  font-size: 16px; /* Prevents zoom on iPhone */
  background: #fff;
  appearance: none; /* Removes default OS styling */
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* --- Buttons --- */
input[type="submit"],
button,
.btn,
.button {
  display: inline-block;
  width: 100%;
  padding: 14px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background-color 0.2s;
  text-decoration: none;
}

input[type="submit"]:hover, .button:hover {
  background-color: var(--primary-dark);
}

.btn-secondary, .btn-logout {
  background-color: transparent;
  color: var(--text-muted);
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  font-size: 0.85rem;
  width: auto;
}

/* --- Utility / Flash --- */
.flash {
  padding: 10px;
  border-radius: var(--radius);
  margin: 10px var(--container-padding);
  font-size: 0.9rem;
  text-align: center;
}
.flash.notice { background-color: #dcfce7; color: #166534; }
.flash.alert { background-color: #fee2e2; color: #991b1b; }

/* --- Footer --- */
footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(5px);
  padding: 15px;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}

footer a {
  font-weight: 600;
  color: var(--primary);
}