/* 1indexer website — same look as 1indexer-admin, styled after the PostHog app (us.posthog.com, Dec 2026):
   tokens read from its computed styles (--color-bg-*, --color-border-*,
   --color-text-*, LemonButton, LemonTable). We copy the look, not the brand.
   Font: Inter (OFL, embedded), the fallback in PostHog's own font stack.
   Token table: docs/DESIGN.md. */

@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/inter-latin-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/inter-latin-ext-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 100 900; font-display: swap;
  src: url(fonts/inter-vietnamese-wght-normal.woff2) format("woff2-variations");
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }

:root {
  --app: #e5e7df;            /* bg-surface-tertiary: frame and sidebar */
  --panel: #f3f4f0;          /* bg-primary: the main content panel */
  --surface: #ffffff;        /* bg-surface-primary: cards, tables, inputs */
  --surface-2: #f7f7f5;      /* bg-fill-secondary */
  --table-head: #ffffff;
  --border: #dbded4;         /* border-primary */
  --border-2: #abad9f;       /* border-secondary */
  --btn-border: #cccccc;
  --btn-edge: #e1dddd;
  --text: #0d0d0d;           /* text-primary */
  --text-2: #404040;         /* text-secondary */
  --text-3: #666666;         /* text-tertiary */
  --hover: rgba(0, 0, 0, .05);
  --hover-2: rgba(0, 0, 0, .075);
  --accent: #f54e00;         /* color-accent hsl(19 100% 48%) */
  --accent-soft: rgba(245, 78, 0, .1);
  --amber: #eb9d2a;
  --amber-edge: #b17816;
  --success: #007a35; --success-bg: #dcfce7;
  --warning: #8a5300; --warning-bg: #fef9c2;
  --danger: #c40013;  --danger-bg: #ffe2e2;
  --chart: #1d4aff; --chart-hover: #0f2fb8;
  --i-blue: #1d4aff; --i-teal: #0d9488; --i-orange: #f54e00; --i-amber: #e09b00;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --app: #131316; --panel: #131316; --surface: #232429; --surface-2: #17171c; --table-head: #232429;
    --border: #2f3037; --border-2: #5e616e; --btn-border: #45474f; --btn-edge: #2a2b31;
    --text: #e6e6e6; --text-2: #a6a6a6; --text-3: #999999;
    --hover: rgba(255, 255, 255, .06); --hover-2: rgba(255, 255, 255, .1);
    --success: #4ade80; --success-bg: rgba(5, 223, 114, .14);
    --warning: #fbbf24; --warning-bg: rgba(247, 201, 0, .14);
    --danger: #ff8a8a; --danger-bg: rgba(251, 44, 54, .16);
    --chart: #5b7bff; --chart-hover: #9bb0ff; --i-blue: #6f8cff; --i-teal: #2dd4bf;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --app: #131316; --panel: #131316; --surface: #232429; --surface-2: #17171c; --table-head: #232429;
  --border: #2f3037; --border-2: #5e616e; --btn-border: #45474f; --btn-edge: #2a2b31;
  --text: #e6e6e6; --text-2: #a6a6a6; --text-3: #999999;
  --hover: rgba(255, 255, 255, .06); --hover-2: rgba(255, 255, 255, .1);
  --success: #4ade80; --success-bg: rgba(5, 223, 114, .14);
  --warning: #fbbf24; --warning-bg: rgba(247, 201, 0, .14);
  --danger: #ff8a8a; --danger-bg: rgba(251, 44, 54, .16);
  --chart: #5b7bff; --chart-hover: #9bb0ff; --i-blue: #6f8cff; --i-teal: #2dd4bf;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--app); color: var(--text);
  font: 14px/1.57 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 4px; }
