@import url('https://fonts.googleapis.com/css2?family=Instrument+Sans:wght@400;500;600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
    --ink: #0A1F44;
    --ink-2: #1B3563;
    --gold: #CBA052;
    --gold-soft: #F3E7CC;
    --paper: #F3F5F8;
    --white: #FFFFFF;
    --line: #D8DEE8;
    --slate: #56627A;
    --ok: #17744F;
    --ok-soft: #DDF1E7;
    --warn: #8A5A00;
    --warn-soft: #FBEFD5;
    --bad: #B02A37;
    --bad-soft: #F9E0E2;
    --radius: 6px;
    --sans: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--sans); font-size: 16px; line-height: 1.55; color: var(--ink); background: var(--paper); }
a { color: var(--ink-2); text-underline-offset: 3px; }
a:hover { color: var(--ink); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
code, pre, .mono { font-family: var(--mono); font-size: .88em; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.muted { color: var(--slate); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ---------------------------------------------------------------- buttons & forms */
.btn { display: inline-flex; align-items: center; gap: .4em; padding: .62em 1.1em; border-radius: var(--radius); border: 1px solid var(--ink); background: var(--ink); color: var(--white); font: 600 .95rem var(--sans); text-decoration: none; cursor: pointer; }
.btn:hover { background: var(--ink-2); color: var(--white); }
.btn.secondary { background: var(--white); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { border-color: var(--ink); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.danger { background: var(--bad); border-color: var(--bad); }
.btn.small { padding: .35em .7em; font-size: .82rem; }
.btn.link { background: none; border: 0; color: var(--ink-2); padding: 0; text-decoration: underline; font-weight: 500; }
.btn[disabled] { opacity: .6; cursor: default; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 .3em; }
.hint { display: block; font-weight: 400; color: var(--slate); font-size: .82rem; margin-top: .25em; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    width: 100%; padding: .6em .7em; border: 1px solid var(--line); border-radius: var(--radius); font: inherit; background: var(--white); color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px rgba(203,160,82,.35); }
.field { margin-bottom: 1rem; }
.field .error { color: var(--bad); font-size: .85rem; margin-top: .3em; }
.check { display: flex; gap: .5em; align-items: flex-start; font-weight: 400; }
.check input { margin-top: .3em; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; margin-bottom: 0; }
form.inline { display: inline; }

.notice { padding: .8em 1em; border-radius: var(--radius); margin-bottom: 1.2rem; border-left: 4px solid; }
.notice.ok { background: var(--ok-soft); border-color: var(--ok); }
.notice.err { background: var(--bad-soft); border-color: var(--bad); }
.notice.warn { background: var(--warn-soft); border-color: var(--gold); }

.badge { display: inline-block; padding: .1em .55em; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--paper); border: 1px solid var(--line); }
.badge.ok { background: var(--ok-soft); border-color: #B7E0CB; color: var(--ok); }
.badge.bad { background: var(--bad-soft); border-color: #F0B9BF; color: var(--bad); }
.badge.warn { background: var(--warn-soft); border-color: #EBD29C; color: var(--warn); }

/* ---------------------------------------------------------------- tables & panels */
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--white); margin-bottom: 1.25rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .6em .75em; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; color: var(--slate); font-weight: 600; background: #FAFBFD; }
tr:last-child td { border-bottom: 0; }
td.empty { text-align: center; color: var(--slate); padding: 2rem; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.stat .v { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { color: var(--slate); font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.25rem; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin: 1rem 0; }
details > summary { cursor: pointer; color: var(--ink-2); font-size: .85rem; }
pre.detail { background: var(--paper); border: 1px solid var(--line); padding: .6em; white-space: pre-wrap; word-break: break-word; font-size: .75rem; max-height: 260px; overflow: auto; }

/* usage meter */
.meter { height: 12px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--ink); }
.meter.warn > span { background: var(--gold); }
.meter.bad > span { background: var(--bad); }

/* 30-day bar chart (pure CSS) */
.bars { display: flex; align-items: flex-end; gap: 3px; height: 120px; padding-top: .5rem; }
.bars span { flex: 1; background: var(--ink); border-radius: 2px 2px 0 0; min-height: 2px; }
.bars span.zero { background: var(--line); }

/* key reveal */
.secret { display: flex; gap: .5rem; align-items: center; background: var(--ink); color: var(--white); padding: .8em 1em; border-radius: var(--radius); font-family: var(--mono); overflow-x: auto; }
.secret code { flex: 1; white-space: nowrap; }

/* ---------------------------------------------------------------- public site */
.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.site-header .inner, .site-footer .inner, .wrap { max-width: 1120px; margin: 0 auto; padding: 0 1.25rem; }
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 1rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: .5rem; }
.brand-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--ink); color: var(--gold); display: grid; place-items: center; font-size: .8rem; font-weight: 700; }
.site-nav { display: flex; gap: 1.25rem; align-items: center; }
.site-nav a { text-decoration: none; font-weight: 500; }
.site-footer { border-top: 1px solid var(--line); background: var(--white); margin-top: 4rem; padding: 2rem 0; color: var(--slate); font-size: .88rem; }
.site-footer .inner { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

.hero { padding: 4.5rem 0 3.5rem; }
.hero .wrap { display: grid; grid-template-columns: 1.05fr 1fr; gap: 3rem; align-items: center; }
.hero h1 { font-size: clamp(2.1rem, 4.6vw, 3.2rem); max-width: 16ch; }
.hero .lede { font-size: 1.15rem; color: var(--slate); max-width: 46ch; }
.hero .actions { display: flex; gap: .75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* The signature element: a consignment label showing a real request and answer */
.label-card { background: var(--white); border: 2px solid var(--ink); border-radius: 4px; box-shadow: 8px 8px 0 var(--ink); font-family: var(--mono); font-size: .82rem; }
.label-card .strip { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--ink); padding: .55rem .9rem; font-family: var(--sans); font-weight: 700; }
.label-card .barcode { height: 22px; width: 120px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, transparent 2px 4px, var(--ink) 4px 5px, transparent 5px 8px, var(--ink) 8px 11px, transparent 11px 12px); }
.label-card .route { display: grid; grid-template-columns: 1fr auto 1fr; border-bottom: 2px dashed var(--line); }
.label-card .route div { padding: .7rem .9rem; }
.label-card .route .arrow { align-self: center; color: var(--gold); font-weight: 700; }
.label-card .route strong { display: block; font-family: var(--sans); font-size: 1.5rem; }
.label-card pre { margin: 0; padding: .9rem; white-space: pre; overflow-x: auto; }
.label-card .req { background: var(--paper); border-bottom: 1px solid var(--line); color: var(--slate); }
.label-card .k { color: var(--ink-2); }
.label-card .s { color: var(--ok); }
.label-card .n { color: #8A4B00; }

.band { padding: 3.5rem 0; }
.band.white { background: var(--white); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem; counter-reset: step; margin-top: 1.5rem; }
.steps li { list-style: none; counter-increment: step; }
.steps li::before { content: counter(step); display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--ink); font-weight: 700; margin-bottom: .6rem; }
.steps { padding: 0; }
.price-table { width: 100%; max-width: 760px; }
.price-table td, .price-table th { padding: 1rem; font-size: 1rem; }
.price-table .per { font-size: 1.3rem; font-weight: 700; }
.services-list { columns: 2; padding-left: 1.2rem; }

.docs { display: grid; grid-template-columns: 220px 1fr; gap: 2.5rem; padding: 2.5rem 0; }
.docs nav { position: sticky; top: 1rem; align-self: start; font-size: .92rem; }
.docs nav a { display: block; padding: .25rem 0; text-decoration: none; }
.docs pre { background: var(--ink); color: #E7ECF5; padding: 1rem; border-radius: var(--radius); overflow-x: auto; font-size: .82rem; }
.docs section { margin-bottom: 2.5rem; }

/* ---------------------------------------------------------------- auth pages */
.auth-body { min-height: 100vh; }
.auth-card { max-width: 440px; margin: 3rem auto; background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; }
.auth-card h1 { font-size: 1.6rem; }
.auth-card .btn { width: 100%; justify-content: center; }
.auth-links { margin-top: 1.25rem; font-size: .92rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------------------------------------------------------------- portal / admin shell */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #C9D2E3; padding: 1.25rem 1rem; display: flex; flex-direction: column; gap: 1.5rem; }
.sidebar .brand { color: var(--white); }
.sidebar .brand-mark { background: var(--gold); color: var(--ink); }
.sidebar nav a { display: block; color: #C9D2E3; text-decoration: none; padding: .5rem .7rem; border-radius: var(--radius); font-weight: 500; }
.sidebar nav a:hover { background: rgba(255,255,255,.07); color: var(--white); }
.sidebar nav a.on { background: rgba(203,160,82,.18); color: var(--white); box-shadow: inset 3px 0 0 var(--gold); }
.sidebar .balance { background: rgba(255,255,255,.06); border-radius: var(--radius); padding: .8rem; font-size: .85rem; }
.sidebar .balance strong { display: block; font-size: 1.4rem; color: var(--white); font-variant-numeric: tabular-nums; }
.sidebar .foot { margin-top: auto; font-size: .85rem; }
.sidebar .foot .btn.link { color: #C9D2E3; }
.main { padding: 1.75rem 2rem 3rem; min-width: 0; }
.main-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.main-head h1 { font-size: 1.6rem; margin: 0; }
.menu-btn { display: none; }
.admin .sidebar { background: #111B2E; }

@media (max-width: 880px) {
    .hero .wrap, .docs { grid-template-columns: 1fr; }
    .docs nav { position: static; }
    .steps { grid-template-columns: 1fr; }
    .services-list { columns: 1; }
    .shell { grid-template-columns: 1fr; }
    .sidebar { display: none; }
    body.menu-open .sidebar { display: flex; }
    .menu-btn { display: inline-flex; }
    .main { padding: 1.25rem 1rem 3rem; }
    .site-nav .hide-sm { display: none; }
}
