/* ==========================================================================
   ETHORA DESIGN SYSTEM — v1.0 (Sprint 4.2)
   Official component layer. Prefix: .eds-
   Additive by design: it never overrides legacy selectors, so pages can be
   migrated one at a time without visual regressions elsewhere.
   ========================================================================== */

:root {
  /* Espaçamento — escala única (substitui 116 valores de padding avulsos) */
  --eds-space-0: 0;
  --eds-space-1: 0.25rem;
  --eds-space-2: 0.5rem;
  --eds-space-3: 0.75rem;
  --eds-space-4: 1rem;
  --eds-space-5: 1.25rem;
  --eds-space-6: 1.5rem;
  --eds-space-8: 2rem;
  --eds-space-10: 2.5rem;

  /* Tipografia */
  --eds-font: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --eds-text-xs: 0.6875rem;
  --eds-text-sm: 0.75rem;
  --eds-text-base: 0.8125rem;
  --eds-text-md: 0.875rem;
  --eds-text-lg: 1rem;
  --eds-text-xl: 1.25rem;
  --eds-text-2xl: 1.5rem;
  --eds-leading: 1.45;
  --eds-tracking-caps: 0.06em;

  /* Raio */
  --eds-radius-sm: 8px;
  --eds-radius-md: 12px;
  --eds-radius-lg: 16px;
  --eds-radius-pill: 999px;

  /* Cor — herda a identidade Ethora existente */
  --eds-bg: var(--ethora-bg, #07191c);
  --eds-surface: linear-gradient(180deg, rgba(11, 39, 45, 0.72), rgba(7, 25, 28, 0.88));
  --eds-surface-solid: #0a2226;
  --eds-surface-raised: #0b2b31;
  --eds-surface-hover: #10333a;
  --eds-overlay-scrim: rgba(3, 12, 14, 0.66);
  --eds-border: rgba(20, 184, 166, 0.18);
  --eds-border-strong: rgba(20, 184, 166, 0.42);
  --eds-text: var(--ethora-text, #f2f4f5);
  --eds-text-muted: var(--ethora-muted, #8ab7b0);
  --eds-primary: var(--ethora-primary, #14b8a6);
  --eds-primary-soft: rgba(20, 184, 166, 0.12);
  --eds-primary-light: var(--ethora-primary-light, #7ee6c7);
  --eds-danger: var(--ethora-danger, #ff5a6a);
  --eds-danger-soft: rgba(255, 90, 106, 0.12);
  --eds-warning: var(--ethora-warning, #facc15);
  --eds-warning-soft: rgba(250, 204, 21, 0.12);
  --eds-success: var(--ethora-success, #34d399);
  --eds-success-soft: rgba(52, 211, 153, 0.12);
  --eds-info: #60a5fa;
  --eds-info-soft: rgba(96, 165, 250, 0.12);

  /* Elevação */
  --eds-shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.22);
  --eds-shadow-md: 0 12px 40px rgba(0, 0, 0, 0.28);
  --eds-shadow-lg: 0 24px 64px rgba(0, 0, 0, 0.45);

  /* Camadas */
  --eds-z-sticky: 20;
  --eds-z-popover: 320;
  --eds-z-modal: 340;
  --eds-z-toast: 400;

  /* Alvo mínimo de toque */
  --eds-touch: 40px;

  --eds-transition: 0.15s ease;
}

/* ── Base ───────────────────────────────────────────────────────────────── */

.eds-root,
[class^="eds-"],
[class*=" eds-"] {
  box-sizing: border-box;
}

.eds-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.eds-icon {
  flex: none;
  pointer-events: none;
}

.eds-stack {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-4);
  min-width: 0;
  max-width: 100%;
}

/* Sprint 4.2C — shell: never scroll the whole page horizontally */
html.eds-shell,
body.eds-shell {
  overflow-x: hidden;
  max-width: 100%;
}
.eds-shell .ethora-main-scroll,
.eds-shell #ethora-main-scroll {
  overflow-x: hidden;
  min-width: 0;
}
.eds-shell #ethora-global-header {
  position: sticky;
  top: 0;
  z-index: var(--eds-z-header, 40);
}
.eds-shell .ethora-table-card,
.eds-shell .table-wrap,
.eds-shell .alerts-table-wrap {
  max-width: 100%;
  min-width: 0;
}
.eds-page-loading { display: grid; gap: var(--eds-space-3); }

.eds-grid {
  display: grid;
  gap: var(--eds-space-4);
  min-width: 0;
  max-width: 100%;
}
.eds-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.eds-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 1024px) {
  .eds-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .eds-grid--2,
  .eds-grid--3 { grid-template-columns: 1fr; }
}

/* ── Button ─────────────────────────────────────────────────────────────── */

.eds-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--eds-space-2);
  min-height: var(--eds-touch);
  padding: 0 var(--eds-space-4);
  border-radius: var(--eds-radius-sm);
  border: 1px solid transparent;
  font-family: var(--eds-font);
  font-size: var(--eds-text-base);
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--eds-transition), border-color var(--eds-transition), color var(--eds-transition);
}

