:root {
  /* Brand Pink Palette (Derived from Watch & Lanyard) */
  --brand: hsl(338, 82%, 48%); /* Hot Magenta / Lanyard Pink */
  --brand-dark: hsl(338, 85%, 32%); /* Deep Raspberry for text/contrast */
  --brand-soft: hsl(340, 80%, 94%); /* Very Light Pastel Pink */

  /* Accents */
  --accent: hsl(345, 90%, 60%); /* Vibrant Button Red/Pink */
  --accent-soft: hsl(345, 95%, 95%); /* Soft Accent Background */

  /* Surfaces & Backgrounds */
  --bg: hsl(340, 60%, 98%); /* Off-White Rose Tint */
  --surface: hsl(0, 0%, 100%); /* Pure White */
  --surface-soft: hsl(340, 45%, 95%); /* Soft Pinkish Gray Container */

  /* Functional Status Colors */
  --green: hsl(148, 55%, 42%);
  --green-soft: hsl(148, 50%, 93%);
  --amber: hsl(327, 95%, 52%); /* Bright Orange/Amber (Watch Ear Accents) */
  --coral: hsl(350, 85%, 56%); /* SOS Alert Red */
  --coral-soft: hsl(350, 85%, 94%);
  --blue: hsl(215, 90%, 52%);
  --blue-soft: hsl(215, 90%, 94%);
  --amber-soft: hsl(38, 95%, 92%);

  /* Typography & Structure */
  --text: hsl(
    330,
    35%,
    15%
  ); /* Deep Charcoal-Plum for high contrast readability */
  --muted: hsl(330, 15%, 45%); /* Muted Mauve Slate */
  --border: hsl(340, 40%, 88%); /* Delicate Pink Border */
  --shadow: 0 18px 45px rgba(219, 39, 119, 0.12); /* Soft Pink Tinted Shadow */

  /* Border Radii */
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

body.dark-theme {
  --bg: hsl(330, 20%, 8%);
  --surface: hsl(330, 18%, 13%);
  --surface-soft: hsl(330, 16%, 18%);
  --text: hsl(0, 0%, 95%);
  --muted: hsl(330, 10%, 70%);
  --brand-dark: hsl(338, 85%, 85%);
  --brand-soft: hsl(338, 30%, 22%);
  --border: hsl(330, 15%, 24%);
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.45);
  --accent-soft: rgba(229, 70, 142, 0.2);
  --coral-soft: rgba(239, 68, 68, 0.2);
  --green-soft: rgba(34, 197, 94, 0.2);
}

.path-chip {
  display: inline-flex;
  margin-bottom: 0.85rem;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
}
.login-role-grid {
  display: grid;
  gap: 0.8rem;
}
.login-role-card {
  display: grid;
  gap: 0.35rem;
  padding: 1.05rem 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    box-shadow 160ms ease;
}
.login-role-card:hover,
.login-role-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--brand);
  box-shadow: var(--shadow);
  background: var(--surface);
}
.login-role-card small {
  color: var(--muted);
  line-height: 1.45;
}
.back-to-roles {
  margin-bottom: 1rem;
  border: none;
  background: transparent;
  color: var(--brand);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.demo-hint {
  display: block;
  text-align: center;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
}
.stat-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stat-icon.green {
  background: var(--green-soft);
}
.stat-icon.blue {
  background: var(--blue-soft);
}
.stat-icon.coral {
  background: var(--coral-soft);
}

.auth-tabs {
  display: flex;
  background: var(--surface-soft);
  padding: 4px;
  border-radius: 14px;
  margin-bottom: 1.2rem;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  padding: 0.65rem 1rem;
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.85rem;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.auth-tab.active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow);
}

.alert-banner {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  margin-bottom: 1rem;
  font-size: 0.88rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: fadeIn 0.3s ease;
}

.alert-banner.success {
  background: var(--green-soft);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert-banner.error {
  background: var(--coral-soft);
  color: var(--coral);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

body.dark-theme .field input {
  background: var(--surface-soft);
  color: var(--text);
  border-color: var(--border);
}

.theme-toggle-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition:
    background 0.2s ease,
    transform 0.2s ease,
    border-color 0.2s ease;
}
.theme-toggle-btn:hover {
  transform: scale(1.08);
  border-color: var(--brand);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
a {
  color: inherit;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
}

input.input-error,
select.input-error {
  border-color: var(--coral) !important;
  box-shadow: 0 0 0 4px var(--coral-soft) !important;
}
/* Modal Backdrop & Card Styles */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.8rem;
  width: min(540px, calc(100% - 2rem));
  box-shadow: var(--shadow);
  transform: translateY(12px);
  transition: transform 0.25s ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.2rem;
}

.modal-header h2 {
  font-size: 1.3rem;
  color: var(--brand-dark);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--muted);
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
}

