/* ============================================================
   AEGIS by Allegiance — design system v2 "Glacier" (dark)
   Cool security-tech palette drawn from /brand/aegis-mark-alt-blue.png:
   near-black base, frosted dark-glass panels, ice-blue/pink accent
   gradient - glowing aurora blobs and soft radial glows, Vite-homepage
   inspired.
   ============================================================ */

:root {
  --ink: #0a0d13;
  --ink-2: #0e1219;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-solid: #12151d;
  --panel-2: #171320;
  --field: rgba(255, 255, 255, 0.045);
  --glass: rgba(255, 255, 255, 0.05);

  --ice: #ffe3ef;    /* lightest accent - pink */
  --sky: #8ec5f5;    /* primary accent - light blue */
  --azure: #ff8fc2;  /* mid - pink */
  --steel: #6fa8dc;  /* deep blue */

  --border: rgba(124, 192, 245, 0.22);
  --border-strong: rgba(255, 143, 194, 0.5);
  --hairline: rgba(255, 255, 255, 0.08);

  --text: #eef2f9;
  --dim: #9aa4b8;
  --faint: #6b7488;

  --success: #1ec98a;
  --success-bg: rgba(30, 201, 138, 0.14);
  --success-border: rgba(30, 201, 138, 0.34);
  --danger: #ff3d6e;
  --danger-bg: rgba(255, 61, 110, 0.14);
  --danger-border: rgba(255, 61, 110, 0.4);
  --warn: #f2a71f;
  --warn-bg: rgba(242, 167, 31, 0.14);
  --warn-border: rgba(242, 167, 31, 0.34);
  --info: #6fa8dc;
  --info-bg: rgba(111, 168, 220, 0.14);
  --info-border: rgba(111, 168, 220, 0.34);

  /* Conditional-formatting rule colors */
  --rule-red: #ff3d6e;
  --rule-amber: #e08a00;
  --rule-green: #16b17a;
  --rule-blue: #4a86c8;

  --grad-brand: linear-gradient(135deg, #ff8fc2 0%, #ffb3d9 36%, #7cc0f5 72%, #4a86c8 100%);
  --grad-btn: linear-gradient(135deg, #ff8fc2 0%, #6fa8dc 100%);
  --neon: #ff8fc2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  --shadow-card: 0 10px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 6px 26px rgba(255, 143, 194, 0.35);

  /* Neumorphic resting/pressed shadow pairs, one per button variant so the
     soft dual-shadow feel doesn't flatten primary/outline/ghost/danger into
     one indistinguishable color. Dark-mode neumorphism flips the light-mode
     "white highlight" side to a faint, low-alpha white glint instead - a
     true rgba(255,255,255,0.9) highlight would look like a light leak. */
  --shadow-neu-primary: 6px 6px 16px rgba(255, 143, 194, 0.35), -6px -6px 16px rgba(255, 255, 255, 0.06);
  --shadow-neu-primary-active: 3px 3px 10px rgba(255, 143, 194, 0.35), -3px -3px 10px rgba(255, 255, 255, 0.06);
  --shadow-neu-outline: 6px 6px 16px rgba(0, 0, 0, 0.4), -6px -6px 16px rgba(255, 255, 255, 0.04);
  --shadow-neu-outline-active: 3px 3px 10px rgba(0, 0, 0, 0.4), -3px -3px 10px rgba(255, 255, 255, 0.04);
  --shadow-neu-ghost: 6px 6px 14px rgba(0, 0, 0, 0.4), -6px -6px 14px rgba(255, 255, 255, 0.035);
  --shadow-neu-ghost-active: 3px 3px 9px rgba(0, 0, 0, 0.4), -3px -3px 9px rgba(255, 255, 255, 0.035);
  --shadow-neu-danger: 6px 6px 16px rgba(255, 61, 110, 0.35), -6px -6px 16px rgba(255, 255, 255, 0.06);
  --shadow-neu-danger-active: 3px 3px 10px rgba(255, 61, 110, 0.35), -3px -3px 10px rgba(255, 255, 255, 0.06);

  --font-display: "Sora", -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Consolas, monospace;

  --ease-lux: cubic-bezier(0.7, 0, 0.22, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-display);
  -webkit-font-smoothing: antialiased;
}

html {
  /* Reserves the scrollbar's width permanently instead of toggling it on/off
     as page height changes. Without this, picking a calendar day re-renders
     the attendance table with a different row count, which changes the
     page's total height, which shows/hides the scrollbar, which shifts the
     available width for the whole layout - and because .cal-day cells use
     aspect-ratio (height derived from width), that width shift visibly
     resizes the entire calendar grid on every click. */
  scrollbar-gutter: stable;
}

body {
  background-image:
    radial-gradient(ellipse 60% 40% at 12% -8%, rgba(255, 143, 194, 0.16), transparent 60%),
    radial-gradient(ellipse 50% 35% at 95% 0%, rgba(111, 168, 220, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 50% at 50% 110%, rgba(255, 179, 217, 0.1), transparent 60%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.016) 0 1px, transparent 1px 90px);
  background-attachment: fixed;
}

a { color: inherit; }
::selection { background: rgba(255, 143, 194, 0.4); }

/* ---------- Animated aurora background: dynamic floating glass blobs ----------
   mix-blend-mode is "screen" (not the light-mode "multiply") - screen
   brightens against a dark base the same way multiply darkens against a
   light one, so the blobs still read as glowing color, not black smudges. */
.aurora {
  position: fixed; inset: -22%; z-index: -1;
  overflow: hidden; pointer-events: none;
  filter: blur(72px) saturate(115%);
}
.aurora .blob {
  position: absolute; border-radius: 50%;
  mix-blend-mode: screen;
  will-change: transform;
}
.aurora .b1 {
  width: 58vmax; height: 58vmax; top: -12%; left: -8%;
  background: radial-gradient(circle at 35% 35%, rgba(255, 143, 194, 0.4), transparent 62%);
  animation: drift-a 30s ease-in-out infinite alternate;
}
.aurora .b2 {
  width: 46vmax; height: 46vmax; top: 16%; right: -12%;
  background: radial-gradient(circle at 60% 40%, rgba(111, 168, 220, 0.36), transparent 60%);
  animation: drift-b 24s ease-in-out infinite alternate;
}
.aurora .b3 {
  width: 52vmax; height: 52vmax; bottom: -18%; left: 24%;
  background: radial-gradient(circle at 50% 60%, rgba(255, 213, 233, 0.32), transparent 62%);
  animation: drift-c 36s ease-in-out infinite alternate;
}
@keyframes drift-a { from { transform: translate(0, 0) scale(1); } to { transform: translate(9vw, 7vh) scale(1.18); } }
@keyframes drift-b { from { transform: translate(0, 0) scale(1.1); } to { transform: translate(-7vw, 9vh) scale(0.92); } }
@keyframes drift-c { from { transform: translate(0, 0) scale(0.95); } to { transform: translate(6vw, -8vh) scale(1.15); } }

/* Subtle drifting grid layered over the aurora on hero-style screens */
.grid-drift {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(rgba(156, 196, 234, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(156, 196, 234, 0.07) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: radial-gradient(ellipse 75% 60% at 50% 40%, #000 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 75% 60% at 50% 40%, #000 20%, transparent 75%);
  animation: grid-move 40s linear infinite;
}
@keyframes grid-move { from { background-position: 0 0, 0 0; } to { background-position: 0 72px, 72px 0; } }

/* Generic fade+rise-in entrance, used by .feed-tile (and formerly the
   removed splash screen). */
@keyframes splash-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .aurora .blob, .grid-drift { animation: none; }
}

/* App content hidden until the auth check resolves, then fades in - no
   splash screen, no logo/text animation, no artificial hold. */
body.aegis-pre { overflow: hidden; }
.app { opacity: 0; transform: translateY(6px); }
body.aegis-ready .app {
  opacity: 1; transform: none;
  transition: opacity 0.6s 0.15s var(--ease-lux), transform 0.6s 0.15s var(--ease-lux);
}
@media (prefers-reduced-motion: reduce) {
  .app { transition: none; }
}

/* ---------- Nav ---------- */
.navbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.6rem;
  background: rgba(10, 13, 20, 0.65);
  border-bottom: 1px solid var(--hairline);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
}

.navbar-brand {
  display: flex; align-items: center; gap: 0.65rem;
  text-decoration: none;
}
.navbar-brand img { width: 30px; height: 30px; object-fit: contain; }
.brand-text {
  font-weight: 800; font-size: 1rem; letter-spacing: 0.24em;
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.brand-text small {
  display: block; font-size: 0.55rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  -webkit-text-fill-color: var(--faint); color: var(--faint);
  margin-top: 0.05rem;
}

.navbar-links { display: flex; gap: 0.25rem; align-items: center; flex-wrap: wrap; }
.navbar-links a {
  text-decoration: none; color: var(--dim);
  font-size: 0.83rem; font-weight: 600;
  padding: 0.48rem 0.9rem; border-radius: var(--radius-full);
  border: 1px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.navbar-links a:hover { color: var(--text); background: rgba(255, 143, 194, 0.1); }
.navbar-links a.active { color: var(--steel); background: rgba(111, 168, 220, 0.16); border-color: var(--border); }

.navbar-user { display: flex; align-items: center; gap: 0.7rem; }
.navbar-user .who { font-size: 0.78rem; color: var(--dim); }
.navbar-user .who b { color: var(--text); font-weight: 700; }

/* ---------- Layout ---------- */
.page { max-width: 1220px; margin: 0 auto; padding: 2.2rem 1.75rem 4rem; }
.page-narrow { max-width: 560px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }

.eyebrow {
  display: inline-block;
  text-transform: uppercase; letter-spacing: 0.16em;
  font-size: 0.66rem; font-weight: 700;
  color: var(--sky);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.28rem 0.75rem;
  margin-bottom: 0.9rem;
  background: rgba(110, 168, 221, 0.1);
}

h1 { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 { font-size: 1rem; font-weight: 700; margin: 0 0 0.75rem; }
p.lead { color: var(--dim); font-size: 0.92rem; margin-top: 0; line-height: 1.55; }

.section-title {
  display: flex; align-items: baseline; gap: 0.7rem;
  margin: 2.2rem 0 1rem;
}
.section-title h2 { font-size: 1.15rem; margin: 0; }
.section-title .note { font-size: 0.75rem; color: var(--faint); }
.section-title::before {
  content: ""; width: 22px; height: 3px; border-radius: 2px;
  background: var(--grad-brand); align-self: center;
}

/* ---------- Card (liquid glass) ---------- */
.card {
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  /* Carved/embossed surface: soft dark inset from the top, soft light
     inset from the bottom, plus a crisp 1px edge highlight - reads as
     "pressed into" the page rather than just floating above it. Kept
     subtle (low opacity, modest reach) so it doesn't shadow over
     card-head text near the top padding. */
  box-shadow:
    var(--shadow-card),
    inset 0 30px 26px rgba(0, 0, 0, 0.35),
    inset 0 -30px 26px rgba(255, 255, 255, 0.05),
    1px 1px 2px rgba(255, 255, 255, 0.08),
    -1px -1px 2px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: box-shadow 0.25s var(--ease-lux), transform 0.25s var(--ease-lux);
}
.card:hover {
  box-shadow:
    0 14px 40px rgba(74, 134, 200, 0.3),
    inset 0 30px 26px rgba(0, 0, 0, 0.3),
    inset 0 -30px 26px rgba(255, 255, 255, 0.055),
    1px 1px 2px rgba(255, 255, 255, 0.08),
    -1px -1px 2px rgba(0, 0, 0, 0.4);
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.6rem; gap: 0.8rem; }
.card-head h2 { margin: 0; }

.grid { display: grid; gap: 1.25rem; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 860px) { .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.72rem; font-weight: 700;
  color: var(--dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 1rem 0 0.4rem;
}

input[type="text"], input[type="password"], input[type="time"], input[type="search"],
input[type="email"], input[type="date"], input[type="number"], input:not([type]), input[type="file"], select, textarea {
  width: 100%;
  background: var(--field);
  border: 1px solid var(--hairline);
  color: var(--text);
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="file"] { padding: 0.5rem; }
textarea { resize: vertical; min-height: 5.5rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--azure);
  box-shadow: 0 0 0 3px rgba(255, 143, 194, 0.22);
}
select option { background: var(--panel-solid); color: var(--text); }
input[type="time"], input[type="date"], input[type="number"] { color-scheme: dark; }

/* Chrome/Safari paint autofilled fields (email is the type they autofill
   most aggressively) with their own white/pale-yellow background via an
   internal UA style that plain background-color can't win against - the
   inset box-shadow trick is the standard override, paired with a long
   transition delay so it doesn't visibly flash on autofill. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  border-radius: var(--radius-md);
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--field) inset;
  box-shadow: 0 0 0 1000px var(--field) inset;
  transition: background-color 5000s ease-in-out 0s;
}

.hint { font-size: 0.75rem; color: var(--faint); margin-top: 0.45rem; line-height: 1.5; }

/* ---------- Buttons: soft lift + glow on hover, no rotation ---------- */
button, a.btn-primary, a.btn-outline, a.btn-ghost {
  font-family: var(--font-display);
  border: none; cursor: pointer;
  border-radius: var(--radius-md);
  font-weight: 700; font-size: 0.87rem;
  padding: 0.7rem 1.25rem;
  position: relative;
  transition: transform 0.2s var(--ease-lux), box-shadow 0.25s var(--ease-lux), background 0.2s, border-color 0.2s, color 0.2s;
}
button:hover, a.btn-primary:hover, a.btn-outline:hover, a.btn-ghost:hover {
  transform: translateY(-2px);
}
button:active, a.btn-primary:active, a.btn-outline:active, a.btn-ghost:active {
  transform: translateY(0) scale(0.98);
}
@media (prefers-reduced-motion: reduce) {
  button, a.btn-primary, a.btn-outline, a.btn-ghost { transition: background 0.2s, border-color 0.2s, color 0.2s; }
  button:hover, a.btn-primary:hover, a.btn-outline:hover, a.btn-ghost:hover,
  button:active, a.btn-primary:active, a.btn-outline:active, a.btn-ghost:active { transform: none; }
}

.btn-primary {
  color: #fff;
  background: var(--grad-btn);
  box-shadow: var(--shadow-neu-primary);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 40px rgba(255, 143, 194, 0.5); }
.btn-primary:active:not(:disabled) { box-shadow: var(--shadow-neu-primary-active); }
.btn-primary:disabled { background: #262b36; color: #6b7280; box-shadow: none; cursor: not-allowed; transform: none !important; }

.btn-outline {
  color: var(--steel);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-neu-outline);
}
.btn-outline:hover { background: rgba(255, 143, 194, 0.14); border-color: var(--azure); box-shadow: 0 8px 24px rgba(74, 134, 200, 0.25); }
.btn-outline:active { box-shadow: var(--shadow-neu-outline-active); }

.btn-ghost {
  color: var(--dim);
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-neu-ghost);
}
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.09); border-color: var(--border-strong); }
.btn-ghost:active { box-shadow: var(--shadow-neu-ghost-active); }

.btn-danger { color: #fff; background: linear-gradient(135deg, #ff3d6e, #c21a4a); box-shadow: var(--shadow-neu-danger); }
.btn-danger:hover:not(:disabled) { box-shadow: 0 12px 32px rgba(255, 61, 110, 0.4); }
.btn-danger:active:not(:disabled) { box-shadow: var(--shadow-neu-danger-active); }

button.full { width: 100%; }
button.sm { padding: 0.42rem 0.8rem; font-size: 0.76rem; border-radius: var(--radius-sm); }

/* ---------- Vista button: deliberate one-off for document/export actions ----------
   Parchment/ink/ember reads as an aged ledger page - reserved for the CSV
   "Download" action (the only export on the site) so it stays a meaningful
   accent, not a diluted 5th button color mixed into routine Save/Cancel UI.
   Kept as a light parchment swatch even in dark mode on purpose - the whole
   point is that it reads as a distinct physical object, not themed chrome.
   Sized down from the original 52px standalone spec to sit in-line inside
   the Day Sheet's compact toolbar row next to "Clear". */
.vista-btn {
  --vista-ink: #0c1320;
  --vista-parchment: #f4efe3;
  --vista-ember: #d98a5c;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  /* Padding-based sizing (no fixed height) so this lines up with the
     neighboring "Clear" button.sm, which sizes itself the same way -
     a fixed height here made it visibly taller than everything beside it. */
  padding: 0.42rem 0.95rem;
  border: 1px solid var(--vista-parchment);
  border-radius: 999px;
  background: var(--vista-parchment);
  color: var(--vista-ink);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  box-shadow: inset 0 0 0 1px rgba(12, 19, 32, 0.06);
  transition: background-color 220ms cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 220ms cubic-bezier(0.22, 0.61, 0.36, 1);
}
.vista-btn svg { width: 13px; height: 13px; stroke-width: 1.75; flex-shrink: 0; }
.vista-btn:hover { background: #ffffff; transform: none; box-shadow: inset 0 0 0 1px rgba(12, 19, 32, 0.06); }
.vista-btn:active { transform: translateY(1px); }
.vista-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--vista-ink), 0 0 0 4px var(--vista-ember);
}

/* Anchors dressed as buttons need the button metrics too */
a.btn-primary, a.btn-outline, a.btn-ghost {
  display: inline-block; text-decoration: none; text-align: center;
}

/* ---------- Status banners ---------- */
.status { padding: 0.7rem 0.9rem; border-radius: var(--radius-md); font-size: 0.84rem; border: 1px solid transparent; line-height: 1.5; }
.status.ok   { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.status.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-border); }
.status.err  { background: var(--danger-bg); color: #ff8d85; border-color: var(--danger-border); }
.status.info { background: var(--info-bg); color: var(--info); border-color: var(--info-border); }

.pulse-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor; margin-right: 6px;
  animation: pulse 1.4s infinite;
  box-shadow: 0 0 8px currentColor;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ---------- Tables ---------- */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.62rem 0.7rem; font-size: 0.83rem; border-bottom: 1px solid var(--hairline); white-space: nowrap; }
th { color: var(--faint); font-weight: 700; text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.08em; }
tbody tr { transition: background 0.15s; }
tbody tr:hover { background: rgba(74, 134, 200, 0.08); }
tbody tr.rowlink { cursor: pointer; }
tbody tr.rowlink:hover { background: rgba(255, 143, 194, 0.1); }
tr.late-row td:first-child { border-left: 3px solid var(--danger); }
tr.late-row { background: rgba(255, 61, 110, 0.08); }
td.mono, span.mono { font-family: var(--font-mono); font-size: 0.78rem; }

.pill {
  display: inline-block;
  padding: 0.16rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.7rem; font-weight: 700;
  font-family: var(--font-mono);
}
.pill.ok     { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.pill.warn   { background: var(--warn-bg); color: var(--warn); border: 1px solid var(--warn-border); }
.pill.err    { background: var(--danger-bg); color: #ff8d85; border: 1px solid var(--danger-border); }
.pill.brand  { background: rgba(110, 168, 221, 0.12); color: var(--sky); border: 1px solid var(--border-strong); }
.pill.dim    { background: rgba(255, 255, 255, 0.03); color: var(--dim); border: 1px solid var(--hairline); }

/* Conditional-formatting rule tints */
tr.fmt { border-left: 3px solid transparent; }
tr.fmt td:first-child { border-left: 3px solid var(--fmt-color, transparent); }
tr.fmt-red   { --fmt-color: var(--rule-red);   background: rgba(255, 93, 93, 0.09); }
tr.fmt-amber { --fmt-color: var(--rule-amber); background: rgba(255, 189, 92, 0.09); }
tr.fmt-green { --fmt-color: var(--rule-green); background: rgba(66, 211, 146, 0.09); }
tr.fmt-blue  { --fmt-color: var(--rule-blue);  background: rgba(110, 168, 221, 0.1); }
tbody tr.fmt-red:hover   { background: rgba(255, 93, 93, 0.15); }
tbody tr.fmt-amber:hover { background: rgba(255, 189, 92, 0.15); }
tbody tr.fmt-green:hover { background: rgba(66, 211, 146, 0.15); }
tbody tr.fmt-blue:hover  { background: rgba(110, 168, 221, 0.16); }

.fmt-badge {
  display: inline-block; margin-left: 0.45rem;
  padding: 0.1rem 0.5rem; border-radius: var(--radius-full);
  font-size: 0.62rem; font-weight: 700; letter-spacing: 0.04em;
  border: 1px solid;
}
.fmt-badge.red   { color: var(--rule-red);   border-color: rgba(255, 93, 93, 0.4);   background: rgba(255, 93, 93, 0.12); }
.fmt-badge.amber { color: var(--rule-amber); border-color: rgba(255, 189, 92, 0.4);  background: rgba(255, 189, 92, 0.12); }
.fmt-badge.green { color: var(--rule-green); border-color: rgba(66, 211, 146, 0.4);  background: rgba(66, 211, 146, 0.12); }
.fmt-badge.blue  { color: var(--rule-blue);  border-color: rgba(110, 168, 221, 0.4); background: rgba(110, 168, 221, 0.12); }

/* ---------- Stat tiles ---------- */
.stat-tile {
  position: relative; overflow: hidden; cursor: pointer;
  background: linear-gradient(165deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.025));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.3rem;
  /* Same carved-emboss treatment as .card, scaled down for the tile's
     shorter height - the number/label stay fully visible, no animation,
     just a soft "pressed into the page" depth. */
  box-shadow:
    var(--shadow-card),
    inset 0 20px 18px rgba(0, 0, 0, 0.35),
    inset 0 -20px 18px rgba(255, 255, 255, 0.05),
    1px 1px 2px rgba(255, 255, 255, 0.08),
    -1px -1px 2px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 0.2s var(--ease-lux), box-shadow 0.2s;
}
.stat-tile:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow:
    0 14px 34px rgba(255, 143, 194, 0.3),
    inset 0 20px 18px rgba(0, 0, 0, 0.3),
    inset 0 -20px 18px rgba(255, 255, 255, 0.055),
    1px 1px 2px rgba(255, 255, 255, 0.08),
    -1px -1px 2px rgba(0, 0, 0, 0.4);
}
.stat-tile.late .num { color: var(--danger); }
.stat-tile.ontime .num { color: var(--success); }
.stat-tile::after {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: var(--grad-brand); opacity: 0.7;
}
.stat-tile .num { font-family: var(--font-mono); font-size: 1.75rem; font-weight: 700; color: var(--text); }
.stat-tile .label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--dim); margin-top: 0.25rem; }

