/* Customer dashboard and its login/sign-up screens. Same look as the website ("Phosphor"): ink, light and one bright
   line. A reseller's brand colour replaces the accent (applyBrand in app.js sets --accent, --accent-text and --link). */

@font-face { font-family: "Bricolage Grotesque"; src: url("/fonts/bricolage-grotesque.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Geist"; src: url("/fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Geist Mono"; src: url("/fonts/geist-mono.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --bg: #0a0b0f; --bg-2: #0d0f14; --surface: #12141b; --surface-2: #161922; --text: #eceef3; --text-2: #c3c9d6; --muted: #9aa1b2;
  --border: #232733; --border-strong: #2e3340;
  --accent: #b8f35b; --accent-text: #0a0b0f; --link: #b8f35b; --lime: #b8f35b;
  --ok: #b8f35b; --ok-bg: rgba(184, 243, 91, .12); --warn: #fdba74; --warn-bg: rgba(253, 186, 116, .12);
  --bad: #ff8a80; --bad-bg: rgba(255, 138, 128, .12); --code-bg: #161922;
  --display: "Bricolage Grotesque", system-ui, sans-serif; --sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
body.menu-open { overflow: hidden; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.03em; line-height: 1.1; }
h1 { font-size: clamp(30px, 3.4vw, 40px); font-weight: 700; margin: 0 0 .5rem; }
h2 { font-size: 22px; font-weight: 700; margin: 1.75rem 0 .6rem; }
h3 { font-size: 17px; font-weight: 700; margin: 1.1rem 0 .5rem; letter-spacing: -.015em; }
p { margin: 0 0 .75rem; }
p.muted, .muted { color: var(--muted); }
code, .mono { font-family: var(--mono); font-size: .86em; }
/* The hidden attribute must win over display rules like label { display: flex }. */
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.layout { display: flex; min-height: 100vh; }
nav.side { width: 248px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg-2); border-right: 1px solid var(--border); padding: 20px 14px; display: flex; flex-direction: column; gap: 2px; }
.app-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font: 700 20px var(--display); letter-spacing: -.02em; padding: 4px 10px 14px; }
.app-brand:hover { text-decoration: none; }
.app-brand svg { flex: 0 0 auto; }
nav.side .brand { font: 500 12px var(--mono); color: var(--muted); letter-spacing: .06em; text-transform: uppercase; padding: 0 10px 14px; margin-bottom: 6px; border-bottom: 1px solid var(--border); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
nav.side > a:not(.app-brand) { position: relative; display: flex; align-items: center; min-height: 40px; color: var(--text-2); text-decoration: none; padding: 0 12px; border-radius: 10px; font-size: 14.5px; }
nav.side > a:not(.app-brand):hover { background: var(--surface); color: var(--text); }
nav.side > a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
nav.side > a.active::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
nav.side .spacer { flex: 1; min-height: 16px; }
.side-user { border-top: 1px solid var(--border); padding: 14px 10px 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.side-user .mono { color: var(--text-2); word-break: break-all; }
.side-user a { color: var(--muted); }
.side-user a:hover { color: var(--text); }
main { flex: 1; padding: 40px clamp(20px, 4vw, 56px) 80px; max-width: 1120px; min-width: 0; }

/* mobile top bar + burger */
.topbar { display: none; }
.menu-toggle { position: relative; width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); padding: 0; cursor: pointer; }
.menu-toggle span { position: absolute; left: 12px; width: 18px; height: 2px; border-radius: 2px; background: currentColor; transition: transform .2s ease, opacity .2s ease, top .2s ease; }
.menu-toggle span:nth-child(1) { top: 15px; }
.menu-toggle span:nth-child(2) { top: 21px; }
.menu-toggle span:nth-child(3) { top: 27px; }
.menu-toggle[aria-expanded="true"] span:nth-child(1) { top: 21px; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-toggle[aria-expanded="true"] span:nth-child(3) { top: 21px; transform: rotate(-45deg); }
@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 40; min-height: 64px; padding: 10px 16px; background: var(--bg); border-bottom: 1px solid var(--border); }
  .topbar .app-brand { padding: 0; font-size: 18px; }
  .topbar .brand-mark { margin: 0; }
  nav.side { display: none; }
  nav.side > .app-brand, nav.side > .brand-mark { display: none; }
  .layout.nav-open nav.side { display: flex; position: fixed; z-index: 39; top: 64px; left: 0; right: 0; bottom: 0; width: auto; height: auto; border-right: 0; padding: 12px 16px 24px; animation: menu-in .18s ease-out; }
  .layout.nav-open nav.side > a:not(.app-brand) { min-height: 50px; font-size: 17px; }
  main { padding: 24px 16px 64px; }
}
@keyframes menu-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .layout.nav-open nav.side, .menu-toggle span { animation: none; transition: none; } }

/* ---------------------------------------------------------------- building blocks */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 22px 24px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
form.stack { display: flex; flex-direction: column; gap: 14px; }
.stack h3 { margin: .75rem 0 0; font-size: 15px; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13.5px; color: var(--text-2); }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], input[type=search], select, textarea {
  font: 15px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--border-strong); border-radius: 10px; min-height: 44px; padding: 0 12px;
}
textarea { padding: 10px 12px; width: 100%; line-height: 1.5; }
select { padding: 0 34px 0 12px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='M7 10l5 5 5-5' stroke='%239aa1b2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; }
input::placeholder, textarea::placeholder { color: #6b7385; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
.row { display: flex; flex-direction: row; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > input { flex: 1; min-width: 200px; }
.row.spread { justify-content: space-between; align-items: center; }
label.row.inline { font-weight: 400; gap: 8px; flex-wrap: nowrap; color: var(--text-2); }
label.row.inline input { flex: 0 0 auto; min-width: 0; }
label.check { flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 400; flex-wrap: nowrap; color: var(--text-2); }
label.check input { flex: 0 0 auto; min-width: 0; margin-top: 3px; }
label.consent { font-weight: 400; align-items: flex-start; flex-wrap: nowrap; gap: 10px; color: var(--text-2); }
label.consent input { flex: 0 0 auto; min-width: 0; margin-top: 3px; }

button { font: 600 14px var(--sans); min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--border-strong); background: transparent; color: var(--text); cursor: pointer; transition: background .15s, border-color .15s; }
button:hover { border-color: #566075; background: var(--surface-2); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); background: var(--accent); }
button.danger { color: var(--bad); }
button.danger:hover { border-color: var(--bad); background: var(--bad-bg); }
button.small { min-height: 32px; padding: 0 12px; font-size: 13px; }
button:disabled { opacity: .55; cursor: default; }
form.stack > button.primary { min-height: 48px; font-size: 15px; }
/* In the dashboard a form's button sits at its natural width; on the login screens it fills the form. */
main form.stack > button { align-self: flex-start; }
.auth-body form.stack > button { align-self: stretch; }

.badge { display: inline-flex; align-items: center; font: 500 12px var(--mono); padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.warn { color: var(--warn); background: var(--warn-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.badge.muted-badge { color: var(--muted); background: transparent; border: 1px solid var(--border-strong); }
.badge.scope { margin-right: 4px; }
.notice { padding: 12px 16px; border-radius: 12px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(253, 186, 116, .25); }
.notice.ok { background: var(--ok-bg); color: var(--ok); border-color: rgba(184, 243, 91, .25); }
.notice.bad { background: var(--bad-bg); color: var(--bad); border-color: rgba(255, 138, 128, .25); }
.notice button { margin-left: 6px; }
.error { color: var(--bad); font-size: 14px; min-height: 1.2em; }

.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 6px 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: top; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
th { font: 500 11.5px var(--mono); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
td.host { min-width: 13rem; }
.record-value, .secret { display: block; background: var(--code-bg); border: 1px solid var(--border); padding: 8px 10px; border-radius: 8px; word-break: break-all; font-family: var(--mono); font-size: 13px; color: var(--text); }
code.big, .record-value.big { font-size: 16px; padding: 8px 12px; color: var(--lime); }
.codes { font-family: var(--mono); columns: 2; margin: 12px 0; }
.qr { display: block; margin: 8px 0 16px; border-radius: 12px; background: #fff; padding: 8px; }
.small { font-size: 13px; }
.small-text { font-size: 12px; word-break: break-all; }
pre.code { background: #07080b; border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; overflow-x: auto; font: 12.5px/1.7 var(--mono); color: var(--text-2); }
ul.rules { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-direction: column; gap: 6px; }
.inbox-card { border-color: #3b4a1e; }
.inbox-card h2 { margin-top: 0; }
h2.flush { margin: 0; }

/* parsers */
table.fields input[type=text], table.fields select { width: 100%; min-width: 0; }
table.fields .rule-pattern, table.fields .rule-end { flex: 1 1 8rem; }
table.fields.mode-rules .ai-only, table.fields.mode-ai .rules-only { display: none; }
table.fields td.rules-only select { width: auto; flex: 0 0 auto; }
table.fields td.rules-only .row { flex-wrap: nowrap; gap: 6px; }

/* billing */
.meter { margin: 16px 0; }
.meter .bar { height: 10px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 6px; }
.meter .bar span { display: block; height: 100%; border-radius: 999px; background: var(--ok); }
.meter .bar.high span { background: var(--warn); }
.meter .bar.full span { background: var(--bad); }
.toggle { margin: 8px 0 16px; gap: 8px; }
.plans { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.card.plan { display: flex; flex-direction: column; margin: 0; }
.card.plan h3 { margin: 0; font-size: 20px; }
.card.plan .price { font: 700 36px/1.1 var(--display); letter-spacing: -.04em; margin: 6px 0 10px; }
.card.plan ul { padding-left: 1.1rem; margin: 0 0 16px; color: var(--muted); font-size: 14px; flex: 1; }
.card.plan.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }

/* routing rules */
.condition { padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg-2); }
.condition select, .condition .c-header { flex: 0 1 auto; }
.condition .c-value { flex: 1; min-width: 160px; }
.rule-editor .target { border: 1px solid var(--border-strong); border-radius: 999px; padding: 6px 12px; }

/* ---------------------------------------------------------------- login, sign-up and other account screens */
.auth-layout { display: flex; flex-wrap: wrap; min-height: 100vh; }
.auth { flex: 1 1 520px; display: flex; flex-direction: column; gap: 24px; padding: 32px clamp(24px, 5vw, 72px); }
.auth-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font: 700 22px var(--display); letter-spacing: -.02em; align-self: flex-start; }
.auth-brand:hover { text-decoration: none; }
.auth-brand .brand-mark { margin: 0; font-size: 20px; }
.auth-body { flex: 1 1 auto; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 440px; padding: 24px 0; }
.auth-body h1 { font-size: clamp(34px, 4vw, 48px); margin-bottom: 20px; }
.auth-body h1 + p.muted { margin-top: -10px; }
.auth-body > p.muted { margin-bottom: 22px; }
.auth-body form.stack { gap: 16px; }
.auth-foot { margin: 0; max-width: 440px; }
.legal-links { margin: 0; font-size: 13px; }
.legal-links a { color: var(--muted); }
.captcha { min-height: 65px; }
.auth-aside { flex: 1 1 480px; position: relative; overflow: hidden; background: var(--accent); color: var(--accent-text); padding: clamp(32px, 5vw, 72px); display: flex; flex-direction: column; justify-content: center; gap: 28px; min-height: 100vh; }
.auth-aside > * { position: relative; }
.auth-aside .ghost-big { position: absolute; right: -120px; top: -100px; width: 520px; height: 520px; opacity: .14; }
.auth-aside h2 { font-size: clamp(34px, 4vw, 54px); line-height: 1.04; letter-spacing: -.035em; margin: 0; max-width: 520px; }
.aside-card { max-width: 480px; padding: 18px 20px; border-radius: 18px; background: #0a0b0f; color: #eceef3; display: flex; flex-direction: column; gap: 6px; }
.aside-card small { font: 12px var(--mono); color: #9aa1b2; letter-spacing: .06em; }
.aside-card strong { font: 500 17px var(--mono); color: #b8f35b; word-break: break-all; }
.aside-json { max-width: 480px; margin: 0; padding: 18px 20px; border-radius: 18px; background: rgba(10, 11, 15, .08); border: 1px solid rgba(10, 11, 15, .18); font: 13px/1.8 var(--mono); white-space: pre-wrap; color: inherit; }
.aside-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 22px; font-weight: 600; font-size: 15px; }
@media (max-width: 960px) { .auth-aside { display: none; } .auth { min-height: 100vh; } }

/* white-label: a reseller's logo and name */
.brand-mark { display: flex; align-items: center; gap: 8px; font-weight: 700; margin-bottom: 12px; color: var(--text); }
.brand-mark img { max-height: 32px; max-width: 140px; object-fit: contain; }
