/* Signed-in app (product register): one family, fixed rem scale, dense and
   predictable. Same tokens as the landing page; turmeric marks primary
   actions and the current place, never decoration. */
body { font-size: 1rem; line-height: 1.5; background: var(--paper); }
h1, h2, h3 { font-family: var(--font-body); letter-spacing: -0.01em; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
.muted { color: var(--ink-2); }
.small { font-size: 0.875rem; }
.mono { font-family: var(--font-mono); font-size: 0.875em; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }
.row-flex { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.row-flex.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* ---------- shell ---------- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.topbar .wrap { display: flex; align-items: center; gap: 1.25rem; min-height: 3.5rem; }
.topbar .brand { font: 800 1.25rem/1 var(--font-body); }
.topnav { display: flex; gap: 0.25rem; margin-left: 0.75rem; }
.topnav a { text-decoration: none; padding: 0.5rem 0.8rem; border-radius: 0.5rem; font-weight: 600; font-size: 0.95rem; color: var(--ink-2); }
.topnav a:hover { background: var(--paper-2); color: var(--ink); }
.topnav a[aria-current="page"] { background: var(--turmeric-soft); color: var(--ink); box-shadow: inset 0 -3px 0 var(--turmeric-deep); }
.who { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; font-size: 0.9rem; }
.who .name { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
@media (max-width: 40rem) {
  .topbar .wrap { flex-wrap: wrap; row-gap: 0; padding-top: 0.5rem; }
  .topnav { order: 3; width: 100%; margin: 0 -0.5rem; overflow-x: auto; padding-bottom: 0.4rem; }
  .who .name { display: none; }
}
main.wrap { padding-block: 2rem 4rem; max-width: 60rem; outline: none; }
.page-head { margin-bottom: 1.5rem; }
.page-head p { margin-top: 0.35rem; }
.crumb { display: inline-block; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--ink-2); text-decoration: none; font-weight: 600; }
.crumb:hover { color: var(--ink); text-decoration: underline; }

/* ---------- buttons (extend the shared pill) ---------- */
.btn { min-height: 2.5rem; padding: 0.5rem 1.1rem; font-size: 0.95rem; }
.btn-sm { min-height: 2rem; padding: 0.3rem 0.8rem; font-size: 0.85rem; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--surface); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink); }
.btn-ghost:hover { background: var(--paper-2); }
.btn[disabled] { cursor: not-allowed; }
.btn.loading { position: relative; color: transparent; pointer-events: none; }
.btn.loading::after { content: ""; position: absolute; width: 1rem; height: 1rem; border: 2px solid var(--paper); border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
.btn-outline.loading::after, .btn-turmeric.loading::after { border-color: var(--ink); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .btn.loading::after { animation-duration: 2s; } }

/* ---------- forms ---------- */
.field { display: grid; gap: 0.35rem; }
.field label, .label { font-weight: 600; font-size: 0.9rem; }
.field .hint { font-size: 0.85rem; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"], input[type="tel"], textarea, select {
  width: 100%; min-height: 2.6rem; padding: 0.55rem 0.8rem; font: inherit; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 0.6rem;
}
input:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid var(--turmeric-deep); outline-offset: 1px; border-color: var(--ink); }
input:disabled { background: var(--paper-2); color: var(--ink-2); }
input[aria-invalid="true"] { border-color: var(--danger); }
.form { display: grid; gap: 1.1rem; max-width: 30rem; }
.form-error { color: var(--danger); font-weight: 600; font-size: 0.92rem; min-height: 1.3em; }