.modal-close:hover {
  background: var(--surface-soft);
  color: var(--brand);
}

.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
  margin-top: 1rem;
}

.analytics-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem;
  text-align: center;
}

.analytics-card strong {
  display: block;
  font-size: 1.6rem;
  color: var(--brand);
}

.analytics-card span {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
}

.Parent-list-modal {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.Parent-item-modal {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.Parent-item-modal strong {
  color: var(--brand-dark);
  display: block;
  font-size: 0.9rem;
}

.Parent-item-modal small {
  color: var(--muted);
  font-size: 0.76rem;
}

.app-shell {
  width: min(1180px, calc(100% - 2rem));
  margin-inline: auto;
}

.app-header,
.auth-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.app-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 900;
}
.app-brand small {
  display: block;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.72rem;
  margin-top: -0.2rem;
}
.app-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.area-badge {
  border-radius: 999px;
  padding: 0.45rem 0.7rem;
  background: var(--surface-soft);
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
}
.text-button {
  text-decoration: none;
  color: var(--brand);
  font-weight: 800;
  font-size: 0.9rem;
}
.portal-action,
.portal-switch-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 38px;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}
.portal-action:hover,
.portal-action:focus-visible,
.portal-switch-button:hover,
.portal-switch-button:focus-visible {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.portal-logout-action {
  color: var(--coral);
  border-color: var(--coral-soft);
}
.portal-logout-action:hover,
.portal-logout-action:focus-visible {
  background: var(--coral-soft);
  color: var(--coral);
}
.portal-switch-button {
  flex-shrink: 0;
  color: var(--brand);
  border-color: var(--brand-soft);
}
.parent-select {
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 2.2rem 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--text);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
}
.parent-select:hover,
.parent-select:focus-visible {
  border-color: var(--brand);
  outline: 3px solid var(--brand-soft);
}
.icon-button {
  border: 1px solid var(--border);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface);
}

.dashboard {
  padding-block: 2.4rem 4rem;
}
.eyebrow {
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.6rem;
}
.page-heading h1 {
  margin-top: 0.4rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  color: var(--brand-dark);
  letter-spacing: -0.03em;
}
.page-heading p {
  margin-top: 0.45rem;
  color: var(--muted);
}
.primary-button {
  border: 0;
  background: var(--brand);
  color: #fff;
  padding: 0.78rem 1rem;
  border-radius: 12px;
  font-weight: 900;
  box-shadow: 0 10px 25px rgba(80, 49, 30, 0.14);
}
.primary-button:hover {
  background: var(--brand-dark);
}
.full-width {
  width: 100%;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 1rem;
  display: flex;
  gap: 0.9rem;
  align-items: center;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  font-weight: 900;
}
.stat-icon.blue {
  background: var(--blue-soft);
  color: var(--blue);
}
.stat-icon.amber {
  background: var(--amber-soft);
  color: var(--amber);
}
.stat-icon.coral {
  background: var(--coral-soft);
  color: var(--coral);
}
.stat-icon.green {
  background: var(--green-soft);
  color: var(--green);
}
.stat-card small,
.stat-card span {
  display: block;
}
.stat-card small {
  color: var(--muted);
  font-size: 0.78rem;
}
.stat-card strong {
  display: block;
  color: var(--brand-dark);
  font-size: 1.55rem;
  line-height: 1.2;
}
.stat-card div > span {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}

