/*
 * Expense Tracker — application styles.
 * Plain CSS, no framework. Loaded via `stylesheet_link_tag :app`.
 */

:root {
  --ink:        #16191d;
  --ink-soft:   #5b6470;
  --ink-faint:  #8b939e;
  --rule:       #e3e6ea;
  --ground:     #f6f7f9;
  --surface:    #ffffff;
  --accent:     #2f5d84;
  --positive:   #1f7a4d;
  --negative:   #b23c33;
  --radius:     8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 0.6rem; font-weight: 600; }
h1 { font-size: 1.6rem; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; }
h3 { font-size: 0.95rem; }
a { color: var(--accent); }

/* Layout ------------------------------------------------------------------ */

.page {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
}

.masthead__inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.masthead__brand {
  font-weight: 650;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.masthead__nav { display: flex; gap: 0.25rem; flex-wrap: wrap; flex: 1; }

.masthead__link {
  color: var(--ink-soft);
  text-decoration: none;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.masthead__link:hover { background: var(--ground); color: var(--ink); }
.masthead__link--current { background: var(--ground); color: var(--ink); font-weight: 600; }

.masthead__account { display: flex; align-items: center; gap: 0.6rem; }
.masthead__user { color: var(--ink-soft); font-size: 0.9rem; }

.page__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}

/* Cards and panels -------------------------------------------------------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.panel__title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
  margin-bottom: 0.85rem;
}

.card-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.card__period {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--ink-faint);
}
.card__label { font-size: 0.95rem; color: var(--ink); margin-bottom: 0.75rem; font-weight: 600; }
.card__figures { display: grid; gap: 0.3rem; }
.card__figure { display: flex; justify-content: space-between; gap: 1rem; font-variant-numeric: tabular-nums; }
.card__figure--net {
  border-top: 1px solid var(--rule);
  margin-top: 0.35rem;
  padding-top: 0.45rem;
  font-weight: 650;
}
.card__figure dt { color: var(--ink-soft); margin: 0; }
.card__figure dd { margin: 0; }

/* Tables ------------------------------------------------------------------ */

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-bottom: 1px solid var(--rule);
}

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
  font-weight: 600;
}

tbody tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 650; border-top: 2px solid var(--rule); border-bottom: 0; }

.numeric { text-align: right; }
.table-scroll { overflow-x: auto; }

.amount--positive { color: var(--positive); }
.amount--negative { color: var(--negative); }
.muted { color: var(--ink-faint); }
.tag {
  display: inline-block;
  background: var(--ground);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0.65;
  min-width: 2px;
}

/* Forms and buttons ------------------------------------------------------- */

.form { max-width: 460px; }
.form__field { margin-bottom: 0.9rem; }
.form__field label { display: block; font-size: 0.85rem; color: var(--ink-soft); margin-bottom: 0.25rem; }

input[type="text"], input[type="email"], input[type="password"],
input[type="date"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 1px;
  border-color: var(--accent);
}

.button, input[type="submit"], button {
  display: inline-block;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}
.button:hover, input[type="submit"]:hover, button:hover { filter: brightness(1.08); }

.button--quiet, .masthead__account button {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--rule);
}
.button--quiet:hover, .masthead__account button:hover { background: var(--ground); filter: none; }

.button--danger { background: transparent; color: var(--negative); border-color: var(--rule); }
.button--danger:hover { background: #fdf3f2; filter: none; }

.actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.actions form { display: inline; }

/* Flash and errors --------------------------------------------------------- */

.flash {
  padding: 0.6rem 0.85rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  border: 1px solid;
}
.flash--notice { background: #eef7f1; border-color: #cbe5d6; color: var(--positive); }
.flash--alert  { background: #fdf1f0; border-color: #f0d2cf; color: var(--negative); }

.errors {
  background: #fdf1f0;
  border: 1px solid #f0d2cf;
  border-radius: 6px;
  padding: 0.6rem 0.85rem 0.6rem 1.6rem;
  margin-bottom: 1rem;
  color: var(--negative);
}
.errors li { font-size: 0.9rem; }

/* Sign in ------------------------------------------------------------------ */

.session {
  max-width: 340px;
  margin: 4rem auto;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.session h1 { font-size: 1.25rem; margin-bottom: 1rem; }
.session input[type="submit"] { width: 100%; }
.session__footer { margin-top: 0.9rem; font-size: 0.85rem; }

/* Pagination / period nav --------------------------------------------------- */

.period-nav { display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.period-nav__current { font-weight: 600; }

.empty {
  color: var(--ink-faint);
  padding: 1.25rem 0;
  text-align: center;
}

/* Language switcher ---------------------------------------------------------- */

.locales { display: inline-flex; gap: 0.15rem; }
.locales__form { display: inline; }
.locales .button {
  padding: 0.25rem 0.45rem;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}
.locales .button--current {
  background: var(--ground);
  color: var(--ink);
  font-weight: 650;
  border-color: var(--rule);
}

/* Admin ---------------------------------------------------------------------- */

.breadcrumb { margin: 0 0 0.5rem; font-size: 0.9rem; }
.breadcrumb a { color: var(--ink-soft); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); text-decoration: underline; }

.card--section { display: flex; flex-direction: column; align-items: flex-start; }
.card__heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
}
.card--section .card__label { margin-bottom: 0.35rem; }
.card__description { font-size: 0.9rem; margin: 0 0 1rem; flex: 1; }

/* Filtered lists ------------------------------------------------------------- */

.filter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
}
