/* tip — Concierge baseline + shared primitives.
   Tokens live in tokens.css. This file is intentionally lean: type,
   layout, buttons, chips, cards, AREA palette utilities. Pages add
   their own per-page CSS for unique layouts. */

@import url("tokens.css");

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

/* Type baseline */
h1, h2, h3, h4 { margin: 0 0 var(--s-5); font-weight: 700; letter-spacing: -.02em; line-height: 1.25; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
h4 { font-size: 13px; }
p  { margin: 0 0 var(--s-5); }
a  { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* Page container */
main.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--s-3) var(--s-9) var(--s-11);
}

/* ===== Shell — Concierge two-column grid =====
   layouts/base.html mounts .app whenever the viewer has a User and
   the page is NOT NoChrome (auth / take / security / privacy /
   report pages render document-first into <main class="page"> only).
   The sidebar partial (partials/sidebar.html) branches on .Scope and
   carries the workspace identity card + hierarchical sub-nav + member
   footer. The topbar carries breadcrumbs + the org-switcher popover.

   Two body classes carry orthogonal context:
     - body.platform        — viewer holds a platform role (used by
                              .btn--primary below; pre-PR semantic).
     - body.scope-platform  — current PAGE is in /platform scope (used
                              by sidebar / sb-mark / eyebrow tinting).
   Don't gate scope-driven shell tinting on body.platform — a platform
   admin viewing an /app/ page would mis-tint the app sidebar + eyebrows. */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.sidebar {
  padding: var(--s-6) var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-7);
  border-right: 1px solid var(--rule);
  /* Pin nav + user footer to the viewport. Without these the grid
     cell stretches to .app's full content height (often well past
     100vh on audit / roster / cms pages) and the sb-bottom user
     card disappears below the fold. align-self: start opts out of
     the grid's default stretch so position: sticky has a smaller
     element to pin; overflow-y handles the rare case where the
     sidebar's own contents exceed the viewport. */
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}
body.scope-platform .sidebar { background: var(--platform-tint); }
.sb-brand { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-3); }
.sb-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--ink); color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; letter-spacing: -.02em;
  position: relative;
}
.sb-mark::after {
  content: ""; position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
body.scope-platform .sb-mark::after { background: var(--platform); }
.sb-wordmark { font-size: 18px; font-weight: 700; letter-spacing: -.025em; }
.sb-org {
  background: var(--surface); border-radius: var(--radius);
  padding: var(--s-4); display: flex; align-items: center; gap: var(--s-4);
  box-shadow: var(--shadow-card);
}
.sb-org-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, var(--dim-r-tint), var(--dim-e-tint));
  border: 1px solid var(--rule);
  display: grid; place-items: center;
  color: var(--dim-r); font-weight: 700; font-size: 13px;
}
.sb-org-text { flex: 1; min-width: 0; }
.sb-org-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sb-org-mode { font-size: 11px; color: var(--ink-3); margin-top: 1px; }
.sb-section {
  font-size: 11px; font-weight: 600; color: var(--ink-3);
  letter-spacing: .04em; text-transform: uppercase;
  padding: 0 var(--s-3); margin-bottom: var(--s-3);
}
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-link {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; color: var(--ink-2);
  text-decoration: none;
}
.sb-link:hover { background: var(--paper-2); color: var(--ink); text-decoration: none; }
.sb-link.is-active {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-card);
}
.sb-link.is-active .sb-link-icon { color: var(--accent); }
body.scope-platform .sb-link.is-active .sb-link-icon { color: var(--platform); }
.sb-link-icon {
  display: grid; place-items: center;
  width: 16px; height: 16px; color: var(--ink-3);
}
.sb-link-icon svg { width: 16px; height: 16px; }
.sb-link-count {
  margin-left: auto; font-family: var(--mono); font-size: 11px;
  padding: 1px 7px; border-radius: 999px;
  background: var(--paper-2); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.sb-link.is-active .sb-link-count { background: var(--accent-tint); color: var(--accent-ink); }
.sb-bottom { margin-top: auto; display: flex; flex-direction: column; gap: var(--s-3); }
.sb-user {
  display: grid; grid-template-columns: 32px 1fr; align-items: center; gap: var(--s-4);
  padding: var(--s-3) var(--s-4); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-card);
}
.sb-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--dim-e), var(--dim-r));
  color: #fff; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.sb-user-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.sb-user-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.sb-user-email { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Topbar — breadcrumbs left, org-switcher right */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 64px; padding: 0 var(--s-9); gap: var(--s-6);
}
.crumbs {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: 13px; color: var(--ink-3);
}
.crumbs a { color: var(--ink-3); }
.crumbs a:hover { color: var(--ink); text-decoration: none; }
.crumbs .sep { color: var(--ink-4); }
.crumbs .now { color: var(--ink); font-weight: 600; }
.crumbs .eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-3);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin-right: var(--s-3);
}
body.scope-platform .crumbs .eyebrow { color: var(--platform); }
.icon-btn {
  width: 40px; height: 40px;
  background: var(--surface); border: 0; border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: grid; place-items: center;
  color: var(--ink-2); cursor: pointer;
}

/* Page head — eyebrow + title + sub, used at the top of each page's content */
.page-head {
  display: flex; align-items: end; justify-content: space-between;
  padding-bottom: var(--s-7); border-bottom: 1px solid var(--rule);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-3);
  font-size: 12px; font-weight: 600; color: var(--accent);
  margin-bottom: var(--s-4);
}
.eyebrow::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
body.scope-platform .eyebrow { color: var(--platform); }
body.scope-platform .eyebrow::before { background: var(--platform); }
.page-title { font-size: 32px; font-weight: 700; letter-spacing: -.025em; line-height: 1.05; }
.page-sub { margin-top: var(--s-4); font-size: 13px; color: var(--ink-3); }

