/*!
 * expense-ui.css v1.0.0
 * A tiny CSS library for the Expense Tracker app.
 * Usage: <link rel="stylesheet" href="expense-ui.css">
 * Theme it by overriding the --eu-* variables on :root.
 */
:root {
  --eu-primary: #4f46e5;
  --eu-primary-dark: #4338ca;
  --eu-danger: #dc2626;
  --eu-danger-dark: #b91c1c;
  --eu-bg: #f3f4f6;
  --eu-card: #ffffff;
  --eu-text: #1f2937;
  --eu-muted: #6b7280;
  --eu-border: #e5e7eb;
  --eu-radius: 12px;
  --eu-shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--eu-bg);
  color: var(--eu-text);
  line-height: 1.5;
}
a { color: var(--eu-primary); }
h1, h2 { margin: 0 0 .75rem; line-height: 1.2; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 1rem; }
.page { padding-top: 1.5rem; padding-bottom: 3rem; }
.narrow { max-width: 600px; }

/* ---------- Header / nav ---------- */
.site-header { background: var(--eu-primary); color: #fff; position: sticky; top: 0; z-index: 10; }
.header-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-top: .75rem; padding-bottom: .75rem; }
.brand { color: #fff; font-weight: 700; font-size: 1.15rem; text-decoration: none; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a { color: #e0e7ff; text-decoration: none; padding: .35rem .75rem; border-radius: 8px; font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.15); color: #fff; }
.nav a.active { background: rgba(255,255,255,.25); color: #fff; }
.clock { margin: 0; font-variant-numeric: tabular-nums; font-size: .9rem; opacity: .9; }

/* ---------- Cards & hero ---------- */
.card { background: var(--eu-card); border-radius: var(--eu-radius); box-shadow: var(--eu-shadow); padding: 1.25rem; margin-bottom: 1.25rem; }
.hero { text-align: center; padding: 2rem 1rem; }
.hero h1 { font-size: 2rem; }
.hero p { max-width: 560px; margin: 0 auto 1.25rem; color: var(--eu-muted); }
.page-list { padding-left: 1.2rem; margin: 0; }
.page-list li { margin-bottom: .4rem; }
.hint { color: var(--eu-muted); font-size: .9rem; margin-bottom: 0; }
.simple-list { list-style: none; padding: 0; margin: 0 0 .75rem; }
.simple-list li { padding: .5rem 0; border-bottom: 1px solid var(--eu-border); display: flex; justify-content: space-between; gap: 1rem; }
.simple-list li:last-child { border-bottom: 0; }

/* ---------- Stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { margin: 0; display: flex; flex-direction: column; gap: .25rem; }
.stat-label { color: var(--eu-muted); font-size: .85rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; }
.stat-small { font-size: 1.05rem; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; cursor: pointer; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--eu-border);
  background: #fff; color: var(--eu-text); text-decoration: none;
  transition: background .15s, transform .05s;
}
.btn:hover { background: #f9fafb; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--eu-primary); border-color: var(--eu-primary); color: #fff; }
.btn-primary:hover { background: var(--eu-primary-dark); }
.btn-danger { background: var(--eu-danger); border-color: var(--eu-danger); color: #fff; }
.btn-danger:hover { background: var(--eu-danger-dark); }
.btn-small { padding: .25rem .6rem; font-size: .85rem; }
.btn-inline { display: inline-block; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--eu-primary); text-decoration: underline; cursor: pointer; }

/* ---------- Forms ---------- */
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 600; margin-bottom: .3rem; font-size: .95rem; }
input[type="text"], input[type="number"], input[type="date"], input[type="search"], select {
  width: 100%; font: inherit; padding: .55rem .7rem;
  border: 1px solid var(--eu-border); border-radius: 8px; background: #fff; color: inherit;
}
input:focus, select:focus { outline: 2px solid var(--eu-primary); outline-offset: 1px; border-color: transparent; }
.field.invalid input, .field.invalid select { border-color: var(--eu-danger); }
.error { display: block; color: var(--eu-danger); font-size: .82rem; min-height: 1em; margin-top: .25rem; }

/* ---------- Toolbar & table ---------- */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; }
.toolbar-controls { display: flex; gap: .5rem; flex-wrap: wrap; }
.toolbar-controls input, .toolbar-controls select { width: auto; min-width: 160px; }
.count { color: var(--eu-muted); font-size: .9rem; font-weight: 400; }

.expense-table { width: 100%; border-collapse: collapse; }
.expense-table th, .expense-table td { text-align: left; padding: .65rem .6rem; border-bottom: 1px solid var(--eu-border); }
.expense-table th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--eu-muted); }
.expense-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.expense-table .actions { text-align: right; white-space: nowrap; }
.expense-table tbody tr:hover { background: #f9fafb; }
.badge { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: #eef2ff; color: var(--eu-primary-dark); font-size: .8rem; font-weight: 600; }
.empty { text-align: center; color: var(--eu-muted); padding: 1.5rem 0; display: none; }
.danger-zone { margin-top: 1rem; text-align: right; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,.5); display: none; align-items: center; justify-content: center; padding: 1rem; z-index: 50; }
.modal-overlay.open { display: flex; }
.modal { background: #fff; border-radius: var(--eu-radius); padding: 1.5rem; width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px);
  background: #111827; color: #fff; padding: .7rem 1.1rem; border-radius: 8px;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--eu-danger); }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .expense-table thead { display: none; }
  .expense-table, .expense-table tbody, .expense-table tr, .expense-table td { display: block; width: 100%; }
  .expense-table tr { border-bottom: 1px solid var(--eu-border); padding: .5rem 0; }
  .expense-table td { border: 0; padding: .2rem .4rem; text-align: left !important; }
  .toolbar-controls input, .toolbar-controls select { width: 100%; }
}
