/* Turnkey Hub styles. Copied from the approved mockup (docs/design/mockups/portal-mockup.html <style>),
   minus the inlined tokens.css and switcher part (served unchanged as their own files) and the
   mockup-only "Example data" tag and skeleton. Uses tokens.css custom properties only. */

@font-face { font-family: 'Inter'; src: url(/static/fonts/Inter-Variable-latin.woff2) format('woff2'); font-weight: 100 900; font-display: swap; }

/* ===== Base ===== */
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-sans); font-size: var(--fs-base); line-height: var(--lh-base); color: var(--c-text); background: var(--c-surface); -webkit-font-smoothing: antialiased; overflow-x: hidden; }
button, input { font: inherit; color: inherit; }
a { color: var(--c-brand); }
:focus-visible { outline: 2px solid var(--c-brand); outline-offset: 2px; }
svg.ic { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
svg.ic.sm { width: 14px; height: 14px; stroke-width: 2.4; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.logo { height: 36px; width: 139px; display: block; }
.logo-dark, .on-light-dark { display: none; }
html[data-theme="dark"] .logo-light, html[data-theme="dark"] .on-light-light { display: none; }
html[data-theme="dark"] .logo-dark, html[data-theme="dark"] .on-light-dark { display: block; }
.muted { color: var(--c-text-muted); }

/* ===== Top bar (Template 1 strip, full width: no sidebar on the landing page) ===== */
.topbar { height: var(--topbar-h); background: var(--c-bg); border-bottom: 1px solid var(--c-border); border-top: 2px solid var(--c-turnkey-red); position: sticky; top: 0; z-index: 30; }
.topbar-inner { max-width: 1248px; margin: 0 auto; height: 100%; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--c-text); }
.brand-div { width: 1px; height: 22px; background: var(--c-border); }
.product { font-size: var(--fs-h3); font-weight: 600; letter-spacing: -0.01em; }
.mobile-mark { width: 28px; height: 28px; }
@media (min-width: 768px) { .mobile-mark { display: none !important; } }
.topbar-right { display: flex; align-items: center; gap: 8px; position: relative; }
.asat { font-size: var(--fs-xs); color: var(--c-text-muted); margin-right: 4px; white-space: nowrap; }
.btn { height: var(--btn-h); padding: 0 16px; border-radius: var(--radius-control); font-size: var(--fs-sm); font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; border: 1px solid var(--c-border-strong); background: var(--c-bg); color: var(--c-text); white-space: nowrap; text-decoration: none; transition: background var(--motion-fast) var(--ease-standard); }
.btn:hover { background: var(--c-surface); }
.btn.primary { background: var(--c-cta); color: var(--c-cta-fg); border-color: var(--c-cta); }
.tk-gear { width: 18px; height: 18px; }
@keyframes tk-gear-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.refresh-btn[aria-busy="true"] .tk-gear { animation: tk-gear-spin 1.15s cubic-bezier(0.4, 0, 0.2, 1) infinite; }

.avatar-btn { width: var(--avatar); height: var(--avatar); border-radius: var(--radius-pill); background: var(--c-turnkey-navy); color: #FFFFFF; font-weight: 700; font-size: 13px; border: 1.5px solid var(--c-border-strong); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
html[data-theme="dark"] .avatar-btn { background: #26384D; color: #F2F4F7; border-color: var(--c-brand); }

/* Popovers (switcher + avatar menu): 150ms enter, instant under reduced motion */
.popover { position: absolute; right: 0; top: calc(100% + 8px); background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-card); box-shadow: 0 10px 25px -5px rgba(0,0,0,0.12); z-index: 50;
  opacity: 0; transform: translateY(-4px); visibility: hidden;
  transition: opacity var(--motion-base) var(--ease-enter), transform var(--motion-base) var(--ease-enter), visibility 0s linear var(--motion-base); }
.popover.open { opacity: 1; transform: none; visibility: visible; transition: opacity var(--motion-base) var(--ease-enter), transform var(--motion-base) var(--ease-enter); }
.app-icon { width: 32px; height: 32px; border-radius: var(--radius-control); background: var(--c-surface-2); color: var(--c-text); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.app-icon svg.ic { width: 18px; height: 18px; }
.app-icon img { width: 22px; height: 22px; }
#user-menu { width: 260px; padding: 14px; }
.pop-head { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--c-border); }
.pop-name { font-weight: 700; font-size: var(--fs-sm); }
.pop-sub { font-size: var(--fs-xs); color: var(--c-text-muted); }
.pop-row { padding: 10px 2px; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-xs); color: var(--c-text-muted); gap: 8px; }
.pop-row a { font-weight: 600; text-decoration: none; }
.seg { display: inline-flex; background: var(--c-surface); border: 1px solid var(--c-border); border-radius: var(--radius-control); padding: 2px; gap: 2px; }
.seg button { border: none; background: none; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 6px; color: var(--c-text-muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--c-bg); color: var(--c-text); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
.signout { margin-top: 10px; width: 100%; }

/* ===== Page ===== */
.page { max-width: 1248px; margin: 0 auto; padding: 28px 24px 48px; display: flex; flex-direction: column; gap: var(--stack-gap); }
.greet-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap; }
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); font-weight: 700; letter-spacing: var(--tracking-tight); }
.status-line { font-size: var(--fs-status); line-height: var(--lh-status); font-weight: 600; display: flex; align-items: center; gap: 10px; }
.status-line .ic { width: 20px; height: 20px; }
.status-line.warn .ic { color: var(--c-warning); }
.status-line.ok .ic { color: var(--c-positive); }
#content { display: flex; flex-direction: column; gap: 16px; }
.status-sub { font-size: var(--fs-base); color: var(--c-text-muted); margin-top: -10px; padding-left: 30px; }

