:root {
  color-scheme: light;
  --bg: #f3f7f8;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-solid: #ffffff;
  --ink: #111827;
  --muted: #65727f;
  --line: #dce6ea;
  --green: #0f8f6e;
  --green-dark: #0a6a52;
  --blue: #2563eb;
  --blue-soft: #e8f1ff;
  --red: #d64045;
  --red-dark: #a92f33;
  --amber: #c47a13;
  --panel-shadow: 0 22px 60px rgba(17, 24, 39, 0.1);
  --soft-shadow: 0 12px 34px rgba(17, 24, 39, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 143, 110, 0.1), rgba(37, 99, 235, 0.08) 45%, rgba(214, 64, 69, 0.04)),
    var(--bg);
  color: var(--ink);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(17, 24, 39, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 24, 39, 0.035) 1px, transparent 1px);
  background-size: 38px 38px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent 72%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

svg,
.lucide-icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 30px;
  height: 100vh;
  padding: 28px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), transparent 28%),
    #0d1f23;
  color: #f7fbff;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  flex: 0 0 50px;
  width: 50px;
  height: 50px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: linear-gradient(135deg, #ddfff4, #dbeafe);
  color: var(--green-dark);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.18);
}

.secret-trigger {
  cursor: default;
}

.secret-trigger:focus-visible {
  outline: 2px solid rgba(221, 255, 244, 0.8);
  outline-offset: 3px;
}

.brand-mark .lucide-icon {
  width: 26px;
  height: 26px;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 22px;
  letter-spacing: 0;
}

.brand span,
.sidebar-status {
  color: rgba(247, 251, 255, 0.7);
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 9px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 13px 14px;
  background: transparent;
  color: rgba(247, 251, 255, 0.76);
  text-align: left;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  transform: translateX(2px);
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 13px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.pulse {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #50e0a4;
  box-shadow: 0 0 0 7px rgba(80, 224, 164, 0.15);
}

.main {
  position: relative;
  z-index: 1;
  width: min(1380px, 100%);
  margin: 0 auto;
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.03;
}

h2 {
  margin-bottom: 6px;
  font-size: 19px;
}

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

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 17px;
  font-weight: 800;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--green), var(--blue));
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(15, 143, 110, 0.26);
}

.primary-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 36px rgba(37, 99, 235, 0.24);
}

.secondary-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.04);
}

.secondary-button:hover {
  border-color: rgba(37, 99, 235, 0.32);
  transform: translateY(-1px);
}

.danger-button {
  background: var(--red);
  color: #ffffff;
  box-shadow: 0 14px 28px rgba(214, 64, 69, 0.22);
}

.danger-button:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
}

.icon-button {
  width: 40px;
  min-height: 40px;
  padding: 0;
  background: #f5f8fa;
  color: var(--muted);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric,
.panel,
.modal-card,
.success-card {
  background: var(--surface);
  border: 1px solid rgba(220, 230, 234, 0.86);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(16px);
}

.metric {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  padding: 18px;
}

.metric::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: linear-gradient(90deg, var(--green), var(--blue), var(--red));
  opacity: 0.7;
}

.metric span,
dt {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

.metric span .lucide-icon {
  width: 16px;
  height: 16px;
  color: var(--green);
}

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 31px;
  line-height: 1;
}

.content-layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.86fr) minmax(470px, 1.14fr);
  gap: 18px;
}

.panel {
  min-width: 0;
  border-radius: 8px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 21px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
}

.panel-header p {
  margin-bottom: 0;
}

.segmented {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border: 1px solid #dce6ea;
  border-radius: 8px;
  background: #eef5f6;
}

.segment {
  border: 0;
  border-radius: 6px;
  padding: 8px 10px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.segment.active {
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(17, 24, 39, 0.08);
}

.device-list {
  display: grid;
  gap: 11px;
  padding: 14px;
  max-height: 610px;
  overflow: auto;
}

.device-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  color: inherit;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.device-card:hover,
.device-card.selected {
  border-color: rgba(15, 143, 110, 0.5);
  box-shadow: 0 14px 30px rgba(15, 143, 110, 0.13);
  transform: translateY(-1px);
}

.device-select {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-width: 0;
  border: 0;
  padding: 3px;
  background: transparent;
  color: inherit;
  text-align: left;
}

.phone-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #ddfff4, var(--blue-soft));
  color: var(--green-dark);
}

