/*
 * Yail.Shared.Web — yail-app-shell.css
 *
 * Shared chrome for every Yail.<Module> landing page. Independent of yail.css
 * (the DaisyUI bundle for admin chrome) — these landing pages use the warm
 * coffee/cream/amber YailOS marketing palette and Fraunces editorial type.
 * Each module's home Index.cshtml loads this with Layout = null and renders
 * its own custom hero art on top.
 *
 * Tokens duplicated from the design's colours.css so this file is self-contained
 * and can be loaded standalone.
 */

:root {
  /* Brand palette */
  --yail-coffee: #3D2A1A;
  --yail-amber: #A86D2C;
  --yail-cream: #F5EBD9;
  --yail-stone: #C9B895;
  --yail-mocha: #6B5B45;
  --yail-ink: #2B1D11;
  --yail-amber-light: #D4A56F;
  --yail-coffee-dark: #1A1209;

  /* Type */
  --yail-font-sans: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Shadows */
  --shadow-card: 0 1px 1px rgba(61,42,26,.04), 0 8px 28px rgba(61,42,26,.06);
  --shadow-card-soft: 0 1px 1px rgba(61,42,26,.03), 0 4px 14px rgba(61,42,26,.04);
  --font-display: "Fraunces", "Times New Roman", serif;
  --sidebar-w: 88px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--yail-font-sans);
  background: var(--yail-cream);
  color: var(--yail-ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: 0; background: transparent; }

/* ── Layout: sidebar + content ── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ── Sidebar (constellation pattern) ── */
.sidebar {
  position: sticky; top: 0; align-self: start;
  height: 100vh;
  padding: 22px 14px 22px;
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-right: 1px solid var(--yail-stone);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  z-index: 10;
}
.sidebar .home {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  border: 1px solid var(--yail-stone);
  background: #fff;
  box-shadow: var(--shadow-card-soft);
  transition: border-color .2s, transform .2s;
}
.sidebar .home img { width: 70%; height: 70%; }
.sidebar .home:hover { border-color: var(--yail-amber); transform: translateY(-1px); }

.sidebar .divider { width: 28px; height: 1px; background: var(--yail-stone); margin: 4px 0; }

.sidebar nav { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: 1; }

.s-app {
  position: relative;
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: transparent;
  padding: 9px;
  transition: background .2s, transform .2s;
}
.s-app img { width: 100%; height: 100%; }
.s-app:hover { background: #fff; box-shadow: var(--shadow-card-soft); transform: translateY(-1px); }
.s-app.on { background: #fff; box-shadow: var(--shadow-card-soft); }
.s-app.on::before {
  content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 22px; background: var(--yail-amber); border-radius: 0 3px 3px 0;
}

/* Floating tooltip on sidebar hover */
.s-app .tip {
  position: absolute; left: calc(100% + 12px); top: 50%; transform: translateY(-50%);
  background: var(--yail-coffee); color: var(--yail-cream);
  padding: 5px 10px; border-radius: 6px;
  font-size: 11.5px; white-space: nowrap;
  pointer-events: none; opacity: 0;
  transition: opacity .15s;
  z-index: 20;
  letter-spacing: .04em;
}
.s-app .tip::before {
  content: ""; position: absolute; right: 100%; top: 50%; transform: translateY(-50%);
  border: 4px solid transparent; border-right-color: var(--yail-coffee);
}
.s-app:hover .tip { opacity: 1; }

.sidebar .foot {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--yail-mocha); writing-mode: vertical-rl; transform: rotate(180deg);
  margin-top: 8px;
}

/* ── Content column ── */
.content { min-width: 0; padding: 28px 48px 80px; max-width: 1320px; }

/* ── Top bar (within content) ── */
.topbar {
  display: flex; gap: 12px; align-items: center;
  padding-bottom: 18px;
  margin-bottom: 12px;
}
.crumb { flex: 1 1 0%; display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--yail-mocha); min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.acct-name {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--yail-mocha); letter-spacing: .04em;
  padding: 6px 12px; border: 1px solid var(--yail-stone); border-radius: 999px; background: #fff;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none;
  transition: border-color .15s, color .15s;
}
a.acct-name:hover { border-color: var(--yail-coffee); color: var(--yail-coffee); }
.acct-name .who-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yail-amber); flex-shrink: 0; }
.acct-form { display: inline; margin: 0; padding: 0; }
.crumb a { color: var(--yail-mocha); }
.crumb a:hover { color: var(--yail-coffee); }
.crumb .sep { opacity: .4; }
.crumb .current { color: var(--yail-coffee); font-weight: 600; }

.pill-status {
  display: inline-flex; gap: 8px; align-items: center;
  font-size: 11.5px; color: var(--yail-mocha); letter-spacing: .04em;
  padding: 6px 12px; border: 1px solid var(--yail-stone); border-radius: 999px; background: #fff;
}
.pill-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #6b8a3f; }
.pill-status.beta .dot { background: var(--yail-amber); }

