/* ==========================================================================
   Version 5 look. 5.0.8: "Merlin Corporate" (navy menu, light grey page, company colour
   for actions only, 6-8px corners, Public Sans bundled in assets/fonts). See DESIGN.md.
   Loaded after app.css, and only when Setup -> Appearance turns the new look on
   (or an admin previews it). Everything is scoped to html.ui-v5, so the classic
   look is untouched. Brand colours (--brand, --brand-on, --brand-text, --brand-soft,
   --brand-hover) are written into the page head from the admin's chosen colour.
   ========================================================================== */

/* ---------- font (bundled, works without internet) ---------- */
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("../fonts/public-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("../fonts/public-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("../fonts/public-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 700; font-display: swap; src: url("../fonts/public-sans-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Public Sans"; font-style: normal; font-weight: 800; font-display: swap; src: url("../fonts/public-sans-latin-800-normal.woff2") format("woff2"); }

/* ---------- tokens ---------- */
html.ui-v5 {
  --font: "Public Sans", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bg: #F4F6F9; --surface: #FFFFFF; --surface-2: #F7F9FB; --text: #0F1B2D; --muted: #5A6474;
  --border: #D9DEE5; --soft: #EEF1F5; --side: #0E2240; --side-text: #C9D4E5;
  --ok: #157347; --ok-bg: #E3F3EA; --warn: #A15C00; --warn-bg: #FDF0DC; --bad: #B42318; --bad-bg: #FCE8E6;
  --info: #1F5FA8; --info-bg: #E6EFFA;
  --r-sm: 6px; --r: 8px; --r-lg: 8px;
  --shadow: 0 1px 2px rgba(15,27,45,.05), 0 4px 14px rgba(15,27,45,.05);
  /* the classic stylesheet's names, pointed at the new tokens */
  --navy: var(--text); --accent: var(--brand); --light: var(--brand-soft); --grey: var(--muted);
  --red: var(--bad); --green: var(--ok); --amber: var(--warn); --radius: var(--r-lg);
  color-scheme: light;
}
html.ui-v5[data-theme="dark"] {
  --bg: #0B111A; --surface: #121A26; --surface-2: #162030; --text: #E6EBF2; --muted: #9AA6B6;
  --border: #243041; --soft: #1A2433; --side: #08142A; --side-text: #AFC0D8;
  --ok: #86EFAC; --ok-bg: #14321F; --warn: #FCD34D; --warn-bg: #3A2A0A; --bad: #FCA5A5; --bad-bg: #3B1414;
  --info: #93C5FD; --info-bg: #172554;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}

/* ---------- base ---------- */
html.ui-v5 body { font-family: var(--font); background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; transition: background .2s, color .2s; }
html.ui-v5 a { color: var(--brand-text); }
html.ui-v5 h1, html.ui-v5 h2, html.ui-v5 h3 { color: var(--text); letter-spacing: -0.01em; }
html.ui-v5 h1 { font-size: 26px; font-weight: 700; }
html.ui-v5 h2 { font-size: 18px; font-weight: 700; }
html.ui-v5 h3 { font-size: 16px; font-weight: 700; }
html.ui-v5 .muted { color: var(--muted); }
html.ui-v5 :focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
html.ui-v5 ::selection { background: var(--brand-soft); }

/* ---------- cards, buttons, forms ---------- */
html.ui-v5 .card, html.ui-v5[data-theme="dark"] .card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 22px; }
html.ui-v5 .btn { border-radius: var(--r-sm); font-weight: 600; padding: 10px 18px; font-size: 14.5px; transition: background-color .15s, border-color .15s, transform .05s; }
html.ui-v5 .btn:active { transform: translateY(1px); }
html.ui-v5 .btn-primary { background: var(--brand); color: var(--brand-on); }
html.ui-v5 .btn-primary:hover { background: var(--brand-hover); }
html.ui-v5 .btn-outline { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
html.ui-v5 .btn-outline:hover { border-color: var(--brand); }
html.ui-v5 .btn-success { background: #157347; color: #fff; }
html.ui-v5 .btn-danger { background: #B42318; color: #fff; }
html.ui-v5 .btn-lg { padding: 15px; font-size: 16px; }
html.ui-v5 label { font-weight: 700; font-size: 13.5px; }
html.ui-v5 input[type=text], html.ui-v5 input[type=email], html.ui-v5 input[type=tel], html.ui-v5 input[type=password],
html.ui-v5 input[type=number], html.ui-v5 input[type=date], html.ui-v5 input[type=time], html.ui-v5 input[type=search],
html.ui-v5 input[type=url], html.ui-v5 input[type=datetime-local], html.ui-v5 select, html.ui-v5 textarea, html.ui-v5 .emp-picker-input {
  border: 1px solid var(--border); border-radius: var(--r-sm); background-color: var(--surface); color: var(--text); font-family: inherit;
}
html.ui-v5 input:focus, html.ui-v5 select:focus, html.ui-v5 textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
html.ui-v5 input::placeholder, html.ui-v5 textarea::placeholder { color: var(--muted); }
html.ui-v5 input[type=checkbox], html.ui-v5 input[type=radio] { accent-color: var(--brand); }

/* ---------- messages, badges, tables ---------- */
html.ui-v5 .alert { border-radius: var(--r); border: 1px solid transparent; font-weight: 600; }
html.ui-v5 .alert-error { background: var(--bad-bg); color: var(--bad); }
html.ui-v5 .alert-success { background: var(--ok-bg); color: var(--ok); }
html.ui-v5 .alert-info { background: var(--brand-soft); color: var(--text); }
html.ui-v5 .badge { padding: 3px 8px; font-weight: 700; border-radius: 4px; }
html.ui-v5 .badge-pending { background: var(--warn-bg); color: var(--warn); }
html.ui-v5 .badge-ground { background: var(--info-bg); color: var(--info); }
html.ui-v5 .badge-floor { background: var(--ok-bg); color: var(--ok); }
html.ui-v5 .badge-out { background: var(--soft); color: var(--muted); }
html.ui-v5 table.simple th, html.ui-v5 table.simple td { border-bottom: 1px solid var(--border); }
html.ui-v5 table.simple th { color: var(--muted); font-size: 12px; letter-spacing: .02em; background: var(--soft); }
html.ui-v5 table.simple tbody tr:hover td { background: var(--surface-2); }
html.ui-v5 .visitor-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow); }
html.ui-v5 .emp-picker-menu { background: var(--surface); border-color: var(--border); border-radius: var(--r); }
html.ui-v5 .emp-picker-option .emp-picker-name { color: var(--text); }
html.ui-v5 .emp-picker-option:hover, html.ui-v5 .emp-picker-option.active { background: var(--brand-soft); }
html.ui-v5 .step-indicator span.active { background: var(--brand); }

/* Dark mode: soften the light colours some older pages set directly on an element. */
html.ui-v5[data-theme="dark"] [style*="background:#fff"], html.ui-v5[data-theme="dark"] [style*="background: #fff"],
html.ui-v5[data-theme="dark"] [style*="background:#ffffff"], html.ui-v5[data-theme="dark"] [style*="background: #ffffff"],
html.ui-v5[data-theme="dark"] [style*="background:#f7f9fc"], html.ui-v5[data-theme="dark"] [style*="background:#f6f7f9"],
html.ui-v5[data-theme="dark"] [style*="background:#f4f6f8"], html.ui-v5[data-theme="dark"] [style*="background:#fafafa"],
html.ui-v5[data-theme="dark"] [style*="background:#e8f0fa"] { background: var(--surface-2) !important; color: var(--text); }
html.ui-v5[data-theme="dark"] [style*="background:#fdf1d8"], html.ui-v5[data-theme="dark"] [style*="background:#fff8e1"],
html.ui-v5[data-theme="dark"] [style*="background:#fff3cd"] { background: var(--warn-bg) !important; color: var(--warn); }
html.ui-v5[data-theme="dark"] [style*="color:#555"], html.ui-v5[data-theme="dark"] [style*="color:#595959"],
html.ui-v5[data-theme="dark"] [style*="color:#666"], html.ui-v5[data-theme="dark"] [style*="color:#777"],
html.ui-v5[data-theme="dark"] [style*="color:#333"], html.ui-v5[data-theme="dark"] [style*="color:#222"],
html.ui-v5[data-theme="dark"] [style*="color:#52514e"], html.ui-v5[data-theme="dark"] [style*="color:#4b5765"] { color: var(--muted) !important; }
html.ui-v5[data-theme="dark"] [style*="color:#17529e"], html.ui-v5[data-theme="dark"] [style*="color:#1f3864"] { color: var(--brand-text) !important; }
html.ui-v5[data-theme="dark"] [style*="color:#96650a"], html.ui-v5[data-theme="dark"] [style*="color:#8a5a00"] { color: var(--warn) !important; }
html.ui-v5[data-theme="dark"] [style*="color:#b3261e"], html.ui-v5[data-theme="dark"] [style*="color:#b83430"],
html.ui-v5[data-theme="dark"] [style*="color:#b42318"] { color: var(--bad) !important; }
html.ui-v5[data-theme="dark"] [style*="color:#1f7a4d"], html.ui-v5[data-theme="dark"] [style*="color:#1a7f37"] { color: var(--ok) !important; }

/* ---------- page shell: side menu + top bar ---------- */
html.ui-v5 .v5-app { display: flex; min-height: 100vh; }
html.ui-v5 .v5-side {
  width: 248px; flex-shrink: 0; box-sizing: border-box; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--side); color: #FFFFFF; --nav-fg: var(--side-text); --nav-hover: rgba(255,255,255,.07);
  --nav-cur-bg: var(--brand); --nav-cur-fg: var(--brand-on);
}
html.ui-v5 .v5-side-brand .v5-side { background: var(--brand); color: var(--brand-on); --nav-fg: var(--brand-on); --nav-hover: rgba(255,255,255,.12); --nav-cur-bg: rgba(255,255,255,.2); --nav-cur-fg: var(--brand-on); }
html.ui-v5 .v5-side-light .v5-side { background: var(--surface); color: var(--text); border-right: 1px solid var(--border); --nav-fg: var(--muted); --nav-hover: var(--soft); }
html.ui-v5 .v5-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; color: inherit; text-decoration: none; font-weight: 700; font-size: 14.5px; line-height: 1.3; }
html.ui-v5 .v5-logo { min-width: 36px; height: 36px; border-radius: 6px; background: var(--brand); color: var(--brand-on); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px; }
html.ui-v5 .v5-side-brand .v5-logo { background: rgba(255,255,255,.2); }
html.ui-v5 .v5-logo { flex-shrink: 0; }
html.ui-v5 .v5-brand-name { min-width: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
/* An uploaded logo (often a wide wordmark): its own row on a white tile, the app name under it. */
html.ui-v5 .v5-brand-has-img { flex-direction: column; align-items: stretch; gap: 8px; }
html.ui-v5 .v5-logo-img { height: auto; min-height: 0; padding: 8px 12px; border-radius: 6px; background: #FFFFFF; justify-content: flex-start; }
html.ui-v5 .v5-side-brand .v5-logo-img { background: #FFFFFF; }
html.ui-v5 .v5-logo-img img { display: block; max-width: 100%; max-height: 40px; width: auto; height: auto; object-fit: contain; }
html.ui-v5 .v5-brand-has-img .v5-brand-name { font-size: 13px; font-weight: 700; opacity: .85; white-space: normal; line-height: 1.35; padding: 0 2px; }
html.ui-v5 .v5-login-brand .v5-brand-has-img { align-items: flex-start; }
html.ui-v5 .v5-login-brand .v5-logo-img { padding: 12px 16px; border-radius: 8px; }
html.ui-v5 .v5-login-brand .v5-logo-img img { max-height: 56px; max-width: 240px; }
html.ui-v5 .v5-nav { display: flex; flex-direction: column; gap: 2px; }
html.ui-v5 .v5-nav-title { padding: 16px 12px 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--nav-fg); opacity: .75; }
html.ui-v5 .v5-nav-link { display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: 6px; color: var(--nav-fg); text-decoration: none; font-weight: 600; font-size: 14.5px; transition: background .15s, color .15s; }
html.ui-v5 .v5-nav-link:hover { background: var(--nav-hover); color: inherit; }
html.ui-v5 .v5-side-light .v5-nav-link:hover { color: var(--text); }
html.ui-v5 .v5-nav-link.is-current { background: var(--nav-cur-bg); color: var(--nav-cur-fg); }
/* dark (navy) menu: the current page is a light row with a company-colour bar, not a bright block */
html.ui-v5 .v5-app:not(.v5-side-brand):not(.v5-side-light) .v5-nav-link.is-current { background: rgba(255,255,255,.1); color: #FFFFFF; box-shadow: inset 3px 0 0 var(--brand); }
html.ui-v5 .v5-side-light .v5-nav-link.is-current { background: var(--brand-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--brand); }
html.ui-v5 .v5-ic { flex-shrink: 0; }
html.ui-v5 .v5-ext { margin-left: auto; opacity: .6; display: inline-flex; }
html.ui-v5 .v5-ext .v5-ic { width: 14px; height: 14px; }
html.ui-v5 .v5-side-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 2px; }
html.ui-v5 .v5-who { display: flex; align-items: center; gap: 10px; padding: 12px; margin-bottom: 4px; border-radius: 8px; background: var(--nav-hover); }
html.ui-v5 .v5-who-text { display: flex; flex-direction: column; min-width: 0; font-size: 14px; }
html.ui-v5 .v5-who-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.ui-v5 .v5-who-label { font-size: 11.5px; color: var(--nav-fg); }
html.ui-v5 .v5-avatar { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; background: var(--brand); color: var(--brand-on); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; }
html.ui-v5 .v5-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
html.ui-v5 .v5-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); }
html.ui-v5 .v5-top-title { font-weight: 700; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html.ui-v5 .v5-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
html.ui-v5 .v5-iconbtn { width: 40px; height: 40px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
html.ui-v5 .v5-iconbtn:hover { border-color: var(--brand); }
html.ui-v5 .v5-menu-btn { display: none; }
html.ui-v5 .v5-chip { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: 4px; background: var(--warn-bg); color: var(--warn); font-size: 12.5px; font-weight: 700; }
html.ui-v5 .v5-content { flex: 1 1 auto; }
html.ui-v5 .v5-content > .container-wide { padding: 28px 32px 40px; max-width: 1320px; }
html.ui-v5 .v5-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 70; }
html.ui-v5 .v5-scrim[hidden] { display: none; }
html.ui-v5 .v5-bottom { display: none; }
/* the classic sticky top bar and toast offsets */
html.ui-v5 .vp-toast-wrap { top: 76px; }

/* ---------- phones and small tablets ---------- */
@media (max-width: 900px) {
  html.ui-v5 .v5-side { position: fixed; left: 0; top: 0; bottom: 0; z-index: 80; width: 280px; transform: translateX(-100%); transition: transform .22s ease, visibility .22s; visibility: hidden; }
  html.ui-v5 .v5-menu-open .v5-side { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  html.ui-v5 .v5-menu-btn { display: inline-flex; }
  html.ui-v5 .v5-top { padding: 0 12px; }
  html.ui-v5 .v5-avatar-top { display: none; }
  html.ui-v5 .v5-content > .container-wide { padding: 16px 16px 32px; }
  html.ui-v5 h1 { font-size: 23px; }
  html.ui-v5 .card { padding: 16px; border-radius: var(--r); }
  html.ui-v5 table.simple { display: block; overflow-x: auto; }
  html.ui-v5 .v5-has-bottom .v5-content > .container-wide { padding-bottom: 104px; }
  html.ui-v5 .v5-bottom { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; padding: 6px; border-radius: 10px; background: var(--side); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
  html.ui-v5 .v5-bottom a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; border-radius: 6px; color: var(--side-text); text-decoration: none; font-size: 11.5px; font-weight: 700; }
  html.ui-v5 .v5-bottom a.is-current { background: rgba(255,255,255,.14); color: #FFFFFF; box-shadow: inset 0 -3px 0 var(--brand); }
}
@media (prefers-reduced-motion: reduce) {
  html.ui-v5 *, html.ui-v5 *::before, html.ui-v5 *::after { transition: none !important; animation: none !important; }
}

/* ---------- sign-in page ---------- */
html.ui-v5 .v5-login { min-height: 100vh; display: flex; flex-wrap: wrap; }
html.ui-v5 .v5-login-brand { flex: 1 1 440px; box-sizing: border-box; padding: 40px 48px; background: var(--side); color: #FFFFFF; display: flex; flex-direction: column; gap: 28px; }
html.ui-v5 .v5-side-brand .v5-login-brand { background: var(--brand); color: var(--brand-on); }
html.ui-v5 .v5-login-brand .v5-brand { padding: 0; font-size: 17px; }
html.ui-v5 .v5-login-hero { flex-grow: 1; display: flex; flex-direction: column; justify-content: center; gap: 16px; max-width: 480px; }
html.ui-v5 .v5-login-hero h1 { color: inherit; font-size: 38px; line-height: 1.15; margin: 0; letter-spacing: -0.015em; font-weight: 700; }
html.ui-v5 .v5-login-hero p { margin: 0; font-size: 16px; line-height: 1.6; opacity: .85; }
html.ui-v5 .v5-login-credit, html.ui-v5 .v5-login-credit .muted, html.ui-v5 .v5-login-credit a { color: inherit; opacity: .8; }
html.ui-v5 .v5-login-credit p { text-align: left !important; margin: 0 !important; }
html.ui-v5 .v5-login-form { flex: 1 1 420px; box-sizing: border-box; padding: 32px 24px; display: flex; flex-direction: column; }
html.ui-v5 .v5-login-form-top { display: flex; justify-content: flex-end; }
html.ui-v5 .v5-login-box { flex-grow: 1; display: flex; align-items: center; justify-content: center; }
html.ui-v5 .v5-login-box form { width: 100%; max-width: 400px; }
html.ui-v5 .v5-login-box h2 { font-size: 30px; margin: 0 0 4px; }
html.ui-v5 .v5-login-box input[type=text], html.ui-v5 .v5-login-box input[type=password] { height: 52px; border-radius: var(--r); font-size: 16px; }
html.ui-v5 .v5-login-box .btn-lg { margin-top: 22px; height: 54px; padding: 0; }
@media (max-width: 900px) {
  html.ui-v5 .v5-login-brand { flex-basis: 100%; padding: 24px; gap: 12px; }
  html.ui-v5 .v5-login-hero h1 { font-size: 26px; }
  html.ui-v5 .v5-login-hero p { font-size: 14.5px; }
}

/* Analytics: the selected tab follows the company colour (chart colours stay as designed). */
html.ui-v5 .an-tabs .is-on { border-bottom-color: var(--brand); }
html.ui-v5 .an-tabs :focus-visible { outline-color: var(--brand); }

/* Number, date and time boxes match the other fields (the classic stylesheet left them unstyled). */
html.ui-v5 input[type=number], html.ui-v5 input[type=date], html.ui-v5 input[type=time], html.ui-v5 input[type=search],
html.ui-v5 input[type=url], html.ui-v5 input[type=datetime-local] { box-sizing: border-box; width: 100%; padding: 11px 14px; font-size: 15px; min-height: 46px; }

/* 5.0.8 — visitor form helpers in dark mode */
html.ui-v5[data-theme="dark"] input.field-error, html.ui-v5[data-theme="dark"] select.field-error, html.ui-v5[data-theme="dark"] textarea.field-error { border-color: var(--bad) !important; background-color: var(--bad-bg) !important; }
html.ui-v5[data-theme="dark"] .field-msg { color: var(--bad); }
html.ui-v5 .step-label { color: var(--muted); }
html.ui-v5 .notice-more { color: var(--brand-text); }
html.ui-v5 .btn:disabled, html.ui-v5 .btn[disabled] { opacity: .45; cursor: not-allowed; }
html.ui-v5[data-theme="dark"] .btn-primary:disabled { color: #FFFFFF; }

/* 5.0.8 — Setup grouped list follows the theme */
html.ui-v5 .setup-grid { background: var(--surface); border-color: var(--border); }
html.ui-v5 .setup-tile { border-color: var(--border) !important; }
html.ui-v5 .setup-tile:hover { background: var(--surface-2); }
html.ui-v5 .setup-tile h3 { color: var(--brand-text); }
html.ui-v5 .setup-tile p { color: var(--muted); }
