/* Tiny custom layer on top of Pico.css — sidebar, status badges, htmx feedback. */
:root {
  --brand: #0a58ca;
  --muted: #6c757d;
  --ok: #1e7e34;
  --warn: #c98a00;
  --err: #c92a2a;
}

/* ---- Login background: subtle drifting brand-coloured glow (CSS only) ---- */
/* A discreet, professional animated backdrop sitting BEHIND the login card.
   Soft blurred "orbs" in the brand blue/green drift very slowly; a faint dot
   grid adds texture. Honours prefers-reduced-motion (freezes the motion). */
#login-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  background:
    radial-gradient(1200px 600px at 50% -10%, #eef4fc 0%, rgba(238,244,252,0) 60%),
    linear-gradient(160deg, #f6f9fd 0%, #eef2f8 100%);
}
#login-bg::after {
  /* Fine dot grid for a quiet, technical texture — slowly drifting. */
  content: "";
  position: absolute;
  inset: -28px;
  background-image: radial-gradient(rgba(10,88,202,0.06) 1px, transparent 1.4px);
  background-size: 28px 28px;
  -webkit-mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 80%);
          mask-image: radial-gradient(70% 60% at 50% 40%, #000 0%, transparent 80%);
  animation: gridDrift 40s linear infinite;
}
@keyframes gridDrift {
  from { background-position: 0 0; }
  to   { background-position: 28px 28px; }  /* one tile → seamless loop */
}

/* Rising particles — discreet but clearly visible motion in the background. */
#login-bg .particles { position: absolute; inset: 0; overflow: hidden; }
#login-bg .particle {
  position: absolute;
  bottom: -14px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: rgba(10, 88, 202, 0.30);
  animation: floatUp linear infinite;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0); opacity: 0; }
  11%  { opacity: 0.70; }
  88%  { opacity: 0.70; }
  100% { transform: translateY(-103vh) translateX(26px); opacity: 0; }
}
/* Stagger position / size / speed / start time so it never looks mechanical.
   Negative delays make particles already mid-flight on first paint.
   Tuned to sit between "barely there" and "busy" — ~13 mid-size, mid-speed. */
#login-bg .particle:nth-child(1)  { left: 7%;  width: 7px;  height: 7px;  animation-duration: 22s; animation-delay: -3s;  }
#login-bg .particle:nth-child(2)  { left: 18%; width: 10px; height: 10px; animation-duration: 27s; animation-delay: -11s; background: rgba(30,126,52,0.26); }
#login-bg .particle:nth-child(3)  { left: 28%; width: 6px;  height: 6px;  animation-duration: 19s; animation-delay: -7s;  }
#login-bg .particle:nth-child(4)  { left: 38%; width: 9px;  height: 9px;  animation-duration: 25s; animation-delay: -16s; }
#login-bg .particle:nth-child(5)  { left: 47%; width: 7px;  height: 7px;  animation-duration: 23s; animation-delay: -5s;  background: rgba(59,130,246,0.28); }
#login-bg .particle:nth-child(6)  { left: 56%; width: 11px; height: 11px; animation-duration: 30s; animation-delay: -19s; }
#login-bg .particle:nth-child(7)  { left: 65%; width: 6px;  height: 6px;  animation-duration: 20s; animation-delay: -9s;  background: rgba(30,126,52,0.24); }
#login-bg .particle:nth-child(8)  { left: 74%; width: 9px;  height: 9px;  animation-duration: 26s; animation-delay: -13s; }
#login-bg .particle:nth-child(9)  { left: 83%; width: 7px;  height: 7px;  animation-duration: 24s; animation-delay: -21s; background: rgba(59,130,246,0.26); }
#login-bg .particle:nth-child(10) { left: 90%; width: 10px; height: 10px; animation-duration: 28s; animation-delay: -2s;  }
#login-bg .particle:nth-child(11) { left: 13%; width: 7px;  height: 7px;  animation-duration: 21s; animation-delay: -24s; background: rgba(30,126,52,0.24); }
#login-bg .particle:nth-child(12) { left: 51%; width: 8px;  height: 8px;  animation-duration: 25s; animation-delay: -6s;  }
#login-bg .particle:nth-child(13) { left: 70%; width: 8px;  height: 8px;  animation-duration: 23s; animation-delay: -14s; background: rgba(59,130,246,0.26); }
#login-bg .orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.45;
  will-change: transform;
}
#login-bg .orb-1 { width: 480px; height: 480px; top: -120px; left: -100px;
  background: #0a58ca; opacity: 0.30; animation: orbDrift1 26s ease-in-out infinite alternate; }