/* ---------- surfaces ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.panel > h2 { margin-bottom: 0.9rem; }
.panel + .panel { margin-top: 1rem; }
.banner { border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 0.9rem 1.1rem; background: var(--paper-2); display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); }
.banner.danger { background: var(--danger-soft); border-color: var(--danger); }
.banner.ok { background: var(--leaf-soft); border-color: var(--leaf); }
.banner b { font-weight: 700; }
.banner + *, * + .banner { margin-top: 1rem; }

.badge { display: inline-flex; align-items: center; gap: 0.4rem; font: 600 0.8rem/1 var(--font-body); padding: 0.35rem 0.65rem; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }
.badge.ok { background: var(--leaf-soft); color: var(--leaf); }
.badge.wait { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--danger-soft); color: var(--danger); }

/* ---------- project list ---------- */
.list { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.list-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) auto; gap: 0.75rem 1.25rem; align-items: center; padding: 1rem 1.25rem; text-decoration: none; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--turmeric-soft); }
.list-row .title { font-weight: 700; }
.list-row .sub { font-size: 0.85rem; color: var(--ink-2); }
@media (max-width: 40rem) { .list-row { grid-template-columns: 1fr auto; } .list-row .num { display: none; } }
.empty { text-align: left; padding: 2rem 1.5rem; background: var(--surface); border: 1.5px dashed var(--line-strong); border-radius: var(--radius); }
.empty h2 { margin-bottom: 0.4rem; }
.empty p { max-width: 38rem; }
.empty ol { margin: 1rem 0 1.25rem; padding-left: 1.25rem; max-width: 38rem; }
.empty li + li { margin-top: 0.3rem; }
.skel { background: linear-gradient(90deg, var(--paper-2), var(--surface), var(--paper-2)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 0.5rem; height: 1rem; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }

/* ---------- tabs ---------- */
.tabbar { display: flex; gap: 0.25rem; border-bottom: 2px solid var(--line); margin: 1.25rem 0 1.5rem; overflow-x: auto; }
.tabbar a { text-decoration: none; padding: 0.7rem 1rem; font-weight: 600; color: var(--ink-2); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabbar a:hover { color: var(--ink); }
.tabbar a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--turmeric-deep); }

/* ---------- connect ---------- */
.connect { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.5rem 2rem; align-items: start; }
.qr { width: 15rem; height: 15rem; background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 0.6rem; }
.qr img { width: 100%; height: 100%; image-rendering: pixelated; }
.qr.empty-qr { display: grid; place-items: center; color: var(--ink-2); text-align: center; font-size: 0.9rem; padding: 1rem; }
.steps-ol { margin: 0; padding-left: 1.25rem; }
.steps-ol li + li { margin-top: 0.4rem; }
@media (max-width: 40rem) { .connect { grid-template-columns: 1fr; } .qr { width: min(100%, 16rem); height: auto; aspect-ratio: 1; } }