/* Active-organisation chip — rendered in the topbar by _YailAuthControls when the user's
   principal carries an org_slug claim. Higher-contrast than the surrounding pills so the
   organisation the user is currently signed in *to* is always obvious. Picks up the
   brand-kit's primary colour when one is in scope (set inline on <html> by the brand-kit
   overlay), otherwise falls back to the editorial amber. */
.org-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600; letter-spacing: -.01em;
  padding: 6px 14px 6px 10px; border-radius: 999px;
  background: var(--yail-ink); color: var(--yail-cream);
  text-decoration: none;
  max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: background .15s;
}
a.org-chip:hover { background: var(--yail-coffee); }
.org-chip .org-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-primary, var(--yail-amber));
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(255,255,255,.18);
}
.org-chip .org-label {
  font-size: 9.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase;
  opacity: .65;
}

/* Platform org-switcher — the chip becomes a dropdown for PlatformAdmin/PlatformSupport operators
   so they can view any portfolio organisation. The "viewing" variant flips to amber so it's obvious
   when an operator is impersonating a portfolio org rather than seeing their own. */
.org-switch { position: relative; display: inline-block; }
.org-switch > summary { list-style: none; cursor: pointer; }
.org-switch > summary::-webkit-details-marker { display: none; }
.org-switch .org-caret { margin-left: 1px; opacity: .7; flex-shrink: 0; }
.org-chip.viewing { background: var(--yail-amber); color: var(--yail-ink); }
.org-chip.viewing .org-dot { background: var(--yail-ink); box-shadow: 0 0 0 2px rgba(0,0,0,.12); }
.org-switch-panel {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 60;
  width: 320px; max-width: 86vw;
  background: #fff; border: 1px solid var(--yail-stone); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(40,30,20,.16); padding: 8px;
}
.org-switch-home {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 9px; text-decoration: none;
  font-size: 12.5px; font-weight: 600; color: var(--yail-coffee);
  background: var(--yail-cream); border: 1px solid var(--yail-stone);
}
.org-switch-home:hover { border-color: var(--yail-coffee); }
.org-switch-home .org-up { font-weight: 700; }
.org-switch-search { padding: 8px 2px 4px; }
.org-switch-search input {
  width: 100%; box-sizing: border-box; padding: 8px 12px; border-radius: 9px;
  border: 1px solid var(--yail-stone); font-size: 13px; background: #fff; color: var(--yail-ink);
}
.org-switch-search input:focus { outline: none; border-color: var(--yail-coffee); }
.org-switch-results { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; }
.org-switch-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--yail-ink);
}
.org-switch-item:hover { background: var(--yail-cream); }
.org-switch-item .oi-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--color-primary, var(--yail-amber)); flex-shrink: 0; }
.org-switch-item .oi-name { font-size: 13px; font-weight: 500; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-switch-item .oi-slug { font-size: 11px; color: var(--yail-mocha); opacity: .8; flex-shrink: 0; }
.org-switch-hint { margin: 6px 4px 2px; font-size: 11.5px; color: var(--yail-mocha); }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; line-height: 1;
  background: #fff;
  color: var(--yail-coffee);
  border: 1px solid var(--yail-stone);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.btn:hover { transform: translateY(-1px); border-color: var(--yail-coffee); }
.btn-primary { background: var(--yail-coffee); color: var(--yail-cream); border-color: var(--yail-coffee); }
.btn-primary:hover { background: var(--yail-ink); border-color: var(--yail-ink); color: var(--yail-cream); }
.btn-amber { background: var(--yail-amber); color: #fff; border-color: var(--yail-amber); }
.btn-amber:hover { background: #8d5821; border-color: #8d5821; color: #fff; }
.btn-ghost { background: transparent; color: var(--yail-coffee); border-color: var(--yail-stone); }
.btn-ghost:hover { border-color: var(--yail-coffee); }

/* ── Hero (each app supplies its own .hero-art) ── */
.hero {
  display: grid;
  grid-template-columns: 1fr 1.05fr;
  gap: 56px;
  align-items: center;
  padding: 56px 0 48px;
  border-bottom: 1px solid var(--yail-stone);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 10px;
  font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--yail-amber); margin: 0 0 22px;
}
.hero-eyebrow .icn { width: 22px; height: 22px; }
.hero-eyebrow .slug { color: var(--yail-mocha); font-family: ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .04em; text-transform: none; font-weight: 500; font-size: 12px; }
.hero-eyebrow::before { content: ""; width: 28px; height: 1px; background: var(--yail-amber); }

.hero-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(48px, 5.6vw, 84px);
  line-height: .95;
  letter-spacing: -.03em;
  margin: 0;
  color: var(--yail-ink);
}
.hero-title em { font-style: italic; font-weight: 400; color: var(--yail-coffee); }
.hero-title .dot { color: var(--yail-amber); font-style: normal; }

.hero-sub {
  margin: 24px 0 0; color: var(--yail-mocha);
  font-size: 17px; line-height: 1.55; max-width: 52ch; text-wrap: pretty;
}
.hero-actions { display: flex; gap: 12px; align-items: center; margin-top: 32px; flex-wrap: wrap; }
.hero-actions .meta { font-size: 12px; color: var(--yail-mocha); margin-left: 4px; }

.hero-art {
  position: relative;
  aspect-ratio: 5 / 4;
  background: #fff;
  border: 1px solid var(--yail-stone);
  border-radius: 18px;
  box-shadow: var(--shadow-card);
  padding: 24px;
  overflow: hidden;
}

/* ── Section header ── */
.section { margin-top: 72px; }
.section-h {
  display: grid; grid-template-columns: auto 1fr auto;
  gap: 24px; align-items: baseline; margin-bottom: 22px;
  padding-bottom: 14px; border-bottom: 1px solid var(--yail-stone);
}
.section-num { font-size: 11px; color: var(--yail-amber); letter-spacing: .22em; font-weight: 600; }
.section-t { font-size: 24px; font-weight: 600; letter-spacing: -.02em; margin: 0; color: var(--yail-ink); }
.section-t em { font-family: var(--font-display); font-style: italic; font-weight: 500; color: var(--yail-coffee); }
.section-d { font-size: 12.5px; color: var(--yail-mocha); justify-self: end; max-width: 42ch; text-align: right; }

/* ── Cards ── */
.card {
  background: #fff; border: 1px solid var(--yail-stone);
  border-radius: 14px; padding: 22px; box-shadow: var(--shadow-card-soft);
}
.card h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; letter-spacing: .04em; color: var(--yail-coffee); }
.card .pd { font-size: 11.5px; color: var(--yail-mocha); margin: 0 0 14px; letter-spacing: .04em; }

