/* MUSEA analytics dashboard — deliberately self-contained.
   It does not share style.css: this is an internal tool on its own subdomain,
   and coupling it to the public site's stylesheet would mean a design tweak on
   the website could silently break the dashboard. */

:root {
  --bg:      #0b0805;
  --surface: #14100b;
  --raised:  #1c1710;
  --line:    #2b2318;
  --text:    #f2e9d8;
  --muted:   #b3a288;
  --faint:   #8a7a62;
  --gold:    #e0a44a;
  --gold-hi: #f0c070;
  --green:   #25d366;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  padding-bottom: 60px;
}

/* ------------------------------------------------------------------ login */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.login {
  width: 100%; max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 32px 28px;
  display: flex; flex-direction: column; gap: 14px;
}
.login h1 { text-align: center; margin-bottom: 6px; }
.login label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login input {
  background: var(--raised); border: 1px solid var(--line); border-radius: 9px;
  padding: 11px 13px; color: var(--text); font: inherit; outline: none;
}
.login input:focus { border-color: var(--gold); }
.login button {
  margin-top: 6px; padding: 12px; border: none; border-radius: 9px; cursor: pointer;
  font: inherit; font-weight: 700; color: #241a08;
  background: linear-gradient(135deg, var(--gold-hi), var(--gold));
}
.login button:hover { filter: brightness(1.06); }
.login .err {
  background: rgba(200, 60, 40, .14); border: 1px solid rgba(200, 60, 40, .4);
  color: #ffb4a5; padding: 9px 12px; border-radius: 9px; font-size: 13.5px;
}
.login .hint { color: var(--faint); font-size: 12.5px; text-align: center; }

/* -------------------------------------------------------------------- top */
h1 { font-family: "Playfair Display", Georgia, serif; font-size: 22px; letter-spacing: .08em; }
h1 span { color: var(--gold); font-style: italic; margin-inline-start: 7px; font-size: 17px; }

.top {
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
  background: var(--surface); position: sticky; top: 0; z-index: 10;
}
.ranges { display: flex; gap: 6px; margin-inline-start: auto; flex-wrap: wrap; }
.ranges a {
  padding: 6px 13px; border-radius: 999px; font-size: 13px; text-decoration: none;
  color: var(--muted); border: 1px solid var(--line);
}
.ranges a:hover { color: var(--text); }
.ranges a.on { background: var(--gold); color: #241a08; border-color: var(--gold); font-weight: 600; }
.who { font-size: 12.5px; color: var(--faint); }
.who a { color: var(--gold); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 18px; }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px 20px; display: flex; flex-direction: column; gap: 3px;
}
.card .n { font-size: 30px; font-weight: 700; color: var(--gold-hi); line-height: 1.1; }
.card .l { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }

/* ----------------------------------------------------------------- panels */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; }
.panel h2 { font-size: 15px; margin-bottom: 4px; }
.panel .sub { font-size: 12.5px; color: var(--faint); margin-bottom: 12px; }
.panel h2 + table, .panel h2 + .feed, .panel h2 + .chart { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; }
.empty { color: var(--faint); font-size: 13.5px; padding: 10px 0; }

/* ----------------------------------------------------------------- tables */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: start; font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--faint); font-weight: 600; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
/* Horizontal padding matters more than it looks: with `padding: 9px 0` the
   numeric columns butt straight up against the next cell and render as
   "16Chrome · Windows". First and last cells stay flush with the panel edge. */
