/* Facegammon admin.
 *
 * A dashboard, not a set of pages that happen to share a header: a
 * fixed sidebar for where you are, a topbar for what you are looking
 * at, and one vocabulary of panels, tables, fields and badges that
 * every screen draws from.
 *
 * The palette is the game's - dark leather, brass, cream - because an
 * admin panel that looks like a different product makes the person
 * using it translate between two worlds all day. It is calmer than the
 * game, though: the game is decorated, this is read.
 */

:root {
  --gold: #d4af6a;
  --gold-soft: rgba(212, 175, 106, 0.35);
  --gold-faint: rgba(212, 175, 106, 0.14);

  --bg: #14100c;
  --bg-side: #1b1510;
  --bg-card: #211a13;
  --bg-raise: #2a2118;
  --bg-input: #171208;

  --line: rgba(212, 175, 106, 0.18);
  --line-strong: rgba(212, 175, 106, 0.38);

  --text: #f3ece0;
  --text-dim: #a99c86;
  --text-faint: #7d7263;

  --good: #6fc08a;
  --warn: #e0b464;
  --bad: #d98080;

  --side-w: 232px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', 'Segoe UI', Roboto, -apple-system, sans-serif;
  font-size: 14px;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------ shell */

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--side-w);
  flex: 0 0 var(--side-w);
  background: var(--bg-side);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(160deg, #e6c98a, #a8813c);
  color: #241a0c;
  font-weight: 800;
  font-family: Georgia, serif;
}
.brand-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  letter-spacing: 0.4px;
  color: var(--text);
}
.brand-text em {
  display: block;
  font-style: normal;
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--gold);
}

.side-nav { padding: 14px 10px; flex: 1; overflow-y: auto; }
.nav-group {
  margin: 16px 10px 6px;
  font-size: 10px;
  letter-spacing: 1.6px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.nav-group:first-child { margin-top: 4px; }

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.side-nav a:hover { background: var(--gold-faint); color: var(--text); text-decoration: none; }
.side-nav a.active {
  background: var(--gold-faint);
  color: var(--text);
  /* The rail, not a full border: it marks the row without boxing it. */
  box-shadow: inset 3px 0 0 var(--gold);
}
.side-nav .ico { width: 16px; text-align: center; color: var(--gold); font-size: 12px; }

.side-out { padding: 14px; border-top: 1px solid var(--line); }
.side-out button {
  width: 100%;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  padding: 9px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
}
.side-out button:hover { color: var(--text); border-color: var(--gold); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(212,175,106,0.05), transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(8px);
}
.topbar h1 {
  margin: 0;
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.crumbs p { margin: 3px 0 0; color: var(--text-dim); font-size: 12.5px; }
.crumbs { flex: 1; min-width: 0; }
.topbar-action { flex: 0 0 auto; }

.burger { display: none; font-size: 20px; cursor: pointer; color: var(--gold); }
.nav-toggle { display: none; }
.scrim { display: none; }

main { padding: 24px 28px 56px; }

/* ------------------------------------------------------------- KPIs */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.kpi::after {
  /* A brass edge along the top, the one flourish these carry. */
  content: '';
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold-soft), transparent);
}
.kpi .label {
  font-size: 10.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.kpi .value {
  font-family: Georgia, serif;
  font-size: 27px;
  margin-top: 6px;
  color: var(--text);
  /* Tabular figures: a column of numbers that jiggles as it updates
     reads as unreliable even when it is right. */
  font-variant-numeric: tabular-nums;
}
.kpi .foot { margin-top: 4px; font-size: 12px; color: var(--text-dim); }
.kpi .foot.good { color: var(--good); }
.kpi .foot.bad { color: var(--bad); }

/* ----------------------------------------------------------- panels */

.panel, .card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 20px;
}
.panel h2, .card h2 {
  margin: 0 0 4px;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.panel > p.muted:first-of-type { margin-top: 0; }

.muted { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.count { color: var(--text-dim); font-size: 12.5px; margin: 0 0 12px; }

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

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--bg-card);
  margin-bottom: 20px;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  position: sticky;
  top: 0;
  background: var(--bg-raise);
  text-align: left;
  padding: 11px 14px;
  font-size: 10.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}
tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(212, 175, 106, 0.08);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(212, 175, 106, 0.05); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.thumb-board { width: 84px; border-radius: 6px; display: block; }
.thumb { width: 40px; border-radius: 6px; display: block; }

/* ----------------------------------------------------------- badges */

.status, .badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.4px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.status.active, .badge.good {
  color: var(--good);
  border-color: rgba(111, 192, 138, 0.4);
  background: rgba(111, 192, 138, 0.08);
}
.status.inactive, .badge.bad {
  color: var(--bad);
  border-color: rgba(217, 128, 128, 0.4);
  background: rgba(217, 128, 128, 0.08);
}
.badge.warn {
  color: var(--warn);
  border-color: rgba(224, 180, 100, 0.4);
  background: rgba(224, 180, 100, 0.08);
}

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

label { display: block; margin-bottom: 14px; font-size: 12.5px; color: var(--text-dim); }
label > span.muted { display: block; margin-top: 5px; }

input[type=text], input[type=number], input[type=url], input[type=email],
input[type=password], input[type=date], input[type=datetime-local],
input[type=color], select, textarea {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-faint);
}
input[type=file] { margin-top: 6px; color: var(--text-dim); font-size: 12.5px; }
input[type=checkbox] { accent-color: var(--gold); }

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 0 18px;
  align-items: start;
}
.grid-form button { grid-column: 1 / -1; justify-self: start; }