/* KPI tile (empty-state friendly) */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.kpi {
  background: #fff; border: 1px solid var(--yail-stone);
  border-radius: 14px; padding: 18px 20px; min-height: 96px;
  display: grid; gap: 6px;
}
.kpi .l { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--yail-mocha); }
.kpi .v { font-size: 28px; font-weight: 600; letter-spacing: -.02em; color: var(--yail-coffee); line-height: 1; font-feature-settings: "tnum"; }
.kpi .v.empty { color: var(--yail-stone); font-family: var(--font-display); font-style: italic; font-weight: 400; }
.kpi .h { font-size: 11px; color: var(--yail-mocha); }

/* Empty state pattern */
.empty-state {
  text-align: center; padding: 48px 24px;
  background: #fff; border: 1px dashed var(--yail-stone);
  border-radius: 14px;
  margin-top: 14px;
}
.empty-state .ic {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--yail-cream); border: 1px solid var(--yail-stone);
  display: inline-flex; align-items: center; justify-content: center; padding: 14px;
  margin-bottom: 14px;
}
.empty-state .ic img { width: 100%; height: 100%; }
.empty-state h5 { margin: 0 0 6px; font-size: 16px; font-weight: 600; color: var(--yail-ink); }
.empty-state h5 em { font-family: var(--font-display); font-style: italic; font-weight: 400; color: var(--yail-coffee); }
.empty-state p { margin: 0 auto 16px; font-size: 13px; color: var(--yail-mocha); max-width: 44ch; line-height: 1.55; }
.empty-state .actions { display: inline-flex; gap: 8px; }

/* Onboarding checklist */
.checklist { display: grid; gap: 8px; }
.check {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 12px; align-items: center;
  padding: 14px 16px; background: #fff; border: 1px solid var(--yail-stone); border-radius: 12px;
}
.check.done { background: var(--yail-cream); border-color: var(--yail-stone); }
.check .box {
  width: 20px; height: 20px; border-radius: 6px; border: 1.5px solid var(--yail-stone);
  display: flex; align-items: center; justify-content: center; color: transparent;
}
.check.done .box { background: var(--yail-coffee); border-color: var(--yail-coffee); color: var(--yail-cream); }
.check.done .box::after { content: "✓"; font-size: 12px; font-weight: 700; }
.check .ttl { font-size: 13.5px; font-weight: 500; color: var(--yail-ink); }
.check.done .ttl { color: var(--yail-mocha); text-decoration: line-through; }
.check .sub { font-size: 12px; color: var(--yail-mocha); margin-top: 2px; }
.check .cta { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--yail-coffee); }
.check .cta::after { content: " →"; color: var(--yail-amber); }

