/* ─────────────────────────────────────────────────────────────────────────
   QPayroll.app design system — deep emerald & gold on warm paper.
   Serves the public site, auth screens, and the three portal shells.
   ───────────────────────────────────────────────────────────────────────── */

:root {
  --ink: #10241d;
  --ink-soft: #47594f;
  --ink-faint: #7d8c82;
  --paper: #faf8f3;
  --surface: #ffffff;
  --line: #e4e0d5;
  --emerald: #0d3b2e;
  --emerald-deep: #092b21;
  --emerald-soft: #eaf2ee;
  --gold: #c9a24b;
  --gold-deep: #a8813a;
  --gold-soft: #f7efdd;
  --red: #b3372e;
  --red-soft: #fbebe9;
  --green: #1c7a4c;
  --green-soft: #e8f5ee;
  --amber: #9c6d1e;
  --amber-soft: #fcf3e2;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 36, 29, .06), 0 8px 24px rgba(16, 36, 29, .07);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--paper); line-height: 1.55; font-size: 15.5px; }
img { max-width: 100%; }
a { color: var(--emerald); }
h1, h2, h3, h4 { line-height: 1.18; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 3.4vw, 2.6rem); margin-bottom: .5rem; }
h2 { font-size: 1.45rem; margin-bottom: .6rem; }
h3 { font-size: 1.05rem; margin-bottom: .35rem; }
code { font-family: var(--mono); font-size: .88em; background: var(--emerald-soft); padding: .1em .4em; border-radius: 5px; }
.muted { color: var(--ink-faint); }
.lede { font-size: 1.08rem; color: var(--ink-soft); max-width: 62ch; margin-bottom: 1.6rem; }
.eyebrow { display: inline-block; text-transform: uppercase; letter-spacing: .14em; font-size: .72rem;
  font-weight: 700; color: var(--gold-deep); margin-bottom: .6rem; }

.container { width: min(1160px, 100% - 2.5rem); margin-inline: auto; }
.container--narrow { width: min(720px, 100% - 2.5rem); }