/* App cards: whole card is one link */
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--stack-gap); list-style: none; }
.app-card { display: flex; flex-direction: column; gap: 12px; min-height: 172px; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-card); padding: var(--card-pad); text-decoration: none; color: var(--c-text); position: relative; transition: border-color var(--motion-fast) var(--ease-standard), box-shadow var(--motion-fast) var(--ease-standard); }
.app-card:hover { border-color: var(--c-border-strong); box-shadow: 0 4px 14px rgba(0,0,0,0.06); }
.card-top { display: flex; align-items: center; gap: 14px; }
.app-card .app-icon { width: 44px; height: 44px; border-radius: 10px; }
.app-card .app-icon svg.ic { width: 22px; height: 22px; }
.app-name { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; letter-spacing: -0.015em; flex: 1; }
.go { color: var(--c-text-muted); }
.app-card:hover .go { color: var(--c-text); }
.purpose { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--c-text-muted); }
.card-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; min-width: 0; }
.card-foot .badge { max-width: 100%; }
.card-foot .badge > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 479px) { .card-foot { flex-direction: column; align-items: flex-start; } }
.updated { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--c-text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Status badge: colour + icon + words */
.badge { display: inline-flex; align-items: center; gap: 6px; min-height: var(--pill-h); padding: 2px 10px; border-radius: var(--radius-pill); font-size: var(--fs-pill); line-height: 18px; font-weight: 600; }
.badge.ok { background: var(--c-positive-bg); color: var(--c-positive); }
.badge.attention { background: var(--c-warning-bg); color: var(--c-warning); }
.badge.action { background: var(--c-negative-bg); color: var(--c-negative); }
.badge.unavailable { background: var(--c-surface-2); color: var(--c-text-muted); }
.badge.checking { background: var(--c-surface-2); color: var(--c-text-muted); }

.app-card.soon { background: var(--c-surface); border-style: dashed; }
.soon-tag { font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: 600; color: var(--c-text-muted); }
.fail-note { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--c-text-muted); }
/* Notice / empty / error panels */
.notice { background: var(--c-bg); border: 1px solid var(--c-border); border-radius: var(--radius-card); padding: 40px 24px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; }
.notice .big { width: 48px; height: 48px; border-radius: 12px; background: var(--c-surface-2); display: inline-flex; align-items: center; justify-content: center; color: var(--c-text-muted); }
.notice.error .big { background: var(--c-negative-bg); color: var(--c-negative); }
.notice h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); font-weight: 600; }
.notice p { max-width: 520px; color: var(--c-text-muted); }
.notice .actions { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

footer.page-footer { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--c-border); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: var(--fs-xs); color: var(--c-text-muted); }

/* ===== Breakpoints ===== */
@media (max-width: 1279px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 767px) {
  :root { --card-pad: 16px; }
  .topbar-inner { padding: 0 12px; }
  .hide-sm { display: none !important; }
  .refresh-btn { width: 36px; height: 36px; padding: 0; }
  .refresh-btn .label { display: none; }
  .page { padding: 20px 16px 40px; }
  h1 { font-size: 24px; line-height: 30px; }
  .status-line { font-size: 16px; line-height: 22px; align-items: flex-start; }
  .cards { grid-template-columns: 1fr; gap: 12px; }
  .app-card { min-height: 0; }
}

/* ===== Hub additions (not in the mockup) ===== */
/* Sign out is a POST form with a CSRF token; the form box disappears so the button sits where the mockup's link does. */
.signout-form, .notice .actions form { display: contents; }
.notice .big img { width: 28px; height: 28px; }
