/* Shared styles for ALYNDA CMS — digital signage system.
   The hand-written utilities layer (utilities.css) handles generic layout
   classes; this file defines the brand tokens, status colors and the
   components that carry the actual identity (the sidebar, badges, stat
   tiles, the player screen, the credit footer). */

:root {
  color-scheme: light;
  --surface-1: #ffffff;
  --surface-2: #f5f7fc;
  --page: #eef1f8;
  --text-primary: #10141f;
  --text-secondary: #565f74;
  --text-muted: #8891a4;
  --border: rgba(16, 20, 31, 0.09);
  --gridline: #e7e9f4;

  --ink: #0c1220;          /* sidebar / dark chrome */
  --ink-2: #171f38;        /* sidebar hover/active */
  --ink-line: rgba(255, 255, 255, 0.09);
  --ink-text: #e8ebf6;
  --ink-text-muted: #8892ab;

  --brand: #2454e0;        /* signal blue — primary actions, links, active state */
  --brand-strong: #1b3fb8;
  --brand-ink: #ffffff;
  --brand-soft: #e7ecfc;

  --status-good: #0ca35f;
  --status-good-soft: #e2f6ec;
  --status-warning: #b8790f;
  --status-warning-bg: #fff2d9;
  --status-serious: #c1512c;
  --status-serious-bg: #fde7dd;
  --status-critical: #d03b3b;
  --status-critical-bg: #fbe4e4;
  --status-neutral: #6b7086;
  --status-neutral-bg: #eceef6;

  --shadow-card: 0 1px 2px rgba(16,20,31,0.04), 0 6px 20px -10px rgba(16,20,31,0.10);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-1: #171c2b;
    --surface-2: #1d2337;
    --page: #0f1320;
    --text-primary: #eef0f8;
    --text-secondary: #aab0c4;
    --text-muted: #7c839b;
    --border: rgba(255, 255, 255, 0.09);
    --gridline: #262c42;
    --ink: #090d16;
    --ink-2: #141b2e;
    --brand: #6e93ff;
    --brand-strong: #8caaff;
    --brand-soft: #1b2646;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.3), 0 6px 20px -10px rgba(0,0,0,0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { text-decoration: none; color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible, .navlink:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

@media (min-width: 1024px) {
  .app-shell { flex-direction: row; }
}

/* --- Nav: a top bar on narrow screens, a fixed sidebar from 1024px up --- */
.topnav {
  background: var(--ink);
  color: var(--ink-text);
  flex: none;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 1rem 1.1rem;
}
.nav-mark {
  width: 34px; height: 34px; border-radius: 0.55rem; flex-shrink: 0;
  background: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
/* A client logo replaces the generic icon mark — bigger, no background
   square of its own (the logo image supplies its own colors/shape), and
   sized to fit whatever aspect ratio the source file has. */
.nav-mark-logo {
  width: 42px; height: 42px; border-radius: 0.4rem;
  background: transparent;
}
.nav-mark-logo img { width: 100%; height: 100%; object-fit: contain; }
.nav-wordmark {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  line-height: 1.25;
}
/* Applied automatically (by applyBrandMarks() in app.js) to every .nav-brand
   block on a page, whenever a client logo is configured — sidebar, and both
   the desktop and mobile brand blocks on the login/landing page. Stacks the
   mark above the name (rather than side-by-side) and centers the whole
   block, with a noticeably bigger logo — the client's identity is meant to
   read as the dominant visual here, not a small corner icon. */
.nav-brand-stacked {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.75rem;
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}
.nav-brand-stacked .nav-mark-logo { width: 84px; height: 84px; }
.nav-brand-stacked .nav-wordmark { font-size: 1rem; line-height: 1.3; }

.nav-links {
  display: flex;
  gap: 0.2rem;
  overflow-x: auto;
  padding: 0 0.6rem 0.7rem;
}
.nav-links a.navlink {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--ink-text-muted);
  font-size: 0.83rem;
  font-weight: 600;
  padding: 0.5rem 0.7rem;
  border-radius: 0.5rem;
  white-space: nowrap;
  flex-shrink: 0;
  /* A visible resting background + border, not just on hover/active - so
     each item reads as its own button at a glance instead of plain text
     that happens to highlight when touched. */
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
}
.nav-links a.navlink svg { flex-shrink: 0; opacity: 0.85; }
.nav-links a.navlink:hover { filter: brightness(1.45); color: #fff; }
.nav-links a.navlink.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.nav-links a.navlink.active svg { opacity: 1; }

/* Alerts is an emergency broadcast override, not a routine content page -
   set apart from the rest of the nav with a red tint and a bit of breathing
   room before it, so it doesn't get lost among (or mistaken for) the
   day-to-day items above it. */
.nav-links a.navlink-danger {
  background: rgba(208, 59, 59, 0.18);
  border-color: rgba(208, 59, 59, 0.55);
  color: #ff9b9b;
}
.nav-links a.navlink-danger:hover { filter: brightness(1.25); color: #fff; }
.nav-links a.navlink-danger.active { background: var(--status-critical); border-color: var(--status-critical); color: #fff; }

.nav-gap { flex: 0 0 auto; width: 0.9rem; }

.nav-user-row {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.6rem 1.1rem 1rem;
  border-top: 1px solid var(--ink-line);
}
.nav-user-name { font-size: 0.83rem; font-weight: 700; color: #fff; }
.nav-user-role { font-size: 0.7rem; color: var(--ink-text-muted); text-transform: capitalize; }

@media (min-width: 1024px) {
  .topnav {
    width: 246px;
    min-height: 100vh;
    position: sticky;
    top: 0;
    align-self: flex-start;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--ink-line);
  }
  .nav-links {
    flex-direction: column;
    overflow-x: visible;
    padding: 0.4rem 0.7rem;
    gap: 0.15rem;
    flex: 1;
  }
  .nav-links a.navlink { width: 100%; }
  .nav-gap { width: auto; height: 0; margin: 0.4rem 0.3rem; border-top: 1px solid var(--ink-line); }
  .nav-user-row { margin-top: auto; }
}

/* --- Cards --- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  box-shadow: var(--shadow-card);
}

/* --- Stat tiles --- */
.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-card);
}
.stat-tile .stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.stat-tile .stat-value {
  font-size: 2rem;
  line-height: 1.15;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: proportional-nums;
}
.stat-tile .stat-sub {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  line-height: 1.5;
}
.badge .dot { width: 6px; height: 6px; border-radius: 999px; display: inline-block; }
.badge-good { background: var(--status-good-soft); color: var(--status-good); }
.badge-good .dot { background: var(--status-good); }
.badge-warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge-warning .dot { background: var(--status-warning); }
.badge-serious { background: var(--status-serious-bg); color: var(--status-serious); }
.badge-serious .dot { background: var(--status-serious); }
.badge-critical { background: var(--status-critical-bg); color: var(--status-critical); }
.badge-critical .dot { background: var(--status-critical); }
.badge-neutral { background: var(--status-neutral-bg); color: var(--status-neutral); }
.badge-neutral .dot { background: var(--status-neutral); }

/* --- Buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font-size: 0.875rem; font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--brand-ink); }
.btn-primary:hover:not(:disabled) { background: var(--brand-strong); }
.btn-secondary { background: var(--surface-1); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--brand-soft); }
.btn-danger { background: var(--status-critical-bg); color: var(--status-critical); }
.btn-danger:hover:not(:disabled) { background: #f5c8c8; }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); color: var(--brand); }

/* --- Inputs --- */
.input, select.input, textarea.input {
  width: 100%;
  font-size: 0.875rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface-1);
  color: var(--text-primary);
}
.input:focus, select.input:focus, textarea.input:focus {
  outline: 2px solid var(--brand);
  outline-offset: -1px;
}
label.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 0.25rem;
}