td { padding: 9px 14px 9px 0; border-bottom: 1px solid rgba(43, 35, 24, .5); }
td:last-child, th:last-child { padding-right: 0; }
th { padding-right: 14px; }
th:last-child { padding-right: 0; }
tr:last-child td { border-bottom: none; }
.num { text-align: end; font-variant-numeric: tabular-nums; }
.muted { color: var(--faint); }
/* Long URLs must not force the table wide — they wrap instead. */
.path { color: var(--muted); word-break: break-all; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-inline-end: 8px; background: var(--gold); }
.dot--whatsapp  { background: var(--green); }
.dot--facebook  { background: #1877f2; }
.dot--instagram { background: #e1306c; }
.dot--youtube   { background: #ff0000; }
.dot--tiktok    { background: #69c9d0; }

.tag {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  background: var(--raised); color: var(--muted); border: 1px solid var(--line);
}
.tag--admin      { color: var(--gold-hi); border-color: rgba(224, 164, 74, .45); }
.tag--instructor { color: #9fd6ff; border-color: rgba(120, 180, 255, .35); }
.tag--student    { color: #a8e6a1; border-color: rgba(120, 210, 120, .35); }

/* ------------------------------------------------------------------ chart */
.chart { display: flex; align-items: flex-end; gap: 5px; height: 150px; overflow-x: auto; padding-top: 6px; }
.bar { flex: 1 1 0; min-width: 16px; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar__fill {
  width: 100%; margin-top: auto; border-radius: 5px 5px 0 0; min-height: 2px;
  background: linear-gradient(180deg, var(--gold-hi), var(--gold));
}
.bar:hover .bar__fill { filter: brightness(1.15); }
.bar__lbl { font-size: 10px; color: var(--faint); margin-top: 5px; white-space: nowrap; }

/* ------------------------------------------------------------------- feed */
.feed { display: flex; flex-direction: column; gap: 1px; max-height: 340px; overflow-y: auto; }
.feed__row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid rgba(43, 35, 24, .5); font-size: 13px;
}
.feed__t { color: var(--faint); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed__n { color: var(--gold-hi); font-weight: 600; white-space: nowrap; }
.feed__p { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }

@media (max-width: 640px) {
  .top { padding: 12px 16px; }
  main { padding: 16px; }
  .ranges { width: 100%; margin-inline-start: 0; }
}

/* =========================================================================
   Traffic monitor — IP list, per-IP drill-down, live feed
   ========================================================================= */

.tabs { display: flex; gap: 4px; }
.tabs a {
  padding: 6px 14px; border-radius: 9px; font-size: 13.5px; text-decoration: none;
  color: var(--muted);
}
.tabs a:hover { color: var(--text); background: var(--raised); }
.tabs a.on { background: var(--raised); color: var(--gold-hi); font-weight: 600; }

.filters {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 18px;
}
.filters label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.filters select {
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 13px; padding: 6px 9px;
}
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.clear { color: var(--gold); font-size: 13px; margin-inline-start: auto; }

.panel.warn { border-color: rgba(224, 164, 74, .45); background: rgba(224, 164, 74, .07); }
code {
  background: var(--raised); border: 1px solid var(--line); border-radius: 5px;
  padding: 1px 6px; font-size: 12.5px;
}

/* Tabular data reads far better in a monospace face — IPs especially, where
   aligned digits make an odd address jump out. */
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.flag { font-size: 15px; }
td a { color: var(--gold); text-decoration: none; }
td a:hover { text-decoration: underline; }
.ua {
  color: var(--faint); font-size: 12px; word-break: break-all;
  background: var(--raised); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 11px; margin-bottom: 12px;
}

/* Bots stay visible but recede — they are usually noise, not the answer. */
tr.isbot { opacity: .5; }

.badge {
  display: inline-block; min-width: 34px; text-align: center;
  padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.st2 { background: rgba(80, 190, 100, .16); color: #8fe098; }
.st3 { background: rgba(90, 160, 240, .16); color: #9fc8ff; }
.st4 { background: rgba(230, 160, 60, .18); color: #ffd08a; }
.st5 { background: rgba(220, 70, 60, .20); color: #ff9b90; }

/* ------------------------------------------------------------------- live */
.livehead { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.livectl { display: flex; align-items: center; gap: 10px; }
.livectl button {
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); font: inherit; font-size: 12.5px; padding: 6px 13px; cursor: pointer;
}
.livectl button:hover { border-color: var(--gold); }

.pulse {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  background: #3c6b42; margin-inline-end: 8px; vertical-align: middle;
  transition: background .25s, box-shadow .25s;
}
.pulse.hit { background: #43e05a; box-shadow: 0 0 0 4px rgba(67, 224, 90, .22); }

/* The feed scrolls inside its own box so the page itself never grows
   unbounded while it is running. */
.livewrap { max-height: 62vh; overflow: auto; margin-top: 12px; }
.live thead th { position: sticky; top: 0; background: var(--surface); z-index: 1; }
.live td { padding: 6px 14px 6px 0; font-size: 12.5px; }
.live td:last-child { padding-right: 0; }

@media (max-width: 760px) {
  .filters { gap: 10px; }
  .livewrap { max-height: 50vh; }
  /* Wide tables must scroll inside their panel, not push the page sideways. */
  .panel { overflow-x: auto; }
}