/* ---------- key/value + code ---------- */
.kv { display: grid; grid-template-columns: 9rem minmax(0, 1fr) auto; gap: 0.5rem 1rem; align-items: center; padding: 0.7rem 0; border-top: 1px solid var(--line); }
.kv:first-of-type { border-top: 0; }
.kv dt { color: var(--ink-2); font-size: 0.9rem; font-weight: 600; margin: 0; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
dl.kvs { margin: 0; }
@media (max-width: 40rem) { .kv { grid-template-columns: 1fr auto; } .kv dt { grid-column: 1 / -1; } }
pre.code-block { margin: 0; background: var(--code-bg); color: var(--code-fg); padding: 1rem 1.15rem; border-radius: 0.6rem; overflow-x: auto; font-size: 0.83rem; line-height: 1.65; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.4rem; }
.lang-tabs { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 0.6rem; }
.lang-tabs button { font: 600 0.85rem var(--font-body); padding: 0.4rem 0.8rem; border-radius: 0.5rem; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; color: var(--ink); }
.lang-tabs button:hover { background: var(--paper-2); }
.lang-tabs button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
table.ref { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.ref th, table.ref td { text-align: left; padding: 0.6rem 0.75rem; border-top: 1px solid var(--line); vertical-align: top; }
table.ref th { font-size: 0.8rem; color: var(--ink-2); border-top: 0; }
.tbl-wrap { overflow-x: auto; }

/* ---------- logs ---------- */
.logs { list-style: none; margin: 0; padding: 0; }
.logs li { display: grid; grid-template-columns: 12.5rem minmax(0, 1fr); gap: 0.25rem 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
.logs li:first-child { border-top: 0; }
.logs time { color: var(--ink-2); font-family: var(--font-mono); font-size: 0.8rem; }
@media (max-width: 40rem) { .logs li { grid-template-columns: 1fr; } }

/* ---------- plans ---------- */
.plan-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.plan-opt { background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: var(--radius); padding: 1.15rem; display: flex; flex-direction: column; gap: 0.5rem; }
.plan-opt.current { border-color: var(--ink); background: var(--turmeric-soft); }
.plan-opt .price { font: 800 1.4rem/1.1 var(--font-body); }
.plan-opt .btn { margin-top: auto; }
.plan-durations { display: flex; flex-direction: column; gap: 0.5rem; margin-top: auto; }
.plan-durations .btn { margin-top: 0; }
@media (max-width: 44rem) { .plan-grid { grid-template-columns: 1fr; } }
.meter { height: 0.6rem; background: var(--paper-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; background: var(--turmeric-deep); }
.meter.full > i { background: var(--danger); }

/* ---------- auth screen ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-side { background: var(--turmeric); color: var(--on-turmeric); padding: clamp(1.5rem, 5vw, 3.5rem); display: flex; flex-direction: column; gap: 2rem; }
.auth-side .brand { font: 800 1.5rem/1 var(--font-body); }
.auth-side h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; max-width: 14ch; margin-top: auto; }
.auth-side ul { margin: 0; padding-left: 1.1rem; max-width: 26rem; color: var(--on-turmeric-2); }
.auth-side li + li { margin-top: 0.35rem; }
.auth-main { padding: clamp(1.5rem, 5vw, 3.5rem); display: flex; flex-direction: column; justify-content: center; }
.auth-main .form { width: 100%; max-width: 24rem; }
.auth-main h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 1.25rem; }
.auth-alt { margin-top: 1.25rem; font-size: 0.95rem; }
@media (max-width: 52rem) { .auth { grid-template-columns: 1fr; } .auth-side { padding-bottom: 2rem; } .auth-side h1 { margin-top: 0; } }

/* ---------- toast ---------- */
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem); background: var(--ink); color: var(--paper); padding: 0.7rem 1.1rem; border-radius: 0.6rem; font-weight: 600; font-size: 0.92rem; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s var(--ease-out); z-index: 30; max-width: min(90vw, 28rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- operator console ---------- */
.badge.role { background: var(--ink); color: var(--paper); margin-left: -0.5rem; }
.badge.role::before { background: var(--turmeric); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-bottom: 1rem; }
.toolbar input[type="search"] { flex: 1 1 14rem; max-width: 24rem; }
input[type="search"] { width: 100%; min-height: 2.6rem; padding: 0.55rem 0.8rem; font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 0.6rem; }
input[type="number"] { min-height: 2.4rem; padding: 0.4rem 0.6rem; font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line-strong); border-radius: 0.6rem; }
select { min-height: 2.4rem; }
.chips { display: flex; gap: 0.25rem; }
.chips button { font: 600 0.85rem var(--font-body); padding: 0.45rem 0.9rem; border-radius: 999px; border: 1.5px solid var(--line-strong); background: var(--surface); cursor: pointer; color: var(--ink); }
.chips button:hover { background: var(--paper-2); }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.attn > h2 { margin-bottom: 0.6rem; display: flex; align-items: center; gap: 0.5rem; }
.count { font: 700 0.78rem/1 var(--font-body); background: var(--turmeric); color: var(--on-turmeric); padding: 0.25rem 0.55rem; border-radius: 999px; }
.list-row.cust { grid-template-columns: minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr) auto; }
.list-row.req { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.5fr) auto; align-items: start; }
.list-row .title { color: var(--ink); }
a.title { text-decoration: none; font-weight: 700; }
a.title:hover { text-decoration: underline; }
@media (max-width: 52rem) { .list-row.cust, .list-row.req { grid-template-columns: 1fr auto; } .list-row.cust .num { display: none; } .list-row.req > :last-child { grid-column: 1 / -1; } }
.stack-lg > .empty { margin-top: 0; }

/* A list inside a panel would be a card inside a card: drop its own frame. */
.panel .list { border: 0; border-radius: 0; background: transparent; }
.panel .list-row { padding-inline: 0; }
.panel .list-row:first-child { padding-top: 0.25rem; }
a.list-row:hover { background: var(--turmeric-soft); }
.list-row > .badge { justify-self: start; }
@media (max-width: 40rem) { .logs li { grid-template-columns: 1fr; } }

/* ---------- invoice ---------- */
.invoice-issuer { margin-bottom: 0.9rem; }
.invoice-timeline { margin-top: 1.25rem; }
.invoice-timeline > p { margin-bottom: 0.4rem; }

/* window.print() on the invoice page: browser's own "Save as PDF" printer
   destination is the PDF export, no client-side PDF library needed. Hide
   everything but the invoice panel itself. */
@media print {
  .topbar, .toast, .crumb, #invoice-actions { display: none !important; }
  main.wrap { padding: 0; max-width: none; }
  #invoice-print { border: none; padding: 0; }
}
