html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem #fff, 0 0 0 0.25rem #d4a94f;
}

html {
  position: relative;
  min-height: 100%;
}

body {
  margin-bottom: 60px;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}
/* Links take the brand color instead of Bootstrap blue; footer links stay quiet. */
.app-shell, .auth-page { --bs-link-color-rgb: 110,37,48; --bs-link-hover-color-rgb: 92,30,40; }
.app-content footer a { color: var(--muted); }

/* ---- Brand button: one place for the burgundy primary ---- */
.app-shell .btn-primary, .auth-card .btn-primary { --bs-btn-bg: #6e2530; --bs-btn-border-color: #6e2530; --bs-btn-hover-bg: #7d2b38; --bs-btn-hover-border-color: #7d2b38; --bs-btn-active-bg: #5c1e28; --bs-btn-active-border-color: #5c1e28; }

/* ---- App shell: floating burgundy sidebar ---- */
body { margin-bottom: 0; }
.app-shell {
  --bg: #fafafa; --line: #e8e8e9; --text: #171717; --muted: #737373;
  --sb: #6e2530; --sb-text: #ecd9d0; --sb-muted: #c79a8f; --brass: #d4a94f;
  --sb-hover: rgba(255,255,255,.08); --sb-active: rgba(212,169,79,.24);
  display: grid; grid-template-columns: 272px 1fr; height: 100vh; height: 100dvh; padding: 12px; gap: 4px;
  background: var(--bg); color: var(--text);
}
.app-shell aside {
  background: var(--sb); color: var(--sb-text); border-radius: 20px; padding: 16px 12px 12px;
  display: flex; flex-direction: column; overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.12), inset 0 0 0 1px rgba(212,169,79,.4);
}
.app-shell .i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.app-shell .brand { display: flex; align-items: center; gap: 8px; padding: 4px 12px 16px; color: #fff; font-weight: 600; font-size: 16px; text-decoration: none; }
.app-shell .brand i { width: 22px; height: 22px; background: url(/icon-brass.svg) center/contain no-repeat; }
.app-shell .nl { display: flex; align-items: center; gap: 12px; height: 36px; padding: 0 12px; border-radius: 8px; color: var(--sb-text); text-decoration: none; white-space: nowrap; transition: background-color 150ms ease-out; }
.app-shell .nl:hover { background: var(--sb-hover); color: var(--sb-text); }
.app-shell .nl[aria-current=page] { background: var(--sb-active); color: #fff; }
.app-shell .um { position: relative; margin-top: auto; padding-top: 12px; }
.app-shell .me { display: flex; align-items: center; gap: 12px; width: 100%; padding: 8px; border: 0; border-radius: 12px; background: var(--sb-hover); color: inherit; text-align: left; transition: background-color 150ms ease-out; }
.app-shell .me:hover { background: var(--sb-active); }
.app-shell .av { width: 28px; height: 28px; border-radius: 50%; background: var(--brass); color: #171717; display: grid; place-items: center; font-size: 11px; font-weight: 600; flex: none; }
.app-shell .meb { min-width: 0; overflow: hidden; line-height: 1.3; }
.app-shell .meb b { display: block; color: #fff; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-shell .meb small { color: var(--sb-muted); }
.app-shell .um-menu { position: absolute; left: 0; right: 0; bottom: calc(100% - 2px); padding: 6px; background: #ffffff; color: var(--text); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 32px rgba(0,0,0,.25);
  opacity: 0; visibility: hidden; pointer-events: none; transform: scale(.96); transform-origin: bottom left; transition: opacity 150ms ease-out, transform 150ms ease-out, visibility 0s 150ms; }
.app-shell .um[data-open] .um-menu { opacity: 1; visibility: visible; pointer-events: auto; transform: none; transition: opacity 150ms ease-out, transform 150ms ease-out; }
.app-shell .mi { display: block; width: 100%; height: 34px; padding: 0 10px; border: 0; border-radius: 8px; background: none; text-align: left; color: inherit; }
.app-shell a.mi { line-height: 34px; text-decoration: none; }
.app-shell .mi:hover { background: #f4f4f5; }
.app-shell .app-main { min-width: 0; height: 100%; display: flex; flex-direction: column; }
.app-shell .app-content { flex: 1; overflow: auto; display: flex; flex-direction: column; padding: 0 clamp(8px, 2vw, 32px); } /* top and bottom edges line up with the floating sidebar */
.app-shell .app-content > * { flex-shrink: 0; }
.app-shell .app-content footer { margin-top: auto; }
.app-shell .app-top, .app-shell .app-scrim { display: none; }
.app-shell :focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }

@media (max-width: 800px) {
  .app-shell { grid-template-columns: 1fr; padding: 0; }
  .app-shell .app-content { padding: 24px 16px 16px; }
  .app-shell .app-top { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 12px; background: #ffffff; border-bottom: 1px solid var(--line); }
  .app-shell .menu-btn { display: grid; place-items: center; height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--text); }
  .app-shell aside { position: fixed; inset: 8px auto 8px 8px; width: 264px; z-index: 30; transform: translateX(calc(-100% - 8px)); visibility: hidden; transition: transform 220ms cubic-bezier(.23,1,.32,1), visibility 0s 220ms; }
  .app-shell[data-open] aside { transform: none; visibility: visible; transition: transform 220ms cubic-bezier(.23,1,.32,1); }
  .app-shell .app-scrim { display: block; position: fixed; inset: 0; z-index: 25; background: rgba(0,0,0,.35); opacity: 0; pointer-events: none; transition: opacity 200ms ease-out; }
  .app-shell[data-open] .app-scrim { opacity: 1; pointer-events: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell .um-menu { transform: none; }
  @media (max-width: 800px) {
    .app-shell aside { transform: none; opacity: 0; visibility: hidden; transition: opacity 150ms ease-out, visibility 0s 150ms; }
    .app-shell[data-open] aside { opacity: 1; visibility: visible; transition: opacity 150ms ease-out; }
  }
}

/* ---- Login: standalone card, no app shell ---- */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: #fafafa; color: #171717; }
.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; background: #ffffff; border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08), inset 0 0 0 1px rgba(212,169,79,.45); animation: auth-rise 220ms cubic-bezier(.23,1,.32,1); }
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; font-weight: 600; font-size: 18px; }
.auth-brand i { width: 34px; height: 34px; background: url(/icon.svg) center/contain no-repeat; }
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card .sub { margin: 0 0 24px; color: #737373; font-size: 14px; }
.auth-card .form-control { height: 42px; border-radius: 10px; }
.auth-card .form-control:focus { border-color: #d4a94f; box-shadow: 0 0 0 2px #d4a94f; }
.auth-card .btn-primary { width: 100%; height: 42px; border-radius: 10px; font-weight: 600; }
.auth-card .btn-primary:focus-visible { box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #d4a94f; }
.auth-card .hint { margin: 16px 0 0; font-size: 13px; color: #737373; text-align: center; }
@keyframes auth-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .auth-card { animation: none; } }

/* ---- Home ---- */
.home-hero { background: #ffffff; padding: 24px; border-radius: 20px; box-shadow: inset 0 0 0 1px rgba(212,169,79,.5); }
.home-hero h1 { color: var(--sb); font-size: 28px; overflow-wrap: anywhere; }
.home-hero p { margin: 0 0 16px; color: var(--muted); }
.home-hero .go { display: inline-block; padding: 8px 16px; border-radius: 10px; background: var(--brass); color: #171717; font-weight: 600; text-decoration: none; transition: background-color 150ms ease-out; }
.home-hero .go:hover { background: #dcb560; color: #171717; }
.home-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 1.5fr); gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .home-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.home-stat { display: flex; flex-direction: column; gap: 4px; padding: 20px; background: #fff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); color: var(--text); text-decoration: none; transition: box-shadow 150ms ease-out; }
a.home-stat:hover { box-shadow: inset 0 0 0 1px var(--brass); color: var(--text); }
.home-stat small { color: var(--muted); font-size: 13px; }
.home-stat b { font-size: 32px; font-weight: 500; line-height: 1.1; font-variant-numeric: tabular-nums; }
.home-stat span { color: var(--muted); font-size: 13px; }
.home-stat.warn b { color: #b3261e; }
.home-empty { margin: 0; padding: 24px; background: #fff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.home-h { margin: 24px 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }

/* ---- Account ---- */
.acct-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.acct-head h1 { margin: 0; font-size: 26px; overflow-wrap: anywhere; }
.acct-head p { margin: 0; color: var(--muted); }
.acct-av { width: 56px; height: 56px; border-radius: 50%; background: var(--brass); color: #171717; display: grid; place-items: center; font-weight: 600; font-size: 20px; flex: none; }
.acct-tabs { border-bottom-color: var(--line); flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; }
.acct-tabs .nav-link { color: var(--muted); border: 0; border-bottom: 2px solid transparent; white-space: nowrap; background: none; }
.acct-tabs .nav-link:hover { color: var(--text); }
.acct-tabs .nav-link.active { color: var(--sb); font-weight: 600; background: none; border-bottom-color: var(--sb); }
.acct-pane { margin-top: 16px; padding: 20px; background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.acct-pane h2 { font-size: 17px; }
.acct-form { max-width: 420px; }
.acct-pane .form-control:focus { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.acct-pane .btn-primary { font-weight: 600; }
.acct-sess { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.acct-sess:first-child { border-top: 0; padding-top: 0; }
.acct-ua { flex: 1; min-width: 0; }
.acct-ua b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-ua small { display: block; color: var(--muted); overflow-wrap: anywhere; }
.acct-ip { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.acct-cur { padding: 2px 8px; border-radius: 999px; background: #f1dfc0; color: #6e2530; font-size: 12px; font-weight: 600; white-space: nowrap; }

/* ---- Admin users ---- */
.users-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.users-tools .form-control { max-width: 260px; height: 38px; border-radius: 10px; }
.users-tools .form-control:focus { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.users-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.users-chip { padding: 4px 12px; border-radius: 999px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--muted); text-decoration: none; transition: background-color 150ms ease-out, color 150ms ease-out; }
.users-chip[aria-pressed=true] { background: var(--sb); color: #fff; box-shadow: none; }
.users-list { background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.users-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.users-item:first-child { border-top: 0; }
.users-av { width: 40px; height: 40px; border-radius: 50%; background: #f1dfc0; color: var(--sb); display: grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; }
.users-av.off { background: #eee; color: #888; }
.users-who { flex: 1; min-width: 0; }
.users-who small { display: flex; gap: 6px; align-items: center; min-height: 20px; margin-top: 2px; }
.users-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--sb); font-weight: 600; text-decoration: none; }
.users-name:hover { text-decoration: underline; }
.users-bg { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.users-bg.ad { background: #f1dfc0; color: #6e2530; }
.users-bg.ok { background: #e3f1e6; color: #1d6b3a; }
.users-bg.off { background: #eee; color: #666; }
.users-kb { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; line-height: 1; color: var(--muted); }
.users-kb:hover { background: #f4f4f5; }
.users-empty { margin: 0; padding: 24px; color: var(--muted); }

/* ---- Admin user detail: one tile per app, click the role ---- */
.ud-back { display: inline-block; margin-bottom: 12px; color: var(--muted); text-decoration: none; font-size: 14px; }
.ud-back:hover { color: var(--text); }
.ud-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.ud-av { width: 48px; height: 48px; border-radius: 50%; background: #f1dfc0; color: var(--sb); display: grid; place-items: center; font-weight: 600; font-size: 17px; flex: none; }
.ud-av.off { background: #eee; color: #888; }
.ud-who { flex: 1; min-width: 200px; }
.ud-who h1 { margin: 0; font-size: 24px; overflow-wrap: anywhere; }
.ud-badges { display: flex; gap: 6px; flex-wrap: wrap; min-height: 22px; }
.ud-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.ud-reset { margin-bottom: 16px; padding: 12px 16px; border-radius: 12px; background: #fdf6e3; box-shadow: inset 0 0 0 1px rgba(212,169,79,.55); }
.ud-reset input { margin: 8px 0; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.ud-h { margin: 24px 0 8px; font-size: 14px; color: var(--muted); font-weight: 500; }
.ud-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ud-tile { margin: 0; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #fff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.ud-tile.on { box-shadow: inset 0 0 0 2px var(--sb); }
.ud-app { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ud-seg { display: flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: #f4f4f5; }
.ud-seg button { flex: 1 1 auto; border: 0; background: none; padding: 5px 10px; border-radius: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; transition: background-color 150ms ease-out, color 150ms ease-out; }
.ud-seg button:hover:not(:disabled) { color: var(--text); }
.ud-seg button[aria-pressed=true] { background: #fff; color: var(--sb); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.ud-seg button.none[aria-pressed=true] { color: var(--muted); }

/* ---- Admin apps: guided create ---- */
.wiz { max-width: 560px; margin: 0 auto 8px; padding: 20px; background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.wiz fieldset { border: 0; padding: 0; margin: 0; }
.wiz fieldset[hidden] { display: none; }
.wiz h2 { font-size: 17px; }
.wiz-dots { display: none; gap: 8px; margin-bottom: 16px; }
.wiz-js .wiz-dots { display: flex; }
.wiz-dots i { height: 4px; flex: 1; border-radius: 2px; background: var(--line); transition: background-color 150ms ease-out; }
.wiz-dots i.on { background: var(--sb); }
.wiz-nav { display: flex; gap: 8px; }
.wiz .form-control:focus { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.wiz .btn-primary { font-weight: 600; }
.wiz-types { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wiz-opt { display: block; padding: 14px; border-radius: 12px; background: #fff; box-shadow: inset 0 0 0 1px var(--line); cursor: pointer; transition: box-shadow 150ms ease-out, background-color 150ms ease-out; }
.wiz-opt small { display: block; color: var(--muted); }
.wiz-opt input { position: absolute; opacity: 0; pointer-events: none; }
.wiz-opt:has(input:checked) { box-shadow: inset 0 0 0 2px var(--sb); background: #f4f4f5; }
.wiz-opt:has(input:focus-visible) { outline: 2px solid var(--brass); outline-offset: 2px; }
.wiz-done { max-width: 560px; margin: 0 auto 14px; padding: 14px 16px; border-radius: 12px; background: #fff8e6; box-shadow: inset 0 0 0 1px var(--brass); }
.wiz-done code { display: block; margin: 8px 0; padding: 8px 10px; background: #fff; border-radius: 8px; color: #171717; overflow-wrap: anywhere; }

/* ---- Admin audit: console log ---- */
.audit-q { display: flex; gap: 8px; margin-bottom: 8px; }
.audit-q .form-control { font-family: ui-monospace, Consolas, monospace; font-size: 13px; height: 38px; border-radius: 10px; }
.audit-q .form-control:focus { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.audit-q .btn-primary { font-weight: 600; }
.audit-hint { color: var(--muted); font-size: 12.5px; }
.audit-hint code { background: #fff; padding: 1px 6px; border-radius: 6px; box-shadow: inset 0 0 0 1px var(--line); color: var(--sb); }
.audit-log { font: 12.5px ui-monospace, Consolas, monospace; max-height: calc(100vh - 260px); overflow: auto; padding: 4px 0; background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.audit-row { display: flex; gap: 12px; align-items: center; height: 28px; padding: 0 16px 0 12px; border-left: 3px solid transparent; white-space: nowrap; }
.audit-row:hover { background: #f4f4f5; }
.audit-row.bad { border-left-color: #c4372e; background: #fdf5f4; }
.audit-row.warn { border-left-color: var(--brass); }
.audit-row.ok { border-left-color: #3a9d5d; }
.audit-row span { overflow: hidden; text-overflow: ellipsis; }
.audit-row .t { flex: none; color: var(--muted); }
.audit-row .e { flex: 0 1 170px; min-width: 0; font-weight: 600; }
.audit-row .w { flex: 0 1 130px; min-width: 0; }
.audit-row .a { flex: none; width: 80px; color: var(--muted); }
.audit-row .ip { flex: none; width: 120px; color: var(--muted); }
.audit-row .dd { flex: 1; min-width: 0; color: #777; }
@media (max-width: 1200px) { .audit-row .a, .audit-row .ip { display: none; } }

/* ---- Admin invites ---- */
.inv-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.inv-head > div { flex: 1; min-width: 0; }
.inv-head .btn-primary, .inv-pn .btn-primary, .inv-ok .btn-primary { font-weight: 600; }
.users-bg.bad { background: #fbeceb; color: #8c1d18; }
.inv-item { padding: 12px 0; border-top: 1px solid var(--line); }
.inv-item:first-child { border-top: 0; padding-top: 0; }
.inv-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; font-size: 13px; }
.inv-gr { display: flex; flex-wrap: wrap; gap: 4px; }
.inv-gr span { padding: 1px 8px; border-radius: 6px; background: #f4f4f5; box-shadow: inset 0 0 0 1px var(--line); font-size: 12.5px; overflow-wrap: anywhere; }
.inv-back { display: inline-block; margin-bottom: 10px; color: var(--sb); font-weight: 600; text-decoration: none; }
.inv-back:hover { text-decoration: underline; }
.inv-cols { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 14px; align-items: start; }
.inv-pn { padding: 20px; background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.inv-pn h2 { font-size: 16px; }
.inv-side { position: sticky; top: 0; }
.inv-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.inv-row select { min-width: 0; flex: 1 1 140px; }
.inv-row .form-select:focus { border-color: var(--brass); box-shadow: 0 0 0 2px var(--brass); }
.inv-rm { border: 0; background: none; width: 34px; height: 34px; border-radius: 8px; font-size: 18px; color: var(--muted); flex: none; }
.inv-rm:hover { background: #f4f4f5; }
.inv-days { display: flex; flex-wrap: wrap; gap: 6px; }
.inv-days button { border: 0; background: #fff; box-shadow: inset 0 0 0 1px var(--line); border-radius: 999px; padding: 4px 12px; font-size: 13px; color: var(--muted); transition: background-color 150ms ease-out, color 150ms ease-out; }
.inv-days button[aria-pressed=true] { background: var(--sb); color: #fff; box-shadow: none; }
.inv-bt { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.inv-ok { max-width: 620px; margin: 0 auto; padding: 28px 20px; text-align: center; background: #ffffff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); }
.inv-ok h1 { font-size: 22px; }
.inv-ok code { display: block; margin: 14px 0 10px; padding: 12px; background: #fff; border-radius: 10px; box-shadow: inset 0 0 0 1px var(--line); overflow-wrap: anywhere; text-align: left; color: #171717; }
.inv-ok .inv-gr { justify-content: center; margin: 12px 0 4px; }
.inv-ok .inv-bt { justify-content: center; }
.inv-none { margin: 0; padding: 24px; background: #fff; border-radius: 16px; box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); }
.inv-check { width: 48px; height: 48px; border-radius: 50%; background: #e3f1e6; color: #1d6b3a; display: grid; place-items: center; margin: 0 auto 12px; font-size: 24px; }
@media (max-width: 900px) { .inv-cols { grid-template-columns: 1fr; } .inv-side { position: static; } }
