:root {
  --bg: #0f1115;
  --panel: #171a21;
  --panel-2: #1f232c;
  --line: #2a2f3a;
  --text: #e7e9ee;
  --muted: #9aa3b2;
  --accent: #f5a623;
  --accent-ink: #1a1300;
  --danger: #e5484d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 .6rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; }

/* ---- Topbar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: .7rem 1.1rem;
  background: rgba(15,17,21,.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .01em; }
.topbar .search { flex: 1; max-width: 460px; }
.topbar .search input {
  width: 100%; padding: .55rem .9rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.logout { display: flex; align-items: center; gap: .6rem; margin-left: auto; }
.who { color: var(--muted); font-size: .9rem; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.4rem 1.1rem 4rem; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: .4rem; cursor: pointer; font: inherit; font-weight: 600;
  padding: .55rem 1rem; border-radius: 10px;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); transition: .15s ease;
}
.btn:hover { border-color: #3a4150; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.danger { color: #ffd7d8; background: transparent; border-color: #5a2a2c; }
.btn.danger:hover { background: rgba(229,72,77,.14); }
.btn.small { padding: .3rem .65rem; font-size: .82rem; border-radius: 8px; }
.btn.block { width: 100%; }

.flash {
  background: rgba(245,166,35,.12); border: 1px solid rgba(245,166,35,.4);
  color: #ffd9a1; padding: .6rem .9rem; border-radius: 10px; margin-bottom: 1.2rem;
}
.alert {
  background: rgba(229,72,77,.12); border: 1px solid rgba(229,72,77,.45);
  color: #ffd7d8; padding: .55rem .85rem; border-radius: 10px; margin-bottom: 1rem; font-size: .92rem;
}
.muted { color: var(--muted); }

/* ---- Page head ---- */
.page-head, .item-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1.4rem; }
.page-head h1, .item-head h1 { flex: 1; }
.item-head .back { color: var(--muted); font-size: .9rem; }
.item-head .del { margin-left: auto; }

/* ---- Grid de itens ---- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 1.1rem; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; transition: .18s ease;
}
.card:hover { transform: translateY(-3px); border-color: #3a4150; box-shadow: var(--shadow); }
.card .thumb { aspect-ratio: 1/1; background: var(--panel-2); display: grid; place-items: center; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { color: var(--muted); font-size: .85rem; }
.card .meta { padding: .7rem .8rem; display: flex; flex-direction: column; gap: .2rem; }
.card .name { font-weight: 600; }
.card .counts { color: var(--muted); font-size: .8rem; }

/* ---- Empty ---- */
.empty { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.empty .btn { margin-top: 1rem; }

/* ---- Uploader ---- */
.uploader { margin-bottom: .5rem; }
.dropzone {
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 1.6rem; border: 2px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); cursor: pointer; transition: .15s ease;
}
.dropzone:hover, .dropzone.drag { border-color: var(--accent); color: var(--text); background: rgba(245,166,35,.06); }
.dropzone input[type=file] { display: none; }

