/* siphon admin UI. Dark theme shared with the other Neofit apps. */
:root {
  --bg: #121212;
  --surface: #1c1c1c;
  --surface-2: #242424;
  --border: #333;
  --text: #ececec;
  --muted: #a6a6a6;
  --accent: #f39200;
  --accent-text: #121212;
  --ok: #4cc38a;
  --info: #6cb6ff;
  --warn: #f5b942;
  --bad: #ff6b6b;
  --radius: 10px;
  --gutter: 16px;
  --font: Montserrat, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 600; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; margin-top: 1.6em; }
h3 { font-size: 1rem; margin-top: 1.2em; }
p { margin: 0 0 .8em; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: #ffb347; }
code, .mono { font-family: var(--mono); font-size: .9em; }
.key { word-break: break-all; overflow-wrap: anywhere; }
strong { font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--accent); color: var(--accent-text); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; top: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 var(--gutter); }
main.wrap { padding-top: 20px; padding-bottom: 32px; }

/* header */
.top { background: var(--surface); border-bottom: 1px solid var(--border); }
.top-inner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; min-height: 56px; padding-top: 8px; padding-bottom: 8px; }
/* Logo: the brand kit's mark and lockup (brand/), inline SVG in this theme's
   --text and --accent. Motion: on hover the accent "liquid" runs from the source
   node through the S into the drop, which swells; the first page of a visit and
   the sign-in page draw the mark in. All motion is off for prefers-reduced-motion. */
