:root {
  --alerto-primary: #1f6feb;
  --alerto-dark: #0b1f3a;
  --alerto-danger: #e5484d;
}

body { background: #f3f5f9; color: #1c2433; }

/* ---------- Brand ---------- */
.brand-badge {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--alerto-danger), #ff7a45);
  color: #fff; font-size: 1.4rem;
}
.brand-badge.sm { width: 32px; height: 32px; font-size: 1rem; border-radius: 9px; }

/* ---------- Login ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #0b1f3a, #15325f);
}
.login-card {
  background: #fff; border-radius: 16px; padding: 2.25rem; width: 100%; max-width: 380px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35);
}

/* PIN quick-unlock overlay (installed app only) — same treatment as the login card so it
   reads as "still Alerto", not a broken/different screen. Opaque + high z-index: it must
   fully cover the page underneath, which is already loaded from a valid session. */
.pin-lock-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: linear-gradient(160deg, #0b1f3a, #15325f);
  align-items: center; justify-content: center; padding: 1rem;
}
.pin-lock-card {
  background: #fff; border-radius: 16px; padding: 2.25rem; width: 100%; max-width: 340px;
  box-shadow: 0 25px 60px rgba(0,0,0,.35); text-align: center;
}
.pin-lock-card #pinLockInput { letter-spacing: .5em; font-size: 1.3rem; }