.eds-btn:focus-visible,
.eds-icon-btn:focus-visible,
.eds-menu-item:focus-visible,
.eds-tab:focus-visible,
.eds-input:focus-visible,
.eds-select:focus-visible {
  outline: 2px solid var(--eds-primary);
  outline-offset: 2px;
}

.eds-btn--primary {
  background: var(--eds-primary);
  border-color: var(--eds-primary);
  color: #04211f;
}
.eds-btn--primary:hover { background: var(--eds-primary-light); border-color: var(--eds-primary-light); }

.eds-btn--secondary {
  background: var(--eds-primary-soft);
  border-color: var(--eds-border-strong);
  color: var(--eds-primary-light);
}
.eds-btn--secondary:hover { background: rgba(20, 184, 166, 0.22); color: #fff; }

.eds-btn--ghost { background: transparent; border-color: var(--eds-border); color: var(--eds-text-muted); }
.eds-btn--ghost:hover { background: var(--eds-primary-soft); color: var(--eds-text); }

.eds-btn--danger { background: var(--eds-danger-soft); border-color: rgba(255, 90, 106, 0.45); color: #ffb0b8; }
.eds-btn--danger:hover { background: rgba(255, 90, 106, 0.26); color: #fff; }

.eds-btn--link {
  background: transparent;
  border-color: transparent;
  color: var(--eds-primary-light);
  padding: 0 var(--eds-space-1);
  text-decoration: underline;
}

.eds-btn--sm { min-height: 32px; font-size: var(--eds-text-sm); padding: 0 var(--eds-space-3); }
.eds-btn--lg { min-height: 48px; font-size: var(--eds-text-md); padding: 0 var(--eds-space-6); }
.eds-btn--block { width: 100%; }

.eds-btn[disabled],
.eds-btn[aria-disabled="true"],
.eds-icon-btn[disabled],
.eds-icon-btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
  border-style: dashed;
  pointer-events: none;
}

/* ── IconButton ─────────────────────────────────────────────────────────── */

.eds-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--eds-touch);
  height: var(--eds-touch);
  min-width: var(--eds-touch);
  min-height: var(--eds-touch);
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--eds-border-strong);
  background: var(--eds-primary-soft);
  color: var(--eds-primary-light);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--eds-transition), color var(--eds-transition), border-color var(--eds-transition);
}
.eds-icon-btn:hover { background: rgba(20, 184, 166, 0.24); color: #fff; }
.eds-icon-btn--danger { border-color: rgba(255, 90, 106, 0.45); background: var(--eds-danger-soft); color: #ffb0b8; }
.eds-icon-btn--danger:hover { background: rgba(255, 90, 106, 0.26); color: #fff; }
.eds-icon-btn--ghost { background: transparent; border-color: var(--eds-border); color: var(--eds-text-muted); }

.eds-actions {
  display: flex;
  align-items: center;
  gap: var(--eds-space-1);
  flex-wrap: nowrap;
}
.eds-actions--wrap { flex-wrap: wrap; }

/* ── Badge / StatusChip ─────────────────────────────────────────────────── */

.eds-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--eds-space-1);
  min-height: 26px;
  min-width: 5.5rem;
  padding: 0 var(--eds-space-3);
  border-radius: var(--eds-radius-pill);
  border: 1px solid var(--eds-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--eds-text-muted);
  font-size: var(--eds-text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.eds-badge--neutral { }
.eds-badge--success { border-color: rgba(52, 211, 153, 0.4); background: var(--eds-success-soft); color: #9df0d0; }
.eds-badge--warning { border-color: rgba(250, 204, 21, 0.4); background: var(--eds-warning-soft); color: #f6e08a; }
.eds-badge--danger { border-color: rgba(255, 90, 106, 0.4); background: var(--eds-danger-soft); color: #ffb0b8; }
.eds-badge--info { border-color: rgba(96, 165, 250, 0.4); background: var(--eds-info-soft); color: #b6d5ff; }
.eds-badge--muted { border-color: var(--eds-border); background: rgba(255, 255, 255, 0.03); color: var(--eds-text-muted); }
.eds-badge--auto { min-width: 0; }

/* StatusChip = badge + marcador não-cromático (nunca só cor) */
.eds-chip { }
.eds-chip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.eds-chip--danger .eds-chip-dot,
.eds-chip--warning .eds-chip-dot { border-radius: 2px; }
.eds-chip--muted .eds-chip-dot { background: transparent; border: 1.5px solid currentColor; }

/* ── Card / Section ─────────────────────────────────────────────────────── */

.eds-card {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-3);
  padding: var(--eds-space-5);
  border-radius: var(--eds-radius-lg);
  border: 1px solid var(--eds-border);
  background: var(--eds-surface);
  box-shadow: var(--eds-shadow-md);
  min-width: 0;
  max-width: 100%;
}
.eds-card--flat { box-shadow: none; background: rgba(7, 25, 28, 0.4); }
.eds-card--compact { padding: var(--eds-space-3); gap: var(--eds-space-2); }

.eds-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--eds-space-3);
  flex-wrap: wrap;
}
.eds-card-title { font-size: var(--eds-text-lg); font-weight: 600; color: var(--eds-text); margin: 0; }
.eds-card-subtitle { font-size: var(--eds-text-base); color: var(--eds-text-muted); margin: 0; }
.eds-card-body { min-width: 0; font-size: var(--eds-text-base); line-height: var(--eds-leading); }
.eds-card-foot { display: flex; gap: var(--eds-space-2); flex-wrap: wrap; }

.eds-section { display: flex; flex-direction: column; gap: var(--eds-space-4); min-width: 0; max-width: 100%; }
.eds-section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--eds-space-3); flex-wrap: wrap; }
.eds-section-title { font-size: var(--eds-text-xl); font-weight: 600; margin: 0; }
.eds-section-desc { font-size: var(--eds-text-base); color: var(--eds-text-muted); margin: 0; }

/* ── Header / Breadcrumb ────────────────────────────────────────────────── */

.eds-header { display: flex; flex-direction: column; gap: var(--eds-space-2); min-width: 0; }
.eds-header-row { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--eds-space-4); flex-wrap: wrap; }
.eds-header-title { font-size: var(--eds-text-2xl); font-weight: 700; margin: 0; }
.eds-header-subtitle { font-size: var(--eds-text-md); color: var(--eds-text-muted); margin: 0; }
.eds-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: var(--eds-space-2); font-size: var(--eds-text-sm); color: var(--eds-text-muted); list-style: none; padding: 0; margin: 0; }
.eds-breadcrumb a { color: var(--eds-primary-light); text-decoration: none; }
.eds-breadcrumb a:hover { text-decoration: underline; }
.eds-breadcrumb li + li::before { content: "/"; margin-right: var(--eds-space-2); opacity: 0.5; }

