/* Hoard panel.
 *
 * Dark only, on purpose: this is the same surface as the desktop app and the
 * metrics dashboard, and a self-hoster who opens both in one sitting should not
 * get two different products. The accent (emerald) appears in four places and
 * nowhere else — the mark, the active tab, primary buttons, and anything that
 * means "live". If a fifth use shows up, it is one of the other four wearing a
 * disguise.
 *
 * There are no inline styles anywhere: the page is served under a CSP without
 * 'unsafe-inline' (see routes/panel.rs). The two things that must be computed
 * at runtime — meter fill and strip height — go through custom properties set
 * with CSSOM, which CSP does not cover.
 */

:root {
  --bg: #0a0d0b;
  --surface: #10150f;
  --line: #1c2621;
  --line-soft: #151d18;
  --text: #e4ece6;
  --muted: #86998e;
  --dim: #5a6b62;
  --accent: #34d399;
  --accent-deep: #10b981;
  --accent-ink: #04120c;
  --warn: #e0b341;
  --danger: #d9615a;

  --gap: 20px;
  --radius: 6px;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

body { overflow-x: hidden; }

.sprite { position: absolute; width: 0; height: 0; }

h1, h2 { font-weight: 600; letter-spacing: -0.01em; }

a { color: var(--accent); }

[hidden] { display: none !important; }

/* --- the mark ----------------------------------------------------------- */

.mark { width: 20px; height: 20px; fill: var(--accent); flex: none; }
.mark-lg { width: 34px; height: 34px; }

/* --- login -------------------------------------------------------------- */

.gate {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-inner { width: 100%; max-width: 310px; }

.gate-title {
  margin: 14px 0 2px;
  font-size: 19px;
}

.gate-sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 13px;
}

.gate-foot {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* --- forms -------------------------------------------------------------- */

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: var(--muted);
}
.field.inline { display: flex; align-items: center; gap: 10px; margin-bottom: 0; }
.field.inline > span { margin: 0; }
.field.inline input { width: 110px; }

input, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  font: inherit;
  padding: 8px 10px;
}

input:focus-visible, select:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent-deep);
  outline-offset: 2px;
}

button { font: inherit; cursor: pointer; border-radius: var(--radius); }

.primary {
  width: 100%;
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  padding: 9px 14px;
  font-weight: 600;
}
.primary:hover { background: var(--accent-deep); }

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 6px 12px;
}
.ghost:hover { color: var(--text); border-color: var(--dim); }

.danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 6px 12px;
}
.danger:hover { background: var(--danger); color: #140505; }

.link {
  background: none;
  border: 0;
  color: var(--muted);
  padding: 2px 0;
  font-size: 13px;
}
.link:hover { color: var(--accent); }

.locale {
  width: auto;
  padding: 4px 6px;
  font-size: 12px;
  color: var(--muted);
}

/* Password field with its show/hide button. The input keeps room on the right
   so a long password never runs under the eye. */
.pw { position: relative; display: block; }
.pw input { padding-right: 38px; }
.reveal {
  position: absolute;
  right: 1px;
  top: 1px;
  bottom: 1px;
  width: 34px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--dim);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.reveal:hover { color: var(--text); }
.reveal svg { width: 17px; height: 17px; }

.hint { margin: -6px 0 14px; color: var(--dim); font-size: 12px; }
.error { margin: 10px 0 0; color: var(--danger); font-size: 13px; }
.caption { margin: -4px 0 14px; color: var(--muted); font-size: 12.5px; }

/* --- chrome ------------------------------------------------------------- */

.top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; }
.wordmark { font-weight: 600; letter-spacing: -0.01em; }
.version { color: var(--dim); font-size: 12px; font-family: var(--mono); }

.who {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 1px 9px;
  font-size: 11px;
  color: var(--accent);
  text-transform: lowercase;
}

.tabs {
  display: flex;
  gap: 2px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 11px 12px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }

.sheet {
  max-width: 1060px;
  margin: 0 auto;
  padding: 26px 24px 60px;
}

.foot {
  max-width: 1060px;
  margin: 0 auto;
  padding: 0 24px 30px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--dim);
  font-size: 12px;
}

