:root {
  --bg: #f6f1ea;
  --surface: #fffdf9;
  --surface-2: #f0e9df;
  --ink: #2b2420;
  --muted: #7d7068;
  --line: #e6dccf;
  --accent: #c2683f;
  --accent-ink: #fff;
  --accent-soft: #f7e3d8;
  --green: #3f7d58;
  --green-soft: #e1efe5;
  --amber: #a8711b;
  --amber-soft: #f8ecd2;
  --red: #b0413e;
  --red-soft: #f7e0de;
  --blue: #3c6a8f;
  --blue-soft: #e0ebf3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 20, .06), 0 4px 14px rgba(60, 40, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1816;
    --surface: #24201d;
    --surface-2: #2e2925;
    --ink: #f1e9e1;
    --muted: #a99c92;
    --line: #3a332e;
    --accent: #e08a5f;
    --accent-ink: #1b1816;
    --accent-soft: #3d2a20;
    --green: #7cc296;
    --green-soft: #22352a;
    --amber: #e0b25e;
    --amber-soft: #3a2f1c;
    --red: #e8827f;
    --red-soft: #3d2322;
    --blue: #8ab8dc;
    --blue-soft: #1f2e3a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--red); min-height: 1.2em; margin: 0; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
a { color: var(--accent); }

/* botões e campos */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  background: var(--surface); padding: 32px 26px; border-radius: 20px; box-shadow: var(--shadow);
  width: 100%; max-width: 340px; display: grid; gap: 12px; text-align: center;
}
.login-card p { margin: 0; }
.logo-lg { width: 48px; height: 48px; fill: var(--accent); justify-self: center; }

/* topo */
.top {
  position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left)); flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; }
.logo { width: 24px; height: 24px; fill: var(--accent); }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.tab { border: 0; background: transparent; font: inherit; font-weight: 600; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.tab.active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

main { max-width: 1040px; margin: 0 auto; padding: 14px 16px 80px; }

.robot { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 10px; flex-wrap: wrap; }

/* banner de promoções */
.deals {
  background: linear-gradient(135deg, var(--accent-soft), var(--surface));
  border: 1px solid var(--line); border-radius: 18px; padding: 14px 14px 6px; margin-bottom: 14px;
}
.deals-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.deals-head h2 { font-size: 17px; }
.deals-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; scroll-snap-type: x mandatory; }
.deal {
  flex: 0 0 250px; scroll-snap-align: start; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px; display: grid; grid-template-columns: 64px 1fr; gap: 10px; text-decoration: none; color: inherit;
}
.deal img, .thumb { width: 64px; height: 64px; object-fit: contain; border-radius: 10px; background: #fff; }
.deal .item { font-weight: 700; font-size: 14px; }
.deal .title { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.deal .price { font-weight: 800; font-size: 17px; color: var(--green); }
.deal .old { text-decoration: line-through; color: var(--muted); font-size: 12px; margin-left: 4px; font-weight: 400; }
.deal .reason { font-size: 12px; font-weight: 600; color: var(--accent); }
.deal-actions { grid-column: 1 / -1; display: flex; gap: 6px; }
.deals-empty { color: var(--muted); font-size: 14px; padding: 4px 2px 12px; }

/* resumo */
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; }
.progress { height: 6px; background: var(--surface-2); border-radius: 99px; margin-top: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--green); border-radius: 99px; }

/* filtros */
.toolbar { display: flex; gap: 8px; margin-bottom: 10px; }
.toolbar input { flex: 1 1 200px; }
.toolbar select { flex: 0 1 180px; }
.chips { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; padding-bottom: 2px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); padding: 5px 12px; border-radius: 99px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink);
}
.chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip small { opacity: .65; font-weight: 500; }

