/* ============================================================
   Base: reset, typography, shared primitives, header, footer,
   buttons, forms. Everything styled through tokens.css.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}

/* ---------- primitives ---------- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }
/* App shell: header and content share this so the two stay aligned. */
.wrap.wide { max-width: var(--maxw-app); }

.eyebrow {
  font-family: var(--mono); font-size: var(--fs-eyebrow);
  letter-spacing: .16em; text-transform: uppercase; color: var(--muted); margin: 0;
}
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

h1, h2, h3 { text-wrap: balance; letter-spacing: -0.02em; line-height: 1.08; margin: 0; }
h1 { font-size: var(--fs-h1); font-weight: 680; letter-spacing: -0.03em; }
h2 { font-size: var(--fs-h2); font-weight: 660; }
h3 { font-size: var(--fs-h3); font-weight: 620; line-height: 1.25; }
p  { margin: 0; }

a { color: inherit; text-decoration: none; }
a.link { color: var(--accent); }
a.link:hover { color: var(--accent-2); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  font-family: var(--sans); font-size: var(--fs-small); font-weight: 560;
  padding: .68rem 1.15rem; border-radius: 8px;
  border: 1px solid transparent; cursor: pointer; text-align: center;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink-2); background: var(--surface); }
.btn-block { width: 100%; }
.btn .arw { transition: transform .18s ease; }
.btn:hover .arw { transform: translateX(3px); }

/* ---------- theme toggle ---------- */
.theme-toggle {
  display: inline-grid; place-items: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line-2); background: transparent; color: var(--muted);
  cursor: pointer; transition: color .18s, border-color .18s; flex: none;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-2); }
.theme-toggle svg { width: 16px; height: 16px; }

/* ---------- brand ---------- */
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 640; letter-spacing: -0.02em; color: var(--ink); white-space: nowrap; flex: none; }
.brand .glyph { width: 20px; height: 20px; border-radius: 5px; background: var(--accent); position: relative; flex: none; }
.brand .glyph::after { content: ""; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--on-accent); top: 6px; right: 6px; }

/* ---------- header ---------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; align-items: center; gap: 2rem; height: 66px; }
.nav .links { display: flex; gap: 1.6rem; margin-left: .5rem; }
.nav .links a { font-size: var(--fs-small); color: var(--muted); }
.nav .links a:hover { color: var(--ink); }
.nav .spacer { flex: 1; }
.nav .right { display: flex; align-items: center; gap: 1rem; }
.nav .right .navlink { font-size: var(--fs-small); color: var(--ink-2); }
.nav .right .navlink:hover { color: var(--ink); }
.nav .logout { background: none; border: none; padding: 0; cursor: pointer; font: inherit; }

/* ---------- app header (signed-in shell): top bar + section tabs ---------- */
.app-top { display: flex; align-items: center; gap: 1rem; height: 58px; }
.app-top .spacer { flex: 1 1 auto; min-width: .5rem; }
.app-top .who {
  font-size: var(--fs-small); color: var(--ink-2); font-weight: 540;
  max-width: 32ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-top .theme-toggle { flex: none; }
.btn-sm { padding: .42rem .85rem; font-size: var(--fs-micro); flex: none; }

/* section tab bar (Catalogs · Price Lists · Bids) — sits on the header's bottom border */
.app-subnav-wrap { border-top: 1px solid var(--line); }
.app-subnav { display: flex; align-items: stretch; gap: 1.9rem; height: 46px; overflow-x: auto; scrollbar-width: none; }
.app-subnav::-webkit-scrollbar { display: none; }
.app-subnav .tab {
  position: relative; display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap;
  font-size: var(--fs-small); font-weight: 540; color: var(--muted);
  transition: color .16s ease;
}
.app-subnav a.tab:hover { color: var(--ink); }
.app-subnav .tab.active { color: var(--ink); font-weight: 600; }
.app-subnav .tab::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0;
}
.app-subnav .tab.active::after { opacity: 1; }
.app-subnav .tab.disabled { color: var(--faint); cursor: default; }
.app-subnav .soon {
  font-family: var(--mono); font-size: .58rem; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--faint);
}

@media (max-width: 560px) { .app-top .who { display: none; } }

/* ---------- footer ---------- */
footer.site { border-top: 1px solid var(--line); padding-block: 3rem 2.5rem; margin-top: auto; }
.foot-grid { display: grid; grid-template-columns: 1.6fr repeat(3, 1fr); gap: 2rem; }
.foot-brand .brand { margin-bottom: .9rem; }
.foot-brand p { color: var(--muted); font-size: var(--fs-small); max-width: 30ch; }
.foot-col h4 { font-family: var(--mono); font-size: var(--fs-eyebrow); letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin: 0 0 .9rem; font-weight: 600; }
.foot-col a { display: block; color: var(--muted); font-size: var(--fs-small); padding: .25rem 0; }
.foot-col a:hover { color: var(--ink); }
.foot-base { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-top: 2.5rem; padding-top: 1.4rem; border-top: 1px solid var(--line); }
.foot-base .cp { font-family: var(--mono); font-size: var(--fs-micro); color: var(--faint); letter-spacing: .04em; }

/* ---------- forms ---------- */
.field { display: grid; gap: .4rem; margin-bottom: 1.1rem; }
.field label { font-size: var(--fs-small); font-weight: 540; color: var(--ink-2); }
.field input {
  font-family: var(--sans); font-size: var(--fs-body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  padding: .7rem .8rem; width: 100%;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.field input::placeholder { color: var(--faint); }
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .hint { font-size: var(--fs-micro); color: var(--muted); }

.form-ok {
  font-size: var(--fs-small); color: var(--good);
  background: color-mix(in srgb, var(--good) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--good) 30%, transparent);
  border-radius: 8px; padding: .65rem .8rem; margin-top: 1rem;
}
.form-error {
  font-size: var(--fs-small); color: var(--alert);
  background: color-mix(in srgb, var(--alert) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--alert) 30%, transparent);
  border-radius: 8px; padding: .65rem .8rem; margin-bottom: 1.1rem;
}

/* ---------- reveal animation ---------- */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .7s cubic-bezier(.2,.7,.2,1), transform .7s cubic-bezier(.2,.7,.2,1); }
.reveal.in { opacity: 1; transform: none; }

@media (max-width: 900px) {
  .nav .links { display: none; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .foot-grid { grid-template-columns: 1fr; gap: 1.6rem; }
}
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  * { scroll-behavior: auto !important; }
}