/* Tabs / pills */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--yail-stone); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: 13px; font-weight: 500; color: var(--yail-mocha); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--yail-coffee); }
.tab.active { color: var(--yail-coffee); border-bottom-color: var(--yail-amber); font-weight: 600; }
.tabs-pill { display: inline-flex; padding: 4px; background: #fff; border: 1px solid var(--yail-stone); border-radius: 999px; gap: 2px; }
.tab-pill { padding: 7px 14px; font-size: 12.5px; font-weight: 500; color: var(--yail-mocha); border-radius: 999px; cursor: pointer; }
.tab-pill.active { background: var(--yail-coffee); color: var(--yail-cream); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; letter-spacing: .08em; padding: 3px 8px;
  border-radius: 999px; font-weight: 600;
  border: 1px solid;
}
.badge .d { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.b-coffee { color: var(--yail-coffee); border-color: var(--yail-stone); background: #fff; }
.b-amber { color: var(--yail-amber); border-color: rgba(168,109,44,.3); background: rgba(168,109,44,.1); }
.b-success { color: #5F7A3A; border-color: rgba(95,122,58,.3); background: rgba(95,122,58,.1); }
.b-warn { color: #8B5E1F; border-color: rgba(139,94,31,.3); background: rgba(212,165,111,.18); }
.b-mocha { color: var(--yail-mocha); border-color: var(--yail-stone); background: var(--yail-cream); }

/* Two-col content section */
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

/* Footer */
.app-foot {
  margin-top: 80px; padding-top: 22px; border-top: 1px solid var(--yail-stone);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 11.5px; color: var(--yail-mocha); letter-spacing: .04em;
}
.app-foot .links { display: flex; gap: 22px; }
.app-foot .links a:hover { color: var(--yail-coffee); }

/* Code chip */
.code-chip { display: inline-block; padding: 2px 8px; background: var(--yail-cream); border: 1px solid var(--yail-stone); border-radius: 4px; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--yail-coffee); }

/* Small helpers */
.row-3 { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--yail-mocha); }

/* ── Admin / Platform primitives ── */
/* Sub-rail (second nav column for platform & org sections) */
.subnav {
  position: sticky; top: 28px;
  display: grid; gap: 2px; align-content: start;
  padding: 18px 14px;
  background: rgba(255,255,255,.66);
  backdrop-filter: blur(8px);
  border: 1px solid var(--yail-stone);
  border-radius: 14px;
  box-shadow: var(--shadow-card-soft);
  font-size: 13px;
}
.subnav .group { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--yail-mocha); padding: 14px 10px 6px; font-weight: 600; }
.subnav .group:first-child { padding-top: 4px; }
.subnav a {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 10px; border-radius: 8px;
  color: var(--yail-coffee); font-weight: 500;
  transition: background .15s, color .15s;
}
.subnav a:hover { background: var(--yail-cream); }
.subnav a .ic { width: 22px; height: 22px; display: flex; align-items: center; justify-content: center; color: var(--yail-mocha); }
.subnav a .ic svg { width: 16px; height: 16px; }
.subnav a .count { font-family: ui-monospace, monospace; font-size: 10.5px; color: var(--yail-mocha); padding: 1px 6px; border-radius: 4px; background: var(--yail-cream); border: 1px solid var(--yail-stone); }
.subnav a.on { background: var(--yail-coffee); color: var(--yail-cream); }
.subnav a.on .ic { color: var(--yail-cream); }
.subnav a.on .count { background: rgba(245,235,217,.18); border-color: rgba(245,235,217,.25); color: var(--yail-cream); }

/* Layout: sub-rail + main */
.with-sub { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
.with-sub > *:nth-child(2) { display: flex; flex-direction: column; gap: 24px; min-width: 0; }

/* Page header (admin pages — sits above content) */
.ph {
  display: grid; grid-template-columns: 1fr auto; gap: 24px; align-items: end;
  padding-bottom: 22px; margin-bottom: 22px;
  border-bottom: 1px solid var(--yail-stone);
}
.ph .eyebrow { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--yail-amber); font-weight: 600; margin: 0 0 8px; }
.ph h1 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 44px; letter-spacing: -.025em; line-height: 1; color: var(--yail-ink); }
.ph h1 em { font-style: italic; font-weight: 400; color: var(--yail-coffee); }
.ph .ph-sub { margin: 10px 0 0; color: var(--yail-mocha); font-size: 14px; max-width: 60ch; }
.ph .ph-actions { display: flex; gap: 10px; align-items: center; }

/* Filter / toolbar row */
.toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .grow { flex: 1; }
.toolbar .lbl { font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase; color: var(--yail-mocha); margin-right: 4px; }
.search-input {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--yail-stone);
  border-radius: 999px; padding: 7px 14px;
  width: 320px; max-width: 100%;
}
.search-input input { border: 0; outline: 0; background: transparent; font: inherit; font-size: 13px; color: var(--yail-ink); flex: 1; }
.search-input input::placeholder { color: var(--yail-mocha); }
.search-input svg { color: var(--yail-mocha); flex-shrink: 0; }
.filter-pill {
  background: #fff; border: 1px solid var(--yail-stone);
  color: var(--yail-mocha);
  padding: 7px 14px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  transition: color .15s, border-color .15s, background .15s;
  cursor: pointer;
}
.filter-pill:hover { color: var(--yail-coffee); border-color: var(--yail-coffee); }
.filter-pill.on { background: var(--yail-coffee); border-color: var(--yail-coffee); color: var(--yail-cream); }
.filter-pill .count { opacity: .7; margin-left: 4px; font-family: ui-monospace, monospace; font-size: 11px; }