#login-bg .orb-2 { width: 420px; height: 420px; bottom: -140px; right: -80px;
  background: #1e7e34; opacity: 0.22; animation: orbDrift2 32s ease-in-out infinite alternate; }
#login-bg .orb-3 { width: 360px; height: 360px; top: 40%; right: 18%;
  background: #3b82f6; opacity: 0.20; animation: orbDrift3 22s ease-in-out infinite alternate; }
#login-bg .orb-4 { width: 300px; height: 300px; bottom: 8%; left: 14%;
  background: #6aa9ff; opacity: 0.18; animation: orbDrift1 29s ease-in-out infinite alternate-reverse; }

@keyframes orbDrift1 { from { transform: translate(0,0) scale(1); } to { transform: translate(60px,40px) scale(1.08); } }
@keyframes orbDrift2 { from { transform: translate(0,0) scale(1); } to { transform: translate(-50px,-30px) scale(1.10); } }
@keyframes orbDrift3 { from { transform: translate(0,0) scale(1); } to { transform: translate(-40px,50px) scale(1.06); } }

@media (prefers-reduced-motion: reduce) {
  #login-bg .orb,
  #login-bg::after,
  #login-bg .particle { animation: none; }
  #login-bg .particles { display: none; }
}

/* Required-field marker — a small red dot next to mandatory field labels. */
.req { color: var(--err); font-weight: 700; margin-left: 4px; font-size: 0.85em; vertical-align: middle; }
.req-legend { color: var(--muted); font-size: 0.85rem; margin: 0.2rem 0 0.6rem; }
.req-legend .req { margin-left: 0; margin-right: 4px; }