/* Brand wordmark */
.brand-logo { font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
.brand-logo-tld { color: var(--gold); font-weight: 600; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  border: 1px solid transparent; border-radius: var(--radius); cursor: pointer;
  font: inherit; font-weight: 600; text-decoration: none; padding: .55rem 1.1rem;
  transition: background .15s, border-color .15s, color .15s; }
.btn--primary { background: var(--emerald); color: #fff; }
.btn--primary:hover { background: var(--emerald-deep); }
.btn--gold { background: var(--gold); color: var(--emerald-deep); }
.btn--gold:hover { background: var(--gold-deep); color: #fff; }
.btn--ghost { background: transparent; color: var(--emerald); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--emerald); }
.btn--danger { background: var(--red); color: #fff; }
.btn--sm { padding: .3rem .7rem; font-size: .85rem; }
.btn--lg { padding: .75rem 1.5rem; font-size: 1.02rem; }
.btn--block { width: 100%; }

/* ── Forms ───────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 1rem; }
.field > span { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .55rem .75rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
.input--code { font-family: var(--mono); font-size: 1.4rem; letter-spacing: .35em; text-align: center; }

/* ── Alerts, pills ───────────────────────────────────────────────────── */
.alert { border-radius: var(--radius); padding: .7rem 1rem; margin: .8rem 0; border: 1px solid; }
.alert--success { background: var(--green-soft); color: var(--green); border-color: #bfe3cf; }
.alert--error { background: var(--red-soft); color: var(--red); border-color: #eec7c3; }
.alert--warn { background: var(--amber-soft); color: var(--amber); border-color: #efd9ae; }
.pill { display: inline-block; border-radius: 999px; font-size: .74rem; font-weight: 700;
  padding: .12rem .6rem; text-transform: uppercase; letter-spacing: .04em;
  background: var(--emerald-soft); color: var(--emerald); }
.pill--active, .pill--paid, .pill--approved, .pill--converted, .pill--settled { background: var(--green-soft); color: var(--green); }
.pill--pending, .pill--pending_payment, .pill--trialing, .pill--lead, .pill--draft, .pill--sent { background: var(--amber-soft); color: var(--amber); }
.pill--lapsed, .pill--suspended, .pill--rejected, .pill--cancelled, .pill--revoked, .pill--expired, .pill--overdue, .pill--failed { background: var(--red-soft); color: var(--red); }
.pill--superseded, .pill--closed, .pill--deactivated { background: #eee9dd; color: var(--ink-faint); }

/* ── Cards, tables, stats ────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.card-head h2 { margin-bottom: 0; font-size: 1.12rem; }
.form-card { margin-top: 1rem; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-faint); padding: .5rem .7rem; border-bottom: 2px solid var(--line); white-space: nowrap; }
.table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:hover td { background: var(--emerald-soft); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .9rem; margin: 1rem 0 1.4rem; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: .95rem 1.1rem; display: flex; flex-direction: column; gap: .15rem; box-shadow: var(--shadow); }
.stat-card strong { font-size: 1.45rem; letter-spacing: -.02em; color: var(--emerald); }
.stat-card span { font-size: .82rem; color: var(--ink-faint); }

/* ── Public site ─────────────────────────────────────────────────────── */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.site-header-inner { display: flex; align-items: center; gap: 1.6rem; padding: .8rem 0; }
.site-brand { text-decoration: none; }
.site-nav { display: flex; gap: 1.1rem; margin-right: auto; }
.site-nav a { text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: .95rem; padding: .3rem 0; }
.site-nav a:hover, .site-nav a.active { color: var(--emerald); box-shadow: 0 2px 0 var(--gold); }
.site-actions { display: flex; gap: .6rem; }
.site-main { min-height: 60vh; }

.hero { background: linear-gradient(160deg, var(--emerald-deep) 0%, var(--emerald) 62%, #14523f 100%); color: #f2efe6; }
.hero-inner { display: grid; grid-template-columns: 1.25fr 1fr; gap: 3rem; align-items: center; padding: 4.2rem 0; }
.hero .eyebrow { color: var(--gold); }
.hero h1 { color: #fff; }
.hero p { color: #cfe0d7; margin: 1rem 0 1.6rem; max-width: 56ch; }
.hero-actions { display: flex; gap: .8rem; flex-wrap: wrap; }
.hero .btn--ghost { color: #f2efe6; border-color: rgba(255,255,255,.35); }
.hero .btn--ghost:hover { border-color: var(--gold); color: var(--gold); }
.hero-panel { display: grid; grid-template-columns: 1fr 1fr; gap: .9rem; }
.hero-panel .stat-card { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.14); box-shadow: none; }
.hero-panel .stat-card strong { color: var(--gold); font-size: 1.15rem; }
.hero-panel .stat-card span { color: #cfe0d7; }

.section { padding: 3.6rem 0; }
.section--alt { background: var(--surface); border-block: 1px solid var(--line); }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.1rem; margin-top: 1.4rem; }
.feature-grid--4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.feature { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.2rem 1.3rem; }
.section--alt .feature { background: var(--paper); }
.feature h3 { display: flex; align-items: center; gap: .5rem; color: var(--emerald); }
.feature p { color: var(--ink-soft); font-size: .93rem; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.6rem; align-items: start; }
.callout { background: var(--gold-soft); border: 1px solid #eadfc2; border-radius: var(--radius-lg);
  padding: 1.5rem 1.7rem; margin: 2rem 0 1rem; }
.edition-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.1rem; margin: 1.6rem 0 2.4rem; }
.edition-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 1.4rem 1.5rem; }
.edition-card--featured { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.edition-card ul { margin: .8rem 0 0 1.1rem; color: var(--ink-soft); font-size: .93rem; }
.edition-card li { margin-bottom: .35rem; }

.site-footer { background: var(--emerald-deep); color: #cfe0d7; padding: 2.6rem 0 1rem; margin-top: 3rem; }
.site-footer-inner { display: grid; grid-template-columns: 1.2fr 2fr; gap: 2rem; padding-bottom: 1.6rem; }
.footer-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.4rem; }
.footer-cols h4 { color: var(--gold); font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; margin-bottom: .6rem; }
.footer-cols a { display: block; color: #cfe0d7; text-decoration: none; font-size: .92rem; padding: .18rem 0; }
.footer-cols a:hover { color: #fff; }
.site-footer-legal { border-top: 1px solid rgba(255,255,255,.12); padding-top: 1rem; font-size: .82rem; color: #8fae9f; }
.error-page { text-align: center; padding: 5rem 0; }
.error-page h1 { font-size: 3.4rem; color: var(--emerald); }
.error-page p { margin: .6rem 0 1.6rem; color: var(--ink-soft); }

/* ── Auth shell ──────────────────────────────────────────────────────── */
.auth-body { background: var(--emerald-deep); min-height: 100vh; }
.auth-shell { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-hero { padding: 3.4rem 3.6rem; color: #e9e4d4; display: flex; flex-direction: column; gap: 1.1rem;
  background: linear-gradient(160deg, var(--emerald-deep) 0%, var(--emerald) 78%); }
.auth-hero a { text-decoration: none; }
.auth-hero h2 { color: #fff; font-size: clamp(1.6rem, 2.8vw, 2.3rem); margin-top: auto; }
.auth-hero p { color: #a9c4b7; margin-bottom: 3rem; }
.auth-card-col { background: var(--paper); display: flex; align-items: center; justify-content: center; padding: 2.4rem 1.4rem; }
.auth-card { width: min(430px, 100%); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 2rem 2.1rem; }
.auth-card h1 { font-size: 1.45rem; }
.auth-card > .muted { margin-bottom: 1.2rem; }
.auth-alt { margin-top: 1.1rem; font-size: .92rem; color: var(--ink-soft); }
.totp-setup { display: flex; gap: 1.1rem; align-items: center; margin: 1rem 0 1.2rem; }
.totp-qr { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.totp-manual { font-size: .85rem; display: flex; flex-direction: column; gap: .4rem; }
.totp-secret { word-break: break-all; }

/* ── App shell (admin / customer / partner) ──────────────────────────── */
.app-body { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: var(--paper); }
.sidebar { background: var(--emerald-deep); color: #cfe0d7; display: flex; flex-direction: column;
  padding: 1.1rem .9rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; flex-direction: column; gap: .2rem; padding: .2rem .55rem 1rem; }
.sidebar-brand a { text-decoration: none; }
.sidebar-realm { font-size: .68rem; text-transform: uppercase; letter-spacing: .16em; color: var(--gold); font-weight: 700; }
.sidebar-nav { display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.sidebar-link { display: flex; align-items: center; gap: .65rem; color: #b6cdc2; text-decoration: none;
  font-size: .93rem; font-weight: 600; padding: .5rem .65rem; border-radius: 8px; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.active { background: var(--gold); color: var(--emerald-deep); }
.sidebar-user { border-top: 1px solid rgba(255,255,255,.12); padding: .9rem .55rem 0; display: flex;
  flex-direction: column; gap: .25rem; }
.sidebar-user-name { font-weight: 700; color: #fff; font-size: .93rem; }
.sidebar-user-meta { font-size: .78rem; color: #8fae9f; margin-bottom: .5rem; }
.sidebar-user .btn--ghost { color: #cfe0d7; border-color: rgba(255,255,255,.25); }
.app-main { padding: 1.8rem 2.2rem; min-width: 0; }
.page-head { margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.55rem; }
.page-actions { display: flex; gap: .6rem; align-items: center; }
.page-head--row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.ref-link { display: inline-block; padding: .45rem .7rem; }

/* ── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .hero-inner, .split, .site-footer-inner { grid-template-columns: 1fr; }
  .auth-shell { grid-template-columns: 1fr; }
  .auth-hero { display: none; }
}
@media (max-width: 780px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: column; }
  .site-header-inner { flex-wrap: wrap; gap: .7rem; }
  .site-nav { order: 3; width: 100%; }
  .app-main { padding: 1.2rem 1rem; }
}