.device-card h3 {
  margin: 0 0 5px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.device-card p {
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.small-status,
.status-pill {
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.card-menu-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #8a97a3;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.card-menu-button .lucide-icon {
  width: 18px;
  height: 18px;
}

.card-menu-button:hover {
  border-color: var(--line);
  background: #f4f8fa;
  color: var(--blue);
}

.small-status.online,
.status-pill.online {
  background: #dff8ec;
  color: #087153;
}

.small-status.attention,
.status-pill.attention {
  background: #fff1d9;
  color: #8a5309;
}

.detail-panel {
  min-height: 670px;
}

.empty-state {
  display: grid;
  min-height: 670px;
  place-items: center;
  align-content: center;
  padding: 30px;
  text-align: center;
}

.empty-icon {
  display: grid;
  width: 78px;
  height: 78px;
  margin-bottom: 18px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(135deg, #e0fff4, #e8f1ff);
  color: var(--green);
  box-shadow: var(--soft-shadow);
}

.empty-icon .lucide-icon {
  width: 36px;
  height: 36px;
}

.device-detail {
  display: block;
}

.tracking-map {
  position: relative;
  height: 330px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(15, 143, 110, 0.16), rgba(37, 99, 235, 0.14)),
    #dce6ea;
}

.map-canvas {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #dce6ea;
}

.map-tile {
  position: absolute;
  width: 256px;
  height: 256px;
  user-select: none;
  -webkit-user-drag: none;
}

.map-target {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 999px;
  background: rgba(15, 143, 110, 0.14);
  box-shadow: 0 0 0 18px rgba(15, 143, 110, 0.08);
  translate: -50% -50%;
  animation: target-pulse 2.2s infinite;
}

.map-target span {
  width: 24px;
  height: 24px;
  border: 5px solid #ffffff;
  border-radius: 999px;
  background: var(--green);
  box-shadow: 0 16px 34px rgba(15, 143, 110, 0.42);
}

@keyframes target-pulse {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.06);
  }
}

.map-card {
  position: absolute;
  right: 18px;
  bottom: 18px;
  min-width: 220px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(14px);
  box-shadow: var(--soft-shadow);
}

.map-attribution {
  position: absolute;
  right: 8px;
  bottom: 6px;
  z-index: 2;
  border-radius: 4px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.76);
  color: #4b5563;
  font-size: 9px;
  line-height: 1;
  text-decoration: none;
}

.map-attribution:hover {
  text-decoration: underline;
}

.map-controls {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 3;
  display: grid;
  gap: 6px;
}

.map-zoom-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid rgba(203, 213, 225, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--ink);
  font-size: 20px;
  font-weight: 850;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(17, 24, 39, 0.09);
}

.map-zoom-button:hover {
  background: #ffffff;
  border-color: rgba(15, 143, 110, 0.42);
  color: var(--green-dark);
}

.map-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.map-card strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.detail-body,
.detail-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
}

.detail-body {
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.detail-body h2 {
  margin-bottom: 5px;
  font-size: 25px;
  overflow-wrap: anywhere;
}

.detail-body p {
  margin-bottom: 0;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  background: var(--line);
}

.info-grid div {
  padding: 18px 20px;
  background: #ffffff;
}

dd {
  margin: 8px 0 0;
  overflow-wrap: anywhere;
  font-weight: 850;
}

.detail-actions {
  border-top: 1px solid var(--line);
  background: #fbfdfe;
  flex-wrap: wrap;
}

.modal {
  width: min(540px, calc(100vw - 28px));
  border: 0;
  padding: 0;
  background: transparent;
}

.modal::backdrop {
  background: rgba(13, 31, 35, 0.58);
  backdrop-filter: blur(10px);
}

.modal-card {
  display: grid;
  gap: 16px;
  border-radius: 8px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2,
.danger-card h2 {
  margin-bottom: 0;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 13px;
  background: #fbfdfe;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

input:focus {
  border-color: var(--green);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 143, 110, 0.12);
}

.full {
  width: 100%;
}

.danger-card {
  text-align: center;
}

.danger-card p {
  margin-bottom: 4px;
  font-size: 16px;
}

.warning-mark {
  display: grid;
  width: 66px;
  height: 66px;
  margin: 0 auto;
  place-items: center;
  border-radius: 8px;
  background: #fff0f1;
  color: var(--red);
}

.warning-mark .lucide-icon {
  width: 34px;
  height: 34px;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.success-page {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(135deg, rgba(13, 31, 35, 0.94), rgba(15, 143, 110, 0.82), rgba(37, 99, 235, 0.72)),
    #0d1f23;
}

.success-card {
  width: min(570px, 100%);
  border-color: rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 46px;
  text-align: center;
}

.success-card h1 {
  margin-bottom: 14px;
}

.success-card p:not(.eyebrow) {
  margin-bottom: 26px;
  font-size: 17px;
}

.success-mark {
  display: grid;
  width: 80px;
  height: 80px;
  margin: 0 auto 20px;
  place-items: center;
  border-radius: 999px;
  background: #ddfff0;
  color: var(--green);
  box-shadow: var(--soft-shadow);
}

.success-mark .lucide-icon {
  width: 42px;
  height: 42px;
  stroke-width: 2.6;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    height: auto;
    display: grid;
    grid-template-columns: 1fr;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-status {
    display: none;
  }

  .main {
    padding: 18px;
  }

  .summary-grid,
  .content-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 660px) {
  .topbar,
  .panel-header,
  .detail-body,
  .detail-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar .primary-button,
  .detail-actions button {
    width: 100%;
  }

  .summary-grid,
  .info-grid {
    grid-template-columns: 1fr;
  }

  .nav-item {
    justify-content: center;
    padding: 10px;
    font-size: 13px;
  }

  .nav-item .lucide-icon {
    display: none;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    flex: 1;
  }

  .device-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .device-select {
    grid-column: 1;
  }

  .small-status {
    grid-column: 1;
    margin-left: 56px;
    justify-self: start;
  }

  .card-menu-button {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .tracking-map {
    height: 260px;
  }

  .map-card {
    left: 14px;
    right: 14px;
    min-width: 0;
  }

  .modal-actions {
    grid-template-columns: 1fr;
  }

  .success-card {
    padding: 30px 20px;
  }
}
