:root {
  --bg: #0b0a24;
  --panel: rgba(24, 20, 58, .62);
  --panel-solid: #151233;
  --line: rgba(255, 255, 255, .08);
  --line-strong: rgba(255, 255, 255, .16);
  --text: #e8ebf3;
  --muted: #9a9cc6;
  --accent: #9d5cf0;
  --accent-2: #5fd9ff;
  --amber: #ffb347;
  --radius: 16px;
  --font: "Inter", system-ui, sans-serif;
  --display: "Poppins", "Inter", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { color-scheme: dark; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased;
  min-height: 100vh; overflow-x: hidden;
}
.aurora {
  position: fixed; inset: -20vh -10vw auto; height: 70vh; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40% 50% at 20% 30%, rgba(157, 92, 240, .22), transparent 70%),
    radial-gradient(35% 45% at 80% 20%, rgba(95, 217, 255, .14), transparent 70%),
    radial-gradient(30% 40% at 55% 70%, rgba(255, 107, 203, .08), transparent 70%);
  filter: blur(20px);
}
body::after {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.5), transparent 60%);
  opacity: .35;
}
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
kbd {
  font: 500 11px var(--mono); color: var(--muted); border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 2px 6px; background: rgba(255,255,255,.03);
}
.muted { color: var(--muted); }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px;
  padding: 14px max(16px, env(safe-area-inset-left)); backdrop-filter: blur(18px) saturate(140%);
  background: rgba(11, 10, 36, .7); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none;
  font: 700 20px var(--display); letter-spacing: -.02em; }
.search {
  flex: 1; min-width: 0; max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px;
  transition: border-color .2s, box-shadow .2s;
}
.search:focus-within { border-color: rgba(157,92,240,.6); box-shadow: 0 0 0 4px rgba(157,92,240,.15); }
.search svg { color: var(--muted); flex: none; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--text);
  font: inherit; padding: 11px 0; }
.search input::-webkit-search-cancel-button { filter: invert(.6); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(255,255,255,.04); color: var(--text);
  font: 600 14px var(--font); padding: 10px 16px; border-radius: 12px; transition: transform .15s, background .2s, box-shadow .2s;
}
.btn:hover { background: rgba(255,255,255,.08); }
.btn:active { transform: scale(.97); }
.btn.primary { border: 0; background: linear-gradient(135deg, var(--accent), #7b8cff 55%, var(--accent-2));
  box-shadow: 0 6px 24px -6px rgba(157,92,240,.7); }
.btn.primary:hover { box-shadow: 0 8px 30px -4px rgba(157,92,240,.85); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ff8a8a; border-color: rgba(255,120,120,.3); }
.btn.wide { width: 100%; }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 10px; }

main { padding: 20px max(16px, env(safe-area-inset-left)) 80px; max-width: 1600px; margin: 0 auto; }

