:root {
  --paper: #efe6d4;
  --paper-2: #f7f1e4;
  --ink: #172033;
  --muted: #3d4a5c;
  --line: #ddcfb6;
  --navy: #10284a;
  --blue: #1d4e89;
  --blue-soft: #e5eef8;
  --red: #9d2438;
  --red-soft: #f8e4e6;
  --green: #17613f;
  --green-soft: #e5f3eb;
  --amber: #6d4a0d;
  --amber-soft: #f8efd4;
  --flip: #542f72;
  --flip-soft: #f1e8f6;
  --shadow: 0 10px 30px rgba(16, 40, 74, 0.08);
  --sans: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --serif: "Iowan Old Style", Palatino, Georgia, serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(29, 78, 137, 0.08), transparent 28rem),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
img { max-width: 100%; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.visually-hidden {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  max-width: 1px;
  padding: 0;
  margin: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
.file-slot { position: relative; overflow: hidden; max-width: 100%; }

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card, .panel, .tile, .shot, .ledger, .set-row {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.login-card { width: min(440px, 100%); padding: 28px 22px 22px; }
.eyebrow, .top small, .hint, .meta, .badge { color: var(--muted); }
.eyebrow { letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.75rem; margin: 0 0 8px; }
h1, h2, .brand strong { font-family: var(--serif); font-weight: 600; letter-spacing: -0.03em; }
h1 { font-size: 3rem; line-height: 0.95; margin: 0 0 8px; }
h2 { font-size: 1.35rem; margin: 0 0 10px; }
.lede { margin: 0 0 18px; color: var(--muted); }

.app { min-height: 100vh; }
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: rgba(239, 230, 212, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 3px solid var(--navy);
  box-shadow: inset 0 -4px 0 var(--red);
}
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.brand strong { display: block; font-size: 1.45rem; line-height: 1; }
.brand small { display: block; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 68vw; }
.year-card {
  display: grid;
  gap: 8px;
  min-height: 76px;
  margin-bottom: 12px;
  padding: 14px;
  text-decoration: none;
  color: inherit;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.check-tools {
  position: sticky;
  top: 64px;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding: 8px 0 10px;
  background: rgba(239, 230, 212, 0.94);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 72px;
  border-bottom: 1px solid var(--line);
}
.check-main {
  flex: 1;
  min-width: 0;
  min-height: 64px;
  display: grid;
  grid-template-columns: 44px 3.4rem minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}
.thumb {
  width: 44px;
  height: 62px;
  border-radius: 6px;
  overflow: hidden;
  background: #e7dcc6;
  display: grid;
  place-items: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-fallback { color: var(--navy); font-family: var(--serif); }
.num { font-weight: 700; font-variant-numeric: tabular-nums; }
.who { min-width: 0; }
.who strong, .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who small { color: var(--muted); }
.badge.tenho { background: var(--green-soft); color: var(--green); }
.badge.falta { background: var(--red-soft); color: var(--red); }
.fonte { min-width: 44px; min-height: 44px; display: grid; place-items: center; font-size: 0.75rem; }
main {
  padding: 16px 16px calc(92px + env(safe-area-inset-bottom));
  max-width: 1100px;
}
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  background: var(--navy);
}
.tabbar a {
  color: #f6f1e6;
  text-decoration: none;
  text-align: center;
  font-size: 0.68rem;
  line-height: 1.1;
  min-height: 48px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  padding: 0 2px;
}
.tabbar a[aria-current="page"] { background: rgba(255, 255, 255, 0.16); }
.tabbar a.tab-new[aria-current="page"] { background: var(--red); }

.toolbar, .filters { display: grid; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; min-width: 0; max-width: 100%; }
.check-tools { min-width: 0; }
.chip, .btn {
  border: 1px solid var(--line);
  background: white;
  border-radius: 999px;
  min-height: 44px;
  padding: 0 14px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.chip[aria-pressed="true"], .btn.primary { background: var(--navy); color: #f6f1e6; border-color: var(--navy); }
.btn.danger { background: var(--red); color: white; border-color: var(--red); }
.btn.ghost { background: transparent; }
.btn.wide, .btn.primary, .btn.danger { width: 100%; }
.actions { display: grid; gap: 8px; margin-top: 12px; }
.search, .field input, .field select, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 12px;
  min-height: 48px;
  padding: 10px 12px;
}
.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 0.86rem; color: var(--muted); }
.field textarea { min-height: 96px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; min-height: 44px; }
.form-grid { display: grid; gap: 0 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tile { overflow: hidden; color: inherit; text-decoration: none; display: flex; flex-direction: column; }
.sleeve {
  aspect-ratio: 5 / 7;
  background:
    linear-gradient(180deg, rgba(16, 40, 74, 0.04), rgba(16, 40, 74, 0.14)),
    #e7dcc6;
  display: grid;
  place-items: center;
  color: var(--navy);
  font-family: var(--serif);
  font-size: 2rem;
}
.sleeve img { width: 100%; height: 100%; object-fit: cover; }
.tile-body, .pad { padding: 10px 12px 12px; }
.tile h3, .set-row strong { margin: 0; font-size: 1rem; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.badge {
  font-size: 0.72rem;
  border-radius: 999px;
  padding: 3px 8px;
  background: #efe7d8;
}
.badge.casa { background: var(--blue-soft); color: var(--navy); }
.badge.comc { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: var(--amber); }
.badge.bad { background: var(--red-soft); color: var(--red); }
.badge.flip { background: var(--flip-soft); color: var(--flip); }
.badge.sale { background: #fde7c7; color: #6a3d08; }

.banner { border-radius: 12px; padding: 10px 12px; margin: 0 0 12px; }
.banner.bad { background: var(--red-soft); color: var(--red); }
.banner.warn { background: var(--amber-soft); color: var(--amber); }
.banner.ok { background: var(--green-soft); color: var(--green); }
.empty { padding: 22px 16px; text-align: center; }
.empty h2 { font-size: 1.6rem; }
.photos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.shot { position: relative; overflow: hidden; padding: 10px; display: grid; gap: 8px; }
.shot img { width: 100%; aspect-ratio: 5 / 7; object-fit: cover; border-radius: 12px; background: #e7dcc6; }
.shot-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.shot-actions .btn { width: 100%; min-width: 0; padding-inline: 6px; }
.bar { height: 8px; background: #e7dcc6; border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--blue), var(--navy)); }
.set-row {
  display: grid;
  gap: 6px;
  padding: 12px;
  margin-bottom: 10px;
  color: inherit;
  text-decoration: none;
}
.year-label { margin: 18px 0 8px; font-family: var(--serif); font-size: 1.6rem; }
.list-card { padding: 12px; margin-bottom: 10px; }
.profit-pos { color: var(--green); font-weight: 700; }
.profit-neg { color: var(--red); font-weight: 700; }
.pair { display: flex; justify-content: space-between; gap: 12px; }
.missing { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
details { margin: 8px 0 14px; }
summary { cursor: pointer; min-height: 44px; display: grid; align-items: center; }

@media (min-width: 720px) {
  .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .actions { grid-template-columns: 1fr 1fr; }
  .btn.wide { width: auto; }
}
@media (min-width: 960px) {
  .app { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: auto 1fr; }
  .tabbar {
    position: sticky;
    top: 0;
    height: 100vh;
    grid-row: 1 / span 2;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 18px 12px;
  }
  .tabbar a { justify-content: flex-start; padding: 0 12px; font-size: 0.95rem; }
  .top, main { grid-column: 2; }
  main { padding: 22px 28px 48px; }
}