.block { margin-bottom: 38px; }
.block h2 {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

/* --- stats -------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--gap);
  margin-bottom: 38px;
}

.stat { min-width: 0; }
.stat-label {
  display: block;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.stat-value .unit { font-size: 14px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat-sub { display: block; margin-top: 2px; color: var(--dim); font-size: 12px; }

.meter {
  margin-top: 8px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.meter > i {
  display: block;
  height: 100%;
  width: var(--pct, 0%);
  background: var(--accent);
}
.meter.over > i { background: var(--warn); }

/* --- tables ------------------------------------------------------------- */

.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th {
  text-align: left;
  font-weight: 500;
  font-size: 11.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 10px 7px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid td {
  padding: 9px 10px 9px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
.grid tr:last-child td { border-bottom: 0; }
.grid td:last-child, .grid th:last-child { padding-right: 0; }
/* Every cell hugs its content and exactly one column per table is marked
   `grow`, which takes the slack. Without this the browser distributes the
   width evenly and a 1280px screen pulls "hace 18 horas" onto two lines while
   the version number floats in an empty third of the row. */
.grid td, .grid th { white-space: nowrap; }
.grid .grow { width: 100%; }
.grid .grow, .grid .wrap { white-space: normal; }
.grid .meter { width: 84px; margin-left: auto; }

/* A version in the trash: still listed, visibly not part of the history. */
.grid tr.gone td { color: var(--dim); }
.grid tr.gone .mono { text-decoration: line-through; text-decoration-color: var(--dim); }
/* The strike belongs to the version number, not to the word explaining it. */
.grid tr.gone .badge { text-decoration: none; }
.badge.muted { color: var(--dim); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.name { font-weight: 500; }
.sub { color: var(--dim); font-size: 12px; }
.mono { font-family: var(--mono); font-size: 12px; }

.scroll { overflow-x: auto; }

.empty {
  padding: 22px 0;
  color: var(--dim);
  font-size: 13px;
}

/* --- saves tree --------------------------------------------------------- */

.save { border-bottom: 1px solid var(--line-soft); }
.save > summary {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 11px 0;
  cursor: pointer;
  list-style: none;
}
.save > summary::-webkit-details-marker { display: none; }
.save > summary::before {
  content: "";
  width: 5px; height: 5px;
  flex: none;
  border-right: 1.5px solid var(--dim);
  border-bottom: 1.5px solid var(--dim);
  transform: rotate(-45deg);
  transition: transform .12s ease;
}
.save[open] > summary::before { transform: rotate(45deg); }
.save > summary:hover::before { border-color: var(--accent); }
.save-name { font-weight: 500; }
.save-meta { margin-left: auto; color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.save-body { padding: 2px 0 16px 15px; }

/* --- playtime strip ----------------------------------------------------- */

.strip {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 54px;
  margin: 12px 0 8px;
}
.strip > i {
  flex: 1;
  min-width: 2px;
  height: var(--h, 2px);
  min-height: 2px;
  background: var(--accent-deep);
  border-radius: 1px;
  opacity: .85;
}
.strip > i.zero { background: var(--line); opacity: 1; }
.strip > i:hover { opacity: 1; background: var(--accent); }

/* --- odds and ends ------------------------------------------------------ */

.dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dim);
  margin-right: 7px;
  vertical-align: middle;
}
.dot.on { background: var(--accent); }

.lvl {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  color: var(--dim);
}
.lvl.warn { color: var(--warn); }
.lvl.error { color: var(--danger); }

.filters {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filters select { width: auto; }
.filters input[type="search"] { width: 240px; }

.limits { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; }
.limits .primary { width: auto; }

.row-actions { display: flex; gap: 8px; justify-content: flex-end; }
.row-actions .link { color: var(--dim); }
.row-actions .link:hover { color: var(--accent); }
.row-actions .link.warn:hover { color: var(--danger); }

dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px;
  width: min(360px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(0, 0, 0, .6); }
dialog h2 { margin: 0 0 16px; font-size: 15px; text-transform: none; letter-spacing: 0; }
dialog menu { display: flex; gap: 10px; justify-content: flex-end; margin: 20px 0 0; padding: 0; }
dialog menu .primary { width: auto; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 9px 15px;
  font-size: 13px;
  max-width: min(440px, calc(100vw - 32px));
}
.toast.bad { border-left-color: var(--danger); }

@media (max-width: 620px) {
  .sheet { padding: 20px 16px 50px; }
  .top { padding: 12px 16px; }
  .who { width: 100%; margin-left: 0; }
  .stat-value { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  .save > summary::before { transition: none; }
}