/* ── Toolbar / FilterBar / Search ───────────────────────────────────────── */

.eds-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--eds-space-3);
  flex-wrap: wrap;
  min-width: 0;
}
.eds-toolbar-group { display: flex; align-items: center; gap: var(--eds-space-2); flex-wrap: wrap; min-width: 0; }
.eds-toolbar-group--grow { flex: 1 1 260px; }

.eds-filterbar { display: flex; flex-direction: column; gap: var(--eds-space-3); min-width: 0; }
.eds-filterbar-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--eds-space-3);
}
.eds-field { display: flex; flex-direction: column; gap: var(--eds-space-1); min-width: 0; }
.eds-field-label { font-size: var(--eds-text-sm); color: var(--eds-text-muted); font-weight: 500; }
.eds-field--check { flex-direction: row; align-items: center; gap: var(--eds-space-2); min-height: var(--eds-touch); }

.eds-input,
.eds-select {
  width: 100%;
  min-height: var(--eds-touch);
  padding: 0 var(--eds-space-3);
  border-radius: var(--eds-radius-sm);
  border: 1px solid var(--eds-border);
  background: rgba(4, 18, 21, 0.7);
  color: var(--eds-text);
  font-family: var(--eds-font);
  font-size: var(--eds-text-base);
}
.eds-input::placeholder { color: rgba(138, 183, 176, 0.7); }
.eds-textarea { min-height: 96px; padding: var(--eds-space-3); resize: vertical; }

.eds-search { position: relative; display: flex; align-items: center; min-width: 0; }
.eds-search .eds-input { padding-left: 2.25rem; }
.eds-search-icon { position: absolute; left: var(--eds-space-3); color: var(--eds-text-muted); pointer-events: none; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.eds-tabs { display: flex; gap: var(--eds-space-1); border-bottom: 1px solid var(--eds-border); overflow-x: auto; }
.eds-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--eds-space-2);
  min-height: var(--eds-touch);
  padding: 0 var(--eds-space-4);
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--eds-text-muted);
  font: inherit;
  font-size: var(--eds-text-base);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.eds-tab:hover { color: var(--eds-text); }
.eds-tab[aria-selected="true"] { color: var(--eds-primary-light); border-bottom-color: var(--eds-primary); }
.eds-tabpanel[hidden] { display: none; }

