/* ==========================================================================
   WebhookProxy — shared stylesheet for index.html and admin.html.

   A hand-port of the portfolio's design system (tailwind.config.ts +
   src/index.css + the shadcn components under src/components/ui) into plain
   CSS, so these pages stay build-step-free while matching the portfolio
   exactly. If the portfolio palette changes, update the token block below.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens — verbatim from the portfolio's src/index.css
   (LedgerApp lavender + teal). Dark is default; `.light` on <html> switches.
   -------------------------------------------------------------------------- */
:root {
    --background: 228 22% 12%;
    --foreground: 250 29% 91%;
    --card: 228 25% 18%;
    --card-foreground: 250 29% 91%;
    --primary: 262 33% 66%;
    --primary-foreground: 228 22% 12%;
    --secondary: 228 21% 21%;
    --secondary-foreground: 250 29% 91%;
    --muted: 228 21% 21%;
    --muted-foreground: 249 11% 60%;
    --destructive: 0 62% 66%;
    --border: 228 20% 24%;
    --input: 228 21% 21%;
    --ring: 262 33% 66%;
    --radius: 0.9rem;
    --teal: 176 53% 55%;
    --teal-foreground: 228 22% 12%;
    --success: 155 60% 60%;
    --warning: 44 84% 59%;
    --info: 205 60% 66%;
}

.light {
    --background: 250 30% 97%;
    --foreground: 249 25% 13%;
    --card: 0 0% 100%;
    --card-foreground: 249 25% 13%;
    --primary: 262 40% 56%;
    --primary-foreground: 0 0% 100%;
    --secondary: 250 24% 92%;
    --secondary-foreground: 249 25% 13%;
    --muted: 250 24% 92%;
    --muted-foreground: 249 11% 42%;
    --destructive: 0 62% 52%;
    --border: 250 20% 87%;
    --input: 250 20% 90%;
    --ring: 262 40% 56%;
    --teal: 176 58% 40%;
    --teal-foreground: 0 0% 100%;
    --success: 155 55% 38%;
    --warning: 38 92% 42%;
    --info: 205 70% 42%;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*,
::before,
::after {
    box-sizing: border-box;
    border-width: 0;
    border-style: solid;
    border-color: hsl(var(--border));
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'Lato', system-ui, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
    font-weight: 600;
    margin: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

img,
svg {
    display: block;
    max-width: 100%;
}

code,
pre {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}

::selection {
    background: hsl(var(--primary) / 0.3);
    color: hsl(var(--foreground));
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: hsl(var(--muted-foreground) / 0.35);
    border-radius: 9999px;
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground) / 0.55);
    background-clip: content-box;
}

/* Hidden when JS is unavailable. Mirrors the old page's <withscript>. */
.js-only {
    display: revert;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.container {
    width: 100%;
    max-width: 1120px;
    margin-inline: auto;
    padding-inline: 1.5rem;
}
.container-wide {
    max-width: 1320px;
}

.font-display {
    font-weight: 800;
    letter-spacing: -0.02em;
}

.muted {
    color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   shadcn primitives, hand-ported from the portfolio's ui/ components
   -------------------------------------------------------------------------- */

/* ui/card.tsx — rounded-xl border-border/50 bg-card shadow-sm */
.card {
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border) / 0.5);
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

/* ui/button.tsx */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    white-space: nowrap;
    border-radius: calc(var(--radius) - 2px);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    height: 2.25rem;
    padding: 0.5rem 1rem;
    transition: background-color 0.15s, color 0.15s;
    cursor: pointer;
    user-select: none;
}
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px hsl(var(--background)), 0 0 0 4px hsl(var(--ring));
}
.btn:disabled {
    pointer-events: none;
    opacity: 0.5;
}
.btn svg {
    flex-shrink: 0;
    pointer-events: none;
}
.btn-sm {
    height: 2rem;
    padding-inline: 0.75rem;
    font-size: 0.75rem;
}
.btn-lg {
    height: 2.75rem;
    padding-inline: 1.5rem;
}
.btn-primary {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
}
.btn-primary:hover {
    background: hsl(var(--primary) / 0.9);
}
.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover {
    background: hsl(var(--secondary) / 0.8);
}
.btn-outline {
    border: 1px solid hsl(var(--border));
    background: transparent;
    color: hsl(var(--foreground));
}
.btn-outline:hover {
    background: hsl(var(--secondary));
}
.btn-ghost {
    background: transparent;
    color: hsl(var(--muted-foreground));
}
.btn-ghost:hover {
    background: hsl(var(--secondary));
    color: hsl(var(--foreground));
}
.btn-icon {
    width: 2.25rem;
    padding: 0;
}