/* ---------- bento ---------- */
.bento { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile {
  position: relative; overflow: hidden; padding: 16px 18px; border-radius: var(--radius);
  background: var(--panel); border: 1px solid var(--line); backdrop-filter: blur(12px);
}
.tile .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.tile .value { font: 600 30px var(--display); letter-spacing: -.02em; margin-top: 4px; }
.tile .sub { color: var(--muted); font-size: 13px; }
.tile.glow::before { content: ""; position: absolute; inset: auto -30% -60% auto; width: 160px; height: 160px;
  border-radius: 50%; background: radial-gradient(var(--accent), transparent 70%); opacity: .25; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #4ade80; margin-right: 6px; }
.dot.off { background: #64748b; }
.dot.busy { background: var(--accent-2); animation: pulse 1.4s infinite; }

/* ---------- filtros ---------- */
.filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: rgba(255,255,255,.03); color: var(--text);
  font: 500 13px var(--font); padding: 6px 12px; border-radius: 999px; transition: all .2s;
}
.chip:hover { border-color: var(--line-strong); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip b { color: var(--muted); font-weight: 500; }
.chip.on { background: color-mix(in srgb, var(--c, var(--accent)) 18%, transparent);
  border-color: color-mix(in srgb, var(--c, var(--accent)) 60%, transparent); }
.tags .chip { font-size: 12px; padding: 4px 10px; color: var(--muted); }
.tags .chip.on { color: var(--text); }

/* ---------- mosaico ---------- */
.mosaic { columns: 5 260px; column-gap: 14px; margin-top: 10px; }
.card {
  --c: var(--accent); break-inside: avoid; margin: 0 0 14px; position: relative; cursor: pointer;
  border-radius: var(--radius); overflow: hidden; background: var(--panel); border: 1px solid var(--line);
  backdrop-filter: blur(10px); transition: transform .25s cubic-bezier(.2,.8,.2,1), border-color .25s, box-shadow .25s;
  animation: rise .5s cubic-bezier(.2,.8,.2,1) both;
}
.card:hover, .card:focus-visible { transform: translateY(-3px); outline: none;
  border-color: color-mix(in srgb, var(--c) 55%, transparent);
  box-shadow: 0 14px 40px -14px color-mix(in srgb, var(--c) 70%, transparent); }
.card img { display: block; width: 100%; height: auto; background: #110e2c; }
.card .cover {
  height: 92px; display: grid; place-items: center;
  background: radial-gradient(120% 120% at 0% 0%, color-mix(in srgb, var(--c) 40%, transparent), transparent 60%),
              linear-gradient(135deg, color-mix(in srgb, var(--c) 18%, #110e2c), #110e2c);
  font: 700 34px var(--display); color: color-mix(in srgb, var(--c) 80%, white);
}
.card .body { padding: 12px 14px 14px; }
.meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); min-width: 0; }
.pill { color: var(--c); font-weight: 600; flex: none; }
.meta .site { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card h3 { margin: 6px 0 4px; font: 600 15.5px/1.3 var(--display); letter-spacing: -.01em; }
.card p { margin: 0; color: var(--muted); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 3;
  -webkit-box-orient: vertical; overflow: hidden; }
.price { font: 500 15px var(--mono); color: var(--amber); margin-top: 8px; }
.taglist { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px; font-size: 12px; color: color-mix(in srgb, var(--c) 70%, white); }
.card .when { font-size: 11.5px; color: var(--muted); margin-top: 8px; }
.card.pending::after {
  content: "Processando…"; position: absolute; top: 10px; right: 10px; font-size: 11px; padding: 3px 8px;
  border-radius: 999px; background: rgba(11,10,36,.75); border: 1px solid rgba(95,217,255,.4); color: var(--accent-2);
}
.card.pending { animation: rise .5s both, glow 1.8s ease-in-out infinite; }
.card.error::after { content: "Erro — reprocessar"; position: absolute; top: 10px; right: 10px; font-size: 11px;
  padding: 3px 8px; border-radius: 999px; background: rgba(11,10,36,.75); border: 1px solid rgba(255,120,120,.5); color: #ff8a8a; }

.empty { column-span: all; text-align: center; padding: 60px 20px; }
.empty h2 { font: 600 26px var(--display); margin: 0 0 8px; }
.steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-width: 760px; margin: 28px auto 0; text-align: left; }
.step { padding: 16px; border-radius: var(--radius); background: var(--panel); border: 1px solid var(--line); }
.step b { display: block; font: 600 15px var(--display); margin: 6px 0 2px; }
.step span { color: var(--accent-2); font: 500 12px var(--mono); }
.more { text-align: center; }

/* ---------- gaveta (detalhe) ---------- */
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 40; overflow-y: auto;
  background: rgba(17, 14, 44, .92); backdrop-filter: blur(24px); border-left: 1px solid var(--line-strong);
  transform: translateX(105%); transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.45); opacity: 0; pointer-events: none; transition: opacity .3s; }
.scrim.open { opacity: 1; pointer-events: auto; }
.drawer-inner { padding: 18px 22px 40px; --c: var(--accent); }
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 14px; }
.drawer .hero { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 16px; }
.drawer .hero img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #090a10; }
.drawer h2 { font: 600 22px/1.25 var(--display); margin: 6px 0 10px; outline: none; border-radius: 6px; }
.drawer h2:focus { box-shadow: 0 0 0 2px rgba(157,92,240,.5); }
.summary { padding: 14px 16px; border-radius: 14px; margin: 14px 0;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 14%, transparent), rgba(255,255,255,.02));
  border: 1px solid color-mix(in srgb, var(--c) 30%, transparent); }