/* --- Tables --- */
table.data-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.data-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: var(--text-muted); font-weight: 600; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--gridline);
}
table.data-table td { padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--gridline); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }

/* --- Media thumbnails --- */
.thumb {
  width: 72px; height: 44px; border-radius: 0.4rem; overflow: hidden;
  background: var(--page); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; }

/* --- Drag & drop playlist builder --- */
.playlist-item {
  display: flex; align-items: center; gap: 0.75rem;
  background: var(--surface-1); border: 1px solid var(--border); border-radius: 0.6rem;
  padding: 0.55rem 0.75rem; cursor: grab;
}
.playlist-item.dragging { opacity: 0.4; }
.drop-zone-active { outline: 2px dashed var(--brand); outline-offset: 4px; border-radius: 0.6rem; }

/* --- Player screen --- */
.player-screen {
  position: relative; width: 100%; aspect-ratio: 16/9; background: #000;
  border-radius: 0.75rem; overflow: hidden; display: flex; align-items: center; justify-content: center;
  perspective: 1600px; /* needed for the "Flip" content transition below */
}
.player-screen.portrait { aspect-ratio: 9/16; }
.player-screen img, .player-screen video, .player-screen iframe {
  width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; border: 0;
}
.player-screen .widget-face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  flex-direction: column; color: #fff; text-align: center; padding: 1.5rem;
  background: linear-gradient(135deg,#0f172a,#1e293b);
}
.player-screen .offline-face {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #6b7280; background: #0a0a0a; flex-direction: column; gap: 0.5rem;
}
.player-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,0.2); z-index: 5; }
.player-progress > div { height: 100%; background: var(--brand); width: 0%; transition: width 120ms linear; }

/* --- Emergency alert override ----------------------------------------------
   A full-screen takeover rendered on top of whatever's already playing
   (kiosk.js appends it as an extra layer inside .kiosk-screen/.player-screen
   rather than replacing the current item, so clearing the alert is just
   removing this one element - the paused content underneath is still there,
   untouched, ready to resume). Used two places: the real kiosk screen
   (kiosk.js, with a max-volume siren) and the dashboard's own live-preview
   tiles (player.js, message only, no siren - it's just a visual confirmation
   of what a real screen is showing, not something that should also blast
   the control room's speakers every time an alert fires).

   Two types, each with its own color language and tone (chosen when an
   admin sends the alert, see alerts.html): "danger" is the original
   emergency case (red, flashing, paired with the siren) and "important" is
   a calmer notice for things that need attention but aren't a live hazard
   (steady navy/gold, no flash, and kiosk.js never plays the siren for it).
   Every element except the admin's own typed message is fixed branding
   (icon, headline, footer tagline) - the message is always the thing that
   actually changes per alert.

   Orientation is decided at render time by JS comparing the actual screen
   container's rendered width/height (updateAlertOrientation in
   kiosk.js/player.js) rather than trusting the display's stored
   orientation field, since a physically-rotated screen's real on-screen
   footprint is what actually needs to lay out correctly.

   Sized in em off one root font-size on .alert-override itself, rem by
   default for the small dashboard preview tiles; the .kiosk-screen rule
   below scales that one root size up with vw for an actual full TV
   viewport, and every child element scales proportionally with it. */