/* ---- Galeria ---- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.shot { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.shot.is-cover { border-color: var(--accent); }
.shot img { width: 100%; aspect-ratio: 1/1; object-fit: cover; display: block; cursor: zoom-in; }
.shot figcaption { display: flex; gap: .4rem; padding: .45rem .5rem; }
.mini {
  flex: 1; cursor: pointer; font: inherit; font-size: .76rem; font-weight: 600;
  padding: .3rem; border-radius: 7px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.mini:hover { color: var(--text); }
.mini.danger:hover { color: #ffd7d8; border-color: #5a2a2c; }
.shot.is-cover .mini:first-child { color: var(--accent); }

/* ---- Lista de arquivos ---- */
.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .5rem; }
.files li {
  display: flex; align-items: center; gap: .8rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem;
}
.files .fname { flex: 1; word-break: break-all; }
.files .fsize { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.files form { display: inline; }

/* ---- Modal ---- */
.modal {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: rgba(0,0,0,.6); padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem; width: 100%; max-width: 420px; box-shadow: var(--shadow);
}
.modal-box h2 { margin: 0 0 1rem; color: var(--text); }
.modal-box input[type=text] {
  width: 100%; padding: .6rem .8rem; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.1rem; }

/* ---- Lightbox ---- */
.lightbox {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center;
  background: rgba(0,0,0,.92); padding: 2rem; cursor: zoom-out;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 96vw; max-height: 92vh; object-fit: contain; border-radius: 8px; }
.lb-close {
  position: absolute; top: 1rem; right: 1.2rem; font-size: 2rem; line-height: 1;
  background: none; border: none; color: #fff; cursor: pointer; opacity: .8;
}
.lb-close:hover { opacity: 1; }

/* ---- Auth ---- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.2rem; }
.auth-box {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 2rem; width: 100%; max-width: 380px; box-shadow: var(--shadow);
}
.auth-brand { font-weight: 700; color: var(--accent); margin-bottom: .4rem; }
.auth-box h1 { margin: 0 0 .4rem; }
.auth-box label { display: block; margin: 1rem 0 .3rem; font-size: .85rem; color: var(--muted); }
.auth-box input {
  width: 100%; padding: .6rem .8rem; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
}
.auth-box .btn.block { margin-top: 1.4rem; }

@media (max-width: 560px) {
  .who { display: none; }
  .item-head { flex-wrap: wrap; }
}

/* ---- Filtros ---- */
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; justify-content: space-between; margin-bottom: 1.3rem; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .35rem .7rem; border-radius: 999px; font-size: .85rem;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted); transition: .12s;
}
.chip:hover { color: var(--text); border-color: #3a4150; }
.chip.on { background: var(--panel-2); color: var(--text); border-color: var(--accent); }
.chip .n { font-size: .72rem; color: var(--muted); background: var(--bg); padding: 0 .35rem; border-radius: 999px; }
.chip.on .n { color: var(--accent); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.style-toggle { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.style-toggle .seg { padding: .3rem .8rem; border-radius: 999px; font-size: .82rem; color: var(--muted); }
.style-toggle .seg.on { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.head-actions { display: flex; gap: .6rem; }

/* ---- Card: badge + dots ---- */
.card .thumb { position: relative; }
.card .badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,.65); color: #fff; font-size: .68rem;
  padding: .12rem .4rem; border-radius: 6px;
}
.card .meta { gap: .35rem; }
.card .dots { display: flex; gap: 4px; min-height: 9px; }

/* ---- Menu de contexto ---- */
.ctxmenu {
  position: fixed; z-index: 70; min-width: 220px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: .35rem; font-size: .88rem;
}
.ctxmenu[hidden] { display: none; }
.ctx-title { font-weight: 700; padding: .4rem .55rem .3rem; font-size: .82rem; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.ctx-item { display: block; width: 100%; text-align: left; background: none; border: none; color: var(--text);
  font: inherit; padding: .4rem .55rem; border-radius: 8px; cursor: pointer; }
.ctx-item:hover { background: var(--panel-2); }
.ctx-sep { height: 1px; background: var(--line); margin: .3rem .2rem; }
.ctx-label { font-size: .72rem; color: var(--muted); padding: .2rem .55rem; text-transform: uppercase; letter-spacing: .04em; }
.ctx-cats { max-height: 260px; overflow: auto; }
.ctx-cat { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  background: none; border: none; color: var(--muted); font: inherit; padding: .35rem .55rem; border-radius: 8px; cursor: pointer; }
.ctx-cat:hover { background: var(--panel-2); color: var(--text); }
.ctx-cat.on { color: var(--text); }
.ctx-cat .chk { margin-left: auto; color: var(--accent); width: 12px; }

/* ---- Painel de dados do item ---- */
.info-panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1.2rem; }
.info-grid { display: grid; grid-template-columns: 1fr 200px; gap: 1.2rem; }
.info-label { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 0 0 .4rem; }
.info-side .info-label:not(:first-child) { margin-top: .9rem; }
.cat-checks { display: flex; flex-wrap: wrap; gap: .4rem; }
.cat-check { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .6rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: .82rem; color: var(--muted); cursor: pointer; }
.cat-check input { display: none; }
.cat-check.on { color: var(--text); border-color: var(--accent); }
.info-side select, .info-side input[type=number], .info-panel textarea {
  width: 100%; padding: .5rem .65rem; border-radius: 9px; background: var(--panel-2);
  border: 1px solid var(--line); color: var(--text); font: inherit; }
.info-panel textarea { margin-top: .4rem; resize: vertical; }
.info-actions { margin-top: .9rem; display: flex; justify-content: flex-end; }
@media (max-width: 620px) { .info-grid { grid-template-columns: 1fr; } }