.content-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 1rem;
}
.bottom-grid {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 1rem;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}
.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  margin-bottom: 1rem;
}
.panel-header h2 {
  font-size: 1.05rem;
  color: var(--brand-dark);
}
.panel-header p {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.filter-button,
.outline-button,
.ghost-button {
  border-radius: 10px;
  padding: 0.58rem 0.75rem;
  background: var(--surface);
  font-weight: 800;
  border: 1px solid var(--border);
}
.filter-button {
  color: var(--muted);
  font-size: 0.78rem;
}
.outline-button {
  color: var(--brand);
  border-color: var(--brand-soft);
}
.ghost-button {
  color: var(--muted);
}

.incident-list {
  display: grid;
  gap: 0.75rem;
}
.incident-item {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 0.8rem;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0.9rem;
}
.incident-item.high {
  border-left: 4px solid var(--coral);
}
.incident-item.safe-item {
  border-left: 4px solid var(--green);
}
.incident-badge {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--coral-soft);
  color: var(--coral);
  display: grid;
  place-items: center;
  font-weight: 900;
}
.safe-badge {
  background: var(--green-soft);
  color: var(--green);
}
.incident-title-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}
.incident-main h3 {
  font-size: 0.92rem;
  color: var(--brand-dark);
}
.incident-main p {
  font-size: 0.74rem;
  color: var(--muted);
  margin-top: 0.2rem;
}
.incident-meta {
  display: flex;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-top: 0.55rem;
}
.incident-meta span {
  font-size: 0.69rem;
  font-weight: 800;
  color: var(--muted);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 0.25rem 0.5rem;
}
.severity {
  border-radius: 999px;
  padding: 0.2rem 0.45rem;
  font-size: 0.66rem;
  font-weight: 900;
}
.high-pill {
  background: var(--coral-soft);
  color: var(--coral);
}
.low-pill {
  background: var(--green-soft);
  color: var(--green);
}

.device-panel {
  display: grid;
  align-content: start;
  gap: 0.75rem;
}
.device-card {
  border: 1px solid var(--border);
  border-radius: 15px;
  padding: 0.9rem;
}
.device-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.device-name,
.device-top small {
  display: block;
}
.device-name {
  font-weight: 900;
  color: var(--brand-dark);
  font-size: 0.88rem;
}
.device-top small {
  color: var(--muted);
  font-size: 0.72rem;
  margin-top: 0.1rem;
}
.online {
  align-self: start;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  padding: 0.24rem 0.5rem;
  font-weight: 900;
  font-size: 0.67rem;
}
.device-metrics {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.72rem;
}
.device-metrics b {
  color: var(--brand-dark);
}
.sensor-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.75rem;
}
.sensor-row span {
  font-size: 0.66rem;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--brand);
  font-weight: 800;
}

.workflow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 0.7rem;
  align-items: center;
}
.workflow-step {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}
.workflow-step > span {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface-soft);
  color: var(--muted);
  font-weight: 900;
}
.workflow-step.active > span {
  background: var(--coral-soft);
  color: var(--coral);
}
.workflow-step strong,
.workflow-step small {
  display: block;
}
.workflow-step strong {
  color: var(--brand-dark);
  font-size: 0.8rem;
}
.workflow-step small {
  color: var(--muted);
  font-size: 0.68rem;
}
.workflow-line {
  height: 2px;
  background: var(--border);
}
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}
.quick-actions button {
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--brand);
  padding: 0.8rem;
  border-radius: 12px;
  font-weight: 800;
  text-align: left;
}

.app-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.access-panel {
  margin-bottom: 1.5rem;
}

[hidden] {
  display: none !important;
}

.role-grid,
.workspace-grid,
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.role-card,
.product-card {
  position: relative;
  display: grid;
  gap: 0.55rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}

.role-card {
  cursor: pointer;
}

.role-card:hover,
.role-card:focus-visible {
  border-color: var(--brand);
  box-shadow: var(--shadow);
}

.role-card small,
.product-card p,
.empty-state {
  color: var(--muted);
}

.product-icon {
  font-size: 2rem;
}

.product-card .primary-button {
  margin-top: 0.4rem;
}

.sensor-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  margin-top: 0.7rem;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
}

.sensor-summary span {
  padding: 0.35rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-soft);
}

.sensor-good {
  color: var(--green);
}

.sensor-alert {
  color: var(--coral);
}

.sensor-toggle {
  margin-top: 0.7rem;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--brand);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
}

.sensor-details {
  display: grid;
  gap: 0.25rem;
  margin-top: 0.65rem;
  padding: 0.7rem;
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.76rem;
}

.sensor-details strong {
  color: var(--green);
}

.parent-device-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1rem 0;
}

.parent-device-tools input {
  flex: 1 1 220px;
  min-height: 42px;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}

.parent-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.parent-filter {
  min-height: 38px;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  cursor: pointer;
}

.parent-filter.active,
.parent-filter:hover,
.parent-filter:focus-visible {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.favorite-device {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 1.25rem;
  cursor: pointer;
}

.link-row,
.cart-row,
.cart-total {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
}

.order-confirmation {
  display: grid;
  gap: 0.4rem;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--green-soft);
  border-radius: 12px;
  background: var(--green-soft);
  color: var(--green);
}

.order-confirmation span {
  color: var(--text);
  font-size: 0.85rem;
}

.order-confirmation .portal-action {
  width: fit-content;
  margin-top: 0.35rem;
  background: var(--surface);
  color: var(--brand);
}

