/* Panel styles. Deliberately hand-written and embedded: the panel is four
   CRUD pages, and a build step would cost more than it saves. */

:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #6b7280;
  --line: #e3e5e9;
  --accent: #2f6df6;
  --accent-ink: #ffffff;
  --ok: #12855b;
  --ok-bg: #e6f6ef;
  --bad: #c0392b;
  --bad-bg: #fdeceb;
  --warn: #a06a00;
  --warn-bg: #fdf3e0;
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --panel: #1c1f25;
    --ink: #e8eaee;
    --muted: #98a1b0;
    --line: #2c313a;
    --accent: #5b8bff;
    --ok: #4ade80;
    --ok-bg: #14301f;
    --bad: #f87171;
    --bad-bg: #3a1c1c;
    --warn: #fbbf24;
    --warn-bg: #3a2f13;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

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

.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { font-weight: 650; white-space: nowrap; }
.logo { margin-right: 4px; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 7px 12px; border-radius: 8px; color: var(--ink);
  text-decoration: none; font-weight: 500;
}
.topbar nav a:hover { background: var(--bg); }
.topbar nav a.active { background: var(--accent); color: var(--accent-ink); }
.logout { margin: 0; }

main { max-width: 1500px; margin: 0 auto; padding: 20px; }
main.bare { display: grid; place-items: center; min-height: 100vh; }

.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-head h1 { font-size: 22px; margin: 0; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
  overflow-x: auto;
}
.card h2 { font-size: 15px; margin: 0 0 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

.note {
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 10px 14px; margin: 0 0 18px; color: var(--muted);
}

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

.flash {
  max-width: 1500px; margin: 16px auto -4px; padding: 11px 16px;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
}
.flash.ok   { background: var(--ok-bg);   border-color: var(--ok);   color: var(--ok); }
.flash.bad  { background: var(--bad-bg);  border-color: var(--bad);  color: var(--bad); }
.flash.warn { background: var(--warn-bg); border-color: var(--warn); color: var(--warn); }

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

.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 18px; min-width: 96px;
}
.stat b { display: block; font-size: 20px; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12px; }
.stat.ok b { color: var(--ok); }
.stat.bad b { color: var(--bad); }
.stat.warn b { color: var(--warn); }
.stat.muted b { color: var(--muted); }

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

label { display: block; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink); }
label.check input { width: auto; margin: 0; }

input[type=text], input[type=password], input[type=search], input[type=number],
input[type=date], select, textarea {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink);
  font: inherit;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
.grid-form .wide { grid-column: 1 / -1; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 4px; }

.filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 18px;
}
.filters.wrap .f { margin: 0; min-width: 150px; }
.filters.wrap .f.grow { flex: 1; min-width: 260px; }
.filters > select, .filters > input { width: auto; min-width: 200px; margin: 0; }
.filters .actions { margin: 0; }

/* ------------------------------------------------------------------ buttons */

.btn {
  display: inline-block; padding: 8px 14px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: transparent; }
.btn.danger:hover { border-color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.block { width: 100%; margin-top: 6px; }
.inline { display: inline; margin: 0; }

.linkish {
  background: none; border: 0; padding: 0; margin-left: 6px;
  color: var(--accent); font: inherit; font-size: 11px; cursor: pointer;
}

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

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td {
  padding: 10px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--line);
}
table.data th {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 600; white-space: nowrap;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--bg); }
table.data.compact td { padding: 6px 10px; }
table.data td.empty { text-align: center; color: var(--muted); padding: 32px; }
table.data tr.editor:hover { background: transparent; }
table.data tr.editor > td { background: var(--bg); }

table.kv { width: 100%; border-collapse: collapse; }
table.kv th {
  text-align: left; font-weight: 500; color: var(--muted);
  padding: 7px 16px 7px 0; width: 220px; vertical-align: top;
}
table.kv td { padding: 7px 0; border-bottom: 1px solid var(--line); }
table.kv tr:last-child td { border-bottom: 0; }

.right { text-align: right; }
.nowrap { white-space: nowrap; }
.breakable { word-break: break-all; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 11.5px; }
.err { color: var(--bad); }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ tags */

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}
.tag.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: transparent; }
.tag.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: transparent; }
.tag.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tag.src-facebook { background: #e7efff; color: #1d4ed8; border-color: transparent; }
.tag.src-tiktok   { background: #ffe7ef; color: #be123c; border-color: transparent; }
.tag.src-snapchat { background: #fff6cc; color: #8a6d00; border-color: transparent; }

@media (prefers-color-scheme: dark) {
  .tag.src-facebook { background: #1b2748; color: #93b4ff; }
  .tag.src-tiktok   { background: #3a1a26; color: #ff9ab5; }
  .tag.src-snapchat { background: #3a3413; color: #f5d76b; }
}

/* ------------------------------------------------------------------ misc */

pre.code {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; overflow-x: auto; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; white-space: pre-wrap; word-break: break-word;
}
pre.code.err { color: var(--bad); }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; padding: 8px 0 24px; }

.login { width: min(380px, 92vw); }
.login h1 { font-size: 20px; margin: 0 0 4px; }
.login p { margin: 0 0 18px; }

code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--bg); padding: 1px 5px; border-radius: 4px; }
