/* ==========================================================================
   Odin portal — Devices
   Design tokens lifted from Figma (Payment Devices · node 1677:87270).
   ========================================================================== */

:root {
  /* Colour */
  --white: #ffffff;
  --gray-50: #f9fafb;
  --gray-100: #f2f4f7;
  --gray-200: #eaecf0;
  --gray-300: #d0d5dd;
  --gray-400: #98a2b3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-900: #101828;
  --primary-50: #def4e6;
  --primary-600: #1bb55c;
  --primary-700: #1a983a;
  --primary-800: #198f32;
  --warning-50: #fffaeb;
  --warning-dark: #b54708;
  --error-light: #fffbfa;
  --error-dark: #b42318;

  /* Xplor Pay purple, for the one control on this page that leads into the
     Atlas-purple ordering flow. The values mirror the Atlas brand tokens
     (color/background/brand/default, /hover, /active) rather than redefining
     a colour: if Atlas moves, these follow. Nothing else here is purple. */
  --brand-purple: #793ef7;
  --brand-purple-hover: #6923f4;
  --brand-purple-active: #4d1ab2;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-sm: 0 2px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 4px 6px -2px rgba(16, 24, 40, 0.03), 0 12px 16px -4px rgba(16, 24, 40, 0.08);

  /* Type */
  --font: "Roboto", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* Metrics */
  --appbar-h: 72px;
  --sidebar-w: 240px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  color: var(--gray-700);
  background: var(--gray-50);
  -webkit-font-smoothing: antialiased;
}

img { display: block; }

button { font: inherit; }

/* ==========================================================================
   Header navigation
   ========================================================================== */

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--appbar-h);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}

.appbar__left { padding: 12px 16px; }

.entity-switcher {
  display: flex;
  align-items: center;
  width: 208px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--gray-50);
}

.entity-switcher__logo {
  display: flex;
  align-items: center;
  padding-right: 8px;
  border-right: 1px solid var(--gray-200);
}

.entity-switcher__logo img {
  width: 39px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 2px 1px rgba(16, 24, 40, 0.06));
}

.entity-switcher__label {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-left: 12px;
  font-weight: 600;
}

.entity-switcher__kicker { font-size: 12px; line-height: 18px; color: var(--primary-600); }
.entity-switcher__name { font-size: 14px; line-height: 20px; color: var(--gray-900); }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.icon-btn:hover { background: var(--gray-100); }

.appbar__middle { flex: 1 0 0; min-width: 0; padding: 16px 24px; }

.search { display: flex; width: 320px; height: 36px; }

.search__field {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-right: 0;
  border-radius: 4px 0 0 4px;
}

.search__field input {
  flex: 1 0 0;
  min-width: 0;
  border: 0;
  outline: 0;
  font: inherit;
  color: var(--gray-700);
  background: transparent;
}

.search__field input::placeholder { color: var(--gray-500); }

.search__action {
  display: flex;
  align-items: center;
  padding: 3px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-left: 0;
  border-radius: 0 4px 4px 0;
}

.search:focus-within .search__field,
.search:focus-within .search__action { border-color: var(--gray-700); }

.search__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 7px;
  border: 1px solid var(--gray-600);
  border-radius: 2px;
  background: var(--gray-600);
  cursor: pointer;
}

.search__btn:hover { background: var(--gray-700); border-color: var(--gray-700); }

.appbar__right { display: flex; align-items: center; justify-content: flex-end; padding-right: 24px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  padding: 2px 8px 2px 2px;
  border: 0;
  border-radius: 100px;
  background: var(--white);
  cursor: pointer;
}

.avatar { position: relative; width: 36px; height: 36px; }

.avatar img { width: 36px; height: 36px; border-radius: 200px; object-fit: cover; }

.avatar__initials {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: var(--gray-600);
}

/* ==========================================================================
   Shell + sidebar
   ========================================================================== */

.shell {
  display: flex;
  align-items: stretch;
  height: calc(100vh - var(--appbar-h));
}

.sidebar {
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  background: var(--gray-50);
  border-right: 1px solid var(--gray-200);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar__inner {
  display: flex;
  flex-direction: column;
  padding: 24px 12px;
}

.sidebar__collapse { display: flex; padding: 0 10px 12px; }

.collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: 1px solid var(--gray-300);
  border-radius: 100px;
  background: var(--white);
  cursor: pointer;
}

.nav-group { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 0; list-style: none; }

.nav-group__title {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: var(--gray-400);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  color: var(--gray-500);
  text-decoration: none;
  background: var(--gray-50);
}

.nav-item:hover { background: var(--gray-100); }

.nav-item.is-active { background: var(--white); color: var(--gray-900); box-shadow: var(--shadow-xs); }

.nav-divider { width: 100%; height: 1px; margin: 16px 0; }

/* ==========================================================================
   Content
   ========================================================================== */

.content {
  flex: 1 0 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 32px;
  overflow: auto;
}

.section-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; }

.section-header__actions { display: flex; align-items: center; gap: 12px; }

.section-header__actions .btn { text-decoration: none; }