/* ui/input.tsx */
.input {
    display: flex;
    height: 2.25rem;
    width: 100%;
    border-radius: calc(var(--radius) - 2px);
    border: 1px solid hsl(var(--border));
    background: hsl(var(--input));
    color: hsl(var(--foreground));
    padding: 0.25rem 0.75rem;
    font-family: inherit;
    font-size: 0.875rem;
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    transition: border-color 0.15s;
}
.input::placeholder {
    color: hsl(var(--muted-foreground));
}
.input:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px hsl(var(--background)), 0 0 0 3px hsl(var(--ring));
}
.input[readonly] {
    color: hsl(var(--muted-foreground));
}
select.input {
    cursor: pointer;
}

/* ui/badge.tsx */
.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 9999px;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: hsl(var(--primary) / 0.2);
    color: hsl(var(--primary));
}
.badge-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}
.badge-teal {
    background: hsl(var(--teal) / 0.15);
    color: hsl(var(--teal));
}
.badge-success {
    background: hsl(var(--success) / 0.15);
    color: hsl(var(--success));
}
.badge-warning {
    background: hsl(var(--warning) / 0.15);
    color: hsl(var(--warning));
}
.badge-danger {
    background: hsl(var(--destructive) / 0.15);
    color: hsl(var(--destructive));
}
.badge-info {
    background: hsl(var(--info) / 0.15);
    color: hsl(var(--info));
}

/* Alert callouts, tinted per severity from the token set. */
.alert {
    border-radius: 0.75rem;
    border: 1px solid;
    padding: 1rem 1.15rem;
    margin-bottom: 1rem;
}
.alert h5 {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-weight: 700;
}
.alert p {
    margin: 0 0 0.6rem;
    font-size: 0.9rem;
    color: hsl(var(--foreground) / 0.85);
}
.alert p:last-child {
    margin-bottom: 0;
}
.alert-warning {
    background: hsl(var(--warning) / 0.1);
    border-color: hsl(var(--warning) / 0.3);
    color: hsl(var(--warning));
}
.alert-danger {
    background: hsl(var(--destructive) / 0.1);
    border-color: hsl(var(--destructive) / 0.3);
    color: hsl(var(--destructive));
}
.alert-info {
    background: hsl(var(--info) / 0.1);
    border-color: hsl(var(--info) / 0.3);
    color: hsl(var(--info));
}
.alert-success {
    background: hsl(var(--success) / 0.1);
    border-color: hsl(var(--success) / 0.3);
    color: hsl(var(--success));
}

/* --------------------------------------------------------------------------
   Header / footer chrome
   -------------------------------------------------------------------------- */
header.site {
    position: sticky;
    top: 0;
    z-index: 50;
    background: hsl(var(--background) / 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid hsl(var(--border));
}
header.site .inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    height: 3.75rem;
}
header.site .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    font-size: 1.05rem;
}
header.site .brand img {
    width: 1.6rem;
    height: 1.6rem;
}
header.site .spacer {
    flex: 1;
}

footer.site {
    margin-top: 4rem;
    border-top: 1px solid hsl(var(--border));
    padding: 1.5rem 0;
    font-size: 0.85rem;
    color: hsl(var(--muted-foreground));
}
footer.site .inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
footer.site a {
    color: hsl(var(--primary));
}
footer.site a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Landing page
   -------------------------------------------------------------------------- */