/* ── Scroll inteligente (Fase 3) ────────────────────────────────────────── */

.eds-scroll { position: relative; width: 100%; max-width: 100%; min-width: 0; }

.eds-scroll-rail {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  height: 14px;
  border: 1px solid var(--eds-border);
  border-bottom: 0;
  border-radius: var(--eds-radius-sm) var(--eds-radius-sm) 0 0;
  background: rgba(7, 25, 28, 0.55);
}
.eds-scroll-rail[hidden] { display: none; }
.eds-scroll-rail-spacer { height: 1px; }

.eds-scroll-viewport {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  border: 1px solid var(--eds-border);
  border-radius: 0 0 var(--eds-radius-sm) var(--eds-radius-sm);
  background: rgba(7, 25, 28, 0.35);
}
.eds-scroll-rail[hidden] + .eds-scroll-viewport { border-radius: var(--eds-radius-sm); }
.eds-scroll-viewport:focus-visible { outline: 2px solid var(--eds-primary); outline-offset: -2px; }
.eds-scroll-viewport.is-dragging { cursor: grabbing; user-select: none; }

/* Indicador visual de overflow */
.eds-scroll::before,
.eds-scroll::after {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 0;
  width: 28px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--eds-transition);
  z-index: 5;
}
.eds-scroll::before { left: 0; background: linear-gradient(90deg, rgba(3, 12, 14, 0.85), transparent); }
.eds-scroll::after { right: 0; background: linear-gradient(270deg, rgba(3, 12, 14, 0.85), transparent); }
.eds-scroll.has-overflow-start::before { opacity: 1; }
.eds-scroll.has-overflow-end::after { opacity: 1; }

/* ── DataTable (Fase 4) ─────────────────────────────────────────────────── */

.eds-datatable { display: flex; flex-direction: column; gap: var(--eds-space-3); min-width: 0; max-width: 100%; }

.eds-table {
  --eds-sticky-bg: var(--eds-surface-solid);
  --eds-sticky-bg-hover: var(--eds-surface-hover);
  --eds-sticky-head-bg: #071a1e;
  --eds-sticky-line: rgba(20, 184, 166, 0.28);
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--eds-text-base);
}

.eds-table th,
.eds-table td {
  padding: 0.55rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  line-height: 1.25;
  border-bottom: 1px solid rgba(20, 184, 166, 0.12);
  background-clip: padding-box;
}

.eds-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  height: 44px;
  padding: 0.5rem 0.75rem;
  background: var(--eds-sticky-head-bg);
  border-bottom: 1px solid var(--eds-sticky-line);
  color: var(--eds-text-muted);
  font-size: var(--eds-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: var(--eds-tracking-caps);
  white-space: nowrap;
  vertical-align: middle;
}