/* Data table — editorial with subtle dividers */
.data-table {
  width: 100%;
  background: #fff;
  border: 1px solid var(--yail-stone);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-card-soft);
}
.data-table table { width: 100%; border-collapse: collapse; }
.data-table thead th {
  text-align: left;
  padding: 12px 18px;
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  font-weight: 600; color: var(--yail-mocha);
  background: var(--yail-cream);
  border-bottom: 1px solid var(--yail-stone);
}
.data-table tbody td {
  padding: 16px 18px;
  font-size: 13px; color: var(--yail-ink);
  border-bottom: 1px solid var(--yail-stone);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: rgba(168,109,44,.04); }
.data-table tbody td > a:not(.btn):not(.code-chip) {
  color: var(--yail-coffee);
  font-weight: 600;
  border-bottom: 1px dotted color-mix(in oklab, var(--yail-coffee), transparent 60%);
  transition: color .15s, border-color .15s;
}
.data-table tbody td > a:not(.btn):not(.code-chip):hover {
  color: var(--yail-ink);
  border-bottom-color: var(--yail-coffee);
}
.data-table .strong { font-weight: 600; color: var(--yail-coffee); }
.data-table .meta-row { display: flex; gap: 4px; align-items: center; flex-direction: column; align-items: flex-start; }
.data-table .meta-row .ttl { font-weight: 600; color: var(--yail-coffee); font-size: 13px; }
.data-table .meta-row .sub { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--yail-mocha); }
.data-table .num { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-feature-settings: "tnum"; }
.data-table .ts { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11.5px; color: var(--yail-mocha); }
.data-table .row-actions { display: inline-flex; gap: 6px; }
.data-table .row-actions a { font-size: 11.5px; letter-spacing: .04em; color: var(--yail-mocha); padding: 3px 8px; border-radius: 6px; }
.data-table .row-actions a:hover { color: var(--yail-coffee); background: var(--yail-cream); }

/* Avatar bubble */
.avatar { width: 30px; height: 30px; border-radius: 50%; background: linear-gradient(135deg, var(--yail-amber-light), var(--yail-amber)); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 11.5px; letter-spacing: .04em; flex-shrink: 0; }
.avatar.coffee { background: linear-gradient(135deg, var(--yail-coffee), var(--yail-mocha)); }
.avatar.green  { background: linear-gradient(135deg, #6b8a3f, #506b30); }
.avatar.stone  { background: linear-gradient(135deg, var(--yail-stone), var(--yail-mocha)); }
.avatar-cell { display: flex; gap: 12px; align-items: center; }

/* App chip — small inline app reference */
.app-chip { display: inline-flex; gap: 8px; align-items: center; padding: 4px 10px 4px 4px; border-radius: 999px; background: var(--yail-cream); border: 1px solid var(--yail-stone); font-size: 12px; color: var(--yail-coffee); font-weight: 500; }
.app-chip img { width: 18px; height: 18px; }

/* Detail header (used on org/product detail pages) */
.detail-head {
  display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center;
  padding: 22px 24px; background: #fff;
  border: 1px solid var(--yail-stone); border-radius: 16px;
  box-shadow: var(--shadow-card-soft);
  margin-bottom: 22px;
}
.detail-head .mark { width: 64px; height: 64px; border-radius: 16px; background: var(--yail-cream); border: 1px solid var(--yail-stone); display: flex; align-items: center; justify-content: center; padding: 12px; font-family: var(--font-display); font-style: italic; font-size: 28px; color: var(--yail-coffee); font-weight: 500; }
.detail-head .name { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 28px; letter-spacing: -.02em; color: var(--yail-ink); }
.detail-head .name em { font-style: italic; font-weight: 400; }
.detail-head .meta { font-size: 12px; color: var(--yail-mocha); margin-top: 4px; display: flex; gap: 14px; }
.detail-head .meta .code-chip { font-size: 11px; }

/* Property panel — key/value rail used on detail pages across modules.
   Promoted from yail-crm-shell.css so DealRoom / Membership / Tasks / ForgeAhead
   share the same primitive without each module re-declaring it. */
.props { background: #fff; border: 1px solid var(--yail-stone); border-radius: 14px; box-shadow: var(--shadow-card-soft); overflow: hidden; }
.props-h { padding: 14px 18px 10px; border-bottom: 1px solid var(--yail-cream); display: flex; justify-content: space-between; align-items: baseline; }
.props-h h4 { margin: 0; font-size: 12.5px; font-weight: 600; color: var(--yail-coffee); letter-spacing: .04em; }
.props-h .edit { font-size: 11px; color: var(--yail-mocha); }
.props-row { display: grid; grid-template-columns: 110px 1fr; padding: 8px 18px; align-items: center; gap: 12px; border-bottom: 1px solid var(--yail-cream); font-size: 13px; }
.props-row:last-child { border-bottom: 0; }
.props-row .k { font-size: 11.5px; color: var(--yail-mocha); letter-spacing: .04em; text-transform: uppercase; font-weight: 500; }
.props-row .v { color: var(--yail-ink); display: flex; align-items: center; gap: 6px; min-height: 22px; }
.props-row .v code { font-family: ui-monospace, monospace; font-size: 12px; color: var(--yail-coffee); }
.props-row .v .empty { color: var(--yail-stone); font-style: italic; }

/* DL pairs (key-value lists) */
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 8px 18px; margin: 0; }
dl.kv dt { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--yail-mocha); padding-top: 2px; }
dl.kv dd { margin: 0; font-size: 13.5px; color: var(--yail-ink); }
dl.kv dd code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; color: var(--yail-coffee); }