.hero {
    padding: 4.5rem 0 3rem;
    text-align: center;
}
.hero img.logo {
    width: 96px;
    height: 96px;
    margin: 0 auto 1.5rem;
}
.hero h1 {
    font-size: clamp(2.25rem, 6vw, 3.25rem);
    line-height: 1.1;
    margin-bottom: 0.75rem;
}
.hero .lead {
    color: hsl(var(--muted-foreground));
    font-size: 1.1rem;
    max-width: 34rem;
    margin: 0 auto 2rem;
}

.converter {
    max-width: 46rem;
    margin: 0 auto 2rem;
    padding: 1.15rem;
    text-align: left;
}
.converter .label,
.field-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.4rem;
}
.converter .row {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
}
.converter .field {
    flex: 1;
    min-width: 0;
}
.converter .arrow {
    display: flex;
    align-items: center;
    height: 2.25rem;
    color: hsl(var(--muted-foreground));
}
.converter .copy-wrap {
    display: flex;
    gap: 0.5rem;
}
@media (max-width: 640px) {
    .converter .row {
        flex-direction: column;
        align-items: stretch;
    }
    .converter .arrow {
        transform: rotate(90deg);
        justify-content: center;
        height: auto;
    }
}

.hero-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    max-width: 46rem;
    margin: 0 auto;
}
.stat {
    padding: 1.25rem;
    text-align: center;
}
.stat .value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.1;
    color: hsl(var(--primary));
    font-variant-numeric: tabular-nums;
}
.stat .label {
    font-size: 0.8rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.25rem;
}

section.block {
    padding: 3.5rem 0 0;
}
section.block > h2 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}
section.block > .sub {
    color: hsl(var(--muted-foreground));
    margin: 0 0 1.75rem;
}

.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(275px, 1fr));
    gap: 1rem;
}
.feature {
    padding: 1.35rem;
}
.feature .icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: calc(var(--radius) - 4px);
    background: hsl(var(--primary) / 0.15);
    color: hsl(var(--primary));
    margin-bottom: 0.9rem;
}
.feature h3 {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
}
.feature p {
    margin: 0;
    font-size: 0.9rem;
    color: hsl(var(--muted-foreground));
}
.feature a {
    color: hsl(var(--primary));
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-color: hsl(var(--primary) / 0.4);
}
.feature a:hover {
    text-decoration-color: hsl(var(--primary));
}

/* Inline code and code blocks, matching .prose-portfolio */
:not(pre) > code {
    font-size: 0.85em;
    background: hsl(var(--muted));
    border: 1px solid hsl(var(--border));
    padding: 0.12rem 0.4rem;
    border-radius: 6px;
    color: hsl(var(--foreground));
}
pre {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: calc(var(--radius) - 2px);
    padding: 1rem 1.1rem;
    overflow-x: auto;
    margin: 0 0 1.25rem;
    font-size: 0.82rem;
    line-height: 1.65;
}
pre code {
    background: none;
    border: none;
    padding: 0;
}
/* Minimal Lua tokens, hand-marked. The samples are fixed strings, so this
   replaces Prism (8 KB plus a stylesheet) with four rules. */
.tok-kw {
    color: hsl(var(--primary));
}
.tok-str {
    color: hsl(var(--teal));
}
.tok-fn {
    color: hsl(var(--info));
}
.tok-punct {
    color: hsl(var(--muted-foreground));
}
.hostname-hl {
    color: hsl(var(--warning));
    font-weight: 600;
}

dialog#getStarted {
    width: min(46rem, calc(100vw - 2rem));
    max-height: calc(100vh - 4rem);
    padding: 0;
    border: 1px solid hsl(var(--border));
    border-radius: 0.75rem;
    background: hsl(var(--card));
    color: hsl(var(--card-foreground));
    overflow: hidden;
}
dialog#getStarted::backdrop {
    background: rgb(0 0 0 / 0.6);
    backdrop-filter: blur(2px);
}
dialog#getStarted .head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid hsl(var(--border));
}
dialog#getStarted .head h3 {
    font-size: 1.05rem;
    font-weight: 700;
}
dialog#getStarted .body {
    padding: 1.15rem;
    overflow-y: auto;
    max-height: calc(100vh - 10rem);
}
dialog#getStarted .body p {
    margin: 0 0 0.9rem;
    font-size: 0.92rem;
    color: hsl(var(--muted-foreground));
}