.app-header { background: #1f2937; color: #f3f4f6; padding: 0.4rem 0; margin-bottom: 0.5rem; position: sticky; top: 0; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.25); }
.app-header strong { color: #f3f4f6; }
.app-header .container { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.app-header nav { flex: 1; margin-left: 1.25rem; display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.app-header nav ul { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.9rem; margin: 0; padding: 0; }
.app-header nav ul li { list-style: none; padding: 0; margin: 0; }
.app-header nav a { color: #d1d5db; text-decoration: none; font-size: 0.92rem; white-space: nowrap; }
.app-header nav a:hover { color: #fff; }
.app-header nav a[aria-current="page"] { color: #fff; font-weight: 600; }
.app-header nav small { color: #9ca3af; }
.app-header .brand { white-space: nowrap; font-size: 0.95rem; }

/* Responsive: stack the brand over a wrapping menu on narrow screens. */
@media (max-width: 860px) {
  .app-header .container { flex-direction: column; align-items: flex-start; }
  .app-header nav { margin-left: 0; width: 100%; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
  .app-header nav ul { gap: 0.2rem 0.8rem; }
}

.muted { color: var(--muted); }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.kpi { background: var(--pico-card-background-color); padding: 1rem 1.25rem; border-radius: 8px; box-shadow: var(--pico-card-box-shadow); }
.kpi .v { font-size: 2rem; font-weight: 700; line-height: 1.2; }
.kpi .l { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-top: 1.5rem; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 0.8em; font-weight: 600; }
.badge-ok { background: #d4edda; color: var(--ok); }
.badge-warn { background: #fff3cd; color: var(--warn); }
.badge-err { background: #f8d7da; color: var(--err); }
.badge-mut { background: #e9ecef; color: var(--muted); }

.filters { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; margin-bottom: 1rem; }
.filters > * { margin: 0; }
/* Pico makes form buttons full-width — keep filter buttons content-sized. */
.filters button, .filters a[role="button"] { width: auto; }

.action-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.action-row button, .action-row a[role="button"] { margin: 0; width: auto; }

/* Compact action buttons used in table rows (Edit / Delete). */
.btn-sm { width: auto; padding: 0.2rem 0.7rem; font-size: 0.85em; margin: 0; }
.btn-danger { color: var(--err); border-color: var(--err); }

.htmx-indicator { opacity: 0; transition: opacity 200ms; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }
table.compact th, table.compact td { padding: 0.4rem 0.6rem; font-size: 0.9rem; }

.alert { padding: 0.75rem 1rem; border-radius: 6px; margin: 1rem 0; }
.alert-ok { background: #d4edda; color: var(--ok); }
.alert-err { background: #f8d7da; color: var(--err); }
.alert-warn { background: #fff3cd; color: var(--warn); }

.brand { display: inline-flex; align-items: center; gap: 0.5rem; }
.brand-logo { height: 56px !important; width: auto !important; max-width: 72px !important; vertical-align: middle; }

/* Compact, inline action buttons inside admin tables (Edit / Delete / Save). */
table.compact td form { display: inline; margin: 0; }
table.compact td a[role="button"],
table.compact td button {
  width: auto;
  margin: 0 0.25rem 0 0;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  display: inline-block;
}
.row-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }

/* Form footer actions — content-sized, evenly aligned buttons. */
.form-actions { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.form-actions > button, .form-actions > [role="button"] { width: auto; margin: 0; min-width: 10rem; }

/* Invoice line table — compact, readable inputs. */
.line-table td, .line-table th { padding: 0.3rem 0.45rem; vertical-align: middle; }
.line-table input, .line-table select { margin-bottom: 0; padding: 0.35rem 0.5rem; font-size: 0.9rem; }

/* User avatar chip in the nav (initials in a brand-blue circle). */
.user-chip { display: inline-flex; align-items: center; gap: 0.5rem; }
.user-chip .avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: #3b82f6; color: #fff;
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.02em;
  flex-shrink: 0; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
}
.user-chip small { color: #cbd5e1; }
/* Logout — white pill, sky-blue border, dark text (header colour). */
.app-header .user-chip a {
  color: #1f2937; background: #eef1f5;
  border: 3px solid #3b82f6;
  padding: 0.25rem 0.95rem; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600; line-height: 1.4;
  margin-left: 0.5rem;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
.app-header .user-chip a:hover {
  background: #3b82f6; color: #fff;
  box-shadow: 0 3px 10px rgba(59,130,246,0.55);
  transform: translateY(-1px);
}

/* Admin users list — scrollable with a sticky header, tidy action buttons. */
.users-scroll { max-height: 560px; overflow-y: auto; border: 1px solid #e5e7eb; border-radius: 8px; }
.users-table { margin: 0; }
.users-table thead th { position: sticky; top: 0; background: #f3f4f6; z-index: 2; box-shadow: 0 2px 0 #d1d5db; }
/* Roomier rows + a clear thick separator between each user. */
.users-table td { padding: 0.85rem 0.7rem !important; vertical-align: middle; }
.users-table tbody tr { border-bottom: 3px solid #dfe3e8; }
.users-table tbody tr:last-child { border-bottom: none; }
.users-table .row-actions { flex-direction: column; align-items: stretch; gap: 0.35rem; }
.users-table .row-actions button { width: 100% !important; min-width: 7.5rem; white-space: nowrap; }
.users-table .row-actions label { text-align: center; font-size: 0.85rem; }
