:root {
  --bg: #f5f3ef;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --ink: #2e2a27;
  --muted: #8a817a;
  --line: #ebe6df;
  --accent: #6c8f7d;
  --accent-soft: #e2ece5;
  --accent-ink: #3f5c4d;
  --warn: #c98b6b;
  --warn-soft: #f6e7de;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(46, 42, 39, 0.04), 0 6px 18px rgba(46, 42, 39, 0.05);
}

* { box-sizing: border-box; }

html {
  /* iOS would otherwise inflate the text in landscape. */
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

h1 { font-size: 1.35rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 0 0 0.35rem; font-weight: 620; }
p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.4rem 1.75rem 1rem;
  max-width: 1280px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 0.85rem; }
.logo {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 1.35rem;
}

main, .sheet {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 clamp(0.8rem, 4vw, 1.75rem) 3rem;
}

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

/* ---------------------------------------------------------------- uploader */
.uploader { display: grid; gap: 0.85rem; margin-bottom: 1rem; }
.uploader-text h2 { margin-bottom: 0.2rem; }

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 1.5rem 1rem;
  text-align: center;
  border: 1.5px dashed #d8d1c6;
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.dropzone.is-over {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}
.dropzone.is-busy { opacity: 0.6; pointer-events: none; }
.dz-icon { font-size: 1.5rem; line-height: 1.2; }
.dz-main { font-weight: 600; font-size: 0.92rem; }