/* ---------- Live feed tiles ---------- */
.feed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.feed-tile {
  position: relative; border-radius: var(--radius-lg); overflow: hidden;
  background: #000; border: 1px solid var(--border);
  aspect-ratio: 4 / 3;
  box-shadow: var(--shadow-card);
  animation: splash-in 0.5s var(--ease-lux) both;
}
.feed-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-tile .feed-label {
  position: absolute; left: 10px; top: 10px;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
  background: rgba(5, 8, 12, 0.78); border: 1px solid var(--border-strong);
  color: var(--sky);
  padding: 0.25rem 0.6rem; border-radius: var(--radius-full);
  backdrop-filter: blur(6px);
}
.feed-tile .feed-label .live-dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: pulse 1.4s infinite;
}
.feed-empty {
  display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2.2rem 1.5rem;
  text-align: center; color: var(--faint); font-size: 0.85rem;
}
.feed-empty svg { opacity: 0.45; }

/* ---------- Generic "nothing here" state inside a table row ---------- */
.empty-row {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  padding: 1.8rem 1rem; color: var(--faint); font-size: 0.83rem;
}
.empty-row svg { opacity: 0.45; }

/* ---------- Avatars ---------- */
.avatar {
  width: 84px; height: 84px; border-radius: 50%;
  object-fit: cover; display: block;
  border: 2px solid var(--border-strong);
  box-shadow: 0 0 0 4px rgba(110, 168, 221, 0.1);
  background: var(--panel-2);
}
.avatar-fallback {
  width: 84px; height: 84px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.6rem; letter-spacing: 0.02em;
  color: #fff;
  background: var(--grad-btn);
  border: 2px solid var(--border-strong);
  box-shadow: 0 0 0 4px rgba(255, 143, 194, 0.16);
}