.brand { display: inline-flex; align-items: center; text-decoration: none; border-radius: 8px; padding: 2px 4px; margin-left: -4px; }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sx { display: block; overflow: visible; }
.sx-lockup { height: 34px; width: auto; }
.sx-ring, .sx-flow, .sx-pulse { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.sx-ring { stroke: var(--text); stroke-width: 4.4; stroke-dasharray: 100; stroke-dashoffset: 0; }
.sx-flow { stroke: var(--text); stroke-width: 4.1; stroke-dasharray: 100; stroke-dashoffset: 0; }
.sx-pulse { stroke: var(--accent); stroke-width: 4.1; stroke-dasharray: 16 120; stroke-dashoffset: 16; opacity: 0; }
.sx-src, .sx-word { fill: var(--text); }
.sx-src, .sx-drop { transform-box: fill-box; transform-origin: center; }
.sx-drop { fill: var(--accent); }
.sx-ring { transition: stroke-dasharray .45s cubic-bezier(.2,.8,.2,1); }
.sx-word { transition: fill .25s; }

/* hover / keyboard focus: siphon once per cycle while pointed at */
.brand:hover .sx-pulse, .brand:focus-visible .sx-pulse { animation: sx-run 1.5s cubic-bezier(.45,.05,.55,.95) infinite; }
.brand:hover .sx-drop, .brand:focus-visible .sx-drop { animation: sx-swell 1.5s ease-out infinite; }
.brand:hover .sx-src, .brand:focus-visible .sx-src { animation: sx-push 1.5s ease-out infinite; }
/* the ring opens a gap that turns, like a swirl in the vessel */
.brand:hover .sx-ring, .brand:focus-visible .sx-ring { stroke-dasharray: 80 20; animation: sx-swirl 3s linear infinite; }
.brand:hover .sx-word, .brand:focus-visible .sx-word { fill: #fff; }

@keyframes sx-run {
  0%   { stroke-dashoffset: 16;   opacity: 1; }
  62%  { stroke-dashoffset: -100; opacity: 1; }
  63%, 100% { stroke-dashoffset: -100; opacity: 0; }
}
@keyframes sx-swell {
  0%, 58% { transform: scale(1); }
  70%     { transform: scale(1.75); }
  84%     { transform: scale(.85); }
  100%    { transform: scale(1); }
}
@keyframes sx-push {
  0%   { transform: scale(1); }
  10%  { transform: scale(1.35); fill: var(--accent); }
  30%, 100% { transform: scale(1); }
}

/* draw-in: the ring, then the S, then the drop falls into place */
.sx-intro .sx-ring  { animation: sx-draw .9s cubic-bezier(.6,0,.2,1) both; }
.sx-intro .sx-flow  { animation: sx-draw .8s .45s cubic-bezier(.6,0,.2,1) both; }
.sx-intro .sx-src   { animation: sx-pop .35s .3s cubic-bezier(.3,1.6,.5,1) both; }
.sx-intro .sx-drop  { animation: sx-fall .55s 1.15s cubic-bezier(.3,1.5,.5,1) both; }
.sx-intro .sx-word  { animation: sx-rise .6s .7s cubic-bezier(.2,.8,.2,1) both; }
@keyframes sx-swirl { from { stroke-dashoffset: 0; } to { stroke-dashoffset: -100; } }
@keyframes sx-draw { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
@keyframes sx-pop  { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes sx-fall { 0% { transform: translateY(-14px) scale(.4); opacity: 0; } 100% { transform: none; opacity: 1; } }
@keyframes sx-rise { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* sign-in page: a larger mark that draws in, then siphons now and then */
.signin-mark { width: 72px; height: 72px; margin-bottom: 14px; }
.signin-mark .sx { width: 72px; height: 72px; }
.signin-mark .sx-pulse { animation: sx-run 1.5s 1.9s cubic-bezier(.45,.05,.55,.95) infinite; }
.signin-mark .sx-drop  { animation: sx-fall .55s 1.15s cubic-bezier(.3,1.5,.5,1) both, sx-swell 1.5s 1.9s ease-out infinite; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.nav a { position: relative; color: var(--muted); text-decoration: none; padding: 6px 10px 8px; border-radius: 6px; transition: color .2s, background-color .2s; }
.nav a::after, .nav a::before { content: ""; position: absolute; pointer-events: none; background: var(--accent); }
/* the line: flows in from the left */
.nav a::after { left: 10px; right: 13px; bottom: 3px; height: 2px; border-radius: 2px; transform: scaleX(0); transform-origin: left center; transition: transform .38s cubic-bezier(.2,.8,.2,1); }
/* the drop at its outlet: arrives as the line does, with a little bounce */
.nav a::before { right: 8px; bottom: 1.5px; width: 5px; height: 5px; border-radius: 50%; transform: scale(0); transition: transform .25s cubic-bezier(.3,1.8,.5,1) .26s; }
.nav a:hover, .nav a:focus-visible { color: var(--text); background: var(--surface-2); }
.nav a:hover::after, .nav a:focus-visible::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }
.nav a:hover::before, .nav a:focus-visible::before, .nav a[aria-current="page"]::before { transform: scale(1); }
.nav a:not(:hover):not(:focus-visible)::before { transition-delay: 0s; }
.nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.signout { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.who { color: var(--muted); font-size: .85rem; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alertbar { background: #3a1010; color: #ffb4b4; text-align: center; padding: 8px var(--gutter); font-size: .9rem; border-bottom: 1px solid #6a1d1d; }
.devbar { background: #3a2a00; color: var(--warn); text-align: center; padding: 6px var(--gutter); font-size: .85rem; }
.foot { color: var(--muted); font-size: .8rem; padding-top: 12px; padding-bottom: 24px; border-top: 1px solid var(--border); }

/* layout pieces */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.page-head h1 { margin: 0; overflow-wrap: anywhere; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.section-head h2 { margin-top: 1.2em; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; margin: 16px 0; }
.card.narrow { max-width: 560px; margin: 40px auto; }
.card.callout { border-color: var(--warn); }
.card h2:first-child { margin-top: 0; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 20px; margin-bottom: 8px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.stack { display: flex; flex-direction: column; gap: 8px; max-width: 560px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 12px 0; }
.actions form { margin: 0; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 12px 0; }
.inline-form input:not([type=checkbox]) { flex: 1 1 220px; min-width: 0; }
.crumbs { color: var(--muted); font-size: .9rem; margin-bottom: 8px; overflow-wrap: anywhere; }
.detail { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: .85rem; margin: 2px 0 8px; }
.empty { color: var(--muted); font-style: italic; }
.eyebrow { color: var(--accent); text-transform: uppercase; font-size: .75rem; letter-spacing: .08em; margin: 0 0 4px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin: 8px 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; display: flex; flex-direction: column; }
.stat-n { font-size: 1.6rem; font-weight: 600; }
.stat-l { color: var(--muted); font-size: .85rem; }
.stat-warn .stat-n { color: var(--warn); }

/* facts */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; min-width: 0; }

/* controls */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid #4a4a4a; border-radius: 6px; padding: 7px 10px; max-width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
label { font-weight: 500; }
.check { display: grid; grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 10px; font-weight: 400; margin: 6px 0; }
.check input { width: 18px; height: 18px; margin: 3px 0 0; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 18px; height: 18px; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin: 0; }
legend { padding: 0 6px; color: var(--muted); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; color: var(--text); background: var(--surface-2);
  border: 1px solid #444; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  text-decoration: none; min-height: 38px; text-align: center;
}
.btn:hover { background: #2e2e2e; color: var(--text); }
.btn-primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn-primary:hover { background: #ffa41f; color: var(--accent-text); }
.btn-danger { color: var(--bad); border-color: #6b2b2b; }
.btn-danger:hover { background: #3a1a1a; color: #ff8a8a; }
.btn-ghost { background: transparent; }
.btn-sm { padding: 4px 10px; min-height: 32px; font-size: .88rem; }

/* pills and messages */
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; white-space: nowrap; }
.pill-ok { color: var(--ok); }
.pill-info { color: var(--info); }
.pill-warn { color: var(--warn); }
.pill-bad { color: var(--bad); }
.pill-muted { color: var(--muted); }
.flash { border-radius: 8px; padding: 10px 14px; margin: 12px 0; border: 1px solid; overflow-wrap: anywhere; }
.flash ul { margin: 4px 0 0; padding-left: 20px; }
.flash p:last-child { margin-bottom: 0; }
.flash-ok { background: #10291d; border-color: #1f5a3c; color: #bdf0d4; }
.flash-warn { background: #2d2310; border-color: #6a4e12; color: #ffe2a8; }
.flash-error { background: #2d1414; border-color: #6b2b2b; color: #ffc9c9; }

/* tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 8px 14px; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.search { display: flex; gap: 8px; margin-bottom: 12px; }
.search input { flex: 1; min-width: 0; }

/* lists */
.pick-list, .feed, .keys, .excluded { list-style: none; padding: 0; margin: 0; }
.pick-list li { padding: 10px 0; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.pick-name { font-weight: 500; }
.feed li { padding: 6px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.excluded li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.excluded li .mono { overflow-wrap: anywhere; min-width: 0; }
.excluded form { margin: 0; }
.keys li { padding: 4px 0; }
.reasons { margin: 0; padding-left: 18px; }
.samples { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.sample { font-family: var(--mono); font-size: .78rem; background: var(--surface-2); border-radius: 4px; padding: 0 6px; color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-row { display: flex; gap: 8px; margin: 4px 0 8px; }
.copy-row .token { flex: 1; min-width: 0; }
.rename { margin-top: 4px; font-size: .85rem; }
.rename summary { color: var(--accent); cursor: pointer; width: max-content; }
.rename .inline-form { margin: 6px 0 0; }
.filters { display: grid; gap: 8px; }
.filter { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 2fr); gap: 8px; }
.sorts { display: flex; flex-wrap: wrap; gap: 8px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin: 12px 0; color: var(--muted); }
.grant { margin: 8px 0; }
.grant .btn { white-space: normal; }
.details { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }

/* tables */
table { border-collapse: collapse; width: 100%; }
.list th, .list td, .grid th, .grid td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.list th, .grid th { color: var(--muted); font-weight: 500; font-size: .85rem; }
.list td { overflow-wrap: anywhere; }
.list tbody tr:hover { background: #181818; }
.list input:not([type=checkbox]), .list select { width: 100%; }
.scroll-x { overflow-x: auto; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; }
.grid td, .grid th { white-space: nowrap; font-size: .85rem; }
.grid td { font-family: var(--mono); }

/* phones: tables become cards */
.list td[data-label="Kind"], .list td[data-label="Mode"] { white-space: nowrap; }

@media (max-width: 640px) {
  body { font-size: 15px; }
  h1 { font-size: 1.3rem; }
  h2 { font-size: 1.1rem; }
  .cols { grid-template-columns: 1fr; gap: 0; }
  .card { padding: 14px; }
  .card.narrow { margin: 16px 0; }
  /* header: logo + sign out on one row, the tabs on one scrolling row; no email */
  .top-inner { gap: 4px 12px; min-height: 0; padding-top: 10px; padding-bottom: 0; }
  .who { display: none; }
  .signout { margin-left: auto; }
  .nav { order: 3; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--gutter)); padding: 0 var(--gutter) 4px;
         -webkit-mask-image: linear-gradient(90deg, #000 85%, transparent); mask-image: linear-gradient(90deg, #000 85%, transparent); }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; flex: 0 0 auto; }
  .devbar { font-size: .75rem; padding: 4px var(--gutter); }
  .alertbar { font-size: .8rem; padding: 6px var(--gutter); }
  /* overview numbers: three small tiles a row */
  .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 8px 10px; }
  .stat-n { font-size: 1.25rem; }
  .stat-l { font-size: .75rem; }
  .facts { grid-template-columns: 1fr; gap: 0; }
  .facts dt { margin-top: 8px; }
  .filter { grid-template-columns: 1fr; }
  .inline-form select { flex: 1 1 40%; min-width: 0; }
  .filters { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 8px 10px; }
  .filters select { width: 100%; }
  .filters button { grid-column: 1 / -1; justify-self: start; }
  /* tables become cards: label on the left (absolute, so a cell may hold any
     mix of links, badges and notes), the title cell as the card's heading */
  .list thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .list, .list tbody, .list td { display: block; width: 100%; }
  .list tr { display: flex; flex-direction: column; width: 100%; }
  .list td.m-title { order: -1; } /* the card's heading comes first whatever its column */
  .list tr { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin: 0 0 14px; padding: 10px 14px; }
  .list tbody tr:hover { background: var(--surface); }
  .list td { position: relative; border: 0; padding: 5px 0 5px 7.25em; min-height: 1.9em; overflow-wrap: anywhere; }
  .list td::before { content: attr(data-label); position: absolute; left: 0; top: 7px; width: 6.75em; color: var(--muted); font-size: .8rem; line-height: 1.3;
                     white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .list td[data-label=""], .list td.m-title { padding-left: 0; }
  .list td[data-label=""]::before, .list td.m-title::before { display: none; }
  .list td.m-title { font-weight: 600; font-size: 1.02rem; padding: 2px 0 8px; margin-bottom: 4px; border-bottom: 1px solid var(--border); }
  .list td.m-title .sub { font-weight: 400; }
  .list td:empty, .m-hide { display: none !important; }
  .list td .pill { display: inline-block; }
}

/* the splash overlay: a big centred mark (see app.js, boot.js) */
.splash { display: none; }
html.splashing.in .splash, .splash.splash-live { display: flex; position: fixed; inset: 0; z-index: 100; align-items: center; justify-content: center; background: var(--bg); }
.splash.splash-live { background: transparent; }
/* the mark at the first splash's size (42vmin, at most 320px); the wordmark beside it, still within the screen */
.splash .sx { height: min(42vmin, 320px, 33vw); width: auto; aspect-ratio: 172 / 64; }
/* after sign-in: the wordmark joins the growing mark */
.sx-wordin .sx-word { animation: sx-rise .55s .25s cubic-bezier(.2,.8,.2,1) both; }
html.splashing.in .brand .sx { visibility: hidden; }
.sx-once .sx-pulse { animation: sx-run 1.5s cubic-bezier(.45,.05,.55,.95) 1; }
.sx-once .sx-drop  { animation: sx-swell 1.5s ease-out 1; }
.sx-once .sx-src   { animation: sx-push 1.5s ease-out 1; }
.sx-land .sx-drop  { animation: sx-swell .9s ease-out 1; }
/* sign-in: waiting for the popup */
.signin-actions .btn[aria-busy="true"] { opacity: .55; pointer-events: none; }
.signin-wait { margin-top: 12px; }

/* Pull to refresh (home-screen app only, app.js): a ring that fills as you pull. */
.ptr { position: fixed; top: 0; left: 50%; z-index: 60; width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border); box-shadow: 0 4px 14px rgba(0,0,0,.5);
  display: grid; place-items: center; opacity: 0; transform: translate(-50%,-48px); pointer-events: none; }
.ptr svg { width: 24px; height: 24px; }
.ptr circle { fill: none; stroke: var(--muted); stroke-width: 2.6; stroke-linecap: round;
  stroke-dasharray: 100; stroke-dashoffset: 100; }
.ptr-armed circle, .ptr-busy circle { stroke: var(--accent); }
.ptr-back { transition: transform .25s ease, opacity .25s ease; }
.ptr-busy svg { animation: ptr-spin .8s linear infinite; }
@keyframes ptr-spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .splash { display: none !important; }
  .sx *, .nav a, .nav a::after, .nav a::before { animation: none !important; transition: none !important; }
  .sx-pulse { opacity: 0 !important; }
}