.alert-override {
  position: absolute; inset: 0; z-index: 999;
  display: flex; color: #fff; overflow: hidden;
  font-size: 0.62rem;
}
.kiosk-screen .alert-override { font-size: 2.05vw; }
.alert-override--danger { background: #7f1d1d; animation: alert-flash 1s step-start infinite; }
.alert-override--important { background: #0c1220; }
@keyframes alert-flash { 0%, 49% { background: #b91c1c; } 50%, 100% { background: #7f1d1d; } }

.alert-override__inner {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 1.4em;
  padding: 1.8em 2.2em 3.4em; text-align: center; /* extra bottom padding clears the fixed tagline bar */
}
.alert-override--landscape .alert-override__inner { flex-direction: row; text-align: left; }
.alert-override--portrait .alert-override__inner { flex-direction: column; gap: 3em; }
/* Danger always has a 3rd flex item (the values row) so spreading all three
   across the height reads as a designed layout; "important" only has the
   icon + body, so the same spread would leave one huge empty gap between
   just two items - centered with a fixed gap looks intentional instead. */
.alert-override--danger.alert-override--portrait .alert-override__inner { justify-content: space-evenly; }

.alert-override__icon {
  flex: none; width: 3.6em; height: 3.6em; border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.14); border: 0.1em solid rgba(255,255,255,0.5);
}
.alert-override__icon svg { width: 2em; height: 2em; }
.alert-override--danger .alert-override__icon { color: #fef08a; }
.alert-override--important .alert-override__icon { color: #f0b429; }

.alert-override__body { display: flex; flex-direction: column; gap: 0.35em; min-width: 0; }
.alert-override--landscape .alert-override__body { align-items: flex-start; }
.alert-override--portrait .alert-override__body { align-items: center; }
.alert-override__kicker { font-weight: 800; text-transform: uppercase; letter-spacing: 0.02em; font-size: 2em; line-height: 1.05; }
.alert-override--danger .alert-override__kicker { color: #fef08a; }
.alert-override--important .alert-override__kicker { color: #f0b429; }
.alert-override__tag {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.8em;
  padding: 0.25em 0.7em; border-radius: 0.3em; background: rgba(255,255,255,0.14);
}
.alert-override__text {
  font-weight: 800; line-height: 1.3; font-size: 1.35em; text-shadow: 0 0.15em 0.4em rgba(0,0,0,0.35);
  margin-top: 0.2em; word-break: break-word;
}

.alert-override__values {
  display: flex; flex-wrap: wrap; gap: 0.9em 1.6em; justify-content: center;
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; font-size: 0.62em;
}
.alert-override--landscape .alert-override__values { flex-direction: column; align-items: flex-start; justify-content: center; }
.alert-override__values span { display: flex; align-items: center; gap: 0.5em; white-space: nowrap; }
.alert-override__values svg { width: 1.3em; height: 1.3em; flex: none; }

.alert-override__tagline {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center; gap: 0.6em;
  padding: 0.7em 1em; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.68em;
  background: rgba(0,0,0,0.28); border-top: 0.08em solid rgba(255,255,255,0.2);
}
.alert-override__tagline svg { width: 1.3em; height: 1.3em; flex: none; }
.alert-override--important .alert-override__tagline { background: rgba(0,0,0,0.32); border-top-color: rgba(240,180,41,0.35); }

/* --- Birthday-wishes override ----------------------------------------------
   Auto-triggered full-screen takeover (see resolveBirthdayNow() in server.js
   and kiosk.js's checkBirthday()) - deliberately festive rather than the
   alarm-red styling above, since this is a happy interruption, not a safety
   one. Same em-scaled-off-root-font-size sizing trick as .alert-override so
   it scales cleanly from the small dashboard preview tile up to a full TV. */
.birthday-override {
  position: absolute; inset: 0; z-index: 900; /* under .alert-override's 999 - a safety alert always wins if both would ever overlap */
  display: flex; align-items: center; justify-content: center; color: #fff; overflow: hidden;
  font-size: 0.62rem;
  background: radial-gradient(circle at 30% 20%, #9333ea, #6d28d9 45%, #4c1d95 100%);
}
.kiosk-screen .birthday-override { font-size: 2.05vw; }
/* Cheap "confetti" texture - a few repeating radial-gradient dots layered
   over the background, no image assets to bundle or fail to load. */
.birthday-override::before {
  content: ''; position: absolute; inset: 0; opacity: 0.5; pointer-events: none;
  background-image:
    radial-gradient(circle, #fde047 0.35em, transparent 0.36em),
    radial-gradient(circle, #f472b6 0.3em, transparent 0.31em),
    radial-gradient(circle, #38bdf8 0.28em, transparent 0.29em),
    radial-gradient(circle, #fbbf24 0.32em, transparent 0.33em);
  background-size: 9em 9em, 7em 7em, 11em 11em, 13em 13em;
  background-position: 0 0, 3em 5em, 6em 1em, 9em 8em;
}
.birthday-override__inner {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 2em;
  padding: 2em 2.6em; text-align: center;
}
.birthday-override--portrait .birthday-override__inner { flex-direction: column; gap: 1.6em; }
.birthday-override__photo {
  flex: none; width: 8em; height: 8em; border-radius: 50%; overflow: hidden;
  border: 0.28em solid #fde047; box-shadow: 0 0 0 0.12em rgba(255,255,255,0.5), 0 0.5em 1.4em rgba(0,0,0,0.35);
  background: rgba(255,255,255,0.15);
}
.birthday-override__img { width: 100%; height: 100%; object-fit: cover; display: block; }
.birthday-override--no-photo .birthday-override__photo { display: none; }
.birthday-override__body { display: flex; flex-direction: column; align-items: center; gap: 0.4em; min-width: 0; max-width: 22em; }
.birthday-override__kicker { font-weight: 800; font-size: 1.7em; text-shadow: 0 0.1em 0.3em rgba(0,0,0,0.3); }
.birthday-override__name { font-weight: 800; font-size: 2.3em; line-height: 1.1; word-break: break-word; text-shadow: 0 0.15em 0.4em rgba(0,0,0,0.35); }
.birthday-override__title { font-size: 1.05em; opacity: 0.9; }

/* --- Playlist item transitions --------------------------------------------
   10 simple, dependency-free effects applied when a playlist item appears,
   picked per-item on the Playlists page. Each is a plain CSS @keyframes
   pair (-in for the incoming element, -out for the outgoing one) driven by
   applyContentTransition() in app.js, shared by kiosk.js (the real TV
   output) and player.js (the live previews) so both look identical. Every
   content element these apply to (img/video/.widget-face/iframe) is already
   `position:absolute;inset:0`, so the outgoing and incoming elements simply
   overlap for the animation's duration instead of one instantly replacing
   the other. */
@keyframes t-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes t-fade-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes t-slide-left-in { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes t-slide-left-out { from { transform: translateX(0); } to { transform: translateX(-100%); } }
@keyframes t-slide-right-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes t-slide-right-out { from { transform: translateX(0); } to { transform: translateX(100%); } }
@keyframes t-slide-up-in { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes t-slide-up-out { from { transform: translateY(0); } to { transform: translateY(-100%); } }
@keyframes t-slide-down-in { from { transform: translateY(-100%); } to { transform: translateY(0); } }
@keyframes t-slide-down-out { from { transform: translateY(0); } to { transform: translateY(100%); } }

@keyframes t-zoom-in-in { from { opacity: 0; transform: scale(0.85); } to { opacity: 1; transform: scale(1); } }
@keyframes t-zoom-in-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes t-zoom-out-in { from { opacity: 0; transform: scale(1.15); } to { opacity: 1; transform: scale(1); } }
@keyframes t-zoom-out-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes t-iris-in { from { clip-path: circle(0% at 50% 50%); } to { clip-path: circle(150% at 50% 50%); } }
@keyframes t-iris-out { from { opacity: 1; } to { opacity: 0; } }

@keyframes t-flip-in { from { opacity: 0; transform: rotateY(-90deg); } to { opacity: 1; transform: rotateY(0deg); } }
@keyframes t-flip-out { from { opacity: 1; transform: rotateY(0deg); } to { opacity: 0; transform: rotateY(90deg); } }

@keyframes t-blur-in { from { opacity: 0; filter: blur(16px); } to { opacity: 1; filter: blur(0); } }
@keyframes t-blur-out { from { opacity: 1; filter: blur(0); } to { opacity: 0; filter: blur(16px); } }

.t-fade-in, .t-fade-out, .t-slide-left-in, .t-slide-left-out, .t-slide-right-in,
.t-slide-right-out, .t-slide-up-in, .t-slide-up-out, .t-slide-down-in, .t-slide-down-out,
.t-zoom-in-in, .t-zoom-in-out, .t-zoom-out-in, .t-zoom-out-out, .t-iris-in, .t-iris-out,
.t-flip-in, .t-flip-out, .t-blur-in, .t-blur-out {
  animation-duration: 650ms; animation-timing-function: cubic-bezier(.4,0,.2,1); animation-fill-mode: both;
}
.t-fade-in { animation-name: t-fade-in; } .t-fade-out { animation-name: t-fade-out; }
.t-slide-left-in { animation-name: t-slide-left-in; } .t-slide-left-out { animation-name: t-slide-left-out; }
.t-slide-right-in { animation-name: t-slide-right-in; } .t-slide-right-out { animation-name: t-slide-right-out; }
.t-slide-up-in { animation-name: t-slide-up-in; } .t-slide-up-out { animation-name: t-slide-up-out; }
.t-slide-down-in { animation-name: t-slide-down-in; } .t-slide-down-out { animation-name: t-slide-down-out; }
.t-zoom-in-in { animation-name: t-zoom-in-in; } .t-zoom-in-out { animation-name: t-zoom-in-out; }
.t-zoom-out-in { animation-name: t-zoom-out-in; } .t-zoom-out-out { animation-name: t-zoom-out-out; }
.t-iris-in { animation-name: t-iris-in; } .t-iris-out { animation-name: t-iris-out; }
.t-flip-in { animation-name: t-flip-in; } .t-flip-out { animation-name: t-flip-out; }
.t-blur-in { animation-name: t-blur-in; } .t-blur-out { animation-name: t-blur-out; }

/* Displays page multiview wall. A masonry-style column layout rather than
   CSS grid — landscape tiles are short, a portrait screen's tile is much
   taller, and a grid would size every row to its tallest cell, leaving big
   gaps under the shorter tiles next to a portrait one. Columns let each
   tile flow to its own height instead. */
.display-wall { column-count: 1; column-gap: 1rem; }
@media (min-width: 640px) { .display-wall { column-count: 2; } }
@media (min-width: 1024px) { .display-wall { column-count: 3; } }
@media (min-width: 1280px) { .display-wall { column-count: 4; } }

/* A multiview tile: live preview leads, compact info + a condensed action
   row underneath, so the wall reads at a glance instead of requiring a
   scroll through one screen at a time. break-inside keeps a tile from
   being split across two columns. */
.display-tile { display: flex; flex-direction: column; break-inside: avoid; margin-bottom: 1rem; }

/* Drag-to-reorder state, shared by the Displays grid (displayCard tiles)
   and the Playout Preview grid (per-screen mount divs) - see displays.html
   and player.js. [draggable="true"] gets the grab cursor as a passive hint
   even before a drag starts; .dragging/.drag-over are toggled during an
   actual drag via JS. */
[draggable="true"] { cursor: grab; }
.dragging { opacity: 0.4; }
.drag-over { outline: 2px dashed var(--brand); outline-offset: 2px; }

.scroll-x { overflow-x: auto; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

/* --- Page header (eyebrow + title, used at the top of every section) --- */
.page-header .eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 0.15rem;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}
.page-header p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 0.2rem;
}

/* --- Credit footer, injected at the bottom of every authenticated page --- */
.app-footer {
  margin-top: 2.5rem;
  padding: 1.1rem 0 0.4rem;
  border-top: 1px solid var(--gridline);
  text-align: center;
}
/* The product tagline (e.g. "ALYNDA Digital Signage System") used to sit
   under the brand logo/name; moved down here as a quiet footer note instead,
   so the logo area reads as just the client's own identity. */
.footer-tagline {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.75;
  margin-bottom: 0.4rem;
}
.footer-tagline:empty { display: none; }
.app-footer .credit-line {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-muted);
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  row-gap: 0.3rem;
}
.app-footer .credit-line .sep {
  color: var(--border);
  font-weight: 400;
}
.app-footer .credit-line a { color: var(--text-muted); text-decoration: none; }
.app-footer .credit-line a:hover { color: var(--brand); }

/* --- Login: split brand panel + form. This is also the app's "/" landing
   page (server.js redirects here directly) — one screen instead of a
   separate welcome step, with a feature-highlight panel next to the actual
   sign-in form. --- */
.auth-shell { min-height: 100vh; display: flex; flex-direction: column; }
.auth-panel {
  display: none;
  position: relative;
  background: var(--ink);
  color: #fff;
  padding: 2.75rem 3rem;
  flex-direction: column;
  gap: 1.75rem;
  overflow: hidden;
  overflow-y: auto;
}
/* Soft glow top-right + a faint dot grid, replacing the old lit-tile grid —
   quieter now that the panel carries real copy instead of just texture. */
.auth-panel::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(480px 320px at 88% -8%, rgba(124,155,255,0.22), transparent 65%),
    radial-gradient(circle, rgba(255,255,255,0.09) 1px, transparent 1px);
  background-size: auto, 22px 22px;
  background-position: 0 0, 0 0;
  pointer-events: none;
}
.auth-panel::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(12,18,32,0.35), var(--ink) 72%);
}
/* Centers the (now stacked, auto-width) brand block horizontally within the
   panel — the block itself only needs justify-content:center from a flex
   parent to sit centered, since nav-brand-stacked already centers its own
   children. */
.auth-panel-content { position: relative; z-index: 1; flex: none; display: flex; justify-content: center; }
.auth-panel .nav-wordmark { font-size: 1.4rem; line-height: 1.3; max-width: 34rem; text-align: center; white-space: normal; }
.auth-panel .nav-mark-logo { width: 112px; height: 112px; }
.auth-panel .nav-brand { align-items: center; }

.auth-eyebrow {
  position: relative; z-index: 1;
  display: inline-flex; align-self: flex-start;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cdd8ff;
  background: rgba(124,155,255,0.16);
  border: 1px solid rgba(124,155,255,0.3);
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
}
.auth-headline {
  position: relative; z-index: 1;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.01em;
  max-width: 22rem;
}
.auth-headline .accent { color: #7c9bff; }
.auth-subcopy {
  position: relative; z-index: 1;
  font-size: 0.95rem;
  line-height: 1.55;
  color: var(--ink-text-muted);
  max-width: 24rem;
}

.auth-features {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; gap: 0.9rem;
  max-width: 26rem;
}
.auth-feature { display: flex; align-items: flex-start; gap: 0.75rem; }
.auth-feature-icon {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 0.55rem;
  background: rgba(124,155,255,0.16);
  color: #a9bdff;
  display: flex; align-items: center; justify-content: center;
}
.auth-feature-title { font-size: 0.85rem; font-weight: 700; color: #fff; }
.auth-feature-desc { font-size: 0.78rem; color: var(--ink-text-muted); line-height: 1.45; }

/* Small "live dashboard" preview card — purely decorative, built from plain
   HTML/CSS (no screenshot asset) so it never goes stale and needs no image
   file per brand. */
.auth-preview-card {
  position: relative; z-index: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 0.85rem;
  padding: 0.9rem 1rem;
  margin-top: auto;
}
.auth-preview-card-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--ink-text-muted);
  margin-bottom: 0.7rem;
}
.auth-preview-card-head .live-dot {
  display: inline-flex; align-items: center; gap: 0.35rem;
  color: #7ee0a8; text-transform: none; letter-spacing: 0; font-weight: 600;
}
.auth-preview-card-head .live-dot::before {
  content: ""; width: 6px; height: 6px; border-radius: 999px; background: #2fbf71;
  box-shadow: 0 0 0 3px rgba(47,191,113,0.25);
}
.auth-preview-stats { display: flex; gap: 0.6rem; }
.auth-preview-stat {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border-radius: 0.55rem;
  padding: 0.55rem 0.65rem;
}
.auth-preview-stat .num { font-size: 1.15rem; font-weight: 800; color: #fff; line-height: 1.2; }
.auth-preview-stat .lbl { font-size: 0.66rem; color: var(--ink-text-muted); }

.auth-form-side {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
}
.auth-mobile-brand { display: flex; }

.auth-welcome-title { display: flex; align-items: center; gap: 0.4rem; }
.password-field { position: relative; }
.password-field .input { padding-right: 2.4rem; }
.password-toggle {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; padding: 0.2rem; cursor: pointer;
  color: var(--text-muted); display: flex; align-items: center;
}
.password-toggle:hover { color: var(--text-secondary); }

@media (min-width: 1024px) {
  .auth-shell { flex-direction: row; }
  .auth-panel { display: flex; width: 48%; flex: none; }
  .auth-form-side { padding: 2rem; }
  .auth-mobile-brand { display: none; }
}

/* --- Dashboard --- */
/* KPI tiles get a colored icon roundel on top instead of the plain
   label-only stat-tile used elsewhere - the color is purely decorative
   (keyed per-tile below), every number next to it is real. */
.dash-kpi-icon {
  width: 40px; height: 40px; border-radius: 0.65rem;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.6rem;
}
.dash-kpi-icon svg { width: 20px; height: 20px; }
.dash-kpi-purple { background: #ede9fe; color: #7c3aed; }
.dash-kpi-green { background: var(--status-good-soft); color: var(--status-good); }
.dash-kpi-amber { background: var(--status-warning-bg); color: var(--status-warning); }
.dash-kpi-blue { background: var(--brand-soft); color: var(--brand); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .dash-kpi-purple { background: rgba(124,58,237,0.22); color: #b79bff; }
}
:root[data-theme="dark"] .dash-kpi-purple { background: rgba(124,58,237,0.22); color: #b79bff; }

/* Screens-overview donut (plain SVG, no chart library) plus its legend. */
.dash-donut-row { display: flex; align-items: center; gap: 1.5rem; flex-wrap: wrap; }
.dash-donut-total-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.dash-donut-total-value { font-size: 1.6rem; font-weight: 800; color: var(--text-primary); }
.dash-legend { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; min-width: 10rem; }
.dash-legend-row { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; }
.dash-legend-row .sw { width: 9px; height: 9px; border-radius: 999px; flex-shrink: 0; }
.dash-legend-row .lbl { color: var(--text-secondary); flex: 1; }
.dash-legend-row .val { font-weight: 700; color: var(--text-primary); }

/* Orientation split (real per-display data) - two small stat boxes. */
.dash-orient-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; margin-top: 1rem; }
.dash-orient-box {
  background: var(--surface-2); border-radius: 0.7rem; padding: 0.75rem 0.9rem;
  display: flex; align-items: center; gap: 0.6rem;
}
.dash-orient-box svg { flex-shrink: 0; color: var(--text-muted); }
.dash-orient-box .num { font-size: 1.15rem; font-weight: 800; color: var(--text-primary); line-height: 1.15; }
.dash-orient-box .lbl { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }

/* Live Screens grid - each tile is a real (bare-mode) ScreenPlayer, so what
   shows is genuinely playing, not a static mock. */
.dash-live-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
@media (min-width: 640px) { .dash-live-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.dash-live-tile { position: relative; }
.dash-live-tile .player-screen { aspect-ratio: 4/3; border-radius: 0.6rem; }
.dash-live-tile .player-screen.portrait { aspect-ratio: 3/4; }
/* ScreenPlayer's own bare-mode caption ("Playlist — Media title") is
   redundant with this tile's own name/zone caption below and too long for
   a small grid cell — hide it here without changing ScreenPlayer itself
   (the same caption is exactly what the Playout Preview page wants). */
.dash-live-tile [data-mount] > .text-xs { display: none; }
.dash-live-tile .dash-live-caption { margin-top: 0.4rem; font-size: 0.72rem; }
.dash-live-tile .dash-live-name { font-weight: 700; color: var(--text-primary); display: flex; align-items: center; gap: 0.35rem; }
.dash-live-tile .dash-live-zone { color: var(--text-muted); }
.dash-live-dot { width: 7px; height: 7px; border-radius: 999px; flex-shrink: 0; }
.dash-live-more {
  display: flex; align-items: center; justify-content: center; text-align: center;
  aspect-ratio: 4/3; border-radius: 0.6rem; background: var(--surface-2);
  color: var(--text-secondary); font-size: 0.8rem; font-weight: 600; padding: 0.5rem;
}

/* 7-day play-history mini area chart (plain inline SVG, real counts). */
.dash-chart-wrap { width: 100%; }
.dash-chart-wrap svg { width: 100%; height: auto; display: block; }
.dash-chart-days { display: flex; justify-content: space-between; margin-top: 0.35rem; font-size: 0.68rem; color: var(--text-muted); }

/* Top zones bar list (real display counts per zone). */
.dash-zone-row { margin-bottom: 0.7rem; }
.dash-zone-row:last-child { margin-bottom: 0; }
.dash-zone-head { display: flex; justify-content: space-between; font-size: 0.8rem; margin-bottom: 0.3rem; }
.dash-zone-head .name { font-weight: 600; color: var(--text-primary); }
.dash-zone-head .count { color: var(--text-muted); }
.dash-zone-track { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.dash-zone-fill { height: 100%; background: var(--brand); border-radius: 999px; }

/* Recent-activity rows with a small colored icon roundel keyed to what kind
   of event it was (derived from the activity message text - see
   activityIconFor() in dashboard.html). */
.dash-activity-row { display: flex; gap: 0.65rem; align-items: flex-start; }
.dash-activity-icon {
  width: 28px; height: 28px; border-radius: 999px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.dash-activity-icon svg { width: 14px; height: 14px; }


/* ==========================================================================
   BIRTHDAY CARD v2 - photo fix, rotating bilingual wishes, proper landscape
   and portrait layouts. Sizes are em-based off a font-size kiosk.js sets
   from the screen's real footprint (see updateBirthdayOrientation()).
   ========================================================================== */
/* Fix: kiosk.html's full-bleed `.kiosk-screen img {position:absolute;
   inset:0}` rule (meant for adverts) was stretching the birthday photo over
   the whole card and hiding the name and text. */
.kiosk-screen .birthday-override__img,
.birthday-override .birthday-override__img { position: static !important; inset: auto !important; width: 100% !important; height: 100% !important; object-fit: cover; }

.birthday-override {
  background:
    radial-gradient(ellipse at 15% 10%, rgba(253, 224, 71, 0.22), transparent 45%),
    radial-gradient(ellipse at 90% 95%, rgba(244, 114, 182, 0.28), transparent 50%),
    linear-gradient(140deg, #7c3aed 0%, #5b21b6 48%, #3b0764 100%);
}
.birthday-override__inner { width: 100%; height: 100%; padding: 2.4em 3.2em; gap: 3em; }
.birthday-override--portrait .birthday-override__inner { flex-direction: column; justify-content: center; gap: 1.8em; padding: 3em 2.2em; }

.birthday-override__photo {
  width: 13em; height: 13em; border-width: 0.4em;
  box-shadow: 0 0 0 0.6em rgba(253, 224, 71, 0.18), 0 0 0 1.25em rgba(255, 255, 255, 0.06), 0 1.2em 3em rgba(0, 0, 0, 0.45);
  animation: bd-pop 0.9s cubic-bezier(.2, 1.4, .4, 1) both;
}
.birthday-override--portrait .birthday-override__photo { width: 15em; height: 15em; }

.birthday-override__body { max-width: 32em; gap: 0.55em; align-items: flex-start; text-align: left; }
.birthday-override--portrait .birthday-override__body { align-items: center; text-align: center; max-width: 100%; }
.birthday-override--no-photo .birthday-override__body { align-items: center; text-align: center; }

.birthday-override__kicker {
  font-size: 1em; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  color: #3b0764; background: #fde047; padding: 0.4em 0.95em; border-radius: 999px; text-shadow: none;
}
.birthday-override__name { font-size: 3.6em; line-height: 1.02; letter-spacing: -0.02em; margin-top: 0.15em; animation: bd-rise 0.8s 0.15s ease-out both; }
.birthday-override--portrait .birthday-override__name { font-size: 3.4em; }
.birthday-override__title { font-size: 1.25em; opacity: 0.85; font-weight: 500; }
.birthday-override__title:empty { display: none; }

.bd-wish {
  margin-top: 0.9em; padding: 1em 1.3em; border-radius: 0.9em; max-width: 30em;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.22);
  transition: opacity 0.45s ease, transform 0.45s ease;
}
.bd-wish--out { opacity: 0; transform: translateY(0.4em); }
.bd-wish__sw { font-size: 1.45em; font-weight: 700; line-height: 1.3; }
.bd-wish__en { font-size: 1.1em; opacity: 0.8; margin-top: 0.35em; line-height: 1.35; font-style: italic; }
.bd-from { font-size: 0.95em; opacity: 0.75; margin-top: 0.4em; letter-spacing: 0.04em; }

/* CSS-only balloons drifting up behind the card (no image assets). */
.bd-balloons { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
.bd-balloons span {
  position: absolute; bottom: -9em; width: 3.2em; height: 4em; border-radius: 50% 50% 48% 48%;
  opacity: 0.85; animation: bd-float 14s linear infinite;
}
.bd-balloons span::after { content: ''; position: absolute; left: 50%; top: 100%; width: 1px; height: 4em; background: rgba(255, 255, 255, 0.35); }
.bd-balloons span:nth-child(1) { left: 6%;  background: #fde047; animation-delay: 0s; }
.bd-balloons span:nth-child(2) { left: 22%; background: #f472b6; animation-delay: 5s; transform: scale(0.8); }
.bd-balloons span:nth-child(3) { left: 78%; background: #38bdf8; animation-delay: 2.5s; }
.bd-balloons span:nth-child(4) { left: 90%; background: #fb923c; animation-delay: 8s; transform: scale(0.7); }
.bd-balloons span:nth-child(5) { left: 55%; background: #a3e635; animation-delay: 11s; transform: scale(0.6); }
@keyframes bd-float { 0% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-60vh) rotate(4deg); } 100% { transform: translateY(-130vh) rotate(-4deg); } }
@keyframes bd-pop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes bd-rise { from { transform: translateY(0.4em); opacity: 0; } to { transform: none; opacity: 1; } }
.birthday-override__kicker { white-space: nowrap; font-size: 0.95em; }
.birthday-override--portrait .birthday-override__kicker { font-size: 0.85em; letter-spacing: 0.1em; }
.birthday-override__name { font-size: 3.2em; }
.birthday-override--portrait .birthday-override__name { font-size: 3em; }
.birthday-override::before { opacity: 0.28; }

/* ==========================================================================
   GLASS THEME (dashboard pages only)
   Deep green gradient backdrop with a warm glow, a floating frosted sidebar,
   and light frosted panels. Gentle motion: panels rise in, numbers count up,
   charts draw themselves (see dashboard.html). Scoped with :has(.app-shell)
   so the TV screens (kiosk.html) and the login page are untouched.
   Accent colour lives in --gl-accent.
   ========================================================================== */
:root:has(.app-shell) {
  color-scheme: light;
  --gl-accent: #1f6b4f;          /* deep green - active state, charts */
  --gl-accent-2: #3f9b74;
  --gl-ink: #14201b;             /* dark pill buttons */
  --gl-glass: rgba(244, 247, 245, 0.80);
  --gl-glass-2: rgba(255, 255, 255, 0.58);
  --gl-line: rgba(20, 32, 27, 0.08);

  --page: #0f241d;
  --surface-1: var(--gl-glass);
  --surface-2: rgba(255, 255, 255, 0.55);
  --text-primary: #14201b;
  --text-secondary: #4d5c55;
  --text-muted: #7b8a83;
  --border: rgba(255, 255, 255, 0.55);
  --gridline: rgba(20, 32, 27, 0.07);

  --ink: rgba(16, 38, 30, 0.55);
  --ink-2: rgba(255, 255, 255, 0.08);
  --ink-line: rgba(255, 255, 255, 0.10);
  --ink-text: #dfe9e3;
  --ink-text-muted: #93a89e;

  --brand: var(--gl-accent);
  --brand-strong: #17533d;
  --brand-ink: #ffffff;
  --brand-soft: rgba(31, 107, 79, 0.10);

  --status-good: #23885b;
  --status-good-soft: rgba(35, 136, 91, 0.12);
  --status-warning: #b7791f;
  --status-warning-bg: rgba(183, 121, 31, 0.13);
  --status-critical: #c8423a;
  --status-critical-bg: rgba(200, 66, 58, 0.12);
  --status-neutral: #6b7a73;
  --status-neutral-bg: rgba(107, 122, 115, 0.12);
  --shadow-card: 0 1px 0 rgba(255,255,255,0.6) inset, 0 12px 32px -18px rgba(6, 20, 15, 0.55);
}
:root:has(.app-shell) body {
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  background:
    radial-gradient(1200px 700px at 8% -10%, rgba(78, 150, 115, 0.55), transparent 60%),
    radial-gradient(900px 700px at 105% 110%, rgba(176, 132, 58, 0.55), transparent 60%),
    radial-gradient(700px 500px at 70% 30%, rgba(40, 92, 72, 0.35), transparent 70%),
    linear-gradient(160deg, #13342a 0%, #0d241c 55%, #1b2a1d 100%);
  background-attachment: fixed;
}
.app-shell { background: transparent !important; gap: 0; }
.app-shell ::selection { background: rgba(63, 155, 116, 0.3); }

/* --- Floating glass sidebar ------------------------------------------- */
.app-shell .topnav {
  background: var(--ink); border: 1px solid var(--ink-line); color: var(--ink-text);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
}
@media (min-width: 1024px) {
  .app-shell .topnav {
    width: 236px; margin: 14px 0 14px 14px; height: calc(100vh - 28px); top: 14px;
    border-radius: 20px; overflow-y: auto; scrollbar-width: none;
    box-shadow: 0 20px 50px -25px rgba(0, 0, 0, 0.6);
  }
  .app-shell .topnav::-webkit-scrollbar { display: none; }
}
.app-shell .nav-brand { padding: 1.05rem 1rem 0.8rem; gap: 0.65rem; }
.app-shell .nav-mark { width: 36px; height: 36px; border-radius: 11px; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.18); }
.app-shell .nav-mark-logo { background: transparent; border: 0; width: 40px; height: 40px; }
.app-shell .nav-wordmark { font-size: 0.86rem; font-weight: 700; color: #f2f7f4; }
.app-shell .nav-sub { font-size: 0.62rem; color: var(--ink-text-muted); margin-top: 0.1rem; }
.app-shell .nav-brand-stacked { padding: 1.2rem 1rem 0.9rem; }
.app-shell .nav-brand-stacked .nav-mark-logo { width: 60px; height: 60px; }
.app-shell .nav-brand-stacked .nav-wordmark { font-size: 0.78rem; }

.app-shell .nav-links { gap: 0.15rem; padding: 0.2rem 0.65rem 0.8rem; }
.app-shell .nav-section { font-size: 0.6rem; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: #7f978c; padding: 0.95rem 0.6rem 0.35rem; white-space: nowrap; flex-shrink: 0; }
.app-shell .nav-section:first-child { padding-top: 0.3rem; }
.app-shell .nav-gap { display: none; }
.app-shell .nav-links a.navlink {
  position: relative; background: transparent; border: 1px solid transparent; border-radius: 11px;
  color: #c8d7cf; font-size: 0.8rem; font-weight: 500; padding: 0.52rem 0.7rem; gap: 0.65rem;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}
.app-shell .nav-links a.navlink svg { opacity: 0.9; }
.app-shell .nav-links a.navlink:hover { filter: none; background: rgba(255, 255, 255, 0.07); color: #fff; transform: translateX(2px); }
.app-shell .nav-links a.navlink.active {
  color: #fff; border-color: rgba(160, 225, 190, 0.35);
  background: linear-gradient(135deg, rgba(63, 155, 116, 0.75), rgba(31, 107, 79, 0.75));
  box-shadow: 0 6px 18px -8px rgba(63, 155, 116, 0.8), inset 0 1px 0 rgba(255,255,255,0.18);
}
.app-shell .nav-links a.navlink .nav-count {
  margin-left: auto; min-width: 18px; height: 18px; border-radius: 999px; padding: 0 0.35rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.62rem; font-weight: 600; color: #e9f3ee; background: rgba(255, 255, 255, 0.14);
}
.app-shell .nav-links a.navlink-danger { color: #ffb4ad; background: transparent; border-color: transparent; }
.app-shell .nav-links a.navlink-danger:hover { background: rgba(200, 66, 58, 0.2); color: #fff; }
.app-shell .nav-links a.navlink-danger.active { background: linear-gradient(135deg, rgba(220, 80, 70, 0.8), rgba(170, 40, 35, 0.8)); border-color: rgba(255, 160, 150, 0.4); color: #fff; box-shadow: 0 6px 18px -8px rgba(220, 80, 70, 0.8); }

.app-shell .nav-user-row { border-top: 1px solid var(--ink-line); margin: 0 0.8rem; padding: 0.8rem 0.1rem 0.9rem; gap: 0.6rem; justify-content: flex-start; }
.app-shell .nav-user-name { font-size: 0.75rem; font-weight: 600; color: #eef4f0; }
.app-shell .nav-user-role { font-size: 0.65rem; color: var(--ink-text-muted); }
.app-shell .nav-user-links { font-size: 0.64rem; color: var(--ink-text-muted); margin-top: 0.1rem; }
.app-shell .nav-user-links a { color: var(--ink-text-muted); }
.app-shell .nav-user-links a:hover { color: #fff; }
.app-shell .nav-logout { margin-left: auto; flex: none; width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; color: #b9cbc2; background: rgba(255,255,255,0.06); border: 1px solid var(--ink-line); cursor: pointer; }
.app-shell .nav-logout:hover { color: #ffb4ad; background: rgba(200, 66, 58, 0.18); }
@media (max-width: 1023px) {
  .app-shell .topnav { margin: 10px; border-radius: 16px; }
  .app-shell .nav-section { display: none; }
  .app-shell .nav-links { padding-bottom: 0.6rem; }
}

/* --- Right column: top bar + frosted main area -------------------------- */
.gl-col { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 14px 14px 14px 14px; gap: 12px; }
@media (max-width: 1023px) { .gl-col { padding: 0 10px 10px; } }
.cr-topbar {
  display: flex; align-items: center; gap: 0.7rem; height: 52px; padding: 0 0.5rem 0 0.35rem;
  position: sticky; top: 14px; z-index: 40;
}
.gl-search {
  position: relative; flex: 0 1 420px; height: 42px; border-radius: 14px; display: flex; align-items: center; gap: 0.55rem; padding: 0 0.6rem 0 0.85rem;
  background: rgba(16, 38, 30, 0.45); border: 1px solid var(--ink-line); color: #c8d7cf;
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.gl-search svg { width: 15px; height: 15px; flex: none; opacity: 0.8; }
.gl-search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: #eef4f0; font-size: 0.8rem; }
.gl-search input::placeholder { color: #8fa59b; }
.gl-search kbd { font: 600 0.6rem system-ui; color: #a9bdb3; border: 1px solid var(--ink-line); border-radius: 6px; padding: 0.15rem 0.35rem; }
.gl-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); border-radius: 14px; padding: 0.35rem; background: rgba(244, 247, 245, 0.96); box-shadow: 0 20px 40px -20px rgba(0,0,0,0.6); display: none; }
.gl-results.open { display: block; animation: gl-rise 0.18s ease-out both; }
.gl-results a { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 9px; font-size: 0.8rem; color: var(--text-primary); }
.gl-results a svg { width: 15px; height: 15px; color: var(--gl-accent); }
.gl-results a.sel, .gl-results a:hover { background: var(--brand-soft); }
.cr-topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.gl-round { width: 40px; height: 40px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; background: rgba(16, 38, 30, 0.45); border: 1px solid var(--ink-line); color: #dfe9e3; backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: transform 150ms ease, background 150ms ease; }
.gl-round:hover { transform: translateY(-1px); background: rgba(255,255,255,0.14); }
.gl-round svg { width: 17px; height: 17px; }
.gl-round.light { background: #f4f7f5; color: var(--gl-ink); border-color: transparent; }
.cr-live { display: inline-flex; align-items: center; gap: 0.45rem; height: 40px; padding: 0 0.85rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600; color: #cfeedd; background: rgba(16, 38, 30, 0.45); border: 1px solid var(--ink-line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); white-space: nowrap; }
.cr-live .dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd49a; box-shadow: 0 0 0 0 rgba(95, 212, 154, 0.6); animation: gl-ping 2s infinite; }
.cr-live.is-danger { color: #fff; background: rgba(200, 66, 58, 0.85); border-color: rgba(255, 170, 160, 0.5); }
.cr-live.is-danger .dot { background: #fff; animation: gl-blink 0.9s infinite; }
.cr-live.is-important { color: #241703; background: rgba(240, 180, 41, 0.9); }
.cr-live.is-important .dot { background: #241703; animation: none; }
.gl-user { display: flex; align-items: center; gap: 0.55rem; padding-left: 0.3rem; }
.gl-user .n { font-size: 0.75rem; font-weight: 600; color: #f2f7f4; line-height: 1.15; }
.gl-user .r { font-size: 0.62rem; color: #9db3a9; }
.cr-clock { display: none; }
@media (max-width: 767px) { .gl-user .t, .cr-live span:last-child { display: none; } .gl-search { flex-basis: auto; } }

.app-shell main, .gl-col > main {
  max-width: none !important; width: auto !important; margin: 0 !important; min-width: 0;
  padding: 1.6rem 1.75rem 0 !important; border-radius: 24px;
  background: linear-gradient(160deg, rgba(255,255,255,0.16), rgba(255,255,255,0.07));
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(22px) saturate(130%); -webkit-backdrop-filter: blur(22px) saturate(130%);
  box-shadow: 0 30px 60px -35px rgba(0, 0, 0, 0.7);
}
@media (max-width: 639px) { .gl-col > main { padding: 1rem 0.9rem 0 !important; border-radius: 18px; } }
.gl-col > main.max-w-md > *:not(.app-footer) { max-width: 30rem; }
.gl-col > main.max-w-3xl > *:not(.app-footer) { max-width: 52rem; }
.gl-col > main.max-w-4xl > *:not(.app-footer) { max-width: 60rem; }

/* Page headings sit on the glass, so they read light. */
.gl-col > main h1.text-xl { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.025em; color: #f4f8f6; }

/* Everything inside reads as frosted light glass */
.app-shell .card, .app-shell .stat-tile {
  background: var(--gl-glass); border: 1px solid rgba(255,255,255,0.6); border-radius: 18px;
  box-shadow: var(--shadow-card); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.app-shell .btn { border-radius: 11px; font-size: 0.8rem; transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease; }
.app-shell .btn:hover:not(:disabled) { transform: translateY(-1px); }
.app-shell .btn-primary { background: var(--gl-ink); color: #fff; box-shadow: 0 8px 18px -10px rgba(0,0,0,0.6); }
.app-shell .btn-primary:hover:not(:disabled) { background: #22322b; }
.app-shell .btn-secondary { background: rgba(255,255,255,0.75); border-color: rgba(20,32,27,0.08); color: var(--text-primary); }
.app-shell .btn-secondary:hover:not(:disabled) { background: #fff; }
.app-shell .btn-danger { background: var(--status-critical); color: #fff; }
.app-shell .btn-danger:hover:not(:disabled) { background: #b23630; }
.app-shell .input, .app-shell select.input, .app-shell textarea.input { background: rgba(255,255,255,0.75); border-color: rgba(20,32,27,0.1); border-radius: 11px; }
.app-shell .input:focus { outline-color: var(--gl-accent-2); }
.app-shell table.data-table th { font-size: 0.66rem; letter-spacing: 0.08em; color: var(--text-muted); }
.app-shell table.data-table tbody tr { transition: background 120ms ease; }
.app-shell table.data-table tbody tr:hover td { background: rgba(31, 107, 79, 0.05); }
.app-shell .badge { border-radius: 999px; }
.app-shell .stat-tile .stat-value { letter-spacing: -0.02em; }

/* Alerts page: selected alert-type card stays readable on glass */
.app-shell .alert-type-btn { background: rgba(255,255,255,0.6); }

/* Footer on the glass */
.app-shell .app-footer { margin: 2.2rem -1.75rem 0; padding: 1rem 1.75rem 1.2rem; border-top: 1px solid rgba(255,255,255,0.12); }
.app-shell .footer-tagline { color: #a7bdb2; }
.app-shell .app-footer .credit-line, .app-shell .app-footer .credit-line a { color: #c3d4cb; }

/* Gentle entrance motion for whatever a page renders */
@media (prefers-reduced-motion: no-preference) {
  .gl-col > main > * { animation: gl-rise 0.55s cubic-bezier(.2,.8,.2,1) both; }
  .gl-col > main > *:nth-child(2) { animation-delay: 0.06s; }
  .gl-col > main > *:nth-child(3) { animation-delay: 0.12s; }
  .gl-col > main > *:nth-child(4) { animation-delay: 0.18s; }
  .gl-col > main > *:nth-child(n+5) { animation-delay: 0.24s; }
  .app-shell .card, .app-shell .stat-tile { transition: transform 180ms ease, box-shadow 180ms ease; }
}
@keyframes gl-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes gl-ping { 0% { box-shadow: 0 0 0 0 rgba(95, 212, 154, 0.55); } 80%, 100% { box-shadow: 0 0 0 8px rgba(95, 212, 154, 0); } }
@keyframes gl-blink { 50% { opacity: 0.2; } }
:root:has(.app-shell) { background: #0f241d; }
/* Text colour by where it sits: light on the green glass, dark inside cards. */
.gl-col > main :is(h1, h2, h3):not(:is(.card, .stat-tile, .gd-card, .pt-panel, .pt-stage, .modal, [role="dialog"]) *) { color: #f4f8f6; }
.gl-col > main :is(p, .text-sm, .text-xs, label.field-label):not(:is(.card, .stat-tile, .gd-card, .pt-panel, .pt-stage, .modal, [role="dialog"], .app-footer, .gd-hero) *) { color: #b9cdc3 !important; }
.gl-col > main :is(.card, .stat-tile) :is(h1, h2, h3) { color: var(--text-primary) !important; }
.gl-col > main :is(.card, .stat-tile) h1.text-xl + p { color: var(--text-secondary) !important; }
@media (max-width: 640px) {
  .gl-user, .gl-search kbd { display: none; }
  .gl-search { flex: 1 1 auto; }
  .cr-topbar { gap: 0.4rem; }
  .cr-topbar-right { gap: 0.35rem; }
  .gl-round, .cr-live { width: 38px; height: 38px; padding: 0; justify-content: center; }
}
/* Top bar scrolls with the page (a pinned transparent bar overlapped content). */
.cr-topbar { position: relative; top: auto; }
.app-shell textarea.input { font-family: inherit; }

/* --- Background picker (templates editor + birthdays page) --- */
.bgp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.2rem, 1fr)); gap: 0.4rem; }
.bgp-tile { position: relative; aspect-ratio: 16 / 10; border-radius: 0.55rem; border: 2px solid transparent; background: #1c2a24 center / cover no-repeat; cursor: pointer; padding: 0; color: #fff; font-size: 0.62rem; font-weight: 700; box-shadow: inset 0 0 0 1px rgba(20,32,27,0.12); }
.bgp-tile:hover { border-color: rgba(31,107,79,0.5); }
.bgp-tile.on { border-color: var(--brand, #1f6b4f); box-shadow: 0 0 0 3px var(--brand-soft, rgba(31,107,79,0.2)); }
.bgp-none { background: repeating-linear-gradient(45deg, #f4f6f5 0 6px, #e3e8e5 6px 12px); color: #3d5a4d; }
.bgp-up { background: rgba(20,32,27,0.06); color: var(--text-secondary, #3d5a4d); border: 2px dashed rgba(20,32,27,0.25); font-size: 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.bgp-up small { font-size: 0.55rem; margin-top: 0.15rem; font-weight: 700; }
.bgp-del { position: absolute; top: 2px; right: 2px; width: 1.05rem; height: 1.05rem; border-radius: 50%; background: rgba(0,0,0,0.65); color: #fff; font-size: 0.75rem; line-height: 1.05rem; text-align: center; }
.bgp-dim { display: flex; align-items: center; gap: 0.5rem; margin-top: 0.55rem; font-size: 0.7rem; font-weight: 600; color: var(--text-secondary, #3d5a4d); }
.bgp-dim input { flex: 1; accent-color: var(--brand, #1f6b4f); }
.bgp-dim b { min-width: 2.4em; text-align: right; font-weight: 600; }
.bgp-dim[hidden] { display: none; }

/* Birthday card with a chosen background picture (Birthdays page). */
.birthday-override.birthday-override--bg {
  background: linear-gradient(rgba(10, 6, 20, var(--bd-dim, 0.35)), rgba(10, 6, 20, var(--bd-dim, 0.35))), var(--bd-bg) center / cover no-repeat;
}
.birthday-override--bg::before { display: none; }

/* "Update available" pill in the top bar (admins). */
.cr-update { background: #f2c14e !important; color: #1a1405 !important; gap: 0.35rem; }
.cr-update[hidden] { display: none !important; }

/* Buttons/badges hidden with the `hidden` attribute must really disappear
   (.btn sets its own display, which otherwise wins over [hidden]). */
.btn[hidden], .badge[hidden] { display: none !important; }