/* --------------------------------------------------------------------------
   Admin page
   -------------------------------------------------------------------------- */

/* Login gate */
.login-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 3.75rem);
    padding: 2rem 1.5rem;
}
.login-card {
    width: 100%;
    max-width: 24rem;
    padding: 1.75rem;
}
.login-card h1 {
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}
.login-card .sub {
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
    margin: 0 0 1.35rem;
}
.login-card .btn {
    width: 100%;
    margin-top: 1rem;
}
.login-error {
    display: none;
    margin-top: 0.9rem;
    font-size: 0.85rem;
    color: hsl(var(--destructive));
}

.admin-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: 2rem 0 1.5rem;
}
.admin-head h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}
.admin-head .sub {
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
    margin: 0.15rem 0 0;
}

/* KPI grid */
.kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.5rem;
}
.kpi {
    padding: 1rem 1.1rem;
}
.kpi .k-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: hsl(var(--muted-foreground));
}
.kpi .k-value {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin-top: 0.2rem;
    font-variant-numeric: tabular-nums;
}
.kpi .k-note {
    font-size: 0.75rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.1rem;
}

/* Two-column panel row */
.panels {
    display: grid;
    grid-template-columns: 1.35fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}
@media (max-width: 900px) {
    .panels {
        grid-template-columns: 1fr;
    }
}
.panel {
    padding: 1.15rem;
}
.panel > h2 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 0.15rem;
}
.panel > .sub {
    font-size: 0.78rem;
    color: hsl(var(--muted-foreground));
    margin: 0 0 1rem;
}

/* 24h bar chart, pure CSS */
.chart {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 130px;
}
.chart .bar {
    flex: 1;
    min-width: 0;
    background: hsl(var(--primary) / 0.55);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    transition: background-color 0.15s;
}
.chart .bar:hover {
    background: hsl(var(--primary));
}
.chart-axis {
    display: flex;
    justify-content: space-between;
    font-size: 0.7rem;
    color: hsl(var(--muted-foreground));
    margin-top: 0.4rem;
}

/* Ranked lists (top webhooks / agents) */
.rank {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.rank-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.82rem;
}
.rank-row .name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.75rem;
}
.rank-row .meter {
    width: 5rem;
    height: 5px;
    border-radius: 9999px;
    background: hsl(var(--muted));
    overflow: hidden;
    flex-shrink: 0;
}
.rank-row .meter span {
    display: block;
    height: 100%;
    background: hsl(var(--teal));
}
.rank-row .count {
    width: 3rem;
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: hsl(var(--muted-foreground));
    flex-shrink: 0;
}

/* Filter bar */
.filters {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.filters .grow {
    flex: 1;
    min-width: 12rem;
}

/* Requests table */
.table-wrap {
    overflow-x: auto;
    border-radius: 0.75rem;
    border: 1px solid hsl(var(--border) / 0.5);
    background: hsl(var(--card));
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}
table.data th,
table.data td {
    padding: 0.55rem 0.8rem;
    text-align: left;
    white-space: nowrap;
}
table.data th {
    background: hsl(var(--muted));
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: hsl(var(--muted-foreground));
    position: sticky;
    top: 0;
}
table.data tbody tr {
    border-top: 1px solid hsl(var(--border) / 0.6);
}
table.data tbody tr:hover {
    background: hsl(var(--muted) / 0.4);
}
table.data td.mono {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 0.75rem;
}
table.data td.agent {
    max-width: 22rem;
    overflow: hidden;
    text-overflow: ellipsis;
}
table.data td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.empty {
    padding: 2.5rem 1rem;
    text-align: center;
    color: hsl(var(--muted-foreground));
    font-size: 0.9rem;
}

.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    font-size: 0.82rem;
    color: hsl(var(--muted-foreground));
}
.pager .controls {
    display: flex;
    gap: 0.5rem;
}