/* Card primitive */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: var(--s-7);
}
.card-title { font-size: 14px; font-weight: 700; margin-bottom: var(--s-5); }
.card-sub   { font-size: 12px; color: var(--ink-3); margin-bottom: var(--s-5); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 36px; padding: 0 var(--s-6);
  font: inherit; font-size: 13px; font-weight: 600;
  background: var(--surface); color: var(--ink);
  border: 0; border-radius: var(--radius-sm);
  cursor: pointer; box-shadow: var(--shadow-card);
  text-decoration: none;
}
.btn:hover { background: var(--paper); text-decoration: none; }
.btn--primary { background: var(--accent); color: #fff; box-shadow: 0 1px 0 rgba(20,20,30,.06), 0 1px 2px rgba(50,30,150,.20); }
.btn--primary:hover { background: var(--accent-ink); }
body.platform .btn--primary { background: var(--platform); }
body.platform .btn--primary:hover { background: var(--ink); }
.btn--ghost { background: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--paper-2); color: var(--ink); }
.btn--danger { color: var(--rubric-red); }
.btn--danger:hover { background: var(--bad-tint); }
.btn--sm { height: 28px; padding: 0 var(--s-5); font-size: 12px; }

/* Inputs */
.input, input[type=text], input[type=email], input[type=url],
input[type=password], select, textarea {
  width: 100%; height: 36px; padding: 0 var(--s-5);
  background: var(--surface); border: 0; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
  font: inherit; font-size: 13px; color: var(--ink); outline: none;
}
textarea { height: auto; min-height: 80px; padding: var(--s-4) var(--s-5); line-height: 1.5; }
.input:focus, input:focus, select:focus, textarea:focus {
  box-shadow: 0 0 0 3px var(--accent-tint), var(--shadow-card);
}
label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin: 0 0 var(--s-3); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 22px; padding: 0 var(--s-4);
  font-size: 11px; font-weight: 600;
  border-radius: 999px; background: var(--paper-2); color: var(--ink-2);
  white-space: nowrap;
}
.chip--ok      { background: var(--ok-tint);      color: oklch(36% .10 150); }
.chip--accent  { background: var(--accent-tint);  color: var(--accent-ink); }
.chip--warn    { background: var(--warn-tint);    color: oklch(42% .11 70); }
.chip--bad     { background: var(--bad-tint);     color: oklch(38% .13 25); }
.chip--neutral { background: var(--paper-2);      color: var(--ink-3); }
.chip--complete{ background: var(--dim-x-tint);   color: oklch(38% .10 160); }

/* Recommendation chips */
.rec {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 22px; padding: 0 var(--s-4);
  font-size: 11px; font-weight: 700;
  border-radius: 999px; white-space: nowrap;
}
.rec.r-strong { background: var(--rec-strong-t); color: var(--rec-strong); }
.rec.r-yes    { background: var(--rec-yes-t);    color: var(--rec-yes); }
.rec.r-maybe  { background: var(--rec-maybe-t);  color: var(--rec-maybe); }
.rec.r-no     { background: var(--rec-no-t);     color: var(--rec-no); }

/* AREA dimension tags */
.dim-tag {
  display: inline-flex; align-items: center; gap: var(--s-3);
  height: 20px; padding: 0 8px;
  font-size: 11px; font-weight: 600;
  border-radius: 999px;
}
.dim-tag.a { background: var(--dim-a-tint); color: oklch(38% .10 250); }
.dim-tag.r { background: var(--dim-r-tint); color: oklch(38% .10 295); }
.dim-tag.e { background: var(--dim-e-tint); color: oklch(38% .10 40); }
.dim-tag.x { background: var(--dim-x-tint); color: oklch(38% .10 160); }

/* Impersonation banner — canonical amber, ships above everything */
.impersonation-banner {
  background: linear-gradient(180deg, var(--impersonate) 0%, oklch(70% .13 70) 100%);
  color: var(--impersonate-ink);
  padding: var(--s-4) var(--s-8);
  display: flex; align-items: center; gap: var(--s-5);
  font-size: 13px; font-weight: 600;
  border-bottom: 1px solid var(--impersonate-ink);
}
.impersonation-banner .badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--impersonate-ink); color: var(--impersonate);
  font-family: var(--mono); font-size: 10px; font-weight: 700;
}
.impersonation-banner form { display: inline-flex; margin: 0; }
.impersonation-banner button {
  background: var(--impersonate-ink); color: var(--impersonate);
  border: 0; border-radius: var(--radius-sm);
  padding: var(--s-3) var(--s-5);
  font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer;
}
.impersonation-banner button:hover { opacity: .9; }

/* Tables */
table.data {
  width: 100%; border-collapse: collapse; margin: var(--s-6) 0;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); overflow: hidden;
}
table.data th, table.data td {
  text-align: left; padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--rule-soft); font-size: 13px;
}
table.data th {
  background: var(--paper-2); color: var(--ink-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em;
}
table.data tr:last-child td { border-bottom: 0; }

/* Status helpers */
.error   { color: var(--bad); }
.success { color: var(--ok); }
.muted   { color: var(--ink-3); }

/* KPI tile primitive */
.kpi {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-card); padding: var(--s-6) var(--s-7);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.kpi .label { font-size: 11px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: var(--mono); font-size: 32px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.kpi .delta { font-size: 11px; color: var(--ink-3); }