.section-header__title {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  line-height: 32px;
  color: var(--gray-900);
}

.card {
  display: flex;
  flex-direction: column;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}

/* ---------- Filter bar ---------- */

.filter-bar { display: flex; justify-content: flex-end; padding: 20px 24px; }

.filter-bar__right { display: flex; align-items: center; gap: 12px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 20px;
  cursor: pointer;
  white-space: nowrap;
}

.btn--secondary { background: var(--white); border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn--secondary:hover { background: var(--gray-50); }

.btn--primary { background: var(--primary-50); border: 1px solid var(--primary-50); color: var(--primary-800); }
.btn--primary:hover { background: #cdeeda; border-color: #cdeeda; }

.btn--brand { background: var(--brand-purple); border: 1px solid var(--brand-purple); color: var(--white); }
.btn--brand:hover { background: var(--brand-purple-hover); border-color: var(--brand-purple-hover); }
.btn--brand:active { background: var(--brand-purple-active); border-color: var(--brand-purple-active); }

.btn--pager { background: var(--white); border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn--pager:hover:not(:disabled) { background: var(--gray-50); }
.btn--pager:disabled { border-color: var(--gray-200); color: var(--gray-300); cursor: default; }

.btn__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--primary-50);
  font-size: 12px;
  line-height: 18px;
  color: var(--primary-800);
}

/* ---------- Filters popover ---------- */

.filter-wrap { position: relative; }

.popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 300px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
}

.popover__header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
}

.popover__body { display: flex; flex-direction: column; gap: 16px; padding: 16px; }

.popover__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
}

.field { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; border: 0; }

.field__label { font-size: 12px; font-weight: 500; line-height: 18px; color: var(--gray-700); padding: 0; }

.checks { display: flex; flex-direction: column; gap: 8px; }

.checks label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-700); cursor: pointer; }

.checks input { width: 16px; height: 16px; accent-color: var(--primary-600); }

.select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: var(--white);
  font: inherit;
  color: var(--gray-700);
  cursor: pointer;
}

/* ---------- Table ---------- */

.table-scroll { width: 100%; overflow-x: auto; }

/* Separate borders so each cell's 1px rule sits inside its 44/64px height,
   matching the Figma row metrics exactly. */
.dt { width: 100%; border-collapse: separate; border-spacing: 0; }

.dt__th {
  height: 44px;
  padding: 12px 24px;
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  color: var(--gray-700);
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.dt__th--sortable { cursor: pointer; user-select: none; }
.dt__th--sortable:hover { background: var(--gray-200); }

.dt__th-inner { display: inline-flex; align-items: center; gap: 4px; }

.dt__sort-icon { width: 16px; height: 16px; }
.dt__sort-icon--asc { transform: rotate(180deg); }

.dt__td {
  height: 64px;
  padding: 12px 24px;
  /* Drawn as an inset shadow rather than a border so the rule costs no height:
     12 + 40px device photo + 12 = exactly the 64px row in Figma. */
  box-shadow: inset 0 -1px 0 var(--gray-200);
  font-size: 14px;
  font-weight: 400;
  line-height: 20px;
  color: var(--gray-700);
  white-space: nowrap;
}

.dt tbody tr:hover .dt__td { background: var(--gray-50); }

.dt tbody tr:last-child .dt__td { box-shadow: none; }

.id-chip {
  padding: 4px 8px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  background: var(--white);
  font-size: 12px;
  font-weight: 600;
  line-height: 18px;
  color: var(--gray-700);
  cursor: pointer;
}

.id-chip:hover { background: var(--gray-50); }

.model { display: flex; align-items: center; gap: 12px; }

.model__photo { position: relative; width: 40px; height: 40px; border-radius: 8px; overflow: hidden; flex: 0 0 40px; }

.model__photo img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 8px; }

.model__name { color: var(--gray-600); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 8px 0 6px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  mix-blend-mode: multiply;
}

.badge img { width: 8px; height: 8px; }

.badge--activated, .badge--sent { background: var(--primary-50); color: var(--primary-700); }
.badge--pending { background: var(--warning-50); color: var(--warning-dark); }
.badge--deactivated { background: var(--gray-100); color: var(--gray-700); mix-blend-mode: normal; }
.badge--failed { background: var(--error-light); color: var(--error-dark); }

.empty { margin: 0; padding: 32px 24px; text-align: center; color: var(--gray-500); }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px 16px;
}

.pagination__left { display: flex; align-items: center; gap: 12px; }

.pagination__viewing {
  padding-right: 12px;
  border-right: 1px solid var(--gray-300);
  font-size: 14px;
  font-weight: 500;
  line-height: 20px;
  color: var(--gray-700);
}

.pagination__rows { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--gray-700); }

.select-wrap { position: relative; display: inline-flex; align-items: center; }

.select-wrap img { position: absolute; right: 12px; pointer-events: none; }

.select--sm {
  width: 76px;
  height: 40px;
  padding: 8px 36px 8px 16px;
  font-weight: 500;
  appearance: none;
}

.pagination__actions { display: flex; gap: 12px; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--gray-900);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  font-weight: 500;
  color: var(--white);
}