.summary small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 4px; }
.section-title { font: 600 12px var(--font); color: var(--muted); text-transform: uppercase; letter-spacing: .08em; margin: 22px 0 8px; }
.tagedit { display: flex; flex-wrap: wrap; gap: 6px; }
.tagedit .chip { cursor: default; }
.tagedit .chip button { all: unset; cursor: pointer; color: var(--muted); padding-left: 2px; }
.tagedit input { background: none; border: 1px dashed var(--line-strong); border-radius: 999px; color: var(--text);
  padding: 5px 12px; font: inherit; font-size: 13px; width: 120px; outline: none; }
textarea, .field {
  width: 100%; background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font: inherit; padding: 12px 14px; resize: vertical; outline: none;
}
textarea:focus, .field:focus { border-color: rgba(157,92,240,.6); }
details { border: 1px solid var(--line); border-radius: 12px; margin-top: 10px; }
details summary { cursor: pointer; padding: 10px 14px; color: var(--muted); font-size: 13px; }
details pre { margin: 0; padding: 0 14px 14px; white-space: pre-wrap; font: 13px/1.55 var(--font); color: #c7ccd8; max-height: 360px; overflow: auto; }
.entities { display: flex; flex-wrap: wrap; gap: 6px; }
.related { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.related .card { margin: 0; animation: none; }
.related .card img { max-height: 110px; object-fit: cover; }
.related .card .cover { height: 56px; font-size: 22px; }
.why { font-size: 11.5px; color: var(--accent-2); margin-top: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.openlink { display: inline-flex; align-items: center; gap: 6px; color: var(--accent-2); text-decoration: none; font-size: 13px; word-break: break-all; }

/* ---------- modais ---------- */
.modal {
  width: min(520px, calc(100vw - 32px)); padding: 26px; border-radius: 20px; color: var(--text);
  background: rgba(21, 18, 51, .96); border: 1px solid var(--line-strong);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,.8), 0 0 0 1px rgba(157,92,240,.12);
}
.modal::backdrop { background: rgba(3,4,8,.65); backdrop-filter: blur(6px); }
.modal h2 { font: 600 22px var(--display); margin: 0 0 4px; }
.modal p { margin: 0 0 14px; }
.modal .row { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.drop { display: block; margin-top: 10px; padding: 18px; text-align: center; border: 1px dashed var(--line-strong);
  border-radius: 12px; color: var(--muted); cursor: pointer; font-size: 13px; }
.drop:hover { border-color: rgba(157,92,240,.6); color: var(--text); }
.drop input { display: none; }
.hint { font-size: 12px; color: var(--muted); margin: 14px 0 0 !important; }
#login form, #invite form { text-align: center; }
#login .field, #login input { margin: 6px 0 12px; }
#token { width: 100%; background: rgba(255,255,255,.04); border: 1px solid var(--line-strong); border-radius: 12px;
  color: var(--text); font: inherit; padding: 12px 14px; outline: none; }
.login-logo { margin-bottom: 8px; filter: drop-shadow(0 0 18px rgba(157,92,240,.6)); }
.login-logo.full { display: block; margin: 0 auto 6px; height: auto; border-radius: 16px; filter: drop-shadow(0 0 26px rgba(157,92,240,.45)); }
.brand img { border-radius: 9px; }
.error { color: #ff8a8a; font-size: 13px; }

.dropzone { position: fixed; inset: 0; z-index: 60; display: none; place-items: center; background: rgba(11,10,36,.8); backdrop-filter: blur(6px); }
.dropzone.on { display: grid; }
.dropzone div { padding: 50px 70px; border: 2px dashed var(--accent); border-radius: 24px; font: 600 22px var(--display); color: var(--text); }

.toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: grid; gap: 8px; }
.toast { padding: 10px 16px; border-radius: 12px; background: rgba(24,20,58,.95); border: 1px solid var(--line-strong);
  box-shadow: 0 10px 30px rgba(0,0,0,.5); font-size: 14px; animation: rise .3s both; }
.toast.ok { border-color: rgba(74,222,128,.4); }

/* ---------- conta ---------- */
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; color: var(--text);
  font: 700 15px var(--display); border: 1px solid var(--line-strong);
  background: radial-gradient(circle at 30% 30%, rgba(157,92,240,.5), rgba(95,217,255,.15));
}
.banner { padding: 10px max(16px, env(safe-area-inset-left)); text-align: center; font-size: 14px;
  background: rgba(157,92,240,.12); border-bottom: 1px solid rgba(157,92,240,.3); }
.banner.danger { background: rgba(255,107,107,.12); border-color: rgba(255,107,107,.35); color: #ffc2c2; }
.auth .field { margin: 6px 0; }
.auth .btn { margin-top: 8px; }
.meter { margin: 12px 0; }
.meter-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.meter-top span:first-child { color: var(--text); }
.meter-bar { height: 8px; border-radius: 99px; background: rgba(255,255,255,.06); overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.meter-bar i.hot { background: linear-gradient(90deg, #ffb347, #ff6b6b); }
.box { padding: 14px 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255,255,255,.02); margin-bottom: 10px; }
.box p { margin: 6px 0 10px; font-size: 13px; }
.box .field { margin: 6px 0; }
.box .btn { margin-top: 6px; }
.line { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.line:last-of-type { border-bottom: 0; }
.state { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; color: #4ade80;
  background: rgba(74,222,128,.1); border: 1px solid rgba(74,222,128,.3); }
.state.bad { color: #ff8a8a; background: rgba(255,107,107,.1); border-color: rgba(255,107,107,.3); }
.state.warn { color: #ffb347; background: rgba(255,179,71,.1); border-color: rgba(255,179,71,.3); }
.state.info { color: var(--accent-2); background: rgba(95,217,255,.08); border-color: rgba(95,217,255,.3); }
code { font: 12.5px var(--mono); color: var(--accent-2); word-break: break-all; }
.copy { display: grid; gap: 6px; padding: 10px; border-radius: 10px; background: rgba(0,0,0,.3); border: 1px dashed var(--line-strong); margin: 8px 0; }
.qr { width: 184px; padding: 8px; background: #fff; border-radius: 10px; margin: 8px 0; }
.qr:empty { display: none; }

/* ---------- painel de gestão ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel); border: 1px solid var(--line); width: fit-content; margin-bottom: 18px; overflow-x: auto; max-width: 100%; }
.tabs button { all: unset; cursor: pointer; padding: 8px 14px; border-radius: 9px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tabs button.on { background: rgba(157,92,240,.2); color: var(--text); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .field { width: auto; flex: 1; min-width: 180px; max-width: 360px; padding: 9px 12px; }
.toolbar select.field { flex: 0 1 200px; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr.click { cursor: pointer; }
.table tbody tr.click:hover { background: rgba(255,255,255,.03); }
.table .num { font-family: var(--mono); font-size: 12.5px; white-space: nowrap; }
.mini { height: 5px; width: 80px; border-radius: 9px; background: rgba(255,255,255,.07); overflow: hidden; margin-top: 4px; }
.mini i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.grid2 label, .form label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form .field { margin-bottom: 10px; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
select.field option { background: var(--panel-solid); }
.list-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.list-row:last-child { border-bottom: 0; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
@media (max-width: 860px) { .cols, .grid2 { grid-template-columns: 1fr; } }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes glow { 50% { box-shadow: 0 0 0 1px rgba(95,217,255,.35), 0 0 28px -6px rgba(95,217,255,.5); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 860px) {
  .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .steps { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .top { gap: 10px; }
  .brand span, .search kbd, #openCapture span { display: none; }
  #openCapture { flex: none; padding: 10px 12px; }
  .mosaic { columns: 2 150px; column-gap: 10px; }
  .card { margin-bottom: 10px; }
  .tile .value { font-size: 24px; }
  .drawer-inner { padding: 16px 16px 40px; }
}