/* ---------- Employee profile modal (admin.html + staff.html) ---------- */
.emp-modal-head { display: flex; gap: 1.1rem; align-items: center; margin-bottom: 1.2rem; }
.emp-modal-head .emp-id { flex: 1; min-width: 0; }
.emp-modal-head h2 { font-size: 1.25rem; margin: 0 0 0.3rem; }
.emp-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem; margin: 1.1rem 0; }
@media (max-width: 480px) { .emp-meta { grid-template-columns: 1fr; } }
.emp-meta .m {
  border: 1px solid var(--hairline); border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem; background: rgba(255, 255, 255, 0.02);
}
.emp-meta .m .k { font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); font-weight: 700; }
.emp-meta .m .v { font-size: 0.86rem; margin-top: 0.2rem; font-weight: 600; }

.emp-photo-wrap { position: relative; flex-shrink: 0; }
.change-photo-btn {
  position: absolute; right: -4px; bottom: -4px;
  width: 30px; height: 30px; border-radius: 50%; padding: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-btn); color: #fff;
  border: 2px solid var(--panel-solid);
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}
/* No max-height/overflow of its own - a second, nested scroll region inside
   the already-scrollable .modal (max-height: 86vh; overflow-y: auto) meant
   the mouse wheel got captured by whichever box it happened to be over,
   so scrolling the profile felt broken/stuck. One scroll region (the modal
   itself) for the whole "sub page" instead. */
