/* CrowdArena admin panel.
   Single committed dark look — this is a tool that lives beside a terminal.
   No web fonts: the Content-Security-Policy allows only this origin, and an
   admin panel should not need the network to render. */

:root {
  --bg:        #0B0E13;
  --bg-2:      #11161E;
  --surface:   #161C26;
  --raised:    #1D2531;
  --hover:     #263040;
  --line:      #232C3A;
  --line-firm: #33404F;

  --text:      #E9EEF5;
  --text-2:    #9FADBE;
  --text-3:    #6B7887;

  --accent:    #16BFA9;
  --accent-dk: #0E8C7C;
  --accent-wash:#0F2E2A;

  --good:      #3FB950;
  --warn:      #E0A32E;
  --bad:       #FF5C6E;

  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-2);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { color: var(--text); margin: 0; font-weight: 600; letter-spacing: -0.01em; }

button, input, select, textarea { font: inherit; color: inherit; }

[hidden] { display: none !important; }

/* ── login ─────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 2rem;
}

.login {
  width: min(380px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 2rem;
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  margin-bottom: 1.6rem;
}
.brand .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #5B8CFF);
  display: grid; place-items: center;
  color: #06211E; font-weight: 700; font-size: .95rem;
}
.brand b { color: var(--text); font-size: 1.02rem; }
.brand span { color: var(--text-3); font-size: .8rem; }

.field { display: block; margin-bottom: 1rem; }
.field > span {
  display: block; font-size: .78rem; color: var(--text-2);
  margin-bottom: .35rem; font-weight: 500;
}

input[type="text"], input[type="email"], input[type="password"],
select, textarea {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line-firm);
  border-radius: 8px;
  padding: .55rem .7rem;
  color: var(--text);
  outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea { resize: vertical; min-height: 68px; }

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: .5rem .95rem;
  background: var(--raised);
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
}
.btn:hover { background: var(--hover); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: #04201C;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent-dk); color: #E9FFFB; }

.btn-danger { color: var(--bad); border-color: #4A2226; background: #2A1418; }
.btn-danger:hover { background: #3A191F; }

.btn-wide { width: 100%; justify-content: center; }

.msg {
  border-radius: 8px; padding: .55rem .75rem; font-size: .85rem;
  margin-bottom: 1rem; border: 1px solid transparent;
}
.msg-bad  { background: #2A1418; border-color: #4A2226; color: #FFB3BB; }
.msg-good { background: var(--accent-wash); border-color: #17554C; color: #8FE9DB; }

/* ── app shell ─────────────────────────────────────────────────────── */

.shell { display: grid; grid-template-columns: 226px 1fr; min-height: 100vh; }

.side {
  background: var(--bg-2);
  border-right: 1px solid var(--line);
  padding: 1.2rem 1rem;
  display: flex; flex-direction: column; gap: 1.4rem;
}

.nav { display: flex; flex-direction: column; gap: .15rem; }
.nav button {
  display: flex; align-items: center; gap: .6rem;
  background: none; border: none; border-radius: 8px;
  padding: .5rem .65rem; text-align: left; cursor: pointer;
  color: var(--text-2); font-size: .92rem;
}
.nav button:hover { background: var(--surface); color: var(--text); }
.nav button.on { background: var(--accent-wash); color: var(--accent); font-weight: 600; }
.nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.side-foot { margin-top: auto; font-size: .78rem; color: var(--text-3); }
.side-foot .who { color: var(--text-2); word-break: break-all; margin-bottom: .5rem; }

.main { padding: 1.6rem 1.9rem 4rem; overflow-x: hidden; }

.head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 1rem; margin-bottom: 1.4rem; flex-wrap: wrap;
}
.head p { margin: .25rem 0 0; color: var(--text-3); font-size: .88rem; }

/* ── stat tiles ────────────────────────────────────────────────────── */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1.6rem; }
.tile {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem;
}
.tile b { display: block; font-size: 1.7rem; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile span { font-size: .78rem; color: var(--text-3); }

/* ── table ─────────────────────────────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden;
}
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 700px; }
th, td { text-align: left; padding: .6rem .85rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--text-3); font-weight: 600; background: var(--bg-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--raised); }
td .id { font-family: var(--mono); font-size: .78rem; color: var(--text-3); }
td .title { color: var(--text); font-weight: 500; }

.swatch {
  width: 12px; height: 12px; border-radius: 3px;
  display: inline-block; vertical-align: -1px; margin-right: .45rem;
  border: 1px solid rgba(255,255,255,.15);
}

.name-cell { display: flex; align-items: center; gap: .7rem; }
.thumb {
  width: 46px; height: 30px; flex: none; border-radius: 5px;
  border: 1px solid var(--line-firm); background-size: cover; background-position: center;
  overflow: hidden;
}
.thumb.has-cover { border-color: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.name-meta { min-width: 0; }

.pill {
  display: inline-flex; align-items: center; gap: .4rem;
  font-size: .76rem; padding: .16rem .5rem; border-radius: 20px;
  border: 1px solid var(--line-firm); color: var(--text-2);
  white-space: nowrap;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: block; }
.pill.ready      { color: var(--good); border-color: #1E4429; }
.pill.needsSetup { color: var(--warn); border-color: #4A3A15; }
.pill.comingSoon { color: var(--text-3); }

.tag {
  font-size: .74rem; padding: .14rem .45rem; border-radius: 5px;
  background: var(--raised); color: var(--text-2); border: 1px solid var(--line);
  white-space: nowrap;
}

.row-actions { display: flex; gap: .4rem; justify-content: flex-end; }
.row-actions .btn { padding: .3rem .6rem; font-size: .82rem; }

.empty { padding: 2.2rem; text-align: center; color: var(--text-3); }

/* ── modal ─────────────────────────────────────────────────────────── */

.backdrop {
  position: fixed; inset: 0; background: rgba(4,7,11,.72);
  display: grid; place-items: center; padding: 1.5rem; z-index: 20;
}
.modal {
  width: min(620px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line-firm);
  border-radius: 14px; padding: 1.5rem;
}
.modal h2 { margin-bottom: 1.1rem; font-size: 1.15rem; }

/* cover picker */
.cover-row { display: flex; gap: 1rem; align-items: flex-start; }
.cover-preview {
  width: 132px; height: 74px; flex: none;
  border-radius: 8px; border: 1px solid var(--line-firm);
  background: var(--bg-2) center/cover no-repeat;
  display: grid; place-items: center;
  color: var(--text-3); font-size: .72rem; overflow: hidden;
}
.cover-preview.empty::after { content: "no image"; }
.cover-actions { flex: 1; display: flex; flex-direction: column; gap: .3rem; }
.cover-actions .hint { margin: .1rem 0 0; }
.cover-advanced { margin-top: .7rem; }
.cover-advanced summary {
  cursor: pointer; font-size: .8rem; color: var(--text-3);
  user-select: none; width: fit-content;
}
.cover-advanced summary:hover { color: var(--text-2); }
.cover-advanced input { margin-top: .5rem; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 .9rem; }
.modal-foot { display: flex; gap: .6rem; justify-content: flex-end; margin-top: 1.2rem; }
.hint { font-size: .76rem; color: var(--text-3); margin: -.6rem 0 1rem; }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { border-right: none; border-bottom: 1px solid var(--line); }
  .grid2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