/* Sprint 4.3.2 — shared density for EntityList / DataTable */
.eds-density-normal {
  --eds-row-min: 56px;
  --eds-action-size: 36px;
}
.eds-density-compact {
  --eds-row-min: 48px;
  --eds-action-size: 34px;
}
.eds-density-normal .eds-table tbody td,
.eds-density-compact .eds-table tbody td {
  min-height: var(--eds-row-min);
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  vertical-align: middle;
  line-height: 1.25;
}
.eds-density-compact .eds-table tbody td {
  padding-top: 0.35rem;
  padding-bottom: 0.35rem;
  padding-left: 0.65rem;
  padding-right: 0.65rem;
}
.eds-density-compact .eds-table thead th {
  height: 42px;
  padding: 0.4rem 0.65rem;
}
.eds-density-normal .eds-icon-btn,
.eds-density-compact .eds-icon-btn,
.eds-density-normal .eds-expand-toggle,
.eds-density-compact .eds-expand-toggle {
  width: var(--eds-action-size);
  height: var(--eds-action-size);
  min-width: var(--eds-action-size);
  min-height: var(--eds-action-size);
}
.eds-density-compact .eds-badge,
.eds-density-normal .eds-badge {
  padding: 0.12rem 0.45rem;
  font-size: var(--eds-text-xs);
  line-height: 1.2;
  white-space: nowrap;
}
.eds-cell-strong {
  display: block;
  font-weight: 600;
  line-height: 1.25;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eds-cell-sub {
  display: block;
  font-size: var(--eds-text-xs);
  color: var(--eds-text-muted);
  font-weight: 400;
  line-height: 1.2;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eds-row-identity {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
  vertical-align: middle;
}
.eds-row-identity-body {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
}
.eds-device-identity,
.eds-pet-identity {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  max-width: 100%;
}
.eds-device-identity-text,
.eds-pet-identity-text {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}
.eds-device-identity-text .eds-cell-strong,
.eds-pet-identity-text .eds-cell-strong {
  display: inline;
}
.eds-avatar-sm {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.eds-filterbar--compact {
  gap: var(--eds-space-2);
}
.eds-filterbar--compact .eds-filterbar-fields {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--eds-space-2);
}
.eds-filterbar--compact .eds-input,
.eds-filterbar--compact .eds-select {
  min-height: 34px;
}
.eds-filterbar--compact .eds-field-label {
  font-size: 0.75rem;
  line-height: 1.2;
}
.eds-filterbar--compact .eds-field {
  gap: 0.25rem;
}

/* Compact KPI strip (admin devices / reusable) */
.eds-kpi-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  margin: 0;
  box-sizing: border-box;
}
.eds-kpi-chip {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.12rem;
  min-width: 0;
  padding: 0.4rem 0.55rem;
  border-radius: var(--eds-radius-sm);
  border: 1px solid var(--eds-border);
  background: rgba(11, 27, 33, 0.72);
  box-sizing: border-box;
}
.eds-kpi-chip-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--eds-text-muted);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eds-kpi-chip-value {
  font-size: 1.125rem;
  font-weight: 650;
  line-height: 1.1;
  color: var(--eds-text);
  font-variant-numeric: tabular-nums;
}
.eds-kpi-chip-hint {
  font-size: 0.65rem;
  line-height: 1.2;
  color: var(--eds-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.eds-kpi-strip--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 1599px) {
  .eds-kpi-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .eds-kpi-strip,
  .eds-kpi-strip--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .eds-kpi-strip,
  .eds-kpi-strip--4 {
    grid-template-columns: 1fr 1fr;
  }
  .eds-kpi-chip {
    padding: 0.35rem 0.5rem;
  }
  .eds-kpi-chip-value {
    font-size: 1.05rem;
  }
}

.eds-table tbody tr:hover td { background: rgba(20, 184, 166, 0.05); }

.eds-table th.is-sticky-left,
.eds-table td.is-sticky-left {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--eds-sticky-bg);
  background-clip: padding-box;
  box-shadow: 1px 0 0 var(--eds-sticky-line);
  isolation: isolate;
  /* Prevent scrolled cells from painting through sticky columns */
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

.eds-table th.is-sticky-right,
.eds-table td.is-sticky-right {
  position: sticky;
  right: 0;
  z-index: 2;
  width: 1%;
  background: var(--eds-sticky-bg);
  background-clip: padding-box;
  box-shadow: -1px 0 0 var(--eds-sticky-line);
  isolation: isolate;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  white-space: nowrap;
}

.eds-table thead th.is-sticky-left,
.eds-table thead th.is-sticky-right {
  z-index: 5;
  background: var(--eds-sticky-head-bg);
  background-clip: padding-box;
}

.eds-table tbody tr:hover td.is-sticky-left,
.eds-table tbody tr:hover td.is-sticky-right {
  background: var(--eds-sticky-bg-hover);
  background-clip: padding-box;
}

/* Non-sticky body cells stay under sticky overlays */
.eds-table tbody td:not(.is-sticky-left):not(.is-sticky-right) { z-index: 0; }
.eds-table tbody td.is-sticky-left,
.eds-table tbody td.is-sticky-right { z-index: 3; }

/* EntityList / expandable rows */
.eds-entity-list { min-width: 0; max-width: 100%; }
.eds-entity-list .eds-scroll { max-width: 100%; }
.eds-sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  letter-spacing: var(--eds-tracking-caps);
  text-transform: uppercase;
  cursor: pointer;
  padding: 0;
}
.eds-sort-ind { opacity: 0.55; font-size: 0.7em; }
.eds-col-select,
.eds-col-expand { width: 2.25rem; text-align: center; }
.eds-expand-toggle {
  border: 0;
  background: rgba(20, 184, 166, 0.12);
  color: var(--eds-text);
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.4rem;
  cursor: pointer;
  line-height: 1;
}
.eds-expand-toggle:hover { background: rgba(20, 184, 166, 0.22); }
.eds-entity-expand-row > td { padding: 0 !important; background: rgba(3, 12, 14, 0.45); }
.eds-entity-expand-panel { padding: var(--eds-space-3) var(--eds-space-4); }
.eds-bulk-bar {
  font-size: var(--eds-text-sm);
  color: var(--eds-text-muted);
  padding: 0 var(--eds-space-1);
}
.eds-check { display: inline-flex; align-items: center; justify-content: center; }
.eds-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Global UX: single vertical flow — page must not grow a second horizontal scroller */
.eds-shell,
.eds-shell .ethora-content,
.eds-shell .ethora-page {
  overflow-x: hidden;
  max-width: 100%;
  min-width: 0;
}
.eds-shell .eds-scroll-viewport {
  overflow-x: auto;
  overflow-y: auto;
  max-width: 100%;
}