/* lista */
.room { margin-bottom: 20px; }
.room-head { display: flex; align-items: baseline; justify-content: space-between; margin: 0 2px 8px; }
.room-head h2 { font-size: 16px; }
.room-head span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.items { display: grid; gap: 8px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.card.bought { opacity: .62; }
.row { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; cursor: pointer; }
.row .thumb { width: 52px; height: 52px; }
.thumb.empty { display: grid; place-items: center; color: var(--muted); background: var(--surface-2); font-size: 20px; }
.row .name { font-weight: 700; }
.card.bought .name { text-decoration: line-through; }
.row .meta { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row .right { text-align: right; font-variant-numeric: tabular-nums; }
.row .best { font-weight: 800; }
.row .best.ok { color: var(--green); }
.row .best.over { color: var(--red); }
.row .budget { font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; text-transform: uppercase; letter-spacing: .02em; }
.badge.essencial { background: var(--red-soft); color: var(--red); }
.badge.quero { background: var(--blue-soft); color: var(--blue); }
.badge.sonho { background: var(--amber-soft); color: var(--amber); }
.status {
  font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 99px; border: 0; cursor: pointer; font-family: inherit;
}
.status.pesquisando { background: var(--surface-2); color: var(--muted); }
.status.escolhido { background: var(--blue-soft); color: var(--blue); }
.status.comprado { background: var(--green-soft); color: var(--green); }
.hot { background: var(--accent); color: var(--accent-ink); }

/* detalhe do item */
.detail { border-top: 1px solid var(--line); padding: 12px; display: grid; gap: 12px; background: color-mix(in srgb, var(--surface-2) 40%, var(--surface)); }
.detail h4 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notes { font-size: 14px; white-space: pre-wrap; margin: 0; }
.links { display: grid; gap: 6px; }
.link {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px;
}
.link.best { border-color: var(--green); box-shadow: inset 3px 0 0 var(--green); }
.link .thumb { width: 44px; height: 44px; }
.link .ltitle { font-size: 13px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link .lmeta { font-size: 12px; color: var(--muted); }
.link .lerr { font-size: 12px; color: var(--amber); }
.link .lprice { text-align: right; font-weight: 800; font-variant-numeric: tabular-nums; }
.link .lprice small { display: block; font-weight: 400; color: var(--muted); text-decoration: line-through; }
.link .lactions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.store { font-weight: 700; color: var(--ink); }
.addlink { display: flex; gap: 6px; flex-wrap: wrap; }
.addlink input[name=url] { flex: 1 1 260px; }
.addlink input[name=price] { flex: 0 1 140px; }
.detail-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 0; }

/* histórico */
.hgroup { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.hgroup h3 { font-size: 15px; margin-bottom: 2px; }
.hgroup .sub { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.hlink { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.hlink:first-of-type { border-top: 0; }
.hlink .hl-title { font-size: 13px; }
.hlink .hl-stats { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.chart { grid-column: 1 / -1; width: 100%; height: 120px; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .area { fill: var(--accent-soft); opacity: .6; }
.chart .dot { fill: var(--accent); }
.chart .min { fill: var(--green); }
.chart text { fill: var(--muted); font-size: 11px; }
.chart .grid { stroke: var(--line); stroke-dasharray: 3 3; }
details.table summary { font-size: 12px; color: var(--muted); cursor: pointer; grid-column: 1 / -1; }
details.table table { width: 100%; font-size: 12.5px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
details.table td, details.table th { padding: 3px 6px; border-bottom: 1px solid var(--line); text-align: left; }

/* modal */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(30, 20, 10, .4); }
dialog form { padding: 20px; display: grid; gap: 10px; }
dialog label { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1.3fr .6fr 1.1fr; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
  transition: .2s; pointer-events: none; max-width: calc(100vw - 32px); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%); }

@media (max-width: 720px) {
  .summary { grid-template-columns: 1fr 1fr; }
  .toolbar { flex-wrap: wrap; }
  .toolbar select { flex: 1 1 40%; }
  .toolbar #addItem { flex: 1 1 100%; }
  .tabs { width: 100%; }
  .tab { flex: 1; }
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 label:last-child { grid-column: 1 / -1; }
}