.emp-timeline { margin-top: 0.4rem; }
.tl-row {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.5rem 0.2rem; border-bottom: 1px solid var(--hairline);
  font-size: 0.8rem;
}
.tl-row .tl-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
  background: var(--azure); box-shadow: 0 0 8px rgba(110, 168, 221, 0.55);
}
.tl-row .tl-time { color: var(--dim); font-family: var(--font-mono); font-size: 0.72rem; flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(3, 5, 9, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 1.25rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s var(--ease-lux);
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  width: 100%; max-width: 560px; max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(170deg, rgba(20, 24, 34, 0.94), rgba(13, 16, 24, 0.9));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-xl);
  padding: 1.6rem;
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  transform: translateY(14px) scale(0.98);
  transition: transform 0.3s var(--ease-lux);
}
.modal.wide { max-width: 820px; }
.modal-overlay.open .modal { transform: none; }
.modal-close {
  position: absolute; top: 1rem; right: 1rem;
  width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(74, 134, 200, 0.12); color: var(--dim);
  border: 1px solid var(--hairline); font-size: 1rem; padding: 0;
}
.modal-close:hover { color: var(--text); background: rgba(255, 143, 194, 0.16); }

/* ---------- Mini calendar (Google-style date picker) ---------- */
.cal {
  user-select: none;
  -webkit-user-select: none;
}
.cal-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.7rem;
}
.cal-head .cal-title { font-weight: 700; font-size: 0.9rem; letter-spacing: 0.01em; }
.cal-nav { display: flex; gap: 0.25rem; }
.cal-nav button {
  width: 30px; height: 30px; padding: 0; border-radius: 50%;
  background: rgba(255, 255, 255, 0.05); color: var(--dim);
  border: 1px solid var(--hairline); font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.cal-nav button:hover { color: var(--text); background: rgba(110, 168, 221, 0.16); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 2px; text-align: center;
}
.cal-dow {
  font-size: 0.6rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--faint); padding: 0.3rem 0;
}
.cal-day {
  aspect-ratio: 1; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-family: var(--font-mono);
  color: var(--text); cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cal-day:hover { background: rgba(110, 168, 221, 0.16); }
.cal-day.other { color: var(--faint); opacity: 0.55; }
.cal-day.today { border-color: var(--border-strong); color: var(--sky); font-weight: 700; }
.cal-day.selected {
  background: var(--grad-btn); color: #fff; font-weight: 700;
  box-shadow: 0 2px 12px rgba(95, 150, 203, 0.4);
}
.cal-day.future { color: var(--faint); opacity: 0.4; cursor: default; }
.cal-day.future:hover { background: transparent; }

/* ---------- Formatting rules manager ---------- */
.rule-list { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 0.4rem; }
.rule-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.8rem;
}
.rule-swatch { width: 12px; height: 12px; border-radius: 4px; flex-shrink: 0; }
.rule-swatch.red   { background: var(--rule-red); }
.rule-swatch.amber { background: var(--rule-amber); }
.rule-swatch.green { background: var(--rule-green); }
.rule-swatch.blue  { background: var(--rule-blue); }
.rule-item .rule-text { flex: 1; color: var(--dim); }
.rule-item .rule-text b { color: var(--text); font-family: var(--font-mono); font-weight: 600; }
.rule-item .rule-del {
  width: 26px; height: 26px; padding: 0; border-radius: 50%;
  background: transparent; color: var(--faint); border: 1px solid transparent;
  font-size: 0.95rem; line-height: 1;
}
.rule-item .rule-del:hover { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-border); }
.rule-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