/* Expandable entity list (tutors / compact registries) */
.eds-expand-list { display: flex; flex-direction: column; gap: var(--eds-space-2); min-width: 0; }
.eds-expand-item {
  border: 1px solid rgba(20, 184, 166, 0.16);
  border-radius: var(--eds-radius-sm);
  background: rgba(7, 26, 30, 0.72);
  overflow: hidden;
}
.eds-expand-summary {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1.2fr) auto auto auto;
  gap: var(--eds-space-2) var(--eds-space-3);
  align-items: center;
  padding: var(--eds-space-3) var(--eds-space-3);
  cursor: pointer;
  list-style: none;
}
.eds-expand-summary::-webkit-details-marker { display: none; }
.eds-expand-summary:focus-visible { outline: 2px solid var(--eds-primary); outline-offset: -2px; }
.eds-expand-meta { min-width: 0; }
.eds-expand-meta strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eds-expand-meta span { display: block; color: var(--eds-text-muted); font-size: var(--eds-text-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eds-expand-actions { display: flex; gap: var(--eds-space-2); flex-wrap: wrap; justify-content: flex-end; }
.eds-expand-panel {
  border-top: 1px solid rgba(20, 184, 166, 0.12);
  padding: var(--eds-space-3);
  background: rgba(3, 12, 14, 0.35);
}
@media (max-width: 960px) {
  .eds-expand-summary {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name status"
      "city id"
      "email actions";
  }
  .eds-expand-summary > .eds-expand-meta:nth-child(1) { grid-area: name; }
  .eds-expand-summary > .eds-expand-meta:nth-child(2) { grid-area: city; }
  .eds-expand-summary > .eds-expand-meta:nth-child(3) { grid-area: email; }
  .eds-expand-summary > .eds-badge,
  .eds-expand-summary > .eds-status { grid-area: status; justify-self: end; }
  .eds-expand-summary > .eds-expand-id { grid-area: id; }
  .eds-expand-summary > .eds-expand-actions { grid-area: actions; }
}
@media (max-width: 640px) {
  .eds-expand-summary { grid-template-columns: 1fr; grid-template-areas: "name" "city" "email" "status" "id" "actions"; }
  .eds-expand-actions { justify-content: flex-start; }
}

.eds-table td.eds-table-empty { text-align: center; color: var(--eds-text-muted); padding: var(--eds-space-8); }
.eds-table .eds-badge { max-width: none; }
.eds-cell-strong { display: block; font-weight: 600; }
.eds-cell-sub { display: block; color: var(--eds-text-muted); font-size: var(--eds-text-sm); overflow-wrap: anywhere; }
.eds-cell-nowrap { white-space: nowrap; }

/* ── Pagination ─────────────────────────────────────────────────────────── */

.eds-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--eds-space-3);
  flex-wrap: wrap;
  font-size: var(--eds-text-base);
  color: var(--eds-text-muted);
}
.eds-pagination-controls { display: flex; align-items: center; gap: var(--eds-space-2); }

/* ── ActionMenu (portal) ────────────────────────────────────────────────── */

.eds-menu {
  position: fixed;
  z-index: var(--eds-z-popover);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 14rem;
  max-width: min(20rem, calc(100vw - 1rem));
  padding: var(--eds-space-1);
  border-radius: var(--eds-radius-md);
  border: 1px solid var(--eds-border-strong);
  background: var(--eds-surface-raised);
  box-shadow: var(--eds-shadow-lg);
}
.eds-menu[hidden] { display: none; }
.eds-menu-item {
  display: flex;
  align-items: center;
  gap: var(--eds-space-2);
  width: 100%;
  min-height: var(--eds-touch);
  padding: var(--eds-space-2) var(--eds-space-3);
  border: 0;
  border-radius: var(--eds-radius-sm);
  background: transparent;
  color: var(--eds-text);
  font: inherit;
  font-size: var(--eds-text-base);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.eds-menu-item:hover { background: var(--eds-primary-soft); }
.eds-menu-item--danger { color: #ffb0b8; }
.eds-menu-item--danger:hover { background: var(--eds-danger-soft); }
.eds-menu-sep { height: 1px; margin: var(--eds-space-1) 0; background: var(--eds-border); }

/* ── Modal / Drawer / ConfirmationDialog ────────────────────────────────── */

.eds-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--eds-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--eds-space-4);
  background: var(--eds-overlay-scrim);
  backdrop-filter: blur(2px);
}
.eds-scrim[hidden] { display: none; }
.eds-scrim--drawer { justify-content: flex-end; align-items: stretch; padding: 0; }