/* ---------- Navbar ---------- */
.app-navbar {
  background: var(--alerto-dark);
  position: sticky; top: 0; z-index: 1030;
  gap: .5rem;
}
.app-navbar .navbar-brand { font-weight: 600; }
.app-navbar .nav-link { color: rgba(255,255,255,.7); border-radius: 8px; font-size: .9rem; }
.app-navbar .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
.app-navbar .nav-link.active { color: #fff; background: rgba(255,255,255,.14); }
/* The navbar has no .navbar-expand-* class, so Bootstrap leaves .navbar-nav dropdown
   menus position:static (they render in-flow and shove the bar). Float them like a
   normal dropdown so Popper anchors them under the toggle (e.g. Subscriptions). */
.app-navbar .navbar-nav .dropdown-menu { position: absolute; }

/* ---------- Shift button ---------- */
.shift-btn { border: 1px solid transparent; font-weight: 500; }
.shift-btn.on { background: #1e7e4f; color: #fff; }
.shift-btn.on:hover { background: #1a6e45; color: #fff; }
.shift-btn.off { background: rgba(255,255,255,.12); color: rgba(255,255,255,.85); }
.app-navbar .shift-btn.off { color: rgba(255,255,255,.85); }
table .shift-btn.off { background: #e9ecef; color: #6c757d; }

/* ---------- Activity timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before {
  content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: #e9edf3;
}
.timeline-item { position: relative; padding: 0 0 1rem 2.5rem; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute; left: 0; top: 0; width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: .9rem; z-index: 1;
}
.timeline-body { padding-top: 4px; }

/* ---------- Toasts ---------- */
.alerto-toast { box-shadow: 0 8px 30px rgba(10,20,40,.25); }
.alerto-toast.toast-danger { border-left: 5px solid var(--alerto-danger); }
.alerto-toast.toast-warning { border-left: 5px solid #f5a623; }
.alerto-toast.toast-success { border-left: 5px solid #2fa84f; }
.header-search { position: relative; max-width: 620px; }
.header-search .form-control:focus { box-shadow: none; }
.search-results {
  position: absolute; top: 110%; left: 0; right: 0; z-index: 1050;
  background: #fff; border-radius: 10px; overflow: hidden; display: none; max-height: 60vh; overflow-y: auto;
}
.search-results.show { display: block; }
.search-item {
  display: block; width: 100%; text-align: left; border: 0; background: #fff;
  padding: .6rem .9rem; border-bottom: 1px solid #eef1f5;
}
.search-item:hover { background: #f5f8ff; }
.search-empty { padding: .9rem; color: #6b7280; font-size: .9rem; }

/* ---------- Stat cards ---------- */
.stat-card { background: #fff; border-radius: 12px; padding: 1rem 1.1rem; box-shadow: 0 2px 8px rgba(20,30,60,.05); }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1; }
.stat-label { color: #6b7280; font-size: .82rem; margin-top: .25rem; }

/* ---------- Alert cards ---------- */
.alert-card {
  position: relative;
  background: #fff; border-radius: 14px; padding: 1.1rem; height: 100%;
  box-shadow: 0 2px 10px rgba(20,30,60,.06); border-left: 5px solid #dfe3ea;
  transition: box-shadow .15s ease, transform .15s ease;
}
.alert-card:hover { box-shadow: 0 6px 20px rgba(20,30,60,.12); }
.alert-card[data-href] { cursor: pointer; }
.alert-card[data-href]:hover { transform: translateY(-1px); }
.alert-card.sev-critical { border-left-color: var(--alerto-danger); }
.alert-card.sev-high { border-left-color: #f5a623; }
.alert-card.sev-medium { border-left-color: #3aa0ff; }
.alert-card.status-new.sev-critical { animation: pulseBorder 1.8s infinite; }
@keyframes pulseBorder {
  0%,100% { box-shadow: 0 2px 10px rgba(20,30,60,.06); }
  50% { box-shadow: 0 0 0 4px rgba(229,72,77,.18); }
}
.alert-card.status-resolved { opacity: .82; }
/* Escalation deepens the left-border accent by level (L1 amber -> L3 red); no background tint. */
.alert-card.esc-1 { border-left-color: #f5a623; }
.alert-card.esc-2 { border-left-color: #ef7f1a; }
.alert-card.esc-3 { border-left-color: var(--alerto-danger); }
.alert-card.escalated { border-left-color: var(--alerto-danger); box-shadow: 0 0 0 2px rgba(229,72,77,.35), 0 2px 10px rgba(20,30,60,.06); }
.alert-card.escalated::before {
  content: ''; position: absolute; inset: 0; border-radius: 14px; pointer-events: none;
  animation: escGlow 1.6s ease-in-out infinite;
}
@keyframes escGlow {
  0%,100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); }
  50% { box-shadow: 0 0 0 4px rgba(229,72,77,.18); }
}

/* Severity shown once as a dot (border + icon carry the rest). */
.sev-dot { width: .58rem; height: .58rem; border-radius: 50%; display: inline-block; flex: 0 0 auto; }
.sev-dot.sev-critical { background: var(--alerto-danger); }
.sev-dot.sev-high { background: #f5a623; }
.sev-dot.sev-medium { background: #3aa0ff; }
.sev-dot.sev-low { background: #9aa5b1; }

/* Neutral status pill — deliberately NOT red, so it never competes with severity/escalation. */
.status-pill { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .7rem; font-weight: 600; line-height: 1.4; }
.status-pill.status-new { background: #e7eefc; color: #1c46c9; }
.status-pill.status-acknowledged { background: #fff3cd; color: #8a6100; }
.status-pill.status-resolved { background: #d7f0e2; color: #0f5132; }

/* News ticker on the alert queue — fixed bar along the bottom of the screen */
.news-ticker {
  display: flex; align-items: center; background: #0b1f3a; color: #dfe6f2;
  overflow: hidden; height: 38px;
}
.news-ticker-bottom {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  border-radius: 0; box-shadow: 0 -3px 12px rgba(11,31,58,.25);
}
body.has-news-ticker { padding-bottom: 46px; }   /* keep page content clear of the bar */
.ticker-label {
  flex: 0 0 auto; background: #e5484d; color: #fff; font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; padding: 0 .8rem; height: 100%; display: flex; align-items: center;
}
.ticker-viewport { flex: 1 1 auto; overflow: hidden; height: 100%; display: flex; align-items: center; }
.ticker-track {
  display: inline-flex; align-items: center; white-space: nowrap; will-change: transform;
  animation: tickerScroll 60s linear infinite;
}
.news-ticker:hover .ticker-track { animation-play-state: paused; }
@keyframes tickerScroll { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.ticker-item { color: #dfe6f2; text-decoration: none; font-size: .8rem; }
.ticker-item:hover { color: #fff; text-decoration: underline; }
.ticker-src {
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  border-radius: 4px; padding: .05rem .35rem; margin-right: .4rem; vertical-align: 1px;
}
.ticker-src.ph { background: #f5c518; color: #422e00; }
.ticker-src.intl { background: #3aa0ff; color: #fff; }
.ticker-dot { margin: 0 .9rem; color: #566a85; }

/* Call-outcome logger (case page, family contacts): visually separate "log what happened
   after you called" from the buttons that place/send the contact — dashed box + label so it
   reads as a follow-up step, not another way to reach the contact. */
.call-outcome {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin-top: .5rem; padding: .45rem .6rem;
  background: #f8f9fb; border: 1px dashed #c9d2e0; border-radius: 8px;
}
.call-outcome .co-label {
  font-size: .74rem; font-weight: 600; color: #6b7a94;
  text-transform: uppercase; letter-spacing: .03em; white-space: nowrap;
}

/* SOP response-step guide (alert cards / case page): a vertical progress checklist —
   plain indicators on a connecting line, deliberately NOT styled like buttons. */
.sop-vert { list-style: none; margin: 0; padding: 0; }
.sop-vert li { position: relative; padding: 0 0 .55rem 1.6rem; font-size: .76rem; color: #9aa4b2; }
.sop-vert li:last-child { padding-bottom: 0; }
.sop-vert .sn {
  position: absolute; left: 0; top: .05rem; width: 1.05rem; height: 1.05rem; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .62rem; font-weight: 700; line-height: 1;
  background: #eef1f5; color: #9aa4b2; border: 1.5px solid #dfe3ea;
}
.sop-vert li:not(:last-child)::before {
  content: ''; position: absolute; left: .48rem; top: 1.2rem; bottom: .05rem; width: 2px; background: #e4e8ef;
}
.sop-vert li.done { color: #0f5132; }
.sop-vert li.done .sn { background: #2f9e6e; border-color: #2f9e6e; color: #fff; }
.sop-vert li.done:not(:last-child)::before { background: #bfe5d2; }
.sop-vert li.now { color: #1c2433; font-weight: 600; }
.sop-vert li.now .sn { background: #fff; border-color: #0d6efd; color: #0d6efd; box-shadow: 0 0 0 3px rgba(13,110,253,.14); }
.sop-vert .sop-hint { font-weight: 400; color: #6c757d; font-size: .73rem; margin-top: .1rem; }

/* Function tiles on the device-settings screen */
.settings-tile {
  width: 100%; height: 100%; border: 1px solid #dde3ec; border-radius: 14px; background: #fff;
  padding: .8rem .4rem; text-align: center; cursor: pointer;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.settings-tile:hover { box-shadow: 0 4px 14px rgba(20,30,60,.10); transform: translateY(-2px); }
.settings-tile.active { border-color: #0d6efd; box-shadow: 0 0 0 2px rgba(13,110,253,.18); }
.settings-tile .ti { font-size: 1.5rem; line-height: 1; display: block; }
.settings-tile .tt { font-weight: 600; font-size: .85rem; margin-top: .3rem; }
.settings-tile .ts { font-size: .7rem; color: #6c757d; line-height: 1.2; }

.alert-type-icon {
  width: 48px; height: 48px; min-width: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem;
}
.alert-type-icon.lg { width: 58px; height: 58px; min-width: 58px; font-size: 1.7rem; border-radius: 14px; }
.min-w-0 { min-width: 0; }
.alert-meta { color: #4b5563; }

/* ---------- Profile ---------- */
.avatar {
  width: 52px; height: 52px; border-radius: 50%; background: var(--alerto-primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 1.4rem; font-weight: 600;
}

/* ---------- Contacts drawer ---------- */
.contacts-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 400px; max-width: 92vw;
  background: #fff; z-index: 1080; transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.2);
}
.contacts-drawer.open { transform: translateX(0); }
.contacts-drawer-header { background: var(--alerto-danger); color: #fff; padding: 1rem 1.1rem; }
.contacts-drawer-body { padding: 1.1rem; overflow-y: auto; }
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(8,16,32,.45); z-index: 1070; opacity: 0; visibility: hidden;
  transition: opacity .25s ease;
}
.drawer-backdrop.show { opacity: 1; visibility: visible; }
.drawer-wearer { padding-bottom: .75rem; border-bottom: 1px solid #eef1f5; }
.drawer-contact { padding: .75rem 0; border-bottom: 1px solid #eef1f5; }
.drawer-contact:last-child { border-bottom: 0; }
.contact-row:hover { background: #fbfcfe; }