h1, h2 { margin: 0; }
h1 { font-size: 18px; font-weight: 600; line-height: 25px; }
h2 { font-size: 14px; font-weight: 600; }
.muted { color: var(--text-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; }
.small { font-size: 12px; }
.break { overflow-wrap: anywhere; }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Shell: tertiary frame, sidebar on it, content in a bordered panel */
.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); height: 100vh; }
.sidebar { display: flex; flex-direction: column; gap: 10px; padding: 8px 6px; min-height: 0; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 6px; color: var(--text); font-weight: 500; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.search { position: relative; }
.search .icon { position: absolute; left: 8px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); }
.search input { width: 100%; height: 32px; padding: 4px 8px 4px 28px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.nav-label { padding: 6px 8px 2px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.sidebar nav { display: flex; flex-direction: column; gap: 1px; }
.sidebar nav a { display: flex; align-items: center; gap: 8px; height: 30px; padding: 2px 6px; border-radius: var(--radius); color: var(--text); }
.sidebar nav a:hover { background: var(--hover); text-decoration: none; }
.sidebar nav a[aria-current="page"] { background: var(--hover); font-weight: 500; }
.i-blue { color: var(--i-blue); } .i-teal { color: var(--i-teal); } .i-orange { color: var(--i-orange); } .i-amber { color: var(--i-amber); }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 6px 6px 2px; border-top: 1px solid var(--border); }
.theme-toggle { display: grid; place-items: center; width: 28px; height: 28px; background: none; border: 0; border-radius: var(--radius); color: var(--text-2); cursor: pointer; }
.theme-toggle:hover { background: var(--hover); }

.main {
  margin: 4px 4px 4px 0; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow-y: auto; min-width: 0; padding: 16px 16px 32px; display: flex; flex-direction: column; gap: 16px;
}
.foot { margin-top: 8px; color: var(--text-3); font-size: 12px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-title { display: flex; align-items: center; gap: 8px; }
.page-title .icon { width: 18px; height: 18px; }
.sub { margin: 8px 0 0; color: var(--text); }
.crumbs { display: flex; gap: 6px; color: var(--text-3); font-size: 13px; margin-bottom: -6px; }
.crumbs a { color: var(--text-2); }
.hint { margin: 0; color: var(--text-3); font-size: 12px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head.pad { margin: 0; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.card-head .muted { font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2.wide-left { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.empty { color: var(--text-3); text-align: center; padding: 20px; margin: 0; }

/* Buttons (LemonButton): transparent with a 3D edge; primary has an amber edge */
.btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 33px; padding: 3px 9px 5px;
  font: inherit; font-weight: 500; color: var(--text); background: transparent; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--btn-border); border-radius: var(--radius); box-shadow: 0 3px 0 -1px var(--btn-edge);
  transition: transform .05s ease, box-shadow .05s ease;
}
.btn:hover { background: var(--hover); color: var(--text); text-decoration: none; transform: translateY(-1px); box-shadow: 0 4px 0 -1px var(--btn-edge); }
.btn:active { transform: translateY(1px); box-shadow: 0 1px 0 -1px var(--btn-edge); }
.btn-primary { background: var(--surface); border-color: var(--amber-edge); box-shadow: 0 3px 0 -1px var(--amber); }
.btn-primary:hover { background: var(--surface); box-shadow: 0 4px 0 -1px var(--amber); }
.btn-primary:active { box-shadow: 0 1px 0 -1px var(--amber); }
.btn-sm { height: 28px; padding: 1px 8px 3px; font-size: 13px; }
.btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

/* Inputs (LemonInput) */
.input { height: 37px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 10px; min-width: 0; }
.input::placeholder, .search input::placeholder { color: var(--text-3); }
.input:hover, .search input:hover { border-color: var(--border-2); }
.input:focus, .search input:focus { outline: none; border-color: var(--border-2); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-narrow { width: 110px; }
.input-sm { height: 30px; padding: 2px 8px; font-size: 13px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.toolbar .input[type="search"] { flex: 1 1 240px; max-width: 400px; }
.toolbar.inline .input { flex: 0 1 220px; }

/* Segmented control (LemonSegmentedButton) */
.segmented { display: inline-flex; border: 1px solid var(--btn-border); border-radius: var(--radius); overflow: hidden; box-shadow: 0 3px 0 -1px var(--btn-edge); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; height: 31px; padding: 4px 11px; font-weight: 500; color: var(--text-2); cursor: pointer; }
.segmented label + label span { border-left: 1px solid var(--btn-border); }
.segmented span:hover { background: var(--hover); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: inset 0 -2px 0 var(--accent); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Tables (LemonTable) */
.table-wrap { overflow-x: auto; }
.scroll-y { max-height: 420px; overflow-y: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.table th {
  position: sticky; top: 0; z-index: 1; height: 40px; padding: 8px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text);
  background: var(--table-head); border-bottom: 1px solid var(--border);
}
.table td { height: 44px; padding: 5px 8px; color: var(--text-2); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: 16px; }
.table th:last-child, .table td:last-child { padding-right: 16px; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-2); }
.table.compact td { height: 34px; }
.table td a { color: var(--text); font-weight: 600; }
.table td a:hover { color: var(--accent); text-decoration: none; }
.table .num { text-align: right; white-space: nowrap; }
.table td.name { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.url { max-width: 0; width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table td.url a { font-weight: 400; }
.table td[title] { white-space: nowrap; }
.table tr.dim td { color: var(--text-3); }
.table-view .table { border: 1px solid var(--border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; }
.pos { color: var(--success); }
.neg { color: var(--danger); }
.sort { display: inline-flex; gap: 4px; color: inherit; }
.sort:hover { color: var(--accent); text-decoration: none; }
.sort.on { color: var(--accent); }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; }

/* Tags (LemonTag): small rounded labels; status is always a word, never color alone */
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 6px; border-radius: 4px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; background: var(--hover-2); color: var(--text-2); }
.badge-active, .badge-submitted { background: var(--success-bg); color: var(--success); }
.badge-pending, .badge-scheduled { background: var(--warning-bg); color: var(--warning); }
.badge-locked, .badge-expired, .badge-refunded { background: var(--danger-bg); color: var(--danger); }
.pill { font-size: 12px; font-weight: 500; padding: 1px 6px; border-radius: 4px; background: var(--hover-2); color: var(--text-2); }

/* Properties */
.props { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0 0 12px; }
.props dt { color: var(--text-3); }
.props dd { margin: 0; overflow-wrap: anywhere; }
/* Error page */
.error-card { max-width: 520px; margin: 48px auto; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 32px; }
.error-code { font-size: 44px; font-weight: 700; color: var(--accent); line-height: 1; }

/* Sign in */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.login-card { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.login-card input { height: 34px; padding: 4px 10px; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius); }
.login-card .btn { justify-content: center; }
.login-error { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); }
.signed-in { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 6px; min-width: 0; }
.signed-in span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar .signed-in { margin-top: auto; }
.signed-in + .sidebar-foot { margin-top: 0; }

/* Website additions */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.center { text-align: center; }
.flash { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: var(--success-bg); color: var(--success); font-weight: 500; }
.credit-box { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 8px; margin: 4px 6px 0; padding: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.credit-box .muted { grid-column: 1 / -1; }
.credit-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.sidebar .credit-box { margin-top: auto; }
.credit-box + .signed-in { margin-top: 0; }
.btn-quiet { box-shadow: none; border-color: transparent; color: var(--text-2); }
.btn-quiet:hover { border-color: var(--btn-border); box-shadow: 0 3px 0 -1px var(--btn-edge); }
.btn-danger { border-color: var(--danger); color: var(--danger); box-shadow: 0 3px 0 -1px var(--danger-bg); }
.btn[disabled] { opacity: .6; pointer-events: none; }
.form { display: flex; flex-direction: column; gap: 16px; max-width: 760px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.form .hint { font-weight: 400; }
.field-row { display: flex; align-items: center; gap: 8px; font-weight: 400; }
.textarea { height: auto; min-height: 220px; padding: 8px 10px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.6; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.form-error { margin: 0; padding: 8px 10px; border-radius: var(--radius); background: var(--danger-bg); color: var(--danger); }
.confirm { max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.confirm p { margin: 0; }
.big-number { margin: 0 0 4px; font-size: 32px; font-weight: 700; font-variant-numeric: tabular-nums; }
.key-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.key { padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; overflow-wrap: anywhere; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; }
.code { margin: 0 0 12px; padding: 12px; overflow-x: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12px; line-height: 1.6; }
.card p { margin-top: 0; }
.page-title .badge { margin-left: 4px; }

/* Narrow screens: sidebar becomes a top bar, the panel fills the width */
@media (max-width: 860px) {
  .shell { display: block; height: auto; }
  .sidebar { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px 12px; overflow: visible; }
  .nav-label { display: none; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; order: 3; width: 100%; }
  .search { order: 4; width: 100%; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; gap: 6px; }
  .sidebar-foot .muted { display: none; }
  .sidebar .credit-box { order: 5; width: 100%; margin: 0; grid-template-columns: auto 1fr auto; }
  .credit-box .muted { grid-column: auto; }
  .sidebar .signed-in { margin: 0 0 0 auto; padding: 0; }
  .signed-in + .sidebar-foot { margin-left: 0; }
  .main { margin: 0 4px 4px; padding: 16px 12px 32px; overflow: visible; }
  .grid-2, .grid-2.wide-left { grid-template-columns: minmax(0, 1fr); }
  .table td.name { max-width: 170px; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tile-value { font-size: 22px; }
}