.eds-modal {
  display: flex;
  flex-direction: column;
  width: min(560px, 100%);
  max-height: min(86vh, 720px);
  border-radius: var(--eds-radius-lg);
  border: 1px solid var(--eds-border-strong);
  background: var(--eds-surface-raised);
  box-shadow: var(--eds-shadow-lg);
}
.eds-modal--lg { width: min(880px, 100%); }
.eds-modal--sm { width: min(420px, 100%); }

.eds-drawer {
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  height: 100%;
  border-left: 1px solid var(--eds-border-strong);
  background: var(--eds-surface-raised);
  box-shadow: var(--eds-shadow-lg);
}

.eds-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--eds-space-3);
  padding: var(--eds-space-4) var(--eds-space-5);
  border-bottom: 1px solid var(--eds-border);
}
.eds-dialog-title { font-size: var(--eds-text-lg); font-weight: 600; margin: 0; }
.eds-dialog-body {
  padding: var(--eds-space-5);
  overflow: auto;
  font-size: var(--eds-text-base);
  line-height: var(--eds-leading);
  min-height: 0;
}
.eds-dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: var(--eds-space-2);
  padding: var(--eds-space-4) var(--eds-space-5);
  border-top: 1px solid var(--eds-border);
  flex-wrap: wrap;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */

.eds-toast-region {
  position: fixed;
  right: var(--eds-space-4);
  bottom: var(--eds-space-4);
  z-index: var(--eds-z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-2);
  max-width: min(380px, calc(100vw - 2rem));
}
.eds-toast {
  display: flex;
  align-items: flex-start;
  gap: var(--eds-space-2);
  padding: var(--eds-space-3) var(--eds-space-4);
  border-radius: var(--eds-radius-md);
  border: 1px solid var(--eds-border-strong);
  background: var(--eds-surface-raised);
  box-shadow: var(--eds-shadow-lg);
  font-size: var(--eds-text-base);
  color: var(--eds-text);
}
.eds-toast--success { border-color: rgba(52, 211, 153, 0.5); }
.eds-toast--danger { border-color: rgba(255, 90, 106, 0.5); }
.eds-toast--warning { border-color: rgba(250, 204, 21, 0.5); }
.eds-toast-close { margin-left: auto; }

/* ── Loading / Skeleton (Fase 7) ────────────────────────────────────────── */

.eds-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--eds-space-2);
  padding: var(--eds-space-6);
  color: var(--eds-text-muted);
  font-size: var(--eds-text-base);
}
.eds-loading-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--eds-primary);
  animation: eds-pulse 1s infinite ease-in-out;
}
.eds-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.eds-loading-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes eds-pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1); }
}

.eds-skeleton { display: flex; flex-direction: column; gap: var(--eds-space-3); }
.eds-skeleton-line,
.eds-skeleton-block {
  border-radius: var(--eds-radius-sm);
  background: linear-gradient(90deg, rgba(20, 184, 166, 0.06) 25%, rgba(20, 184, 166, 0.16) 37%, rgba(20, 184, 166, 0.06) 63%);
  background-size: 400% 100%;
  animation: eds-shimmer 1.4s ease infinite;
}
.eds-skeleton-line { height: 12px; }
.eds-skeleton-line--sm { height: 10px; width: 60%; }
.eds-skeleton-line--lg { height: 18px; width: 40%; }
.eds-skeleton-block { height: 84px; }
.eds-skeleton-row { display: grid; gap: var(--eds-space-3); align-items: center; }
.eds-skeleton-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--eds-space-3); }
.eds-skeleton-card { padding: var(--eds-space-4); border-radius: var(--eds-radius-lg); border: 1px solid var(--eds-border); background: var(--eds-surface); display: flex; flex-direction: column; gap: var(--eds-space-2); }

@keyframes eds-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .eds-skeleton-line,
  .eds-skeleton-block,
  .eds-loading-dot { animation: none; }
}

/* ── EmptyState / ErrorState (Fase 6) ───────────────────────────────────── */

.eds-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--eds-space-3);
  padding: var(--eds-space-8) var(--eds-space-5);
  min-width: 0;
}
.eds-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--eds-border-strong);
  background: var(--eds-primary-soft);
  color: var(--eds-primary-light);
}
.eds-state--error .eds-state-icon { border-color: rgba(255, 90, 106, 0.45); background: var(--eds-danger-soft); color: #ffb0b8; }
.eds-state-title { font-size: var(--eds-text-lg); font-weight: 600; margin: 0; }
.eds-state-desc { font-size: var(--eds-text-base); color: var(--eds-text-muted); max-width: 46ch; margin: 0; }
.eds-state-actions { display: flex; gap: var(--eds-space-2); flex-wrap: wrap; justify-content: center; }
.eds-state-help { font-size: var(--eds-text-sm); }
.eds-state-help a { color: var(--eds-primary-light); }

/* ── Cards de linha (mobile) ────────────────────────────────────────────── */

.eds-record-cards { display: grid; gap: var(--eds-space-3); }
.eds-record-card {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-2);
  padding: var(--eds-space-4);
  border-radius: var(--eds-radius-lg);
  border: 1px solid var(--eds-border);
  background: var(--eds-surface);
}
.eds-record-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--eds-space-2); flex-wrap: wrap; }
.eds-record-title { font-weight: 600; }
.eds-record-line { display: flex; justify-content: space-between; gap: var(--eds-space-3); font-size: var(--eds-text-base); }
.eds-record-label { color: var(--eds-text-muted); }
.eds-record-actions { display: flex; gap: var(--eds-space-1); flex-wrap: wrap; margin-top: var(--eds-space-1); }