/* Timeline (for audit log + activity feeds) */
.timeline { display: grid; gap: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 18px; top: 8px; bottom: 8px; width: 1px; background: var(--yail-stone); }
.tl {
  display: grid; grid-template-columns: 36px 1fr auto; gap: 16px; align-items: start;
  padding: 14px 0;
  position: relative;
}
.tl .ic {
  width: 36px; height: 36px; border-radius: 50%; background: #fff; border: 1px solid var(--yail-stone);
  display: flex; align-items: center; justify-content: center; padding: 8px;
  z-index: 1;
}
.tl .ic img { width: 100%; height: 100%; }
.tl .ic.amber { background: rgba(168,109,44,.1); border-color: rgba(168,109,44,.4); color: var(--yail-amber); }
.tl .ic.coffee { background: var(--yail-coffee); border-color: var(--yail-coffee); color: var(--yail-cream); }
.tl .body .ttl { font-size: 13.5px; color: var(--yail-ink); }
.tl .body .ttl b { color: var(--yail-coffee); font-weight: 600; }
.tl .body .sub { font-size: 11.5px; color: var(--yail-mocha); margin-top: 4px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.tl .when { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--yail-mocha); white-space: nowrap; padding-top: 8px; }

/* Stat strip (page-header KPI row) */
.stat-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--yail-stone); border: 1px solid var(--yail-stone); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-card-soft); margin-bottom: 22px; }
.stat-strip .s { background: #fff; padding: 16px 22px; }
.stat-strip .s .l { font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: var(--yail-mocha); margin-bottom: 6px; }
.stat-strip .s .v { font-family: var(--font-display); font-weight: 500; font-size: 32px; color: var(--yail-coffee); line-height: 1; letter-spacing: -.02em; font-feature-settings: "tnum"; }
.stat-strip .s .v small { font-family: var(--yail-font-sans); font-weight: 400; font-size: 13px; color: var(--yail-mocha); margin-left: 4px; letter-spacing: 0; }
.stat-strip .s .h { font-size: 11px; color: var(--yail-mocha); margin-top: 6px; }
.stat-strip .s .h .up { color: #5F7A3A; font-weight: 600; }
.stat-strip .s .h .down { color: #9b3e2a; font-weight: 600; }

/* Sub-tabs (pill style) */
.subtabs { display: inline-flex; padding: 4px; background: #fff; border: 1px solid var(--yail-stone); border-radius: 999px; gap: 2px; }
.subtabs a { padding: 7px 16px; font-size: 12.5px; font-weight: 500; color: var(--yail-mocha); border-radius: 999px; }
.subtabs a:hover { color: var(--yail-coffee); }
.subtabs a.on { background: var(--yail-coffee); color: var(--yail-cream); }

/* Pagination */
.pagination { display: flex; gap: 4px; justify-content: space-between; margin-top: 18px; align-items: center; font-size: 12px; color: var(--yail-mocha); }
.pagination .pages { display: flex; gap: 4px; }
.pagination .pages a { padding: 6px 11px; border-radius: 8px; border: 1px solid var(--yail-stone); background: #fff; font-size: 12px; color: var(--yail-coffee); }
.pagination .pages a.on { background: var(--yail-coffee); color: var(--yail-cream); border-color: var(--yail-coffee); }
.pagination .pages a:hover:not(.on) { border-color: var(--yail-coffee); }

/* Status badge variants used by admin tables */
.b-green { color: #5F7A3A; border-color: rgba(95,122,58,.3); background: rgba(95,122,58,.1); }
.b-stone { color: var(--yail-mocha); border-color: var(--yail-stone); background: var(--yail-cream); }

/* ── Forms (admin/CRM editorial form primitives) ── */
.form-card {
  background: #fff;
  border: 1px solid var(--yail-stone);
  border-radius: 14px;
  box-shadow: var(--shadow-card-soft);
  padding: 28px;
}
.form-card ~ .form-card { margin-top: 24px; }
.form-card + .data-table,
.form-card + .empty-state,
.data-table + .form-card,
.data-table + .data-table { margin-top: 18px; }
.form-card-h {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  margin: 0 0 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--yail-stone);
}
.form-card-h h3 { margin: 0; font-size: 16px; font-weight: 600; color: var(--yail-coffee); letter-spacing: -.01em; }
.form-card-h h3 em { font-family: var(--font-display); font-style: italic; font-weight: 500; }
.form-card-h .desc { font-size: 12.5px; color: var(--yail-mocha); }

.form-grid { display: grid; gap: 18px; max-width: 720px; }
.form-grid.wide { max-width: 100%; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; max-width: 100%; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); max-width: 100%; }
.form-grid .span-all { grid-column: 1 / -1; }

.form-row { display: grid; gap: 6px; }
.form-row > label,
.form-label {
  font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 600; color: var(--yail-mocha);
}
.form-row > label .req { color: var(--yail-amber); margin-left: 2px; }

.input,
input.input,
select.input,
textarea.input {
  width: 100%;
  padding: 10px 14px;
  background: #fff;
  border: 1px solid var(--yail-stone);
  border-radius: 10px;
  font: inherit;
  font-size: 13.5px;
  color: var(--yail-ink);
  transition: border-color .15s, box-shadow .15s, background .15s;
  outline: 0;
}
textarea.input { min-height: 120px; resize: vertical; line-height: 1.55; }
.input:focus,
input.input:focus,
select.input:focus,
textarea.input:focus {
  border-color: var(--yail-coffee);
  box-shadow: 0 0 0 3px rgba(168,109,44,.15);
}
.input::placeholder { color: var(--yail-mocha); opacity: .7; }
.input:disabled, .input[readonly] { background: var(--yail-cream); color: var(--yail-mocha); }
.input.has-error { border-color: #9b3e2a; box-shadow: 0 0 0 3px rgba(155,62,42,.12); }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none' stroke='%236B5B45' stroke-width='1.6'><polyline points='1,1.5 6,6.5 11,1.5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-help { font-size: 12px; color: var(--yail-mocha); line-height: 1.5; }
.form-error { font-size: 12px; color: #9b3e2a; font-weight: 500; }
.form-error:empty { display: none; }

/* Inline checkbox / radio rows */
.check-row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 12px;
  background: #fff;
  border: 1px solid var(--yail-stone);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.check-row:hover { border-color: var(--yail-coffee); }
.check-row input[type=checkbox],
.check-row input[type=radio] { margin-top: 2px; accent-color: var(--yail-coffee); }
.check-row .lbl { font-size: 13px; color: var(--yail-ink); font-weight: 500; }
.check-row .sub { display: block; font-size: 11.5px; color: var(--yail-mocha); margin-top: 2px; font-weight: 400; }
.check-row.on { background: var(--yail-cream); border-color: var(--yail-coffee); }

/* Sticky-ish action bar at bottom of forms */
.form-actions {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--yail-stone);
}
.form-actions .grow { flex: 1; }
.form-actions .danger {
  background: transparent; color: #9b3e2a; border: 1px solid rgba(155,62,42,.4);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 500;
}
.form-actions .danger:hover { background: rgba(155,62,42,.08); border-color: #9b3e2a; }

/* Validation summary block (server-side ModelState) */
.form-summary {
  background: rgba(155,62,42,.08);
  border: 1px solid rgba(155,62,42,.3);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 18px;
  color: #9b3e2a;
}
.form-summary h4 { margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .04em; }
.form-summary ul { margin: 0; padding-left: 18px; font-size: 12.5px; }
.form-summary li { line-height: 1.5; }
/* asp-validation-summary still emits the div when ModelState is valid — hide the empty box. */
.form-summary.validation-summary-valid { display: none; }
.form-summary:empty { display: none; }

/* Lightweight section divider inside a form-card */
.form-divider {
  margin: 22px 0;
  border: 0; border-top: 1px solid var(--yail-stone);
}

/* Read-only key/value rows in detail-style edit pages */
.kv-static {
  display: grid; grid-template-columns: 160px 1fr; gap: 8px 18px;
  padding: 10px 14px; background: var(--yail-cream); border: 1px solid var(--yail-stone);
  border-radius: 10px;
}
.kv-static dt { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--yail-mocha); }
.kv-static dd { margin: 0; font-size: 13.5px; color: var(--yail-coffee); font-family: ui-monospace, "SF Mono", Menlo, monospace; }

/* TempData flash messages used across admin */
.flash {
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 18px;
  font-size: 13px;
  border: 1px solid;
}
.flash.success { color: #5F7A3A; border-color: rgba(95,122,58,.3); background: rgba(95,122,58,.08); }
.flash.error { color: #9b3e2a; border-color: rgba(155,62,42,.3); background: rgba(155,62,42,.08); }
.flash.info { color: var(--yail-coffee); border-color: var(--yail-stone); background: var(--yail-cream); }

@media (max-width: 760px) {
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .form-card { padding: 18px; }
  dl.kv-static { grid-template-columns: 1fr; }
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .hero { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col, .three-col { grid-template-columns: 1fr; }
  .with-sub { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  :root { --sidebar-w: 64px; }
  .content { padding: 20px 20px 60px; }
  .sidebar { padding: 16px 8px; }
  .sidebar .home, .s-app { width: 40px; height: 40px; padding: 7px; }
  .section-h { grid-template-columns: 1fr; }
  .section-d { text-align: left; justify-self: start; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Async tiles (HTMX-driven, hx-trigger="load") ──
   Pages render a skeleton placeholder; HTMX swaps in the real tile fragment
   once the controller action returns. Skeleton matches the shape of the final
   tile so layout doesn't shift on swap. Shimmer is drawn via a ::before
   pseudo-element so it always sits on top of whatever container background
   (.s, .card, .insight) the placeholder is composed with — sidesteps the
   specificity fight with `.stat-strip .s { background: #fff }` etc. */
.yail-tile-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 12px;
  min-height: 64px;
}
.yail-tile-skeleton::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(201,184,149,.28) 0%,
    rgba(201,184,149,.55) 50%,
    rgba(201,184,149,.28) 100%);
  background-size: 200% 100%;
  animation: yail-tile-shimmer 1.4s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}
.yail-tile-skeleton .sk-line {
  position: relative;
  z-index: 1;
  height: 10px;
  background: rgba(255,255,255,.7);
  border-radius: 4px;
  margin: 10px 14px;
  width: 40%;
}
.yail-tile-skeleton .sk-line.big { height: 20px; width: 30%; }
.yail-tile-skeleton .sk-line.wide { width: 70%; }
@keyframes yail-tile-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .yail-tile-skeleton::before { animation: none; }
}

/* HTMX request states — fade the placeholder slightly during an in-flight
   reload (post-initial-load refresh). */
.yail-tile-skeleton.htmx-request { opacity: .85; }

/* Error variant — when a tile action throws the controller returns a fragment
   with .yail-tile-error in the same outer shape so the grid doesn't break. */
.yail-tile-error {
  border: 1px dashed rgba(168,38,38,.4);
  background: rgba(251,228,224,.4);
  border-radius: 12px;
  padding: 14px 16px;
  color: #6b2424;
  font-size: 12.5px;
  line-height: 1.5;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.yail-tile-error .yte-title {
  font-weight: 600;
  margin: 0 0 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #a82626;
}
.yail-tile-error .yte-msg { margin: 0; }
.yail-tile-error .yte-retry {
  margin-top: 8px;
  display: inline-block;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--yail-coffee);
  cursor: pointer;
  align-self: flex-start;
}

/* Wizard launcher gallery (_YailWizardLauncher). Kept here (always-loaded) rather than in
   yail-wizard.css so the gallery renders styled on module dashboards / org hubs that don't
   pull the in-wizard stylesheet. */
.wiz-launch { margin: 8px 0 24px; }
.wiz-launch-h { font-size: 15px; font-weight: 600; color: #2b2622; margin: 0 0 12px; }
.wiz-launch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.wiz-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid #e2dccf;
  border-radius: 12px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.wiz-card:hover {
  border-color: #c9bda6;
  box-shadow: 0 4px 14px rgba(111, 78, 55, 0.10);
  transform: translateY(-1px);
}
.wiz-card-t { font-weight: 600; font-size: 15px; color: #2b2622; }
.wiz-card-s { font-size: 13px; color: #6b6358; line-height: 1.45; }
.wiz-card-go { margin-top: 8px; font-size: 13px; font-weight: 600; color: #6f4e37; }