.link-row span,
.link-row b {
  color: var(--muted);
  font-size: 0.85rem;
}

.registry-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1.15rem;
}

.registry-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
}

.registry-row strong,
.registry-row small {
  display: block;
}

.registry-row small {
  color: var(--muted);
  margin-top: 0.15rem;
}

.registry-remove {
  border: 1px solid var(--coral);
  background: var(--coral-soft);
  color: var(--coral);
  border-radius: 9px;
  padding: 0.4rem 0.55rem;
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
}

.shop-panel {
  margin-top: 1.5rem;
}

.parent-chooser {
  padding: 1rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.parent-chooser h2 {
  margin-bottom: 0.25rem;
}

.parent-chooser p {
  color: var(--muted);
  margin-bottom: 0.8rem;
}

.parent-details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.parent-info-panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-soft);
}

.notification-item,
.child-detail-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.82rem;
}

.notification-item span,
.child-detail-row span {
  color: var(--muted);
}

.notification-item strong {
  color: var(--coral);
  text-transform: capitalize;
}

.detail-safe {
  color: var(--green);
}

.detail-alert {
  color: var(--coral);
}

.cart-panel {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.cart-total {
  margin: 0.5rem 0 1rem;
  border-bottom: 0;
}

.portal-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  padding: 0.8rem 1rem;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  opacity: 0;
  transform: translateY(1rem);
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.portal-message.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 680px) {
  .role-grid,
  .workspace-grid,
  .product-grid,
  .parent-details-grid {
    grid-template-columns: 1fr;
  }

  .child-detail-row {
    align-items: flex-start;
    flex-direction: column;
  }
}
.footer-row {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.auth-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 3rem;
  align-items: center;
  padding-block: 3rem;
}
.auth-intro h1 {
  max-width: 560px;
  margin-top: 0.7rem;
  font-size: clamp(2.4rem, 5vw, 4rem);
  line-height: 1.03;
  letter-spacing: -0.04em;
  color: var(--brand-dark);
}
.auth-intro > p {
  max-width: 560px;
  margin-top: 1rem;
  color: var(--muted);
}
.auth-points {
  margin-top: 1.5rem;
  display: grid;
  gap: 0.7rem;
}
.auth-points div {
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
.auth-points span {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}
.auth-points p {
  color: var(--muted);
}
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.auth-card-heading h2 {
  margin-top: 0.5rem;
  color: var(--brand-dark);
  font-size: 1.75rem;
}
.auth-card-heading p {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.auth-form {
  margin-top: 1.4rem;
  display: grid;
  gap: 1rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.8rem;
}
.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 900;
  color: var(--brand-dark);
  margin-bottom: 0.35rem;
}
.field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.8rem 0.85rem;
  outline: none;
  background: #fffdfa;
}
.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(235, 172, 110, 0.15);
}
.field small {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.68rem;
}
.checkbox-row {
  display: flex;
  gap: 0.55rem;
  align-items: flex-start;
  color: var(--muted);
  font-size: 0.75rem;
}
.checkbox-row input {
  margin-top: 0.22rem;
  accent-color: var(--brand);
}
.auth-note {
  margin-top: 1rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.74rem;
}
.auth-note a {
  color: var(--brand);
  font-weight: 800;
}

@media (max-width: 900px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .content-grid,
  .bottom-grid,
  .auth-layout {
    grid-template-columns: 1fr;
  }
  .auth-intro {
    text-align: center;
  }
  .auth-intro > p {
    margin-inline: auto;
  }
  .auth-points {
    max-width: 420px;
    margin-inline: auto;
    text-align: left;
  }
}
@media (max-width: 620px) {
  .topbar {
    min-height: 68px;
  }
  .topbar-actions .area-badge {
    display: none;
  }
  .page-heading {
    align-items: flex-start;
    flex-direction: column;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .incident-item {
    grid-template-columns: 40px 1fr;
  }
  .incident-item > button {
    grid-column: 2;
    justify-self: start;
  }
  .workflow {
    grid-template-columns: 1fr;
  }
  .workflow-line {
    display: none;
  }
  .quick-actions {
    grid-template-columns: 1fr;
  }
  .field-row {
    grid-template-columns: 1fr;
  }
  .footer-row {
    flex-direction: column;
    justify-content: center;
    padding-block: 1rem;
  }
}

/* ─── History panel ──────────────────────────────────────────────────────── */
.history-section {
  margin-top: 1rem;
}

.history-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  margin-left: 0.5rem;
  vertical-align: middle;
}