.uploader-foot { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.uploader-foot .small { flex: 1 1 260px; }

.upload-results { display: grid; gap: 0.4rem; }
.upload-result {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 0.85rem;
}
.upload-result .res-icon { flex: 0 0 auto; }
.upload-result .res-file { font-weight: 600; }
.upload-result .res-detail { color: var(--muted); flex: 1 1 auto; }
.upload-result.ok { border-color: #c6d8cc; background: var(--accent-soft); }
.upload-result.dup { border-color: #e6dcc7; background: #fbf7ee; }
.upload-result.err { border-color: #e9cdbd; background: var(--warn-soft); }

/* ----------------------------------------------------------------- picker */
.picker {
  display: grid;
  /* minmax(0, ...) and not 1fr: a plain 1fr track keeps its "auto" minimum, so a
     <select> (whose intrinsic width is its longest option) would push the track
     wider than the card. A 0 minimum lets the two fields shrink instead. */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: 0.5rem;
  margin: 0.6rem 0 0.5rem;
}
.picker > *, .filters > * { min-width: 0; }
.picker input[type="search"] {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
}
.picker input[type="search"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.price-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  align-items: center;
  font-size: 0.86rem;
  margin-bottom: 0.35rem;
  min-height: 1.4rem;
}
.price-summary .up { color: var(--warn); font-weight: 650; }
.price-summary .down { color: var(--accent-ink); font-weight: 650; }
.note {
  font-size: 0.8rem;
  color: #7a6a56;
  background: #fbf7ee;
  border: 1px solid #ece2ce;
  border-radius: 10px;
  padding: 0.45rem 0.6rem;
  margin-bottom: 0.5rem;
}

table.table-click tbody tr { cursor: pointer; }
table.table-click tbody tr:hover { background: var(--surface-2); }
table.table-click tbody tr[aria-selected="true"] { background: var(--accent-soft); }

.methodology ul { margin: 0.2rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.4rem; }
.methodology li { font-size: 0.85rem; color: #57504a; }
.methodology b { color: var(--ink); }

/* ------------------------------------------------------- comparar dos meses */
.compare { margin-bottom: 0.9rem; }
.compare-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem 1rem;
  flex-wrap: wrap;
}
.compare-head h2 { margin-bottom: 0.15rem; }
.compare-months { display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap; }
.compare-months select { max-width: 100%; }
.compare-body { display: grid; gap: 0.85rem; margin-top: 0.55rem; }
.compare-body h3 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.25rem;
}
.cmp-headline { font-size: 0.88rem; color: #57504a; margin-bottom: 0.55rem; }
.cmp-buckets { display: grid; gap: 0.5rem; }
.cmp-bucket {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.75rem;
  row-gap: 0.2rem;
  font-size: 0.88rem;
}
.cmp-hint { display: block; }
.cmp-amount { font-variant-numeric: tabular-nums; }
.cmp-bar {
  grid-column: 1 / -1;
  display: block;
  height: 8px;
  border-radius: 4px;
  background: #f3efe9;
  overflow: hidden;
}
.cmp-bar > i { display: block; height: 100%; border-radius: 4px; }
.cmp-foot { margin-top: 0.45rem; }
.cmp-lists > div > h3:not(:first-child) { margin-top: 0.9rem; }
.cmp-sub {
  display: block;
  font-size: 0.76rem;
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}
.compare-body .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: 1px;
}
/* Spending more is the warm colour, spending less the calm one, as in the charts. */
.delta-up { color: var(--warn); font-weight: 640; }
.delta-down { color: var(--accent-ink); font-weight: 640; }

@media (max-width: 640px) {
  .compare-months { width: 100%; }
  .compare-months select { flex: 1 1 120px; }
}

.filters {
  display: grid;
  grid-template-columns:
    minmax(min(220px, 100%), 1.4fr)
    minmax(min(160px, 100%), 0.8fr)
    minmax(min(260px, 100%), 2fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1rem;
}

.filter-group { display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.filter-group > label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.chip {
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: #d9d2c8; }
.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: #c6d8cc;
  color: var(--accent-ink);
  font-weight: 600;
}
.chip .dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 0.4rem;
  vertical-align: 1px;
}

select, .btn {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.7rem;
  cursor: pointer;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent-ink); }

/* Every minmax() wraps its floor in min(..., 100%): on a phone a 420px track would
   otherwise be wider than the screen and push the whole page sideways. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 0.9rem;
  margin-bottom: 1rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.95rem 1.1rem;
}
.kpi .label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.kpi .value { font-size: 1.5rem; font-weight: 680; margin-top: 0.25rem; letter-spacing: -0.02em; }
.kpi .sub { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }
.kpi.accent { background: linear-gradient(180deg, #ffffff, #f4f8f5); }
.kpi.warm { background: linear-gradient(180deg, #ffffff, #fdf5f0); }
.badge {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 650;
  background: var(--accent-soft);
  color: var(--accent-ink);
  vertical-align: 2px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.chart { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.chart svg { display: block; }

/* A tappable line of text: on a touch screen the SVG <title> tooltips never appear,
   so every chart also writes its numbers here when you tap a bar or a point. */
.chart-readout {
  min-height: 1.35rem;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.chart-readout strong { color: var(--ink); }
.chart-readout .up { color: var(--warn); font-weight: 650; }
.chart-readout .down { color: var(--accent-ink); font-weight: 650; }

/* Shown only while a chart is wider than its card, i.e. when it can be dragged. */
.scroll-hint { margin-top: 0.35rem; }

/* ---------------------------------------------------------------- compras */

.purchases { margin-bottom: 0.9rem; }
.purchases-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.3rem;
}
.purchases-head h2 { margin-bottom: 0.15rem; }
.purchases-count { flex: 0 0 auto; white-space: nowrap; padding-top: 0.2rem; }

/* minmax(0, 1fr) as everywhere else: a plain 1fr track keeps its automatic
   minimum and grows to the widest row, which pushes the page sideways on a phone. */
.purchases-list { display: grid; grid-template-columns: minmax(0, 1fr); }

/* The month is a divider across the whole list, also when it runs in two columns.
   It carries the month's own spend, so the monthly figure reads without the chart. */
.purchase-month {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.1rem 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  padding: 0.7rem 0.45rem 0.2rem;
}
.purchase-month:first-child { padding-top: 0.35rem; }
/* Amounts keep their own casing: "340,12 €", not "340,12 €" shouted. */
.pm-total {
  margin-left: auto;
  text-align: right;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.purchase-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 0.5rem 0.45rem;
  font: inherit;
  color: inherit;
  text-align: left;
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}
.purchase-row:hover { background: var(--surface-2); }
.purchase-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.p-main { display: flex; flex-direction: column; min-width: 0; }
.p-date { font-weight: 620; font-size: 0.92rem; }
.p-store {
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Two labelled figures: the value of the basket and what was actually paid. */
.p-money { display: flex; flex-direction: column; align-items: flex-end; flex: 0 0 auto; }
.p-figure { display: flex; align-items: baseline; gap: 0.35rem; }
.p-label {
  font-size: 0.66rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.p-valor { font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.p-total { font-weight: 650; font-variant-numeric: tabular-nums; }

/* On a very narrow phone the line count is the first thing to go: the two amounts
   are the point of the row, and the count is still in the ticket itself. A long
   store name wraps instead of turning into an ellipsis. */
@media (max-width: 359px) {
  .p-lines { display: none; }
  .p-store { white-space: normal; overflow-wrap: anywhere; }
}

.purchases-more { margin-top: 0.85rem; width: 100%; }
.purchases-empty { color: var(--muted); padding: 0.9rem 0.45rem; font-size: 0.9rem; }

/* The ticket opens as a sheet: full screen on a phone, a centred card on a desk. */
.ticket-dialog {
  width: min(560px, calc(100vw - 2rem));
  max-width: none;
  max-height: min(88vh, 940px);
  padding: 0;
  border: none;
  border-radius: 16px;
  background: transparent;
  color: var(--ink);
  overflow: visible;
}
.ticket-dialog::backdrop { background: rgba(46, 42, 39, 0.45); }
.td-panel {
  display: flex;
  flex-direction: column;
  max-height: inherit;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(46, 42, 39, 0.28);
  overflow: hidden;
}
.td-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 0 0 auto;
  padding: 0.55rem 0.75rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.td-bar-title { font-size: 0.88rem; font-weight: 620; color: var(--muted); }
.td-close { flex: 0 0 auto; }

.td-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 1rem 1.1rem 1.5rem;
}

.td-head h2 { font-size: 1.1rem; margin-bottom: 0.1rem; }
.td-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(110px, 100%), 1fr));
  gap: 0.5rem;
  margin: 0.8rem 0 0.2rem;
}
.td-kpi {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
}
.td-kpi span {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}
.td-kpi strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.td-kpi.save strong { color: var(--accent-ink); }

.td-section { margin-top: 1.2rem; }
.td-section h3 {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
  margin: 0 0 0.3rem;
}
.td-section h3 span { text-transform: none; letter-spacing: 0; font-weight: 400; }

.td-items { list-style: none; margin: 0; padding: 0; }
.td-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.9rem;
  padding: 0.42rem 0;
  border-bottom: 1px solid var(--line);
}
.td-item:last-child { border-bottom: none; }
.td-item-name { min-width: 0; font-size: 0.9rem; }
.td-item-sub {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
}
.td-item-total {
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.td-item.discount .td-item-total { color: var(--accent-ink); }

.td-totals { margin: 1.2rem 0 0; display: grid; gap: 0.05rem; }
.td-totals > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.32rem 0;
  font-size: 0.88rem;
  border-bottom: 1px solid var(--line);
}
.td-totals dt { color: var(--muted); }
.td-totals dd { margin: 0; font-variant-numeric: tabular-nums; }
.td-totals .grand { border-bottom: none; padding-top: 0.55rem; }
.td-totals .grand dt { color: var(--ink); font-weight: 650; }
.td-totals .grand dd { font-size: 1.05rem; font-weight: 680; }
.td-totals .method { border-bottom: none; font-size: 0.82rem; }
.td-totals .method dt, .td-totals .method dd { color: var(--muted); }

/* The sheet covers the phone, so the page behind it must not scroll. */
body.is-locked { overflow: hidden; }

/* A wide screen has room for two purchases per line; the month still spans both. */
@media (min-width: 641px) {
  .purchases-list { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); column-gap: 1.5rem; }
}