button, .btn {
  background: linear-gradient(180deg, #e0c184, #b38c45);
  color: #201607;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:active { transform: translateY(1px); }
button.danger, .btn.danger {
  background: transparent;
  border: 1px solid rgba(217, 128, 128, 0.5);
  color: var(--bad);
}
button.ghost {
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  font-weight: 500;
}
button.ghost:hover { color: var(--text); border-color: var(--gold); }
.link-btn {
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 13px; padding: 0;
}
.link-btn:hover { color: var(--gold); }

.row, .row-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ------------------------------------------------------------ flash */

.flash, .notice, .error {
  padding: 11px 15px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-size: 13px;
  border: 1px solid;
}
.flash.success, .notice {
  background: rgba(111, 192, 138, 0.09);
  border-color: rgba(111, 192, 138, 0.35);
  color: var(--good);
}
.flash.error, .error {
  background: rgba(217, 128, 128, 0.09);
  border-color: rgba(217, 128, 128, 0.35);
  color: var(--bad);
}

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

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 34px;
  width: 340px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 20px;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 500;
  text-align: center;
}
.login-card h1 span { color: var(--gold); margin-left: 6px; font-size: 0.62em; }
.login-card button { width: 100%; margin-top: 6px; }

/* ------------------------------------------------------- small print */

.tabs { display: none; }  /* superseded by the sidebar */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 40;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .nav-toggle:checked ~ .sidebar { transform: none; box-shadow: var(--shadow); }
  .nav-toggle:checked ~ .scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(0, 0, 0, 0.55);
  }
  .burger { display: block; }
  main { padding: 18px 16px 48px; }
  .topbar { padding: 14px 16px; }
}

/* ---------------------------------------------------- row actions */

/* Controls that live inside a table cell. Without these they inherit
   the full-width field styling meant for forms on a panel, and every
   row grows to four stacked buttons and a text box the width of the
   column - which is what the first cut of this dashboard did. */
td.actions { white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inline-form { display: inline-flex; gap: 5px; align-items: center; margin: 0; }
.inline-form input[type=number],
.inline-form input[type=text] {
  width: 74px;
  margin-top: 0;
  padding: 6px 8px;
  font-size: 12.5px;
}
.actions button, .inline-form button {
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
}
.actions .badge { margin-left: 4px; }

/* Six figures across on a wide screen, and never one stranded alone on
   a row of its own. */
.kpis { grid-template-columns: repeat(auto-fit, minmax(166px, 1fr)); }

/* -------------------------------------------------------------- help */

/* Tips live behind this, not under every heading. Read once, then in
   the way - and out of the way, they can be longer and more useful
   than a line anybody would tolerate permanently on the page. */
.panel-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 12px;
}
.panel-head h2 { margin: 0; }

.help-btn {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line-strong);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  flex: 0 0 auto;
}
.help-btn:hover { background: var(--gold-faint); filter: none; }

.help-dialog {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.help-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

.help-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.help-title {
  margin: 0;
  flex: 1;
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 500;
}
.help-lang { display: flex; gap: 4px; }
.help-lang button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 500;
}
.help-lang button.on {
  background: var(--gold-faint);
  border-color: var(--gold);
  color: var(--text);
}

.help-body { padding: 16px 20px; }
.help-body p {
  margin: 0 0 11px;
  font-size: 13.5px;
  line-height: 1.62;
  color: var(--text-dim);
}
.help-body p:last-child { margin-bottom: 0; }
/* Persian needs the extra leading, and Tahoma is the face every Windows
   and Android has that renders it properly. */
.help-body.fa p {
  font-family: Tahoma, 'Iranian Sans', 'Segoe UI', sans-serif;
  font-size: 13px;
  line-height: 1.95;
}

.help-foot {
  padding: 12px 20px 16px;
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------------ subtabs */

/* Tabs within a page, under the topbar - not to be confused with the
   sidebar, which says which page you are on. */
.subtabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.subtabs a {
  padding: 8px 14px;
  color: var(--text-dim);
  font-size: 13px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.subtabs a:hover { color: var(--text); text-decoration: none; }
.subtabs a.active { color: var(--text); border-bottom-color: var(--gold); }

/* ------------------------------------------------------- piece thumbs */

/* Checkers are drawn as circles on the board, so they are drawn as
   circles here. Sized, because the source art is around a thousand
   pixels square: unclassed, one of these filled the table cell and
   pushed the row off the screen. */
.thumb-piece, .swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
}
/* The swatch stands in for artwork that ships inside the app and so
   cannot be fetched from here - it is a colour, not a picture, and the
   ring is what stops a dark piece vanishing into the row. */
.swatch {
  border: 1px solid var(--line-strong);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.5);
}
.pieces-cell { display: flex; gap: 8px; align-items: center; }


/* ------------------------------------------------- platform badges */

/* One badge per platform, in tones this panel already uses: a column
   of them is meant to be read at a glance, not decoded. */
.badge.platform {
  color: var(--text-faint);
  border-color: var(--line);
  background: rgba(212, 175, 106, 0.05);
}
.badge.platform.ios {
  color: var(--text-dim);
  border-color: rgba(169, 156, 134, 0.4);
  background: rgba(169, 156, 134, 0.08);
}
.badge.platform.android {
  color: var(--good);
  border-color: rgba(111, 192, 138, 0.4);
  background: rgba(111, 192, 138, 0.08);
}
.badge.platform.web {
  color: var(--warn);
  border-color: rgba(224, 180, 100, 0.4);
  background: rgba(224, 180, 100, 0.08);
}

/* The tilde after a badge: deduced from a device or a purchase, not
   recorded at sign-up. */
.hint { color: var(--text-faint); cursor: help; margin-left: 4px; font-size: 12px; }

/* The breakdown is a short list, not one big number, so it does not
   take the type size the other tiles do. */
.value.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 13px;
  line-height: 1.5;
  margin: 2px 0 4px;
}