.incident-item.history-item {
  border-left-color: var(--green);
  opacity: 0.92;
}

/* ─── Typed alert label tag inside each incident card ────────────────────── */
.inc-alert-tag {
  display: inline-block;
  margin-top: 0.5rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

/* ─── Incident action buttons column ─────────────────────────────────────── */
.inc-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  align-items: flex-end;
  flex-shrink: 0;
}

.inc-action-btn {
  font-size: 0.78rem;
  padding: 0.42rem 0.7rem;
  white-space: nowrap;
}

.inc-delete-btn {
  background: transparent;
  border: 1px solid var(--coral);
  color: var(--coral);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 800;
  cursor: pointer;
  transition: background 0.15s ease;
}
.inc-delete-btn:hover {
  background: var(--coral-soft);
}

.inc-resolved-badge {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  border-radius: 8px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  border: 1px solid var(--green);
  white-space: nowrap;
}

/* ─── All-clear message ──────────────────────────────────────────────────── */
.all-clear-msg {
  padding: 1.2rem 1rem;
  text-align: center;
  color: var(--green);
  font-weight: 800;
  font-size: 0.88rem;
  background: var(--green-soft);
  border-radius: 12px;
  border: 1px solid var(--green);
}

/* ─── Skeleton card (shared) ─────────────────────────────────────────────── */
.skeleton {
  background: var(--surface-soft);
  background-image: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  background-size: 200% 100%;
  border-radius: 8px;
  animation: shimmer 1.5s infinite linear;
}
@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}
.system-skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.skeleton-line {
  height: 14px;
}
.skeleton-line.long {
  width: 80%;
}
.skeleton-line.short {
  width: 45%;
}

/* ─── Responsive: stack inc-actions on narrow cards ─────────────────────── */
@media (max-width: 620px) {
  .inc-actions {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }
}

/* ─── Green Respond button ───────────────────────────────────────────────── */
.inc-respond-btn {
  border: none;
  background: var(--green);
  color: #fff;
  border-radius: 12px;
  padding: 0.45rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
  transition:
    background 0.15s ease,
    transform 0.15s ease;
  white-space: nowrap;
}
.inc-respond-btn:hover {
  background: hsl(148, 55%, 34%);
  transform: translateY(-1px);
}

/* ─── Responding card: subtle green tint so it's visually distinct ───────── */
.incident-item.responding-item {
  background: var(--green-soft);
}
body.dark-theme .incident-item.responding-item {
  background: rgba(34, 197, 94, 0.07);
}

/* ─── Clear All Responded button in panel header ─────────────────────────── */
.clear-responded-btn {
  border: 1px solid var(--green);
  background: var(--green-soft);
  color: var(--green);
  border-radius: 10px;
  padding: 0.5rem 0.8rem;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
  white-space: nowrap;
}
.clear-responded-btn:hover {
  background: var(--green);
  color: #fff;
  transform: translateY(-1px);
}

/* ─── Police escalation card ─────────────────────────────────────────────── */
.escalation-card {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 0.9rem;
  align-items: start;
  background: linear-gradient(135deg, #4c1d95 0%, #6d28d9 100%);
  border: 2px solid #7c3aed;
  border-radius: 16px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  color: #fff;
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.45);
  animation: escalationPulseCard 1.4s ease infinite;
}

@keyframes escalationPulseCard {
  0%,
  100% {
    box-shadow: 0 6px 24px rgba(124, 58, 237, 0.45);
  }
  50% {
    box-shadow: 0 6px 38px rgba(124, 58, 237, 0.8);
  }
}

.escalation-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 1.4rem;
}

.escalation-body {
  min-width: 0;
}

.escalation-title {
  font-size: 0.92rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.escalation-count {
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.escalation-detail {
  font-size: 0.78rem;
  opacity: 0.9;
  margin-top: 0.3rem;
}

.escalation-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.45rem;
  flex-shrink: 0;
}

.escalation-badge {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  padding: 0.25rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 900;
  white-space: nowrap;
  color: #fff;
}

.escalation-respond-btn {
  background: #fff;
  color: #6d28d9;
  border: none;
  border-radius: 10px;
  padding: 0.5rem 0.85rem;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  transition:
    background 0.15s ease,
    transform 0.15s ease;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.escalation-respond-btn:hover {
  background: #ede9fe;
  transform: translateY(-1px);
}

@media (max-width: 620px) {
  .escalation-card {
    grid-template-columns: 40px 1fr;
  }
  .escalation-actions {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }
}