/* ── Responsividade (Fase 8) ────────────────────────────────────────────── */

/* Ultrawide: limita a largura de leitura sem criar buracos */
@media (min-width: 1921px) {
  .eds-datatable,
  .eds-section { max-width: 1800px; }
}

/* Notebook */
@media (max-width: 1440px) {
  .eds-table th,
  .eds-table td { padding: var(--eds-space-2) var(--eds-space-3); }
}

/* Tablet: some colunas marcadas como secundárias */
@media (max-width: 1280px) {
  .eds-table th.is-tier-secondary,
  .eds-table td.is-tier-secondary { display: none; }
}

/* Tela reduzida / DevTools aberto */
@media (max-width: 1024px) {
  .eds-table th.is-tier-compact,
  .eds-table td.is-tier-compact { display: none; }
  .eds-scroll-viewport { max-height: min(60vh, 560px); }
}

/* Mobile: registros viram cards */
@media (max-width: 900px) {
  .eds-datatable[data-eds-mobile="cards"] .eds-scroll { display: none; }
  .eds-datatable[data-eds-mobile="cards"] .eds-record-cards { display: grid; }
  .eds-filterbar-fields { grid-template-columns: 1fr; }
  .eds-toolbar { align-items: stretch; }
  .eds-toolbar-group { width: 100%; }
  .eds-modal { max-height: 92vh; }
  .eds-drawer { width: 100%; }
  .eds-toast-region { left: var(--eds-space-3); right: var(--eds-space-3); max-width: none; }
}

.eds-datatable .eds-record-cards { display: none; }

/* Form toggle groups (Sprint 4.3.1 / 4.3.2) */
.eds-form-group { margin-top: var(--eds-space-4); }
.eds-toggle-grid .checkbox-field,
.eds-toggle-grid .eds-checkbox-field {
  display: flex;
  align-items: center;
  min-height: 2.25rem;
  padding: var(--eds-space-2) var(--eds-space-3);
  border: 1px solid rgba(20, 184, 166, 0.14);
  border-radius: var(--eds-radius-sm);
  background: rgba(7, 26, 30, 0.45);
}
.eds-checkbox-field,
.eds-toggle-grid .checkbox-label,
.eds-toggle-grid .eds-checkbox-field .checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0;
  cursor: pointer;
  line-height: 1.3;
}
.eds-checkbox-field input[type="checkbox"],
.eds-toggle-grid .checkbox-label input[type="checkbox"],
.eds-toggle-grid .eds-checkbox-field input[type="checkbox"] {
  margin: 0;
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}
.eds-checkbox-field span,
.eds-toggle-grid .checkbox-label span {
  flex: 1 1 auto;
  min-width: 0;
}
@media (max-width: 720px) {
  .eds-toggle-grid.form-grid-2 { grid-template-columns: 1fr; }
}

/* List-first entity pages (no permanent side form) */
.eds-page-list-first {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-4);
  min-width: 0;
  max-width: 100%;
}
.eds-page-list-first .eds-list-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eds-space-2);
  align-items: center;
  justify-content: space-between;
}
.eds-page-list-first .eds-list-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--eds-space-2);
  align-items: center;
}
.eds-entity-form-below {
  margin-top: var(--eds-space-4);
}
.eds-entity-form-below[hidden] {
  display: none !important;
}
.eds-registry-list-first {
  display: flex;
  flex-direction: column;
  gap: var(--eds-space-3);
  min-width: 0;
  max-width: 100%;
}
.eds-location-unavailable {
  margin: var(--eds-space-3) 0;
  padding: var(--eds-space-3) var(--eds-space-4);
  border-radius: var(--eds-radius-sm);
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.45);
  color: #cbd5e1;
}
.eds-location-unavailable strong { display: block; margin-bottom: 0.25rem; color: #e2e8f0; }
.eds-pending-list {
  margin: 0;
  padding-left: 1.1rem;
  color: var(--eds-text);
  font-size: var(--eds-text-sm);
}
.eds-pending-list li + li { margin-top: 0.2rem; }
.eds-action-bar {
  align-items: center;
}