.insights {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 0.75rem;
}
.insight {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.75rem 0.85rem;
}
.insight .ico { font-size: 1.1rem; line-height: 1.3; }
.insight strong { display: block; font-size: 0.9rem; }
.insight span { color: var(--muted); font-size: 0.84rem; }

table.table { width: 100%; border-collapse: collapse; }
table.table th, table.table td { text-align: left; padding: 0.45rem 0.3rem; border-bottom: 1px solid var(--line); }
table.table th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table tr:last-child td { border-bottom: none; }

.cert-notice {
  max-width: 1280px;
  margin: 0.75rem auto 0;
  padding: 0.55rem 0.85rem;
  border: 1px solid #eccbb6;
  border-radius: 10px;
  background: var(--warn-soft);
  color: #8a4a2b;
  font-size: 0.84rem;
  line-height: 1.4;
}

.footer { max-width: 1280px; margin: 0 auto; padding: 0 1.75rem 2.5rem; }
.footer p { margin-bottom: 0.3rem; }

.legend { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.65rem; }
.legend div { display: flex; align-items: center; gap: 0.4rem; font-size: 0.83rem; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.loading { color: var(--muted); padding: 2rem 0; text-align: center; }

@media (max-width: 820px) {
  .filters { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
}

/* ------------------------------------------------------------------- movil */

@media (max-width: 640px) {
  .topbar { padding: 1rem clamp(0.8rem, 4vw, 1.75rem) 0.75rem; gap: 0.6rem; }
  h1 { font-size: 1.15rem; }
  .logo { width: 38px; height: 38px; font-size: 1.15rem; }

  .card { padding: 0.95rem 0.85rem 1rem; border-radius: 12px; }
  .kpi { padding: 0.8rem 0.9rem; }
  .kpi .value { font-size: 1.3rem; }

  /* Search and product picker go one under the other: long product names are the
     widest thing in the page and side by side they get clipped anyway. */
  .picker { grid-template-columns: minmax(0, 1fr); }

  /* 16px keeps iOS from zooming the page when a field takes focus. */
  .picker input[type="search"],
  select,
  .btn {
    font-size: 16px;
  }

  /* Fingers, not a mouse: nothing interactive below ~38px. */
  .chip { padding: 0.5rem 0.85rem; font-size: 0.85rem; min-height: 38px; }
  .btn, select { min-height: 40px; padding: 0.5rem 0.8rem; }
  .dropzone { padding: 1.15rem 0.75rem; }
  .uploader-foot { gap: 0.5rem; }
  .uploader-foot .small { flex: 1 1 100%; }

  .upload-result { flex-wrap: wrap; gap: 0.2rem 0.5rem; }
  .upload-result .res-detail { flex: 1 1 100%; }

  table.table th, table.table td { padding: 0.45rem 0.15rem; }
  table.table td { font-size: 0.88rem; }
  /* On a phone the leaderboards keep product + change: the other two are in the
     summary of the product you tap. */
  .col-mid { display: none; }

  .insight { padding: 0.65rem 0.75rem; }
  .methodology li, .legend div { font-size: 0.82rem; }
  .legend { gap: 0.5rem 0.8rem; }
  .footer { padding: 0 clamp(0.8rem, 4vw, 1.75rem) 2rem; }

  /* The ticket takes the whole screen, at whatever height the browser really has. */
  .ticket-dialog {
    inset: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    border-radius: 0;
  }
  .td-panel { height: 100%; max-height: 100%; border-radius: 0; box-shadow: none; }
  .td-bar { padding-top: max(0.55rem, env(safe-area-inset-top)); }
  .td-body { padding: 0.9rem 0.9rem calc(1.5rem + env(safe-area-inset-bottom)); }
  .purchase-row { min-height: 54px; }
}

/* Touch screens get a floor on the hit area. Only min-height, so it cannot undo the
   padding a narrower viewport asked for. */
@media (pointer: coarse) {
  .chip { min-height: 38px; }
  .btn, select { min-height: 40px; }
}

@media (max-width: 380px) {
  .kpi .value { font-size: 1.2rem; }
  .chip { padding: 0.45rem 0.7rem; font-size: 0.82rem; }
}

@media print {
  .uploader, .filters, .scroll-hint { display: none; }
  .card { break-inside: avoid; }
}

/* ------------------------------------------------------------------- login */
.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(1.5rem, env(safe-area-inset-top)) 1rem 2rem;
}

.login-wrap { width: 100%; max-width: 25rem; margin: 0 auto; padding: 0; }
.login-card { display: grid; gap: 1.05rem; padding: 1.6rem 1.5rem 1.35rem; }
.login-brand { align-items: center; gap: 0.75rem; }
.login-brand h1 { font-size: 1.15rem; }
.login-brand .logo { width: 40px; height: 40px; font-size: 1.2rem; }

.login-form { display: grid; gap: 0.85rem; }

.field {
  display: grid;
  gap: 0.3rem;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--muted);
}
.field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.field input:focus {
  outline: 2px solid var(--accent-soft);
  outline-offset: 1px;
  border-color: var(--accent);
  background: var(--surface);
}

.login-submit {
  width: 100%;
  padding: 0.6rem 1rem;
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.login-submit:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #fff; }

.login-error {
  padding: 0.55rem 0.75rem;
  border: 1px solid #eccbb6;
  border-radius: 10px;
  background: var(--warn-soft);
  color: #8a4a2b;
  font-size: 0.85rem;
}

.login-foot { margin: 0; line-height: 1.35; }

.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.logout-form { margin: 0; display: inline-flex; }
